Skip to content

Commit

Permalink
Basic list support
Browse files Browse the repository at this point in the history
  • Loading branch information
Giorgi committed Oct 1, 2023
1 parent b01befb commit 421983d
Show file tree
Hide file tree
Showing 5 changed files with 467 additions and 52 deletions.
28 changes: 28 additions & 0 deletions DuckDB.NET.Bindings/DuckDBNativeObjects.cs
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,28 @@ public enum DuckDBType
Varchar,
// duckdb_blob
Blob,
//decimal
Decimal,
// duckdb_timestamp, in seconds
TimestampS,
// duckdb_timestamp, in milliseconds
TimestampMs,
// duckdb_timestamp, in nanoseconds
TimestampNs,
// enum type, only useful as logical type
Enum,
// list type, only useful as logical type
List,
// struct type, only useful as logical type
Struct,
// map type, only useful as logical type
Map,
// duckdb_hugeint
Uuid,
// union type, only useful as logical type
Union,
// duckdb_bit
Bit,
}

[StructLayout(LayoutKind.Sequential)]
Expand Down Expand Up @@ -117,6 +138,13 @@ public void Dispose()
}
}

[StructLayout(LayoutKind.Sequential)]
public struct DuckDBListEntry
{
public ulong Offset { get; }
public ulong Length { get; }
}

[StructLayout(LayoutKind.Sequential)]
public struct DuckDBHugeInt
{
Expand Down
4 changes: 2 additions & 2 deletions DuckDB.NET.Bindings/NativeMethods/NativeMethods.DataChunks.cs
Original file line number Diff line number Diff line change
Expand Up @@ -26,13 +26,13 @@ public static class DataChunks
public static extern unsafe ulong* DuckDBVectorGetValidity(IntPtr vector);

[DllImport(DuckDbLibrary, CallingConvention = CallingConvention.Cdecl, EntryPoint = "duckdb_list_vector_get_child")]
public static extern long DuckDBListVectorGetChild(IntPtr vector);
public static extern IntPtr DuckDBListVectorGetChild(IntPtr vector);

[DllImport(DuckDbLibrary, CallingConvention = CallingConvention.Cdecl, EntryPoint = "duckdb_list_vector_get_size")]
public static extern long DuckDBListVectorGetSize(IntPtr vector);

[DllImport(DuckDbLibrary, CallingConvention = CallingConvention.Cdecl, EntryPoint = "duckdb_struct_vector_get_child")]
public static extern long DuckDBStructVectorGetChild(IntPtr vector, long index);
public static extern IntPtr DuckDBStructVectorGetChild(IntPtr vector, long index);

[DllImport(DuckDbLibrary, CallingConvention = CallingConvention.Cdecl, EntryPoint = "duckdb_destroy_data_chunk")]
public static extern void DuckDBDestroyDataChunk(out IntPtr chunk);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,9 @@ public static class LogicalType
[DllImport(DuckDbLibrary, CallingConvention = CallingConvention.Cdecl, EntryPoint = "duckdb_decimal_internal_type")]
public static extern DuckDBType DuckDBDecimalInternalType(DuckDBLogicalType type);

[DllImport(DuckDbLibrary, CallingConvention = CallingConvention.Cdecl, EntryPoint = "duckdb_list_type_child_type")]
public static extern DuckDBLogicalType DuckDBListTypeChildType(DuckDBLogicalType type);

[DllImport(DuckDbLibrary, CallingConvention = CallingConvention.Cdecl, EntryPoint = "duckdb_destroy_logical_type")]
public static extern void DuckDBDestroyLogicalType(out IntPtr type);
}
Expand Down
Loading

0 comments on commit 421983d

Please sign in to comment.