|
25 | 25 | #include <cstdint> |
26 | 26 | #include <cstring> |
27 | 27 |
|
| 28 | +// FFI ownership contract (Arrow C Data Interface): |
| 29 | +// - `lance_get_schema` returns an opaque schema handle. The caller must release |
| 30 | +// it exactly once via `lance_free_schema`. |
| 31 | +// - `lance_schema_to_arrow` populates `out_schema` on success (return 0) and |
| 32 | +// transfers ownership of the ArrowSchema to the caller, who must call |
| 33 | +// `out_schema->release(out_schema)` exactly once (or wrap it in RAII). |
| 34 | +// - `lance_create_stream`/`lance_create_fragment_stream` return an opaque stream |
| 35 | +// handle. The caller must release it exactly once via `lance_close_stream`. |
| 36 | +// - `lance_stream_next` returns an opaque RecordBatch handle. The caller must |
| 37 | +// release it exactly once via `lance_free_batch` after use. |
| 38 | +// - `lance_batch_to_arrow` populates `out_array` and `out_schema` on success |
| 39 | +// (return 0) and transfers ownership of both to the caller, who must call |
| 40 | +// `release` exactly once on each. |
| 41 | +// - On error, the callee leaves output `ArrowSchema`/`ArrowArray` untouched; do |
| 42 | +// not call `release` unless the caller initialized them to a valid value. |
28 | 43 | extern "C" { |
29 | 44 | void *lance_open_dataset(const char *path); |
30 | 45 | void lance_close_dataset(void *dataset); |
@@ -524,6 +539,8 @@ static unique_ptr<FunctionData> LanceScanBind(ClientContext &context, |
524 | 539 | result->file_path + LanceFormatErrorSuffix()); |
525 | 540 | } |
526 | 541 |
|
| 542 | + memset(&result->schema_root.arrow_schema, 0, |
| 543 | + sizeof(result->schema_root.arrow_schema)); |
527 | 544 | if (lance_schema_to_arrow(schema_handle, &result->schema_root.arrow_schema) != |
528 | 545 | 0) { |
529 | 546 | lance_free_schema(schema_handle); |
@@ -676,6 +693,7 @@ static bool LanceScanLoadNextBatch(LanceScanLocalState &local_state) { |
676 | 693 | } |
677 | 694 |
|
678 | 695 | auto new_chunk = make_shared_ptr<ArrowArrayWrapper>(); |
| 696 | + memset(&new_chunk->arrow_array, 0, sizeof(new_chunk->arrow_array)); |
679 | 697 | ArrowSchema tmp_schema; |
680 | 698 | memset(&tmp_schema, 0, sizeof(tmp_schema)); |
681 | 699 |
|
|
0 commit comments