Hi,

I will get ArrowSchema and ArrowArray directly from DuckDB. I want to transfer 
the RecordBatch to Bun with bun::ffi. At the moment my procedure is the 
following:
  auto schema = arrow::ImportSchema(arrow_schema);
  auto batch = arrow::ImportRecordBatch(arrow_array, *schema);
  auto output_stream = arrow::io::BufferOutputStream::Create();
  auto batch_writer = arrow::ipc::MakeStreamWriter(*output_stream, *schema);
  auto status = (*batch_writer)->WriteRecordBatch(**batch);
  auto buffer = (*output_stream)->Finish();
  (*out).address = (void *)(*buffer)->address();
  (*out).size = (*buffer)->size();

And then I will read the buffer in Bun with toArrayBuffer and RecordBatchReader 
like this:
  return RecordBatchReader.from(
    toArrayBuffer(
      dab.dab_ipc_address(ipc), 0, Number(dab.dab_ipc_size(ipc))
      )).readAll()[0];

I just wonder Is there a way to read RecordBatch directly from RecordBatch 
which is done by ImportRecordBatch or can I do this without OutputStream at all?

Best regards,

Kimmo

-- 
Kimmo Linna
Nihtisalontie 3 as 1
02630  ESPOO
[email protected]
+358 40 590 1074



Reply via email to