This is an automated email from the ASF dual-hosted git repository.
lidavidm pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/arrow-cookbook.git
The following commit(s) were added to refs/heads/main by this push:
new 9353b68 [Java] Add splicing non-zero index example (#242)
9353b68 is described below
commit 9353b68440d556da150fb582faa3d9d33b2a1183
Author: Ash <[email protected]>
AuthorDate: Mon Aug 8 04:48:50 2022 -0700
[Java] Add splicing non-zero index example (#242)
* added non-zero index splicing example
* fixed build failure
* merged examples into one
---
java/source/create.rst | 10 +++++++++-
1 file changed, 9 insertions(+), 1 deletion(-)
diff --git a/java/source/create.rst b/java/source/create.rst
index 342ee0e..4ab2ebf 100644
--- a/java/source/create.rst
+++ b/java/source/create.rst
@@ -212,6 +212,13 @@ In this example, we copy a portion of the input IntVector
to a new IntVector.
TransferPair tp = vector.getTransferPair(allocator);
tp.splitAndTransfer(0, 5);
+ try (IntVector sliced = (IntVector) tp.getTo()) {
+ System.out.println(sliced);
+ }
+
+ tp = vector.getTransferPair(allocator);
+ // copy 6 elements from index 2
+ tp.splitAndTransfer(2, 6);
try (IntVector sliced = (IntVector) tp.getTo()) {
System.out.print(sliced);
}
@@ -220,7 +227,8 @@ In this example, we copy a portion of the input IntVector
to a new IntVector.
.. testoutput::
[0, 1, 2, 3, 4]
-
+ [2, 3, 4, 5, 6, 7]
+
.. _`FieldVector`:
https://arrow.apache.org/docs/java/reference/org/apache/arrow/vector/FieldVector.html
.. _`ValueVector`: https://arrow.apache.org/docs/java/vector.html
.. _`dictionary-encoding`:
https://arrow.apache.org/docs/format/Columnar.html#dictionary-encoded-layout