From f225c34d82cb6ea4133af64c34f977be00769afc Mon Sep 17 00:00:00 2001 From: Ekaitz Zarraga Date: Thu, 1 Aug 2024 23:56:10 +0200 Subject: Prepare for checking exhaustion --- src/duckdb/Result.zig | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) (limited to 'src/duckdb') diff --git a/src/duckdb/Result.zig b/src/duckdb/Result.zig index 8e06b67..f399fb5 100644 --- a/src/duckdb/Result.zig +++ b/src/duckdb/Result.zig @@ -54,13 +54,12 @@ pub fn Result(comptime T: type) type{ /// There's not way to know how many total elements we have, but we can /// know how many we have in the current chunk. fn getCurrentChunkSize(self: Self) usize { - if (self._chunk == null) { - return 0; - } + std.debug.assert(self._chunk != null); return c.duckdb_data_chunk_get_size(self._chunk); } pub fn getColumnCount(self: Self) usize { + std.debug.assert(self._chunk != null); return c.duckdb_data_chunk_get_column_count(self._chunk); } @@ -70,8 +69,6 @@ pub fn Result(comptime T: type) type{ fn fetchDataChunk(self: *Self) void{ if (self._chunk != null){ c.duckdb_destroy_data_chunk(&self._chunk); - self._chunk = null; - self._current_row = 0; } self._chunk = c.duckdb_fetch_chunk(self._res); for (self._columns, 0..) |_, i| { @@ -81,10 +78,10 @@ pub fn Result(comptime T: type) type{ self._data[i] = c.duckdb_vector_get_data(col); } self._current_row = 0; - } pub fn exausted(self: Self) bool{ + // TODO: check exhaustion properly return self._chunk != null; } -- cgit v1.2.3