Class JniBridge

java.lang.Object
org.apache.datafusion.internal.JniBridge

public final class JniBridge extends Object
Internal trampoline invoked from native code on every UDF call. Not part of the public API.
  • Method Details

    • invokeScalarUdf

      public static byte invokeScalarUdf(ScalarFunction impl, long arrayArgsArrayAddr, long arrayArgsSchemaAddr, long scalarArgsArrayAddr, long scalarArgsSchemaAddr, byte[] argKinds, long resultArrayAddr, long resultSchemaAddr, int rowCount)
      Invoke a scalar UDF for one batch. Called from native code; not for application use.

      Args arrive split into two struct arrays: arrayArgs* of length rowCount holding the ColumnarValue.Array arguments in their relative order, and scalarArgs* of length 1 holding the ColumnarValue.Scalar arguments. argKinds records the original positional order so the bridge can interleave them back into a single List<ColumnarValue> for the user.

      Returns:
      KIND_ARRAY if the UDF returned an Array, KIND_SCALAR if it returned a Scalar. The native caller uses this to reconstruct the right ColumnarValue variant.
    • invokeTableScan

      public static void invokeTableScan(TableProvider provider, long ffiStreamAddr)
      Open a fresh batch stream from a Java TableProvider and export it through the supplied Arrow C Data Interface address. Called from native code; not for application use.

      TableProvider.scan(org.apache.arrow.memory.BufferAllocator) is called with ALLOCATOR so that the reader's buffers share the same allocator root required by Data.exportArrayStream(org.apache.arrow.memory.BufferAllocator, org.apache.arrow.vector.ipc.ArrowReader, org.apache.arrow.c.ArrowArrayStream).

      On success, ownership of the returned reader transfers to the FFI stream's release callback, so the native side closing the stream also closes the reader. On any failure during export, the reader is closed here before the exception propagates.