Skip to content

[C++][JNI] DisposableScannerAdaptor does not handle arrays with offsets #30767

Closed as not planned

Description

@asfimport

The DisposableScannerAdaptor is a JNI bridge from Java to the C++ datasets API. When it scans record batches it collects all of the buffers from all of the arrays and returns a list of buffer handles to Java which puts these into an ArrowRecordBatch on the Java end.

Unfortunately, if the array has offsets then the bridge does not return the offset buffer but it returns the entire buffer. The Java record batch is then incorrect. The length is wrong (and so it doesn't fully free the memory) and the values are incorrect.

I'm not familiar enough with the Java implementation to suggest a good fix. Figuring out the buffer offsets from array offsets is a bit tricky since the logic depends on the data type. Also, I'm pretty sure the Java side now has to take ownership of the entire buffer which could be tricky because multiple batches could share ownership of the buffer.

As a temporary fix for ARROW-13554 I am going to copy the array if it has an offset. This means the transfer is not zero-copy so I'm creating this issue to solve this properly.

Reporter: Weston Pace / @westonpace

Related issues:

Note: This issue was originally created as ARROW-15275. Please see the migration documentation for further details.

Activity

  1. asfimport commented on Feb 22, 2022

    @asfimport
    Author

    Antoine Pitrou / @pitrou:
    The dataset JNI bridge seems to only handle primitive arrays (it doesn't transfer buffers for nested arrays, or dictionaries). It should simply be rewritten using the C data interface, now that Arrow Java supports it.

  2. thisisnic commented on Oct 22, 2026

    @thisisnic
    Member

    @pitrou - can we close this as superseded by #31199?

  3. pitrou commented on Oct 22, 2026

    @pitrou
    Member

    I think so, but someone more familiar with JNI could double-check. @kou Perhaps?

  4. kou commented on Oct 22, 2026

    @kou
    Member

    Let's close this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions