You are viewing a plain text version of this content. The canonical link for it is here.
Posted to github@arrow.apache.org by GitBox <gi...@apache.org> on 2022/01/27 21:34:51 UTC

[GitHub] [arrow-cookbook] davisusanibar commented on a change in pull request #131: [Java]: Java cookbook for create arrow object

davisusanibar commented on a change in pull request #131:
URL: https://github.com/apache/arrow-cookbook/pull/131#discussion_r794017064



##########
File path: java/source/create.rst
##########
@@ -30,8 +30,135 @@ Array of Int (32-bit integer value)
    intVector.set(2, 3);
    intVector.setValueCount(3);
 
-   System.out.println(intVector);
+   System.out.print(intVector);
 
 .. testoutput::
 
-    [1, 2, 3]
\ No newline at end of file
+    [1, 2, 3]
+
+
+Array of Varchar
+----------------
+
+.. testcode::
+
+    import org.apache.arrow.vector.VarCharVector;
+    import org.apache.arrow.memory.RootAllocator;
+
+    RootAllocator rootAllocator = new RootAllocator(Long.MAX_VALUE);
+
+    VarCharVector varVector = new VarCharVector("varVector", rootAllocator);
+    varVector.allocateNew(3);
+    varVector.set(0, "one".getBytes());
+    varVector.set(1, "two".getBytes());
+    varVector.set(2, "three".getBytes());
+    varVector.setValueCount(3);
+
+    System.out.print(varVector);
+
+.. testoutput::
+
+    [one, two, three]
+
+Array of List
+-------------
+
+.. testcode::
+
+    import org.apache.arrow.memory.RootAllocator;
+    import org.apache.arrow.vector.types.Types.MinorType;
+    import org.apache.arrow.vector.types.pojo.FieldType;
+    import org.apache.arrow.vector.complex.ListVector;
+    import org.apache.arrow.vector.IntVector;
+    import org.apache.arrow.vector.BitVectorHelper;
+    import org.apache.arrow.vector.complex.BaseRepeatedValueVector;
+
+    RootAllocator rootAllocator = new RootAllocator(Long.MAX_VALUE);
+
+    ListVector listVector = ListVector.empty("listVector", rootAllocator);
+    listVector.allocateNew();
+    MinorType type = MinorType.INT;
+    listVector.addOrGetVector(FieldType.nullable(type.getType()));

Review comment:
       Changed




-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: github-unsubscribe@arrow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org