# `Adbc.StreamResult`
[🔗](https://github.com/elixir-explorer/adbc/blob/v0.12.1/lib/adbc/result.ex#L1)

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 {: .warning}
>
> 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.

# `t`

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

# `from_ipc_stream`

```elixir
@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!`

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

Same as `from_ipc_stream/1` but raises on error.

# `to_ipc_stream`

```elixir
@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.

---

*Consult [api-reference.md](api-reference.md) for complete listing*
