You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@drill.apache.org by GitBox <gi...@apache.org> on 2019/10/21 11:31:46 UTC

[GitHub] [drill] arina-ielchiieva commented on a change in pull request #1871: DRILL-7403: Validate batch checks, vector integretity in unit tests

arina-ielchiieva commented on a change in pull request #1871: DRILL-7403: Validate batch checks, vector integretity in unit tests
URL: https://github.com/apache/drill/pull/1871#discussion_r336966111
 
 

 ##########
 File path: exec/java-exec/src/main/java/org/apache/drill/exec/physical/impl/validate/BatchValidator.java
 ##########
 @@ -150,57 +424,63 @@ private int validateOffsetVector(String name, UInt4Vector offsetVector, int valu
       error(name, offsetVector, "Offset (0) must be 0 but was " + prevOffset);
     }
 
-    // Note <= comparison: offset vectors have (n+1) entries.
-
-    for (int i = 1; i <= valueCount; i++) {
-      int offset = accessor.get(i);
+    for (int i = 1; i < offsetCount; i++) {
+      final int offset = accessor.get(i);
       if (offset < prevOffset) {
-        error(name, offsetVector, "Decreasing offsets at (" + (i-1) + ", " + i + ") = (" + prevOffset + ", " + offset + ")");
+        error(name, offsetVector, String.format(
+            "Offset vector [%d] contained %d, expected >= %d",
+            i, offset, prevOffset));
       } else if (offset > maxOffset) {
-        error(name, offsetVector, "Invalid offset at index " + i + " = " + offset + " exceeds maximum of " + maxOffset);
+        error(name, offsetVector, String.format(
+            "Invalid offset at index %d: %d exceeds maximum of %d",
+            i, offset, maxOffset));
       }
       prevOffset = offset;
     }
     return prevOffset;
   }
 
   private void error(String name, ValueVector vector, String msg) {
-    if (errorCount == 0) {
-      logger.error("Found one or more vector errors from " + batch.getClass().getSimpleName());
-    }
-    errorCount++;
-    if (errorCount >= MAX_ERRORS) {
-      return;
-    }
-    String fullMsg = "Column " + name + " of type " + vector.getClass().getSimpleName( ) + ": " + msg;
-    logger.error(fullMsg);
-    if (errorList != null) {
-      errorList.add(fullMsg);
-    }
+    errorReporter.error(name, vector, msg);
   }
 
-  private void validateNullableVector(String name, NullableVector vector) {
-    // Can't validate at this time because the bits vector is in each
-    // generated subtype.
-
-    // Validate a VarChar vector because it is common.
-
-    if (vector instanceof NullableVarCharVector) {
-      VarCharVector values = ((NullableVarCharVector) vector).getValuesVector();
-      validateVarCharVector(name + "-values", values, rowCount);
+  private void verifyIsSetVector(ValueVector parent, UInt1Vector bv) {
+    final String name = String.format("%s (%s)-bits",
+        parent.getField().getName(),
+        parent.getClass().getSimpleName());
+    final int rowCount = parent.getAccessor().getValueCount();
+    final int bitCount = bv.getAccessor().getValueCount();
+    if (bitCount != rowCount) {
+      error(name, bv, String.format(
+          "Value count = %d, but bit count = %d",
+          rowCount, bitCount));
+    }
+    final UInt1Vector.Accessor ba = bv.getAccessor();
+    for (int i = 0; i < bitCount; i++) {
+      final int value = ba.get(i);
+      if (value != 0 && value != 1) {
+        error(name, bv, String.format(
 
 Review comment:
   Looks like string format expecting 4 parameters, but only two are passed.

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


With regards,
Apache Git Services