Adbc.StreamResult (adbc v0.12.0)

Copy Markdown View Source

Represents an unmaterialized Arrow stream.

It may be created from a query via Adbc.Connection.query_pointer/4 or from in-memory IPC stream data via from_ipc_stream/1.

The stream can only be consumed once - after being passed to bulk_insert/3 or other operations, it becomes invalid.

It contains:

  • :ref - internal reference to the stream (do not use directly)
  • :conn - internal connection pid (do not use directly)
  • :pointer - pointer to the ArrowArrayStream (integer memory address)
  • :num_rows - the number of rows affected by the query, may be nil for queries depending on the database driver

Garbage collection

You must always hold a whole reference to the struct, and not individual fields. For example, if you only keep a reference to result.pointer, then the struct will be GCed, and so would be the stream.

Summary

Functions

Load an Adbc.StreamResult from in-memory IPC stream data.

Same as from_ipc_stream/1 but raises on error.

Dump the stream to in-memory IPC stream data.

Types

t()

@type t() :: %Adbc.StreamResult{
  conn: pid() | nil,
  num_rows: non_neg_integer() | nil,
  pointer: non_neg_integer(),
  ref: reference()
}

Functions

from_ipc_stream(data)

@spec from_ipc_stream(binary()) :: {:ok, t()} | {:error, Adbc.Error.t()}

Load an Adbc.StreamResult from in-memory IPC stream data.

The stream is not materialized, and can be passed directly to Adbc.Connection.bulk_insert/3 or Adbc.Connection.ingest/2.

from_ipc_stream!(data)

@spec from_ipc_stream!(binary()) :: t()

Same as from_ipc_stream/1 but raises on error.

to_ipc_stream(stream_result)

@spec to_ipc_stream(t()) :: binary()

Dump the stream to in-memory IPC stream data.

The stream can only be consumed once. Raises if the stream has already been consumed.