Class DuckDbResultChunk
A chunk that has been retrieved (and captured) from the results of a query to DuckDB.
Implements
Inherited Members
Namespace: Mallard
Assembly: Mallard.dll
Syntax
public sealed class DuckDbResultChunk : IDisposable
Remarks
This class allows the same chunk to be processed or read over and over again. Such functionality helps to implement row-oriented readers (whereas DuckDB is naturally column-oriented), that implement methods returning individual rows.
For more efficient column-oriented, streaming processing, use methods like ProcessNextChunk<TState, TReturn>(TState, DuckDbChunkReadingFunc<TState, TReturn>, out TReturn) instead.
The data in the chunk is held by the native DuckDB library. Instances of this class should be disposed after the user is finished with a chunk, to avoid unpredictable memory usage (before garbage collection kicks in).
Properties
| Edit this page View SourceColumnCount
Declaration
public int ColumnCount { get; }
Property Value
Type | Description |
---|---|
int |
Length
The number of rows present in this chunk.
Declaration
public int Length { get; }
Property Value
Type | Description |
---|---|
int |
Methods
| Edit this page View SourceDispose()
Disposes this object along with resources allocated in the native DuckDB library for it.
Declaration
public void Dispose()
~DuckDbResultChunk()
Destructor which will dispose this object if it has yet been already.
Declaration
protected ~DuckDbResultChunk()
GetColumnIndex(string)
Declaration
public int GetColumnIndex(string columnName)
Parameters
Type | Name | Description |
---|---|---|
string | columnName |
Returns
Type | Description |
---|---|
int |
GetColumnInfo(int)
Declaration
public DuckDbColumnInfo GetColumnInfo(int columnIndex)
Parameters
Type | Name | Description |
---|---|---|
int | columnIndex |
Returns
Type | Description |
---|---|
DuckDbColumnInfo |
GetColumnName(int)
Declaration
public string GetColumnName(int columnIndex)
Parameters
Type | Name | Description |
---|---|---|
int | columnIndex |
Returns
Type | Description |
---|---|
string |
ProcessContents<TState, TResult>(TState, DuckDbChunkReadingFunc<TState, TResult>)
Access the contents of this chunk of results in a direct, column-oriented manner.
Declaration
public TResult ProcessContents<TState, TResult>(TState state, DuckDbChunkReadingFunc<TState, TResult> func) where TState : allows ref struct
Parameters
Type | Name | Description |
---|---|---|
TState | state | The state object or structure to pass into |
DuckDbChunkReadingFunc<TState, TResult> | func | The caller-specified function that receives the results from the next chunk and may do any processing on it. |
Returns
Type | Description |
---|---|
TResult | Whatever |
Type Parameters
Name | Description |
---|---|
TState | Type of arbitrary state to pass into the caller-specified function. |
TResult | The type of value returned by the caller-specified function. |
Remarks
This method offers fast, direct access to the native memory backing the DuckDB vectors (columns) of the results. However, to make these operations safe (allowing no dangling pointers), this library must be able to bound the scope of access. Thus, the code to consume the vectors' data must be encapsulated in a function that this method invokes.
This method can be called over and over again, and the same data will be seen by the caller-specified function on each invocation.