arrow

package module
v0.0.0-...-fe94244 Latest Latest
Warning

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

Go to latest
Published: Jul 17, 2026 License: BSD-3-Clause Imports: 11 Imported by: 0

README

go-ruby-arrow/arrow

arrow — go-ruby-arrow

Docs License Go Coverage

A pure-Go (no cgo) reimplementation of Ruby's red-arrow gem — the Apache Arrow columnar in-memory format and its IPC serialization. The real red-arrow gem binds the C library libarrow through GObject introspection, so it cannot ship inside a CGO-free static binary. This package mirrors red-arrow's observable Ruby surface — Arrow::Array, Arrow::ArrayBuilder, Arrow::DataType/Field/Schema, Arrow::RecordBatch, Arrow::Table, and the IPC round-trip — on top of github.com/apache/arrow-go/v18, the official pure-Go Apache Arrow implementation. It does not reimplement the columnar format; it re-presents arrow-go through Ruby's naming and semantics.

It is the Arrow backend for go-embedded-ruby, but is a standalone, reusable module — a sibling of go-ruby-marshal and go-ruby-msgpack.

Consumes, does not reinvent. Arrays, schema, record batches, IPC readers and writers all come from arrow-go. The value this package adds is the faithful Ruby surface and the Go↔Ruby scalar mapping, verified wire-compatible with arrow-go's canonical ipc.Reader/FileReader in both directions.

Install

go get github.com/go-ruby-arrow/arrow

Usage

package main

import (
	"bytes"
	"fmt"

	"github.com/go-ruby-arrow/arrow"
)

func main() {
	schema := arrow.NewSchema(
		arrow.NewField("id", arrow.Int64()),
		arrow.NewField("name", arrow.StringType()),
	)
	id, _ := arrow.NewArrayOf(arrow.Int64(), []any{int64(1), int64(2), nil})
	name, _ := arrow.NewArrayOf(arrow.StringType(), []any{"a", "b", "c"})

	table, _ := arrow.NewTable(schema, []*arrow.Array{id, name})
	fmt.Println(table.NumRows(), table.NumColumns()) // 3 2

	// Arrow IPC round-trip (bytes stable, values preserved).
	var buf bytes.Buffer
	_ = arrow.WriteTableStream(&buf, table)
	back, _ := arrow.ReadTableStream(bytes.NewReader(buf.Bytes()))

	col, _ := back.Column("name")
	v, _ := col.Get(2)
	fmt.Println(v) // c
}

Ruby-to-Go mapping

Ruby (red-arrow) Go (this package)
Arrow::Array *ArrayGet (#[]), Length, NullQ, ToSlice (#to_a), Each
Arrow::ArrayBuilder *ArrayBuilderAppend, AppendNull, Finish
Arrow::DataType *DataTypeInt8()Int64()/UInt8()…/Float64()/Boolean()/StringType()/Timestamp()/Date()/Decimal128()/ListOf()/StructOf()
Arrow::Field *Field
Arrow::Schema *Schema
Arrow::RecordBatch *RecordBatchNumRows, NumColumns, Get (#[]), Slice, ToHash, EachRecord
Arrow::Table *Table — same plus NewTableFromRecordBatches, ConcatTables, Save/LoadTable
Arrow::Error tree *Error (Kind + RubyClass())

Ruby predicate methods (null?, valid?) map to Go …Q methods; Ruby's integer/float towers collapse onto Go int64/float64 at the boundary, with the typed builders preserving Arrow's Int8..Int64 / UInt8..UInt64 / Float32/Float64 / Boolean / String / Timestamp / Date32 / Decimal128 / List / Struct widths.

IPC wire compatibility

Tables round-trip through both the Arrow IPC streaming format (WriteTableStream / ReadTableStream) and the Arrow IPC file / Feather v2 format (WriteTableFile / ReadTableFile). The bytes this package emits are the bytes arrow-go's canonical ipc.Reader/FileReader consume, and vice-versa — this is verified by the tests (encode here → decode with arrow-go, and encode with arrow-go → decode here), not asserted. Arrow buffers are little-endian on the wire on every architecture; on big-endian targets (s390x) arrow-go performs the byte swap, so identical bytes round-trip across all six supported 64-bit arches.

Scope

This covers red-arrow's Array/Schema/Table/RecordBatch core plus IPC. It does not (yet) cover compute kernels, Parquet/CSV readers, Datasets, Flight, or the full Dictionary/Categorical DSL; those are additive follow-ups on the same arrow-go foundation. See doc.go for the authoritative scope note.

Tests & coverage

The suite is deterministic and dependency-light (no libarrow, CGO=0): typed build/read for every listed type including nulls, negative indexing, the full error tree, and IPC round-trips in both formats — plus the cross-checks against arrow-go's canonical readers/writers that pin wire compatibility.

COVERPKG=$(go list ./... | paste -sd, -)
go test -race -coverpkg="$COVERPKG" -coverprofile=cover.out ./...
go tool cover -func=cover.out | tail -1   # 100.0%

CGO-free, gofmt + go vet clean, and green across the six 64-bit Go targets (amd64, arm64, riscv64, loong64, ppc64le, s390x — the last big-endian) and three OSes (Linux, macOS, Windows).

License

BSD-3-Clause — see LICENSE. Copyright the go-ruby-arrow/arrow authors.

WebAssembly

Being pure Go (CGO=0), this library also compiles to WebAssembly — both GOOS=js GOARCH=wasm (browser / Node.js) and GOOS=wasip1 GOARCH=wasm (WASI). CI builds both targets on every push, alongside the six 64-bit native/qemu arches.

GOOS=js     GOARCH=wasm go build ./...   # browser / Node
GOOS=wasip1 GOARCH=wasm go build ./...   # WASI (wasmtime, wasmer, wasmedge, …)

Documentation

Overview

Package arrow is a pure-Go (CGO=0), MRI-faithful implementation of the Ruby red-arrow gem's core surface — Apache Arrow's columnar in-memory format and its IPC (Feather / Arrow stream & file) serialization.

Relationship to upstream

The real red-arrow gem is a thin Ruby binding over the C library libarrow (via GObject introspection), so it cannot be shipped in a CGO-free static binary. This package mirrors red-arrow's observable Ruby surface — Array, ArrayBuilder, DataType, Field, Schema, RecordBatch, Table and the IPC round-trip — on top of github.com/apache/arrow-go/v18, the official pure-Go Apache Arrow implementation. It does not reimplement the columnar format itself; it re-presents arrow-go through Ruby's naming and semantics so it can back an embedded Ruby (go-embedded-ruby / rbgo) with no cgo.

Ruby-to-Go mapping

Arrow::Array          -> *Array          (Enumerable via Each/ToSlice)
Arrow::ArrayBuilder   -> *ArrayBuilder
Arrow::DataType       -> *DataType       (Int8()..Decimal128()/ListOf/StructOf)
Arrow::Field          -> *Field
Arrow::Schema         -> *Schema
Arrow::RecordBatch    -> *RecordBatch
Arrow::Table          -> *Table
Arrow::Error (tree)   -> *Error          (Kind + RubyClass mapping)

Ruby predicate methods ending in "?" map to Go methods ending in "Q" (IsNull -> null?, etc.), and mutating "!" methods are spelled out. Ruby integer/float towers collapse onto Go's int64/float64 at the boundary, with explicit typed builders preserving Arrow's Int8..Int64 / UInt8..UInt64 / Float32/Float64 / Boolean / String / Timestamp / Date32 / Decimal128 / List / Struct widths.

IPC wire compatibility

Tables and record batches round-trip through both the Arrow IPC streaming format (WriteTableStream / ReadTableStream) and the Arrow IPC file (a.k.a. Feather v2) format (WriteTableFile / ReadTableFile). The bytes this package emits are the bytes arrow-go's canonical ipc.Reader/FileReader consume, and vice-versa — verified by the differential tests, not asserted. Arrow buffers are little-endian on the wire on every architecture; on big-endian targets (s390x) arrow-go performs the byte swap, so the same bytes round-trip identically across all six supported 64-bit arches.

Scope

This covers red-arrow's Array/Schema/Table/RecordBatch core plus IPC. It does not (yet) cover red-arrow's compute kernels, Parquet/CSV readers, Datasets, Flight, or the full CategoricalArray/DictionaryArray DSL; those are additive follow-ups on the same arrow-go foundation.

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrArrow matches any [*Error] regardless of kind is not provided; use the
	// specific sentinels below. ErrType matches KindType errors, etc.
	ErrType           = &Error{Kind: KindType}
	ErrIndex          = &Error{Kind: KindIndex}
	ErrArgument       = &Error{Kind: KindArgument}
	ErrIO             = &Error{Kind: KindIO}
	ErrNotImplemented = &Error{Kind: KindNotImplemented}
)

Sentinel values for errors.Is matching by kind.

Functions

func WriteTableFile

func WriteTableFile(w io.Writer, t *Table) error

WriteTableFile writes a table to w in the Arrow IPC file / Feather v2 format (Arrow::Table#save with format: :arrow).

func WriteTableStream

func WriteTableStream(w io.Writer, t *Table) error

WriteTableStream writes a table to w in the Arrow IPC streaming format (Arrow::Table#save with format: :arrow_streaming).

Types

type Array

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

Array is the pure-Go counterpart of Arrow::Array — an immutable, typed, nullable column. Build one with NewArray (type inferred), NewArrayOf (explicit type), or an ArrayBuilder. It is Enumerable via Array.Each and Array.ToSlice.

func NewArray

func NewArray(values []any) (*Array, error)

NewArray builds an Array from values, inferring the element type from the first non-null value (Arrow::Array.new(values)). Bool infers Boolean, string infers String, floats infer Float64, signed ints infer Int64, unsigned ints infer UInt64, and time.Time infers Timestamp. An empty or all-null slice is an error, as the type cannot be inferred.

func NewArrayOf

func NewArrayOf(dt *DataType, values []any) (*Array, error)

NewArrayOf builds an Array of the explicit type dt from values (Arrow::Array.new(values, type: dt)).

func (*Array) DataType

func (a *Array) DataType() *DataType

DataType returns the array's element type (Arrow::Array#value_data_type).

func (*Array) Each

func (a *Array) Each(fn func(i int, v any) error) error

Each iterates the elements in order (Arrow::Array#each, Enumerable). It stops and returns the first error fn yields.

func (*Array) Get

func (a *Array) Get(i int) (any, error)

Get returns the element at index i (Arrow::Array#[]). It supports Ruby-style negative indexing and returns an *Error of KindIndex when out of range. A null element reads back as nil.

func (*Array) Length

func (a *Array) Length() int

Length returns the number of elements (Arrow::Array#length / #n_rows).

func (*Array) NNulls

func (a *Array) NNulls() int

NNulls returns the number of null elements (Arrow::Array#n_nulls).

func (*Array) NullQ

func (a *Array) NullQ(i int) bool

NullQ reports whether the element at index i is null (Arrow::Array#null?). It supports Ruby-style negative indexing.

func (*Array) Release

func (a *Array) Release()

Release drops the array's reference to its buffers.

func (*Array) String

func (a *Array) String() string

String returns the array's canonical string form (Arrow::Array#to_s).

func (*Array) ToSlice

func (a *Array) ToSlice() []any

ToSlice returns all elements as a Go slice (Arrow::Array#to_a), nulls as nil.

func (*Array) Unwrap

func (a *Array) Unwrap() xarrow.Array

Unwrap returns the underlying arrow-go array.

func (*Array) ValidQ

func (a *Array) ValidQ(i int) bool

ValidQ reports whether the element at index i is non-null (Arrow::Array#valid?).

type ArrayBuilder

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

ArrayBuilder is the pure-Go counterpart of Arrow::ArrayBuilder — an appender that accumulates typed values (and nulls) and freezes them into an Array.

func NewArrayBuilder

func NewArrayBuilder(dt *DataType) *ArrayBuilder

NewArrayBuilder returns a builder for the given element type (Arrow::ArrayBuilder.build's typed builder).

func (*ArrayBuilder) Append

func (b *ArrayBuilder) Append(v any) error

Append appends one value, coercing Go scalars to the column type. A nil value appends a null (Arrow::ArrayBuilder#append_value / #append_null).

func (*ArrayBuilder) AppendNull

func (b *ArrayBuilder) AppendNull() *ArrayBuilder

AppendNull appends a null and returns the builder for chaining.

func (*ArrayBuilder) AppendValues

func (b *ArrayBuilder) AppendValues(values []any) error

AppendValues appends each value in order, stopping at the first error (Arrow::ArrayBuilder#append_values).

func (*ArrayBuilder) DataType

func (b *ArrayBuilder) DataType() *DataType

DataType returns the element type this builder produces.

func (*ArrayBuilder) Finish

func (b *ArrayBuilder) Finish() *Array

Finish freezes the accumulated values into an Array and resets the builder (Arrow::ArrayBuilder#finish).

func (*ArrayBuilder) Length

func (b *ArrayBuilder) Length() int

Length returns the number of values appended so far.

func (*ArrayBuilder) Release

func (b *ArrayBuilder) Release()

Release frees the builder's working buffers.

type DataType

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

DataType is the pure-Go counterpart of Ruby's Arrow::DataType. It wraps an arrow-go xarrow.DataType and re-presents it with Ruby naming. Construct one with the type constructors (Int8, StringType, ListOf, StructOf, …).

func Boolean

func Boolean() *DataType

Boolean returns the boolean type (Arrow::BooleanDataType).

func Date

func Date() *DataType

Date returns the 32-bit date type — days since the Unix epoch (Arrow::Date32DataType).

func Decimal128

func Decimal128(precision, scale int32) *DataType

Decimal128 returns a 128-bit fixed-point decimal type with the given precision and scale (Arrow::Decimal128DataType).

func Float

func Float() *DataType

Float is an alias of Float64, matching red-arrow's default for Ruby Floats.

func Float32

func Float32() *DataType

Float32 returns the single-precision float type (Arrow::FloatDataType).

func Float64

func Float64() *DataType

Float64 returns the double-precision float type (Arrow::DoubleDataType).

func FromArrowType

func FromArrowType(dt xarrow.DataType) *DataType

FromArrowType wraps an arbitrary arrow-go data type as a DataType. It is the escape hatch for types this package's constructors do not spell out (for example a type recovered from an externally-produced IPC stream).

func Int8

func Int8() *DataType

Int8 returns the 8-bit signed integer type (Arrow::Int8DataType).

func Int16

func Int16() *DataType

Int16 returns the 16-bit signed integer type.

func Int32

func Int32() *DataType

Int32 returns the 32-bit signed integer type.

func Int64

func Int64() *DataType

Int64 returns the 64-bit signed integer type.

func ListOf

func ListOf(elem *DataType) *DataType

ListOf returns a list type whose elements have type elem (Arrow::ListDataType).

func StringType

func StringType() *DataType

StringType returns the UTF-8 string type (Arrow::StringDataType).

func StructOf

func StructOf(fields ...*Field) *DataType

StructOf returns a struct type composed of the given fields (Arrow::StructDataType).

func Timestamp

func Timestamp() *DataType

Timestamp returns a microsecond, timezone-naive timestamp type (Arrow::TimestampDataType), the default red-arrow infers for Ruby Time.

func UInt8

func UInt8() *DataType

UInt8 returns the 8-bit unsigned integer type (Arrow::UInt8DataType).

func UInt16

func UInt16() *DataType

UInt16 returns the 16-bit unsigned integer type.

func UInt32

func UInt32() *DataType

UInt32 returns the 32-bit unsigned integer type.

func UInt64

func UInt64() *DataType

UInt64 returns the 64-bit unsigned integer type.

func (*DataType) EqualQ

func (d *DataType) EqualQ(other *DataType) bool

EqualQ reports whether two data types are equal (Arrow::DataType#==).

func (*DataType) Name

func (d *DataType) Name() string

Name returns the Arrow type name (e.g. "int64", "utf8"), mirroring Arrow::DataType#name.

func (*DataType) String

func (d *DataType) String() string

String returns the type's canonical string form (Arrow::DataType#to_s).

func (*DataType) Unwrap

func (d *DataType) Unwrap() xarrow.DataType

Unwrap returns the underlying arrow-go data type.

type Error

type Error struct {
	Kind ErrorKind
	Msg  string
	Err  error
}

Error is the pure-Go counterpart of red-arrow's Arrow::Error exception tree. It carries the ErrorKind (so the exact Ruby class can be reconstructed) and an optional wrapped cause, and it participates in errors.Is/As via Error.Is and Error.Unwrap.

func (*Error) Error

func (e *Error) Error() string

Error implements the error interface.

func (*Error) Is

func (e *Error) Is(target error) bool

Is reports whether target is an *Error of the same ErrorKind, letting callers write errors.Is(err, arrow.ErrType) against the sentinel values.

func (*Error) RubyClass

func (e *Error) RubyClass() string

RubyClass returns the fully-qualified Ruby exception class name a faithful host raises for this error, mirroring what red-arrow raises.

func (*Error) Unwrap

func (e *Error) Unwrap() error

Unwrap returns the wrapped cause, if any, so errors.Is/As traverse it.

type ErrorKind

type ErrorKind int

ErrorKind identifies which node of red-arrow's exception tree an Error corresponds to. red-arrow raises a small set of Ruby exception classes; the kind records which one so a host (rbgo) can re-raise the faithful class.

const (
	// KindError is the base Arrow::Error (a StandardError in Ruby).
	KindError ErrorKind = iota
	// KindType maps to Ruby's TypeError — a value did not fit the column type.
	KindType
	// KindIndex maps to Ruby's IndexError — an out-of-range row/column.
	KindIndex
	// KindArgument maps to Ruby's ArgumentError — a malformed call.
	KindArgument
	// KindIO maps to Arrow::Error::Io — an IPC read/write failure.
	KindIO
	// KindNotImplemented maps to Ruby's NotImplementedError.
	KindNotImplemented
)

type Field

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

Field is the pure-Go counterpart of Arrow::Field — a named, nullable slot in a Schema or struct type.

func NewField

func NewField(name string, dt *DataType) *Field

NewField returns a nullable field named name of type dt (Arrow::Field.new).

func NewFieldNonNull

func NewFieldNonNull(name string, dt *DataType) *Field

NewFieldNonNull returns a non-nullable field named name of type dt.

func (*Field) DataType

func (f *Field) DataType() *DataType

DataType returns the field's data type (Arrow::Field#data_type).

func (*Field) Name

func (f *Field) Name() string

Name returns the field name (Arrow::Field#name).

func (*Field) NullableQ

func (f *Field) NullableQ() bool

NullableQ reports whether the field admits nulls (Arrow::Field#nullable?).

func (*Field) String

func (f *Field) String() string

String returns the field's canonical string form.

func (*Field) Unwrap

func (f *Field) Unwrap() xarrow.Field

Unwrap returns the underlying arrow-go field.

type Format

type Format int

Format selects the Arrow IPC serialization used by Table.Save and produced by the byte encoders, mirroring red-arrow's :arrow_streaming vs :arrow_file.

const (
	// FormatStream is the Arrow IPC streaming format (a schema message followed
	// by record-batch messages and an end-of-stream marker).
	FormatStream Format = iota
	// FormatFile is the Arrow IPC file format (a.k.a. Feather v2): the stream
	// body framed by "ARROW1" magic and a random-access footer.
	FormatFile
)

type RecordBatch

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

RecordBatch is the pure-Go counterpart of Arrow::RecordBatch — a set of equal-length Array columns sharing one Schema. It is the row-batch unit of the Arrow IPC format.

func NewRecordBatch

func NewRecordBatch(schema *Schema, columns []*Array) (*RecordBatch, error)

NewRecordBatch builds a record batch from a schema and one Array per field (Arrow::RecordBatch.new). It returns an *Error if the column count, a column's type, or a column's length does not match the schema.

func (*RecordBatch) Column

func (r *RecordBatch) Column(i int) (*Array, error)

Column returns the i-th column, supporting Ruby-style negative indexing. Out of range yields an *Error of KindIndex.

func (*RecordBatch) ColumnByName

func (r *RecordBatch) ColumnByName(name string) (*Array, bool)

ColumnByName returns the column named name and whether it was found.

func (*RecordBatch) EachRecord

func (r *RecordBatch) EachRecord(fn func(row int, values map[string]any) error) error

EachRecord yields each row as a column-name-to-value map (Arrow::RecordBatch#each_record). It stops at the first error fn returns.

func (*RecordBatch) Get

func (r *RecordBatch) Get(key any) (*Array, error)

Get returns a column by integer index or by string name (Arrow::RecordBatch#[]).

func (*RecordBatch) NumColumns

func (r *RecordBatch) NumColumns() int64

NumColumns returns the number of columns (Arrow::RecordBatch#n_columns).

func (*RecordBatch) NumRows

func (r *RecordBatch) NumRows() int64

NumRows returns the number of rows (Arrow::RecordBatch#n_rows).

func (*RecordBatch) Release

func (r *RecordBatch) Release()

Release drops the batch's reference to its buffers.

func (*RecordBatch) Schema

func (r *RecordBatch) Schema() *Schema

Schema returns the batch's schema (Arrow::RecordBatch#schema).

func (*RecordBatch) Slice

func (r *RecordBatch) Slice(offset, length int64) (*RecordBatch, error)

Slice returns a zero-copy row slice [offset, offset+length) (Arrow::RecordBatch#slice). Out-of-range bounds yield an *Error of KindIndex.

func (*RecordBatch) String

func (r *RecordBatch) String() string

String returns a compact human-readable summary of the batch.

func (*RecordBatch) ToHash

func (r *RecordBatch) ToHash() map[string][]any

ToHash returns the batch as an ordered column-name-to-values map (Arrow::RecordBatch#to_h). Column order follows the schema.

func (*RecordBatch) Unwrap

func (r *RecordBatch) Unwrap() xarrow.RecordBatch

Unwrap returns the underlying arrow-go record batch.

type Schema

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

Schema is the pure-Go counterpart of Arrow::Schema — an ordered list of [Field]s describing a RecordBatch or Table.

func NewSchema

func NewSchema(fields ...*Field) *Schema

NewSchema builds a schema from the given fields (Arrow::Schema.new).

func (*Schema) Field

func (s *Schema) Field(i int) *Field

Field returns the i-th field (Arrow::Schema#[] by index).

func (*Schema) FieldByName

func (s *Schema) FieldByName(name string) (*Field, bool)

FieldByName returns the field named name and whether it was found (Arrow::Schema#[] by name).

func (*Schema) Fields

func (s *Schema) Fields() []*Field

Fields returns all fields in order (Arrow::Schema#fields).

func (*Schema) NumFields

func (s *Schema) NumFields() int

NumFields returns the number of fields (Arrow::Schema#n_fields).

func (*Schema) String

func (s *Schema) String() string

String returns the schema's canonical string form (Arrow::Schema#to_s).

func (*Schema) Unwrap

func (s *Schema) Unwrap() *xarrow.Schema

Unwrap returns the underlying arrow-go schema.

type Table

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

Table is the pure-Go counterpart of Arrow::Table — a schema plus one column per field. Unlike Arrow's chunked table, this materializes to a single record batch, so Table and RecordBatch share observable behaviour; the extra value a Table carries is multi-batch assembly (NewTableFromRecordBatches, ConcatTables) and IPC round-tripping.

func ConcatTables

func ConcatTables(tables ...*Table) (*Table, error)

ConcatTables concatenates the rows of two or more tables sharing a schema (Arrow::Table#concatenate / #combine).

func DecodeTable

func DecodeTable(data []byte) (*Table, error)

DecodeTable reads a table from in-memory Arrow IPC bytes, auto-detecting the file format (by its "ARROW1" magic) versus the streaming format.

func LoadTable

func LoadTable(path string) (*Table, error)

LoadTable reads a table from a file at path, auto-detecting the IPC format (Arrow::Table.load).

func NewTable

func NewTable(schema *Schema, columns []*Array) (*Table, error)

NewTable builds a table from a schema and one Array per field (Arrow::Table.new). Errors mirror NewRecordBatch.

func NewTableFromRecordBatches

func NewTableFromRecordBatches(batches ...*RecordBatch) (*Table, error)

NewTableFromRecordBatches assembles one table from a non-empty sequence of record batches, concatenating each column across the batches. The batches must agree on column count and column types; otherwise an *Error is returned.

func ReadTableFile

func ReadTableFile(r io.Reader) (*Table, error)

ReadTableFile reads an Arrow IPC file (Feather v2) from r into a Table (Arrow::Table.load of a file input).

func ReadTableStream

func ReadTableStream(r io.Reader) (*Table, error)

ReadTableStream reads an Arrow IPC stream from r into a Table (Arrow::Table.load of a streaming input). Every record batch in the stream is concatenated into the returned table.

func (*Table) Column

func (t *Table) Column(key any) (*Array, error)

Column returns a column by integer index or by string name (Arrow::Table#[]).

func (*Table) EachRecord

func (t *Table) EachRecord(fn func(row int, values map[string]any) error) error

EachRecord yields each row as a column-name-to-value map (Arrow::Table#each_record).

func (*Table) NumColumns

func (t *Table) NumColumns() int64

NumColumns returns the number of columns (Arrow::Table#n_columns).

func (*Table) NumRows

func (t *Table) NumRows() int64

NumRows returns the number of rows (Arrow::Table#n_rows).

func (*Table) RecordBatch

func (t *Table) RecordBatch() *RecordBatch

RecordBatch returns the table's rows as a single RecordBatch.

func (*Table) Release

func (t *Table) Release()

Release drops the table's reference to its buffers.

func (*Table) Save

func (t *Table) Save(path string, format Format) error

Save writes a table to path in the given Format (Arrow::Table#save).

func (*Table) Schema

func (t *Table) Schema() *Schema

Schema returns the table's schema (Arrow::Table#schema).

func (*Table) Slice

func (t *Table) Slice(offset, length int64) (*Table, error)

Slice returns the row range [offset, offset+length) as a new table (Arrow::Table#slice).

func (*Table) String

func (t *Table) String() string

String returns the table's canonical string form (Arrow::Table#to_s).

func (*Table) ToHash

func (t *Table) ToHash() map[string][]any

ToHash returns the table as an ordered column-name-to-values map (Arrow::Table#to_h).

Jump to

Keyboard shortcuts

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