streamreader

package
v0.3.1-preview.2 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 25, 2026 License: Apache-2.0 Imports: 5 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package streamreader adapts a native ArrowArrayStream to an Arrow RecordReader with reference-counted ownership.

The root blob readers and the raw-file readers both consume ffi.StreamReader. They differ only in how a stream failure is classified for their public package, so the lifetime, context and batch-borrowing rules live here once and the caller supplies the error mapping.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Reader

type Reader struct {
	// contains filtered or unexported fields
}

Reader is an array.RecordReader over a Source. A batch returned by Next is borrowed: the next Next call or Release releases it, so call Retain to keep it. The context passed to NewReader is checked before every read.

wrap classifies source failures for the public package. It is called once per source error and stored as Err. Context errors are returned unchanged.

func NewReader

func NewReader(ctx context.Context, source Source, schema *arrow.Schema, wrap func(error) error) *Reader

NewReader takes ownership of source. The caller must not use source after the returned reader is released. A nil ctx uses context.Background; a nil wrap returns source errors unchanged.

func (*Reader) Err

func (r *Reader) Err() error

Err returns the context or wrapped source error that ended iteration.

func (*Reader) Next

func (r *Reader) Next() bool

Next advances to the next batch. It reports false at the end of the stream, after a context or source error, or after the last reference was released.

func (*Reader) Record

func (r *Reader) Record() arrow.Record

Record returns the current borrowed batch.

func (*Reader) RecordBatch

func (r *Reader) RecordBatch() arrow.RecordBatch

RecordBatch returns the current borrowed batch.

func (*Reader) Release

func (r *Reader) Release()

Release drops one reference and closes the source when the last reference is released.

func (*Reader) Retain

func (r *Reader) Retain()

Retain increments the reader reference count.

func (*Reader) Schema

func (r *Reader) Schema() *arrow.Schema

Schema returns the stream schema.

type Source

type Source interface {
	// Next returns the next owned batch. A false return with a nil error marks
	// the end of the stream.
	Next() (arrow.RecordBatch, bool, error)
	// Close releases the native stream.
	Close()
}

Source is the native Arrow stream a Reader drains. *ffi.StreamReader implements it. Close releases the native stream exactly once; batches that were already returned stay valid.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL