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/04/26 07:24:30 UTC

[GitHub] [arrow] tianchen92 opened a new pull request #6912: ARROW-8020: [Java] Implement vector validate functionality

tianchen92 opened a new pull request #6912:
URL: https://github.com/apache/arrow/pull/6912


   Related to [ARROW-8020](https://issues.apache.org/jira/browse/ARROW-8020).
   
   In C++ side, we already have array validate functionality but no similar functionality in Java side.
   This issue is about to implement this functionality.
   
   see ML discussion
   https://lists.apache.org/thread.html/r5e463275b24dd171cb0347adb8dc10a07d5de97cfa6e023b7806db55%40%3Cdev.arrow.apache.org%3E


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



[GitHub] [arrow] liyafan82 commented on a change in pull request #6912: ARROW-8020: [Java] Implement vector validate functionality

Posted by GitBox <gi...@apache.org>.
liyafan82 commented on a change in pull request #6912:
URL: https://github.com/apache/arrow/pull/6912#discussion_r411355185



##########
File path: java/vector/src/main/java/org/apache/arrow/vector/complex/NonNullableStructVector.java
##########
@@ -320,6 +322,20 @@ public int hashCode(int index, ArrowBufHasher hasher) {
     return visitor.visit(this, value);
   }
 
+  @Override
+  public void validate() {
+    if (getValueCount() < 0) {
+      throw new RuntimeException("vector valueCount is negative");
+    }
+
+    if (getNullCount() > getValueCount()) {

Review comment:
       For the Java implementation, since the null count is computed each time, we shoud never expect getNullCount() > getValueCount()?




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



[GitHub] [arrow] liyafan82 commented on a change in pull request #6912: ARROW-8020: [Java] Implement vector validate functionality

Posted by GitBox <gi...@apache.org>.
liyafan82 commented on a change in pull request #6912:
URL: https://github.com/apache/arrow/pull/6912#discussion_r416558074



##########
File path: java/vector/src/main/java/org/apache/arrow/vector/validate/ValidateVectorVisitor.java
##########
@@ -0,0 +1,177 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.arrow.vector.validate;
+
+import java.util.List;
+
+import org.apache.arrow.vector.BaseFixedWidthVector;
+import org.apache.arrow.vector.BaseVariableWidthVector;
+import org.apache.arrow.vector.FieldVector;
+import org.apache.arrow.vector.NullVector;
+import org.apache.arrow.vector.compare.VectorVisitor;
+import org.apache.arrow.vector.complex.DenseUnionVector;
+import org.apache.arrow.vector.complex.FixedSizeListVector;
+import org.apache.arrow.vector.complex.ListVector;
+import org.apache.arrow.vector.complex.NonNullableStructVector;
+import org.apache.arrow.vector.complex.UnionVector;
+import org.apache.arrow.vector.types.pojo.Field;
+
+/**
+ * visitor to validate vector (not include data).
+ */
+public class ValidateVectorVisitor implements VectorVisitor<Void, Void> {
+
+  @Override
+  public Void visit(BaseFixedWidthVector vector, Void value) {
+    if (vector.getValueCount() > 0) {
+      if (vector.getDataBuffer() == null || vector.getDataBuffer().capacity() == 0) {
+        throw new RuntimeException("valueBuffer is null or capacity is 0");
+      }
+    }
+    return null;
+  }
+
+  @Override
+  public Void visit(BaseVariableWidthVector vector, Void value) {
+
+    if (vector.getValueCount() > 0) {

Review comment:
       do we need to check the validity buffer and the offset buffer?




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



[GitHub] [arrow] tianchen92 commented on a change in pull request #6912: ARROW-8020: [Java] Implement vector validate functionality

Posted by GitBox <gi...@apache.org>.
tianchen92 commented on a change in pull request #6912:
URL: https://github.com/apache/arrow/pull/6912#discussion_r416643574



##########
File path: java/vector/src/main/codegen/templates/DenseUnionVector.java
##########
@@ -34,6 +34,8 @@
 import org.apache.arrow.vector.types.pojo.FieldType;
 import org.apache.arrow.vector.util.CallBack;
 import org.apache.arrow.vector.util.TransferPair;
+import org.apache.arrow.vector.util.ValueVectorUtility;
+import org.apache.arrow.vector.validate.Status;

Review comment:
       thanks, fixed




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



[GitHub] [arrow] tianchen92 commented on a change in pull request #6912: ARROW-8020: [Java] Implement vector validate functionality

Posted by GitBox <gi...@apache.org>.
tianchen92 commented on a change in pull request #6912:
URL: https://github.com/apache/arrow/pull/6912#discussion_r416651561



##########
File path: java/vector/src/main/java/org/apache/arrow/vector/util/ValueVectorUtility.java
##########
@@ -82,4 +89,43 @@ public static String getToString(ValueVector vector, int start, int end) {
 
     return sb.toString();
   }
+
+  /**
+   * Validate field vector.
+   */
+  public static void validate(FieldVector vector) {
+    Preconditions.checkNotNull(vector);
+
+    ArrowType arrowType = vector.getField().getType();
+    int typeBufferCount = TypeLayout.getTypeBufferCount(arrowType);
+    TypeLayout typeLayout = TypeLayout.getTypeLayout(arrowType);
+
+    if (vector.getValueCount() < 0) {
+      throw new RuntimeException("vector valueCount is negative");
+    }
+
+    if (vector.getFieldBuffers().size() != typeBufferCount) {
+      throw new RuntimeException(String.format("Expected %s buffers in vector of type %s, got %s",
+          typeBufferCount, vector.getField().getType().toString(), vector.getBufferSize()));
+    }
+
+    for (int i = 0; i < typeBufferCount; i++) {
+      ArrowBuf buffer = vector.getFieldBuffers().get(i);
+      BufferLayout bufferLayout = typeLayout.getBufferLayouts().get(i);
+      if (buffer == null) {
+        continue;
+      }
+      int minBufferSize = vector.getValueCount() * bufferLayout.getTypeBitWidth();
+
+      if (buffer.capacity() < minBufferSize / 8) {

Review comment:
       Thanks, right, I added offset buffer check for variableWidthVector and ListVector in ValueVectorVisitor (rather than add the check here)




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



[GitHub] [arrow] liyafan82 commented on a change in pull request #6912: ARROW-8020: [Java] Implement vector validate functionality

Posted by GitBox <gi...@apache.org>.
liyafan82 commented on a change in pull request #6912:
URL: https://github.com/apache/arrow/pull/6912#discussion_r417948240



##########
File path: java/vector/src/main/java/org/apache/arrow/vector/validate/ValidateVectorVisitor.java
##########
@@ -0,0 +1,177 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.arrow.vector.validate;
+
+import java.util.List;
+
+import org.apache.arrow.vector.BaseFixedWidthVector;
+import org.apache.arrow.vector.BaseVariableWidthVector;
+import org.apache.arrow.vector.FieldVector;
+import org.apache.arrow.vector.NullVector;
+import org.apache.arrow.vector.compare.VectorVisitor;
+import org.apache.arrow.vector.complex.DenseUnionVector;
+import org.apache.arrow.vector.complex.FixedSizeListVector;
+import org.apache.arrow.vector.complex.ListVector;
+import org.apache.arrow.vector.complex.NonNullableStructVector;
+import org.apache.arrow.vector.complex.UnionVector;
+import org.apache.arrow.vector.types.pojo.Field;
+
+/**
+ * visitor to validate vector (not include data).
+ */
+public class ValidateVectorVisitor implements VectorVisitor<Void, Void> {
+
+  @Override
+  public Void visit(BaseFixedWidthVector vector, Void value) {
+    if (vector.getValueCount() > 0) {

Review comment:
       I think we need to clarify how this visitor is going to be used. IMO, there are at least two possibilities:
   1. The visitor is designed to be an independent feature.
   2. The visitor is always used by ValueVectorUtility#validate.
   
   Method 1 provides more flexibility and for method 2, we need to make it package private?




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



[GitHub] [arrow] liyafan82 commented on a change in pull request #6912: ARROW-8020: [Java] Implement vector validate functionality

Posted by GitBox <gi...@apache.org>.
liyafan82 commented on a change in pull request #6912:
URL: https://github.com/apache/arrow/pull/6912#discussion_r417944313



##########
File path: java/vector/src/main/java/org/apache/arrow/vector/complex/NonNullableStructVector.java
##########
@@ -46,6 +46,7 @@
 
 import io.netty.buffer.ArrowBuf;
 
+

Review comment:
       Please also revert this.




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



[GitHub] [arrow] liyafan82 commented on a change in pull request #6912: ARROW-8020: [Java] Implement vector validate functionality

Posted by GitBox <gi...@apache.org>.
liyafan82 commented on a change in pull request #6912:
URL: https://github.com/apache/arrow/pull/6912#discussion_r416553407



##########
File path: java/vector/src/main/java/org/apache/arrow/vector/util/ValueVectorUtility.java
##########
@@ -82,4 +89,43 @@ public static String getToString(ValueVector vector, int start, int end) {
 
     return sb.toString();
   }
+
+  /**
+   * Validate field vector.
+   */
+  public static void validate(FieldVector vector) {
+    Preconditions.checkNotNull(vector);
+
+    ArrowType arrowType = vector.getField().getType();
+    int typeBufferCount = TypeLayout.getTypeBufferCount(arrowType);
+    TypeLayout typeLayout = TypeLayout.getTypeLayout(arrowType);
+
+    if (vector.getValueCount() < 0) {
+      throw new RuntimeException("vector valueCount is negative");

Review comment:
       I think IllegalArgumentException is better?




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



[GitHub] [arrow] liyafan82 commented on a change in pull request #6912: ARROW-8020: [Java] Implement vector validate functionality

Posted by GitBox <gi...@apache.org>.
liyafan82 commented on a change in pull request #6912:
URL: https://github.com/apache/arrow/pull/6912#discussion_r411352198



##########
File path: java/vector/src/main/java/org/apache/arrow/vector/ValueVector.java
##########
@@ -283,4 +283,10 @@
    * @return the name of the vector.
    */
   String getName();
+
+  /**
+   * Validate the vector, will throw exception if validate fail.
+   */
+  void validate();

Review comment:
       I agree with you that it makes the client code simpler. 
   
   IMO, the real benefits are 1) one fewer virtual function call; and 2) one fewer stack frame. However, the cost is that it makes the interface larger and difficult to maintain. In addition, adding new APIs to a public interface has the risk of crashing client code. 
   
   So I think the method of adding new APIs should be reserved for performance-critical operations. 




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



[GitHub] [arrow] emkornfield commented on pull request #6912: ARROW-8020: [Java] Implement vector validate functionality

Posted by GitBox <gi...@apache.org>.
emkornfield commented on pull request #6912:
URL: https://github.com/apache/arrow/pull/6912#issuecomment-629014048


   +1 thank you @tianchen92 


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



[GitHub] [arrow] liyafan82 commented on a change in pull request #6912: ARROW-8020: [Java] Implement vector validate functionality

Posted by GitBox <gi...@apache.org>.
liyafan82 commented on a change in pull request #6912:
URL: https://github.com/apache/arrow/pull/6912#discussion_r417948666



##########
File path: java/vector/src/main/java/org/apache/arrow/vector/validate/ValidateVectorVisitor.java
##########
@@ -0,0 +1,222 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.arrow.vector.validate;
+
+import java.util.List;
+
+import org.apache.arrow.vector.BaseFixedWidthVector;
+import org.apache.arrow.vector.BaseVariableWidthVector;
+import org.apache.arrow.vector.FieldVector;
+import org.apache.arrow.vector.NullVector;
+import org.apache.arrow.vector.compare.VectorVisitor;
+import org.apache.arrow.vector.complex.DenseUnionVector;
+import org.apache.arrow.vector.complex.FixedSizeListVector;
+import org.apache.arrow.vector.complex.ListVector;
+import org.apache.arrow.vector.complex.NonNullableStructVector;
+import org.apache.arrow.vector.complex.UnionVector;
+import org.apache.arrow.vector.types.pojo.Field;
+
+import io.netty.buffer.ArrowBuf;
+
+/**
+ * visitor to validate vector (not include data).
+ */
+public class ValidateVectorVisitor implements VectorVisitor<Void, Void> {
+
+  @Override
+  public Void visit(BaseFixedWidthVector vector, Void value) {
+    if (vector.getValueCount() > 0) {
+      if (vector.getDataBuffer() == null || vector.getDataBuffer().capacity() == 0) {
+        throw new IllegalArgumentException("valueBuffer is null or capacity is 0");
+      }
+    }
+    return null;
+  }
+
+  @Override
+  public Void visit(BaseVariableWidthVector vector, Void value) {
+
+    if (vector.getValueCount() > 0) {
+      if (vector.getDataBuffer() == null || vector.getDataBuffer().capacity() == 0) {
+        throw new IllegalArgumentException("valueBuffer is null or capacity is 0");
+      }
+
+      ArrowBuf offsetBuf = vector.getOffsetBuffer();
+      int minBufferSize = (vector.getValueCount() + 1) * 4;

Review comment:
       Replace 4 with BaseVariableWidthVector#OFFSET_WIDTH?




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



[GitHub] [arrow] emkornfield closed pull request #6912: ARROW-8020: [Java] Implement vector validate functionality

Posted by GitBox <gi...@apache.org>.
emkornfield closed pull request #6912:
URL: https://github.com/apache/arrow/pull/6912


   


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



[GitHub] [arrow] tianchen92 commented on a change in pull request #6912: ARROW-8020: [Java] Implement vector validate functionality

Posted by GitBox <gi...@apache.org>.
tianchen92 commented on a change in pull request #6912:
URL: https://github.com/apache/arrow/pull/6912#discussion_r415229312



##########
File path: java/vector/src/main/java/org/apache/arrow/vector/complex/NonNullableStructVector.java
##########
@@ -320,6 +322,20 @@ public int hashCode(int index, ArrowBufHasher hasher) {
     return visitor.visit(this, value);
   }
 
+  @Override
+  public void validate() {
+    if (getValueCount() < 0) {
+      throw new RuntimeException("vector valueCount is negative");
+    }
+
+    if (getNullCount() > getValueCount()) {

Review comment:
       Thanks, fixed.




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



[GitHub] [arrow] liyafan82 commented on a change in pull request #6912: ARROW-8020: [Java] Implement vector validate functionality

Posted by GitBox <gi...@apache.org>.
liyafan82 commented on a change in pull request #6912:
URL: https://github.com/apache/arrow/pull/6912#discussion_r416557702



##########
File path: java/vector/src/main/java/org/apache/arrow/vector/validate/ValidateVectorVisitor.java
##########
@@ -0,0 +1,177 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.arrow.vector.validate;
+
+import java.util.List;
+
+import org.apache.arrow.vector.BaseFixedWidthVector;
+import org.apache.arrow.vector.BaseVariableWidthVector;
+import org.apache.arrow.vector.FieldVector;
+import org.apache.arrow.vector.NullVector;
+import org.apache.arrow.vector.compare.VectorVisitor;
+import org.apache.arrow.vector.complex.DenseUnionVector;
+import org.apache.arrow.vector.complex.FixedSizeListVector;
+import org.apache.arrow.vector.complex.ListVector;
+import org.apache.arrow.vector.complex.NonNullableStructVector;
+import org.apache.arrow.vector.complex.UnionVector;
+import org.apache.arrow.vector.types.pojo.Field;
+
+/**
+ * visitor to validate vector (not include data).
+ */
+public class ValidateVectorVisitor implements VectorVisitor<Void, Void> {
+
+  @Override
+  public Void visit(BaseFixedWidthVector vector, Void value) {
+    if (vector.getValueCount() > 0) {

Review comment:
       do we need to check the validity buffer?




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



[GitHub] [arrow] liyafan82 commented on a change in pull request #6912: ARROW-8020: [Java] Implement vector validate functionality

Posted by GitBox <gi...@apache.org>.
liyafan82 commented on a change in pull request #6912:
URL: https://github.com/apache/arrow/pull/6912#discussion_r416551607



##########
File path: java/vector/src/main/codegen/templates/DenseUnionVector.java
##########
@@ -34,6 +34,8 @@
 import org.apache.arrow.vector.types.pojo.FieldType;
 import org.apache.arrow.vector.util.CallBack;
 import org.apache.arrow.vector.util.TransferPair;
+import org.apache.arrow.vector.util.ValueVectorUtility;
+import org.apache.arrow.vector.validate.Status;

Review comment:
       This is no longer needed?




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



[GitHub] [arrow] tianchen92 commented on a change in pull request #6912: ARROW-8020: [Java] Implement vector validate functionality

Posted by GitBox <gi...@apache.org>.
tianchen92 commented on a change in pull request #6912:
URL: https://github.com/apache/arrow/pull/6912#discussion_r416646869



##########
File path: java/vector/src/main/java/org/apache/arrow/vector/validate/ValidateVectorVisitor.java
##########
@@ -0,0 +1,177 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.arrow.vector.validate;
+
+import java.util.List;
+
+import org.apache.arrow.vector.BaseFixedWidthVector;
+import org.apache.arrow.vector.BaseVariableWidthVector;
+import org.apache.arrow.vector.FieldVector;
+import org.apache.arrow.vector.NullVector;
+import org.apache.arrow.vector.compare.VectorVisitor;
+import org.apache.arrow.vector.complex.DenseUnionVector;
+import org.apache.arrow.vector.complex.FixedSizeListVector;
+import org.apache.arrow.vector.complex.ListVector;
+import org.apache.arrow.vector.complex.NonNullableStructVector;
+import org.apache.arrow.vector.complex.UnionVector;
+import org.apache.arrow.vector.types.pojo.Field;
+
+/**
+ * visitor to validate vector (not include data).
+ */
+public class ValidateVectorVisitor implements VectorVisitor<Void, Void> {
+
+  @Override
+  public Void visit(BaseFixedWidthVector vector, Void value) {
+    if (vector.getValueCount() > 0) {
+      if (vector.getDataBuffer() == null || vector.getDataBuffer().capacity() == 0) {
+        throw new RuntimeException("valueBuffer is null or capacity is 0");
+      }
+    }
+    return null;
+  }
+
+  @Override
+  public Void visit(BaseVariableWidthVector vector, Void value) {
+
+    if (vector.getValueCount() > 0) {

Review comment:
       No need for validity buffer, and add check for offset buffer




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



[GitHub] [arrow] emkornfield commented on a change in pull request #6912: ARROW-8020: [Java] Implement vector validate functionality

Posted by GitBox <gi...@apache.org>.
emkornfield commented on a change in pull request #6912:
URL: https://github.com/apache/arrow/pull/6912#discussion_r414972130



##########
File path: java/vector/src/main/java/org/apache/arrow/vector/ValueVector.java
##########
@@ -283,4 +283,10 @@
    * @return the name of the vector.
    */
   String getName();
+
+  /**
+   * Validate the vector, will throw exception if validate fail.
+   */
+  void validate();

Review comment:
       Instead of adding this directly to ValueVector, can we make a static utility method that does validation and excepts a ValueVector?




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



[GitHub] [arrow] tianchen92 commented on a change in pull request #6912: ARROW-8020: [Java] Implement vector validate functionality

Posted by GitBox <gi...@apache.org>.
tianchen92 commented on a change in pull request #6912:
URL: https://github.com/apache/arrow/pull/6912#discussion_r416645213



##########
File path: java/vector/src/main/java/org/apache/arrow/vector/validate/ValidateVectorVisitor.java
##########
@@ -0,0 +1,177 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.arrow.vector.validate;
+
+import java.util.List;
+
+import org.apache.arrow.vector.BaseFixedWidthVector;
+import org.apache.arrow.vector.BaseVariableWidthVector;
+import org.apache.arrow.vector.FieldVector;
+import org.apache.arrow.vector.NullVector;
+import org.apache.arrow.vector.compare.VectorVisitor;
+import org.apache.arrow.vector.complex.DenseUnionVector;
+import org.apache.arrow.vector.complex.FixedSizeListVector;
+import org.apache.arrow.vector.complex.ListVector;
+import org.apache.arrow.vector.complex.NonNullableStructVector;
+import org.apache.arrow.vector.complex.UnionVector;
+import org.apache.arrow.vector.types.pojo.Field;
+
+/**
+ * visitor to validate vector (not include data).
+ */
+public class ValidateVectorVisitor implements VectorVisitor<Void, Void> {
+
+  @Override
+  public Void visit(BaseFixedWidthVector vector, Void value) {
+    if (vector.getValueCount() > 0) {
+      if (vector.getDataBuffer() == null || vector.getDataBuffer().capacity() == 0) {
+        throw new RuntimeException("valueBuffer is null or capacity is 0");
+      }
+    }

Review comment:
       valueCount < 0 was handled in ValueVectorUtility, and valueCount == 0 seems dose not need to check.




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



[GitHub] [arrow] tianchen92 commented on a change in pull request #6912: ARROW-8020: [Java] Implement vector validate functionality

Posted by GitBox <gi...@apache.org>.
tianchen92 commented on a change in pull request #6912:
URL: https://github.com/apache/arrow/pull/6912#discussion_r417969515



##########
File path: java/vector/src/main/java/org/apache/arrow/vector/validate/ValidateVectorVisitor.java
##########
@@ -0,0 +1,222 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.arrow.vector.validate;
+
+import java.util.List;
+
+import org.apache.arrow.vector.BaseFixedWidthVector;
+import org.apache.arrow.vector.BaseVariableWidthVector;
+import org.apache.arrow.vector.FieldVector;
+import org.apache.arrow.vector.NullVector;
+import org.apache.arrow.vector.compare.VectorVisitor;
+import org.apache.arrow.vector.complex.DenseUnionVector;
+import org.apache.arrow.vector.complex.FixedSizeListVector;
+import org.apache.arrow.vector.complex.ListVector;
+import org.apache.arrow.vector.complex.NonNullableStructVector;
+import org.apache.arrow.vector.complex.UnionVector;
+import org.apache.arrow.vector.types.pojo.Field;
+
+import io.netty.buffer.ArrowBuf;
+
+/**
+ * visitor to validate vector (not include data).
+ */
+public class ValidateVectorVisitor implements VectorVisitor<Void, Void> {
+
+  @Override
+  public Void visit(BaseFixedWidthVector vector, Void value) {
+    if (vector.getValueCount() > 0) {
+      if (vector.getDataBuffer() == null || vector.getDataBuffer().capacity() == 0) {
+        throw new IllegalArgumentException("valueBuffer is null or capacity is 0");
+      }
+    }
+    return null;
+  }
+
+  @Override
+  public Void visit(BaseVariableWidthVector vector, Void value) {
+
+    if (vector.getValueCount() > 0) {
+      if (vector.getDataBuffer() == null || vector.getDataBuffer().capacity() == 0) {
+        throw new IllegalArgumentException("valueBuffer is null or capacity is 0");
+      }
+
+      ArrowBuf offsetBuf = vector.getOffsetBuffer();
+      int minBufferSize = (vector.getValueCount() + 1) * 4;

Review comment:
       Thanks, done.




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



[GitHub] [arrow] liyafan82 commented on a change in pull request #6912: ARROW-8020: [Java] Implement vector validate functionality

Posted by GitBox <gi...@apache.org>.
liyafan82 commented on a change in pull request #6912:
URL: https://github.com/apache/arrow/pull/6912#discussion_r417944148



##########
File path: java/vector/src/main/codegen/templates/UnionVector.java
##########
@@ -30,6 +30,7 @@
 import org.apache.arrow.vector.types.pojo.FieldType;
 import org.apache.arrow.vector.util.CallBack;
 import org.apache.arrow.vector.util.ValueVectorUtility;
+import org.apache.arrow.vector.validate.Status;

Review comment:
       Please also revert this.

##########
File path: java/vector/src/main/java/org/apache/arrow/vector/ValueVector.java
##########
@@ -283,4 +283,5 @@
    * @return the name of the vector.
    */
   String getName();
+

Review comment:
       Please also revert this.




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



[GitHub] [arrow] liyafan82 commented on a change in pull request #6912: ARROW-8020: [Java] Implement vector validate functionality

Posted by GitBox <gi...@apache.org>.
liyafan82 commented on a change in pull request #6912:
URL: https://github.com/apache/arrow/pull/6912#discussion_r416551750



##########
File path: java/vector/src/main/java/org/apache/arrow/vector/ExtensionTypeVector.java
##########
@@ -264,4 +264,5 @@ public BufferAllocator getAllocator() {
   public <OUT, IN> OUT accept(VectorVisitor<OUT, IN> visitor, IN value) {
     return getUnderlyingVector().accept(visitor, value);
   }
+

Review comment:
       Revert this?




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



[GitHub] [arrow] tianchen92 commented on a change in pull request #6912: ARROW-8020: [Java] Implement vector validate functionality

Posted by GitBox <gi...@apache.org>.
tianchen92 commented on a change in pull request #6912:
URL: https://github.com/apache/arrow/pull/6912#discussion_r416644073



##########
File path: java/vector/src/main/java/org/apache/arrow/vector/util/ValueVectorUtility.java
##########
@@ -82,4 +89,43 @@ public static String getToString(ValueVector vector, int start, int end) {
 
     return sb.toString();
   }
+
+  /**
+   * Validate field vector.
+   */
+  public static void validate(FieldVector vector) {
+    Preconditions.checkNotNull(vector);
+
+    ArrowType arrowType = vector.getField().getType();
+    int typeBufferCount = TypeLayout.getTypeBufferCount(arrowType);
+    TypeLayout typeLayout = TypeLayout.getTypeLayout(arrowType);
+
+    if (vector.getValueCount() < 0) {
+      throw new RuntimeException("vector valueCount is negative");

Review comment:
       thanks, accepted.




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



[GitHub] [arrow] tianchen92 commented on a change in pull request #6912: ARROW-8020: [Java] Implement vector validate functionality

Posted by GitBox <gi...@apache.org>.
tianchen92 commented on a change in pull request #6912:
URL: https://github.com/apache/arrow/pull/6912#discussion_r416643695



##########
File path: java/vector/src/main/java/org/apache/arrow/vector/ExtensionTypeVector.java
##########
@@ -264,4 +264,5 @@ public BufferAllocator getAllocator() {
   public <OUT, IN> OUT accept(VectorVisitor<OUT, IN> visitor, IN value) {
     return getUnderlyingVector().accept(visitor, value);
   }
+

Review comment:
       thanks, fixed.




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



[GitHub] [arrow] liyafan82 commented on a change in pull request #6912: ARROW-8020: [Java] Implement vector validate functionality

Posted by GitBox <gi...@apache.org>.
liyafan82 commented on a change in pull request #6912:
URL: https://github.com/apache/arrow/pull/6912#discussion_r416559338



##########
File path: java/vector/src/main/java/org/apache/arrow/vector/util/ValueVectorUtility.java
##########
@@ -82,4 +89,43 @@ public static String getToString(ValueVector vector, int start, int end) {
 
     return sb.toString();
   }
+
+  /**
+   * Validate field vector.
+   */
+  public static void validate(FieldVector vector) {
+    Preconditions.checkNotNull(vector);
+
+    ArrowType arrowType = vector.getField().getType();
+    int typeBufferCount = TypeLayout.getTypeBufferCount(arrowType);
+    TypeLayout typeLayout = TypeLayout.getTypeLayout(arrowType);
+
+    if (vector.getValueCount() < 0) {
+      throw new RuntimeException("vector valueCount is negative");
+    }
+
+    if (vector.getFieldBuffers().size() != typeBufferCount) {
+      throw new RuntimeException(String.format("Expected %s buffers in vector of type %s, got %s",
+          typeBufferCount, vector.getField().getType().toString(), vector.getBufferSize()));
+    }
+
+    for (int i = 0; i < typeBufferCount; i++) {
+      ArrowBuf buffer = vector.getFieldBuffers().get(i);
+      BufferLayout bufferLayout = typeLayout.getBufferLayouts().get(i);
+      if (buffer == null) {
+        continue;
+      }
+      int minBufferSize = vector.getValueCount() * bufferLayout.getTypeBitWidth();
+
+      if (buffer.capacity() < minBufferSize / 8) {

Review comment:
       for offset buffers, we need to have:
   
   int minBufferSize = (vector.getValueCount() + 1) * bufferLayout.getTypeBitWidth();




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



[GitHub] [arrow] tianchen92 commented on a change in pull request #6912: ARROW-8020: [Java] Implement vector validate functionality

Posted by GitBox <gi...@apache.org>.
tianchen92 commented on a change in pull request #6912:
URL: https://github.com/apache/arrow/pull/6912#discussion_r417969293



##########
File path: java/vector/src/main/java/org/apache/arrow/vector/validate/ValidateVectorVisitor.java
##########
@@ -0,0 +1,177 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.arrow.vector.validate;
+
+import java.util.List;
+
+import org.apache.arrow.vector.BaseFixedWidthVector;
+import org.apache.arrow.vector.BaseVariableWidthVector;
+import org.apache.arrow.vector.FieldVector;
+import org.apache.arrow.vector.NullVector;
+import org.apache.arrow.vector.compare.VectorVisitor;
+import org.apache.arrow.vector.complex.DenseUnionVector;
+import org.apache.arrow.vector.complex.FixedSizeListVector;
+import org.apache.arrow.vector.complex.ListVector;
+import org.apache.arrow.vector.complex.NonNullableStructVector;
+import org.apache.arrow.vector.complex.UnionVector;
+import org.apache.arrow.vector.types.pojo.Field;
+
+/**
+ * visitor to validate vector (not include data).
+ */
+public class ValidateVectorVisitor implements VectorVisitor<Void, Void> {
+
+  @Override
+  public Void visit(BaseFixedWidthVector vector, Void value) {
+    if (vector.getValueCount() > 0) {

Review comment:
       Thanks, I prefer method1 and add some docs.




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



[GitHub] [arrow] tianchen92 commented on a change in pull request #6912: ARROW-8020: [Java] Implement vector validate functionality

Posted by GitBox <gi...@apache.org>.
tianchen92 commented on a change in pull request #6912:
URL: https://github.com/apache/arrow/pull/6912#discussion_r415229163



##########
File path: java/vector/src/main/java/org/apache/arrow/vector/ValueVector.java
##########
@@ -283,4 +283,10 @@
    * @return the name of the vector.
    */
   String getName();
+
+  /**
+   * Validate the vector, will throw exception if validate fail.
+   */
+  void validate();

Review comment:
       Thanks for all your comments, we already have validate method in ValueVectorUtility, and I removed the api from ValueVector.




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



[GitHub] [arrow] liyafan82 commented on a change in pull request #6912: ARROW-8020: [Java] Implement vector validate functionality

Posted by GitBox <gi...@apache.org>.
liyafan82 commented on a change in pull request #6912:
URL: https://github.com/apache/arrow/pull/6912#discussion_r416557129



##########
File path: java/vector/src/main/java/org/apache/arrow/vector/validate/ValidateVectorVisitor.java
##########
@@ -0,0 +1,177 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.arrow.vector.validate;
+
+import java.util.List;
+
+import org.apache.arrow.vector.BaseFixedWidthVector;
+import org.apache.arrow.vector.BaseVariableWidthVector;
+import org.apache.arrow.vector.FieldVector;
+import org.apache.arrow.vector.NullVector;
+import org.apache.arrow.vector.compare.VectorVisitor;
+import org.apache.arrow.vector.complex.DenseUnionVector;
+import org.apache.arrow.vector.complex.FixedSizeListVector;
+import org.apache.arrow.vector.complex.ListVector;
+import org.apache.arrow.vector.complex.NonNullableStructVector;
+import org.apache.arrow.vector.complex.UnionVector;
+import org.apache.arrow.vector.types.pojo.Field;
+
+/**
+ * visitor to validate vector (not include data).
+ */
+public class ValidateVectorVisitor implements VectorVisitor<Void, Void> {
+
+  @Override
+  public Void visit(BaseFixedWidthVector vector, Void value) {
+    if (vector.getValueCount() > 0) {
+      if (vector.getDataBuffer() == null || vector.getDataBuffer().capacity() == 0) {
+        throw new RuntimeException("valueBuffer is null or capacity is 0");
+      }
+    }

Review comment:
       do we need to deal with the case when the valueCount <= 0?




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



[GitHub] [arrow] tianchen92 commented on a change in pull request #6912: ARROW-8020: [Java] Implement vector validate functionality

Posted by GitBox <gi...@apache.org>.
tianchen92 commented on a change in pull request #6912:
URL: https://github.com/apache/arrow/pull/6912#discussion_r416645923



##########
File path: java/vector/src/main/java/org/apache/arrow/vector/validate/ValidateVectorVisitor.java
##########
@@ -0,0 +1,177 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.arrow.vector.validate;
+
+import java.util.List;
+
+import org.apache.arrow.vector.BaseFixedWidthVector;
+import org.apache.arrow.vector.BaseVariableWidthVector;
+import org.apache.arrow.vector.FieldVector;
+import org.apache.arrow.vector.NullVector;
+import org.apache.arrow.vector.compare.VectorVisitor;
+import org.apache.arrow.vector.complex.DenseUnionVector;
+import org.apache.arrow.vector.complex.FixedSizeListVector;
+import org.apache.arrow.vector.complex.ListVector;
+import org.apache.arrow.vector.complex.NonNullableStructVector;
+import org.apache.arrow.vector.complex.UnionVector;
+import org.apache.arrow.vector.types.pojo.Field;
+
+/**
+ * visitor to validate vector (not include data).
+ */
+public class ValidateVectorVisitor implements VectorVisitor<Void, Void> {
+
+  @Override
+  public Void visit(BaseFixedWidthVector vector, Void value) {
+    if (vector.getValueCount() > 0) {

Review comment:
       We already check all buffers capacity in ValueVectorUtility 




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



[GitHub] [arrow] liyafan82 commented on a change in pull request #6912: ARROW-8020: [Java] Implement vector validate functionality

Posted by GitBox <gi...@apache.org>.
liyafan82 commented on a change in pull request #6912:
URL: https://github.com/apache/arrow/pull/6912#discussion_r417948240



##########
File path: java/vector/src/main/java/org/apache/arrow/vector/validate/ValidateVectorVisitor.java
##########
@@ -0,0 +1,177 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.arrow.vector.validate;
+
+import java.util.List;
+
+import org.apache.arrow.vector.BaseFixedWidthVector;
+import org.apache.arrow.vector.BaseVariableWidthVector;
+import org.apache.arrow.vector.FieldVector;
+import org.apache.arrow.vector.NullVector;
+import org.apache.arrow.vector.compare.VectorVisitor;
+import org.apache.arrow.vector.complex.DenseUnionVector;
+import org.apache.arrow.vector.complex.FixedSizeListVector;
+import org.apache.arrow.vector.complex.ListVector;
+import org.apache.arrow.vector.complex.NonNullableStructVector;
+import org.apache.arrow.vector.complex.UnionVector;
+import org.apache.arrow.vector.types.pojo.Field;
+
+/**
+ * visitor to validate vector (not include data).
+ */
+public class ValidateVectorVisitor implements VectorVisitor<Void, Void> {
+
+  @Override
+  public Void visit(BaseFixedWidthVector vector, Void value) {
+    if (vector.getValueCount() > 0) {

Review comment:
       I think we need to clarify how this visitor is going to be used. IMO, there are at least two possibilities:
   1. The visitor is designed to be an independent feature.
   2. The visitor is always used by ValueVectorUtility#validate.
   
   Method 1 provides more flexibility and for method 2, we need to make it package private?
   Method 1 provides 




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