Skip to content

Commit

Permalink
introduce bind buffer step
Browse files Browse the repository at this point in the history
  • Loading branch information
pacman82 committed Feb 2, 2024
1 parent 4278cb8 commit 91e309a
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 1 deletion.
2 changes: 1 addition & 1 deletion python/arrow_odbc/reader.py
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ def more_results(
ptr_schema = _export_schema_to_c(schema)

with ffi.new("bool *") as has_more_results_c:
error = lib.arrow_odbc_reader_next_result_set(
error = lib.arrow_odbc_reader_bind_buffers(
self.handle,
has_more_results_c,
batch_size,
Expand Down
34 changes: 34 additions & 0 deletions src/reader.rs
Original file line number Diff line number Diff line change
Expand Up @@ -166,6 +166,40 @@ pub unsafe extern "C" fn arrow_odbc_reader_next_result_set(
null_mut()
}

/// # Safety
///
/// * `reader` must point to a valid non-null reader, allocated by [`arrow_odbc_reader_make`].
/// * `has_more_results` must point to a valid boolean.
/// * `schema`: Optional input arrow schema. NULL means no input schema is supplied. Should a
/// schema be supplied `schema` Rust will take ownership of it an the `schema` will be
/// overwritten with an empty one. This means the Python code, must only deallocate the memory
/// directly pointed to by `schema`, but not freeing the resources of the passed schema.
#[no_mangle]
pub unsafe extern "C" fn arrow_odbc_reader_bind_buffers(
mut reader: NonNull<ArrowOdbcReader>,
has_more_results: *mut bool,
max_num_rows_per_batch: usize,
max_bytes_per_batch: usize,
max_text_size: usize,
max_binary_size: usize,
fallibale_allocations: bool,
schema: *mut c_void,
) -> *mut ArrowOdbcError {
let schema = take_schema(schema);

let reader_builder = reader_builder_from_c_args(
max_text_size,
max_binary_size,
max_num_rows_per_batch,
max_bytes_per_batch,
fallibale_allocations,
schema,
);
// Move cursor to the next result set.
*has_more_results = try_!(reader.as_mut().next_result_set(reader_builder));
null_mut()
}

/// Retrieve the associated schema from a reader.
#[no_mangle]
pub unsafe extern "C" fn arrow_odbc_reader_schema(
Expand Down

0 comments on commit 91e309a

Please sign in to comment.