Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
46 commits
Select commit Hold shift + click to select a range
f819459
initial commit of Table support
lwhite1 Sep 29, 2022
e64843c
Initial commit of Table support
lwhite1 Sep 29, 2022
abdc234
Update readme with description of exports
lwhite1 Sep 29, 2022
0062d41
Added "experimental API" text to class javadoc
lwhite1 Sep 29, 2022
8b943e1
removed charset options, since arrow doesn't support anything but UTF-8
lwhite1 Sep 30, 2022
89c5299
Merge branch 'apache:master' into 17883-implement-immutable-table
lwhite1 Sep 30, 2022
928d672
Update README.md
lwhite1 Sep 30, 2022
06af9fc
Merge branch '17883-implement-immutable-table' of https://github.com/…
lwhite1 Sep 30, 2022
af63c9f
Added a variation to Data.exportTable
lwhite1 Sep 30, 2022
8437401
More tests; better documentation
lwhite1 Sep 30, 2022
3ac5eff
cleanup and additional test for table
lwhite1 Sep 30, 2022
2a99072
doc and minor tweak to row.
lwhite1 Oct 1, 2022
5764cdd
Merge branch 'apache:master' into 17883-implement-immutable-table
lwhite1 Oct 1, 2022
1fb9751
Extended tests to do initial coverage of UInt vectors
lwhite1 Oct 1, 2022
016f657
Initial set of getter tests using value holders
lwhite1 Oct 1, 2022
879a3f6
added tests for holders for time and timestamp vector types
lwhite1 Oct 1, 2022
bdc3647
Added tests for varbinary and varchar vectors. Some new test methods …
lwhite1 Oct 1, 2022
c5fefa5
more Row tests
lwhite1 Oct 2, 2022
98ce8f2
added tests for duration vectors
lwhite1 Oct 2, 2022
a34dc6f
Minor improvements in testing timestamp vectors
lwhite1 Oct 2, 2022
8631e68
Added tests for bitvector
lwhite1 Oct 2, 2022
c225f5c
added tests for time milli vector
lwhite1 Oct 2, 2022
77e5a64
additional time vector tests
lwhite1 Oct 2, 2022
484bad5
Merge branch 'apache:master' into 17883-implement-immutable-table
lwhite1 Oct 3, 2022
4439648
add support for timestamp with TZ tests and some additional duration …
lwhite1 Oct 3, 2022
f95413a
Merge branch '17883-implement-immutable-table' of https://github.com/…
lwhite1 Oct 3, 2022
33b70db
Added tests for interval day vectors
lwhite1 Oct 3, 2022
bdc2111
tests for interval month and year vectors
lwhite1 Oct 3, 2022
07088bb
added missing tests for complex types
lwhite1 Oct 3, 2022
fdaf4a8
Added tests for extension type, and fixed bug in extensiontype code
lwhite1 Oct 3, 2022
38451d2
remove unnecessary import statement
lwhite1 Oct 3, 2022
420b7eb
cleanup
lwhite1 Oct 3, 2022
2259219
fix line length
lwhite1 Oct 3, 2022
26de767
Documentation and minor cleanup
lwhite1 Oct 4, 2022
a92fff9
fix whitespace
lwhite1 Oct 4, 2022
0159c8f
Update BaseTableTest.java
lwhite1 Oct 4, 2022
27a9bb6
remove unused import
lwhite1 Oct 4, 2022
20339dc
Added Table test to RoundTripTest
lwhite1 Oct 4, 2022
5efff41
Update README.md
lwhite1 Oct 4, 2022
a68d114
fixed inconsistent method signature
lwhite1 Oct 4, 2022
a6d8a05
Merge branch 'apache:master' into 17883-implement-immutable-table
lwhite1 Oct 4, 2022
0c2c151
undo temp changes to pom
lwhite1 Oct 4, 2022
fc00850
Add apache license text to README.md
lwhite1 Oct 5, 2022
983f311
fix readme issues
lwhite1 Oct 5, 2022
c844047
Restore line erroneously deleted
lwhite1 Oct 5, 2022
3887d8c
Removes BaseRow class and converts CharSet variable to static
lwhite1 Oct 5, 2022
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
59 changes: 57 additions & 2 deletions java/c/src/main/java/org/apache/arrow/c/Data.java
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
import org.apache.arrow.vector.dictionary.DictionaryProvider;
import org.apache.arrow.vector.ipc.ArrowReader;
import org.apache.arrow.vector.ipc.message.ArrowRecordBatch;
import org.apache.arrow.vector.table.Table;
import org.apache.arrow.vector.types.pojo.ArrowType;
import org.apache.arrow.vector.types.pojo.ArrowType.ArrowTypeID;
import org.apache.arrow.vector.types.pojo.Field;
Expand Down Expand Up @@ -114,22 +115,76 @@ public static void exportVector(BufferAllocator allocator, FieldVector vector, D
exporter.export(out, vector, provider);
}

/**
* Export the current contents of a Java Table using the C data
* interface format.
* <p>
* The table is exported as if it were a struct array. The
* resulting ArrowArray struct keeps the record batch data and buffers alive
* until its release callback is called by the consumer.
*
* @param allocator Buffer allocator for allocating C data interface fields
* @param table Table to export
* @param out C struct where to export the record batch
*/
public static void exportTable(BufferAllocator allocator, Table table, ArrowArray out) {
exportTable(allocator, table, table.getDictionaryProvider(), out, null);
}

/**
* Export the current contents of a Java Table using the C data
* interface format.
* <p>
* The table is exported as if it were a struct array. The
* resulting ArrowArray struct keeps the record batch data and buffers alive
* until its release callback is called by the consumer.
*
* @param allocator Buffer allocator for allocating C data interface fields
* @param table Table to export
* @param provider Dictionary provider for dictionary encoded vectors
* (optional)
* @param out C struct where to export the record batch
*/
public static void exportTable(BufferAllocator allocator, Table table,
DictionaryProvider provider, ArrowArray out) {
exportTable(allocator, table, provider, out, null);
}

/**
* Export the current contents of a Java Table using the C data interface format.
* <p>
* The table is exported as if it were a struct array. The
* resulting ArrowArray struct keeps the record batch data and buffers alive
* until its release callback is called by the consumer.
*
* @param allocator Buffer allocator for allocating C data interface fields
* @param table Table to export
* @param provider Dictionary provider for dictionary encoded vectors
* (optional)
* @param out C struct where to export the record batch
* @param outSchema C struct where to export the record batch schema (optional)
*/
public static void exportTable(BufferAllocator allocator, Table table,
DictionaryProvider provider, ArrowArray out, ArrowSchema outSchema) {
exportVectorSchemaRoot(allocator, table.toVectorSchemaRoot(), provider, out, outSchema);
}

/**
* Export the current contents of a Java VectorSchemaRoot using the C data
* interface format.
* <p>
* The vector schema root is exported as if it were a struct array. The
* resulting ArrowArray struct keeps the record batch data and buffers alive
* until its release callback is called by the consumer.
*
*
* @param allocator Buffer allocator for allocating C data interface fields
* @param vsr Vector schema root to export
* @param provider Dictionary provider for dictionary encoded vectors
* (optional)
* @param out C struct where to export the record batch
*/
public static void exportVectorSchemaRoot(BufferAllocator allocator, VectorSchemaRoot vsr,
DictionaryProvider provider, ArrowArray out) {
DictionaryProvider provider, ArrowArray out) {
exportVectorSchemaRoot(allocator, vsr, provider, out, null);
}

Expand Down
34 changes: 34 additions & 0 deletions java/c/src/test/java/org/apache/arrow/c/RoundtripTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,7 @@
import org.apache.arrow.vector.holders.IntervalDayHolder;
import org.apache.arrow.vector.holders.NullableLargeVarBinaryHolder;
import org.apache.arrow.vector.holders.NullableUInt4Holder;
import org.apache.arrow.vector.table.Table;
import org.apache.arrow.vector.types.TimeUnit;
import org.apache.arrow.vector.types.Types.MinorType;
import org.apache.arrow.vector.types.pojo.ArrowType;
Expand Down Expand Up @@ -657,6 +658,39 @@ public void testVectorSchemaRoot() {
imported.close();
}

/**
* Tests exporting Table and importing back to VSR. Importing back to Table is not supported at present.
*/
@Test
public void testTable() {
VectorSchemaRoot imported;

// Consumer allocates empty structures
try (ArrowSchema consumerArrowSchema = ArrowSchema.allocateNew(allocator);
ArrowArray consumerArrowArray = ArrowArray.allocateNew(allocator)) {
try (
VectorSchemaRoot vsr = createTestVSR();
Table table = new Table(vsr);
) {
// Producer creates structures from existing memory pointers
try (ArrowSchema arrowSchema = ArrowSchema.wrap(consumerArrowSchema.memoryAddress());
ArrowArray arrowArray = ArrowArray.wrap(consumerArrowArray.memoryAddress())) {
// Producer exports vector into the C Data Interface structures
Data.exportTable(allocator, table, arrowArray);
}
}
// Consumer imports vector
imported = Data.importVectorSchemaRoot(allocator, consumerArrowArray, consumerArrowSchema, null);
}

// Ensure that imported VectorSchemaRoot is valid even after C Data Interface
// structures are closed
try (VectorSchemaRoot original = createTestVSR()) {
assertTrue(imported.equals(original));
}
imported.close();
}

@Test
public void testVectorSchemaRootWithDuplicatedFieldNames() {
VectorSchemaRoot imported;
Expand Down
10 changes: 5 additions & 5 deletions java/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -303,9 +303,9 @@
<version>8.19</version>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>jcl-over-slf4j</artifactId>
<version>1.7.5</version>
<groupId>org.slf4j</groupId>
<artifactId>jcl-over-slf4j</artifactId>
<version>1.7.5</version>
</dependency>
</dependencies>
<executions>
Expand Down Expand Up @@ -749,7 +749,7 @@
<!-- Use the version of arrow-vector that shades flatbuffers and packages format -->
<id>shade-flatbuffers</id>
<properties>
<arrow.vector.classifier>shade-format-flatbuffers</arrow.vector.classifier>
<arrow.vector.classifier>shade-format-flatbuffers</arrow.vector.classifier>
</properties>
</profile>

Expand All @@ -763,7 +763,7 @@
<activation>
<jdk>1.8</jdk>
<property>
<name>!m2e.version</name>
<name>!m2e.version</name>
</property>
</activation>
<build>
Expand Down
Loading