-
Notifications
You must be signed in to change notification settings - Fork 46
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-317: [Java] add recipe for vector schema root appender cases #318
Conversation
java/source/data.rst
Outdated
import org.apache.arrow.vector.ipc.ArrowReader; | ||
import org.apache.arrow.vector.util.VectorSchemaRootAppender; | ||
|
||
VectorSchemaRoot appendVectorSchemaRootAsOne(BufferAllocator allocator) { |
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.
I think it would be clearer if we just constructed the vectors in-memory instead of having to pull in dataset for this
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.
Changed
java/source/data.rst
Outdated
Parquet file with three row groups, gets the three vectors separately, and then | ||
appends the three vectors together: | ||
|
||
There will be another cases of integration w |
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.
Cut off?
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.
Deleted
java/source/data.rst
Outdated
In some cases, VectorSchemaRoot needs to be modeled as a container. To accomplish | ||
this, you can use ``VectorSchemaRootAppender.append``. The following code reads a | ||
Parquet file with three row groups, gets the three vectors separately, and then | ||
appends the three vectors together: |
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.
Text needs updating
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.
Updated
java/source/data.rst
Outdated
try ( | ||
IntVector appenderOne = new IntVector("column", | ||
allocator); | ||
IntVector appenderTwo = new IntVector("column", | ||
allocator) | ||
) { | ||
appenderOne.allocateNew(2); | ||
appenderOne.set(0, 100); | ||
appenderOne.set(1, 20); | ||
appenderOne.setValueCount(2); | ||
appenderTwo.allocateNew(2); | ||
appenderTwo.set(0, 34); | ||
appenderTwo.set(1, 75); | ||
appenderTwo.setValueCount(2); | ||
try ( | ||
final VectorSchemaRoot rootOne = new VectorSchemaRoot( | ||
Collections.singletonList(appenderOne)); | ||
final VectorSchemaRoot rootTwo = new VectorSchemaRoot( | ||
Collections.singletonList(appenderTwo)) | ||
) { |
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.
Why so much nesting? This can be written more clearly.
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.
Updated
java/source/data.rst
Outdated
final VectorSchemaRoot rootTwo = new VectorSchemaRoot( | ||
Collections.singletonList(appenderTwo)) | ||
) { | ||
if (result == null) { |
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.
result is always null...
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.
Changed
java/source/data.rst
Outdated
VectorSchemaRootAppender.append(result, rootOne, rootTwo); | ||
System.out.print(result.contentToTSVString()); | ||
} | ||
result.close(); |
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.
try-with-resources
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.
Added
java/source/data.rst
Outdated
appenderTwo.set(1, 75); | ||
appenderTwo.setValueCount(2); | ||
try ( | ||
final VectorSchemaRoot rootOne = new VectorSchemaRoot( |
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.
you can just use a schema and VectorSchemaRoot.create
to get rid of the nesting here by initializing everything in the top-level try-with-resources
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.
Added
To solve #317