InfluxElixir.Flight.Reader (InfluxElixir v0.1.13)

Copy Markdown View Source

Arrow IPC record batch decoder for Arrow Flight query results.

Converts a list of FlightData messages (received from a DoGet gRPC stream) into a list of Elixir row maps.

Arrow IPC Format Overview

Each FlightData message carries two binary blobs:

  • data_header — serialised Arrow IPC Message flatbuffer. The first message in a stream contains a Schema message; subsequent messages contain RecordBatch messages with buffer offset/length metadata.
  • data_body — raw column buffer bytes referenced by the batch metadata.

Schema and record batch metadata is parsed using a proper FlatBuffer binary reader (InfluxElixir.Flight.FlatBuffer), following the Arrow IPC FlatBuffer schema specification exactly.

Supported Column Types

Arrow TypeElixir type
Int8-64integer()
UInt8-64integer()
Float32/64float()
Boolboolean()
Utf8binary()
Timestampinteger()

Null bitmaps are supported; null values become nil.

Limitations

  • Dictionary-encoded columns are not yet decoded.
  • Nested / list / struct types are not supported.

Summary

Types

Parsed column schema entry

Functions

Decodes a list of FlightData messages into row maps.

Extracts column name/type pairs from an Arrow IPC Schema message header.

Types

column_schema()

@type column_schema() :: %{name: binary(), type_id: non_neg_integer()}

Parsed column schema entry

Functions

decode_flight_data(list)

@spec decode_flight_data([InfluxElixir.Flight.Proto.FlightData.t()]) ::
  {:ok, [map()]} | {:error, term()}

Decodes a list of FlightData messages into row maps.

The first element of flight_data_list is expected to be the schema message (typically with an empty data_body). Subsequent elements are record batch messages.

Returns {:ok, [map()]} on success or {:error, reason} on parse failure.

Parameters

  • flight_data_list — ordered list of FlightData structs from a DoGet stream

Example

iex> InfluxElixir.Flight.Reader.decode_flight_data([])
{:ok, []}

parse_schema(header)

@spec parse_schema(binary() | nil) :: {:ok, [column_schema()]} | {:error, term()}

Extracts column name/type pairs from an Arrow IPC Schema message header.

Parses the FlatBuffer metadata according to the Arrow IPC specification: Message → Schema → Field[] → name + Type union.

Returns {:ok, [column_schema()]} or {:error, reason}.