-
Notifications
You must be signed in to change notification settings - Fork 3.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
GH-40942: [Java] Implement C Data Interface for StringView #41967
Changes from 34 commits
fbbc73d
417b9ae
ffa8405
5f8e7e5
f2c09d9
6b794da
6306cc8
5f57dd5
3f56a3f
1f5f352
431ab79
815d6c5
183f4a4
1649271
c790853
6fa609d
506cb47
086d489
93b702f
eaa8478
5cf52a2
fe41c60
bf0f6fd
ab51fb1
690186a
6b59f22
a0f276a
e104f02
b8f53c7
48b05e9
e8618db
bcf5da5
3ef4dcc
460630a
d8c45a0
57cb306
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -260,6 +260,28 @@ private void createStructVector(StructVector vector) { | |
vector.setValueCount(2); | ||
} | ||
|
||
private void createStructVectorInline(StructVector vector) { | ||
final ViewVarCharVector child1 = | ||
vector.addOrGet( | ||
"f0", FieldType.nullable(MinorType.VIEWVARCHAR.getType()), ViewVarCharVector.class); | ||
final IntVector child2 = | ||
vector.addOrGet("f1", FieldType.nullable(MinorType.INT.getType()), IntVector.class); | ||
|
||
// Write the values to child 1 | ||
child1.allocateNew(); | ||
child1.set(0, "012345678".getBytes()); | ||
child1.set(1, "01234".getBytes()); | ||
vector.setIndexDefined(0); | ||
|
||
// Write the values to child 2 | ||
child2.allocateNew(); | ||
child2.set(0, 10); | ||
child2.set(1, 11); | ||
vector.setIndexDefined(1); | ||
|
||
vector.setValueCount(2); | ||
} | ||
|
||
@Test | ||
public void testVectorLoadUnloadOnStructVector() { | ||
try (final StructVector structVector1 = StructVector.empty("struct", allocator)) { | ||
|
@@ -293,4 +315,38 @@ public void testVectorLoadUnloadOnStructVector() { | |
} | ||
} | ||
} | ||
|
||
@Test | ||
public void testVectorLoadUnloadOnStructVectorWithInline() { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. What does this test have to do with dictionaries? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I was mainly trying to validate the updated C Data interface on There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @lidavidm any thoughts about this? |
||
try (final StructVector structVector1 = StructVector.empty("struct", allocator)) { | ||
createStructVectorInline(structVector1); | ||
Field field1 = structVector1.getField(); | ||
Schema schema = new Schema(field1.getChildren()); | ||
StructVectorUnloader vectorUnloader = new StructVectorUnloader(structVector1); | ||
|
||
try (ArrowRecordBatch recordBatch = vectorUnloader.getRecordBatch(); | ||
BufferAllocator finalVectorsAllocator = | ||
allocator.newChildAllocator("struct", 0, Long.MAX_VALUE); ) { | ||
// validating recordBatch contains an output for variadicBufferCounts | ||
assertFalse(recordBatch.getVariadicBufferCounts().isEmpty()); | ||
assertEquals(1, recordBatch.getVariadicBufferCounts().size()); | ||
assertEquals(0, recordBatch.getVariadicBufferCounts().get(0)); | ||
|
||
StructVectorLoader vectorLoader = new StructVectorLoader(schema); | ||
try (StructVector structVector2 = vectorLoader.load(finalVectorsAllocator, recordBatch)) { | ||
// Improve this after fixing https://github.com/apache/arrow/issues/41933 | ||
// assertTrue(VectorEqualsVisitor.vectorEquals(structVector1, structVector2), "vectors are | ||
// not equivalent"); | ||
assertTrue( | ||
VectorEqualsVisitor.vectorEquals( | ||
structVector1.getChild("f0"), structVector2.getChild("f0")), | ||
"vectors are not equivalent"); | ||
assertTrue( | ||
VectorEqualsVisitor.vectorEquals( | ||
structVector1.getChild("f1"), structVector2.getChild("f1")), | ||
"vectors are not equivalent"); | ||
} | ||
} | ||
} | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
minor change to keep the consistency which was a typo made in a previous PR.