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 2020/06/05 10:03:45 UTC

[GitHub] [arrow] rymurr commented on a change in pull request #7248: ARROW-8402: [Java] Support ValidateFull methods in Java

rymurr commented on a change in pull request #7248:
URL: https://github.com/apache/arrow/pull/7248#discussion_r435819400



##########
File path: java/vector/src/main/java/org/apache/arrow/vector/util/ValueVectorUtility.java
##########
@@ -90,42 +90,59 @@ public static String getToString(ValueVector vector, int start, int end) {
   }
 
   /**
-   * Validate field vector.
+   * Utility to validate vector in O(1) time.
    */
-  public static void validate(FieldVector vector) {
+  public static void validate(ValueVector vector) {
     Preconditions.checkNotNull(vector);
 
-    ArrowType arrowType = vector.getField().getType();
-    int typeBufferCount = TypeLayout.getTypeBufferCount(arrowType);
-    TypeLayout typeLayout = TypeLayout.getTypeLayout(arrowType);
+    ValidateVectorTypeVisitor typeVisitor = new ValidateVectorTypeVisitor();
+    vector.accept(typeVisitor, null);
 
-    if (vector.getValueCount() < 0) {
-      throw new IllegalArgumentException("vector valueCount is negative");
-    }
+    ValidateVectorBufferVisitor bufferVisitor = new ValidateVectorBufferVisitor();
+    vector.accept(bufferVisitor, null);
+  }
 
-    if (vector.getFieldBuffers().size() != typeBufferCount) {
-      throw new IllegalArgumentException(String.format("Expected %s buffers in vector of type %s, got %s",
-          typeBufferCount, vector.getField().getType().toString(), vector.getBufferSize()));
-    }
+  /**
+   * Utility to validate vector in O(n) time, where n is the value count.
+   */
+  public static void validateFull(ValueVector vector) {
+    Preconditions.checkNotNull(vector);

Review comment:
       nit: call validate here and avoid a few lines of duplication




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

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