What is the best way to pass data using the Apache Arrow format from Node.js to Rust? Storing the data in each language is easy enough, but its the sharing memory that is giving me challenges.
I'm using Napi-rs to generate the node.js API bindings.
I'm getting a "Failed to create reference from Buffer" for the JavaScript code below. When I try to pass arrowVector.data[0].buffers
to the rust function I get "../src/node_buffer.cc:245:char *node::Buffer::Data(Local<v8::Value>): Assertion `val->IsArrayBufferView()' failed."
I think I'm missing something core here.
Here is my sample Node test code:
import { makeVector } from 'apache-arrow';
import {testFn} from './index.js';
// Create arrow Vec
const LENGTH = 2000;
const rainAmounts = Float32Array.from(
{ length: LENGTH },
() => Number((Math.random() * 20).toFixed(1)));
const arrowVector = makeVector(rainAmounts);
// how to get buffers from vec? and send to rust function
testFn(arrowVector);
Here is my sample Rust code:
use napi::bindgen_prelude::Buffer;
#[napi]
pub fn test_fn(buffers: Buffer) {
println!("test_fn called");
}