ExArrow.RecordBatch (ex_arrow v0.6.0)

View Source

Arrow record batch handle (opaque reference to native record batch).

A batch is a collection of column arrays with a shared schema and row count. It sits between ExArrow.Array (one column) and ExArrow.Table or ExArrow.Stream (multiple batches). Data stays in native memory; accessors return handles or small metadata.

Position in the hierarchy

Schema  Field (metadata)
            
RecordBatch  Array (one per column)
                  
Table / Stream  RecordBatch (one or more)

Summary

Functions

Returns the column names of this batch.

Returns the number of columns in this batch.

Returns the number of rows in this batch.

Returns the schema of this record batch.

Types

t()

@opaque t()

Functions

column_names(batch)

@spec column_names(t()) :: [String.t()]

Returns the column names of this batch.

Derived from the batch's schema. Equivalent to ExArrow.Schema.field_names(ExArrow.RecordBatch.schema(batch)).

Examples

{:ok, ipc_bin} = ExArrow.Native.ipc_test_fixture_binary()
{:ok, stream}  = ExArrow.IPC.Reader.from_binary(ipc_bin)
batch = ExArrow.Stream.next(stream)
ExArrow.RecordBatch.column_names(batch)  #=> ["id", "name"]

num_columns(batch)

@spec num_columns(t()) :: non_neg_integer()

Returns the number of columns in this batch.

Derived from the batch's schema — no separate NIF call is needed.

Examples

{:ok, ipc_bin} = ExArrow.Native.ipc_test_fixture_binary()
{:ok, stream}  = ExArrow.IPC.Reader.from_binary(ipc_bin)
batch = ExArrow.Stream.next(stream)
ExArrow.RecordBatch.num_columns(batch)  #=> 2

num_rows(record_batch)

@spec num_rows(t()) :: non_neg_integer()

Returns the number of rows in this batch.

schema(record_batch)

@spec schema(t()) :: ExArrow.Schema.t()

Returns the schema of this record batch.