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



##########
File path: java/source/data.rst
##########
@@ -0,0 +1,316 @@
+=================
+Data manipulation
+=================
+
+Recipes related to compare, filtering or transforming data.
+
+.. contents::
+
+We are going to use this util for data manipulation:
+
+.. code-block:: java
+
+   import org.apache.arrow.algorithm.sort.VectorValueComparator;
+   import org.apache.arrow.memory.RootAllocator;
+   import org.apache.arrow.vector.IntVector;
+   import org.apache.arrow.vector.VarCharVector;
+
+   void setVector(IntVector vector, Integer... values) {
+      final int length = values.length;
+      vector.allocateNew(length);
+      for (int i = 0; i < length; i++) {
+          if (values[i] != null) {
+              vector.set(i, values[i]);
+          }
+      }
+      vector.setValueCount(length);
+   }
+
+  class TestVarCharSorter extends VectorValueComparator<VarCharVector> {
+    @Override
+    public int compareNotNull(int index1, int index2) {
+        byte b1 = vector1.get(index1)[0];
+        byte b2 = vector2.get(index2)[0];
+        return b1 - b2;
+    }
+
+    @Override
+    public VectorValueComparator<VarCharVector> createNew() {
+        return new TestVarCharSorter();
+    }
+  }
+  RootAllocator rootAllocator = new RootAllocator(Long.MAX_VALUE); // deal 
with byte buffer allocation
+
+Compare fields on the array

Review comment:
       > Should we try to be consistent about calling it a "vector" instead of 
an "array"?
   
   For this java cookbook we are decided to reuse "array" word that is used on 
python instead of mention "vector" that is only used on java 
   
   Array is more common word than Vector because at the end both terms are 
working close same
   
   How do you see that?
   




-- 
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: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


Reply via email to