amol- commented on a change in pull request #135:
URL: https://github.com/apache/arrow-cookbook/pull/135#discussion_r797521070



##########
File path: java/source/data.rst
##########
@@ -0,0 +1,360 @@
+=================
+Data manipulation
+=================
+
+Recipes related to compare, filtering or transforming data.
+
+.. contents::
+
+Compare Vectors for Field Equality
+==================================
+
+.. testcode::
+
+    import org.apache.arrow.vector.IntVector;
+    import org.apache.arrow.vector.compare.TypeEqualsVisitor;
+    import org.apache.arrow.memory.RootAllocator;
+
+    RootAllocator rootAllocator = new RootAllocator(Long.MAX_VALUE);
+    IntVector right = new IntVector("int", rootAllocator);
+    right.allocateNew(3);
+    right.set(0, 10);
+    right.set(1, 20);
+    right.set(2, 30);
+    right.setValueCount(3);
+    IntVector left1 = new IntVector("int", rootAllocator);
+    IntVector left2 = new IntVector("int2", rootAllocator);
+    TypeEqualsVisitor visitor = new TypeEqualsVisitor(right);
+
+    System.out.println(visitor.equals(left1));
+    System.out.println(visitor.equals(left2));
+
+.. testoutput::
+
+    true
+    false
+
+Compare Values on the Array
+===========================
+
+Comparing two values at the given indices in the vectors:
+
+.. testcode::
+
+    import org.apache.arrow.algorithm.sort.StableVectorComparator;
+    import org.apache.arrow.algorithm.sort.VectorValueComparator;
+    import org.apache.arrow.vector.VarCharVector;
+    import org.apache.arrow.memory.RootAllocator;
+
+    class TestVectorValueComparator 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 TestVectorValueComparator();
+        }
+    }

Review comment:
       I'm not sure why we are making our own implementation of 
`VectorValueComparator`.
   The user coming here looking for information on how to compare the values in 
two arrays might be confused by this and think that it's required instead of 
just using one of the provided subclasses. It's important that recipes don't 
include anymore than the minimum code required to answer the question.




-- 
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