Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions c/src/main/java/org/apache/arrow/c/ArrayImporter.java
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,10 @@ final class ArrayImporter {
void importArray(ArrowArray src) {
ArrowArray.Snapshot snapshot = src.snapshot();
checkState(snapshot.release != NULL, "Cannot import released ArrowArray");
checkState(
snapshot.offset == 0,
"ArrowArray struct has non-zero offset (%s), which is not supported",
snapshot.offset);

// Move imported array
ArrowArray ownedArray = ArrowArray.allocateNew(allocator);
Expand Down
3 changes: 2 additions & 1 deletion c/src/main/java/org/apache/arrow/c/Data.java
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,8 @@
/**
* Functions for working with the C data interface.
*
* <p>This API is EXPERIMENTAL. Note that currently only 64bit systems are supported.
* <p>This API is EXPERIMENTAL. Note that currently only 64bit systems are supported. Importing
* {@link ArrowArray ArrowArrays} with a non-zero offset is not supported.
*/
public final class Data {

Expand Down
21 changes: 21 additions & 0 deletions c/src/test/java/org/apache/arrow/c/RoundtripTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -1051,6 +1051,27 @@ public void testImportReleasedArray() {
}
}

@Test
public void testImportArrayWithNonZeroOffset() {
try (IntVector source = new IntVector("source", allocator);
IntVector destination = new IntVector("destination", allocator);
ArrowArray array = ArrowArray.allocateNew(allocator)) {
setVector(source, 1, 2, 3);
Data.exportVector(allocator, source, null, array);

ArrowArray.Snapshot snapshot = array.snapshot();
snapshot.offset = 1;
array.save(snapshot);

Exception e =
assertThrows(
IllegalStateException.class,
() -> Data.importIntoVector(allocator, array, destination, null));
assertEquals(
"ArrowArray struct has non-zero offset (1), which is not supported", e.getMessage());
}
}

@Test
public void testArrayStructReuse() {
// Consumer allocates empty structures
Expand Down
5 changes: 5 additions & 0 deletions docs/source/cdata.rst
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,11 @@ C Data Interface
Arrow supports exchanging data without copying or serialization within the same process
through :external+arrow:ref:`c-data-interface`, even between different language runtimes.

.. note::

The Arrow Java C Data Interface implementation does not support importing arrays with
a non-zero offset.

Java to Python
--------------

Expand Down
Loading