sunchao commented on a change in pull request #33695:
URL: https://github.com/apache/spark/pull/33695#discussion_r688659716



##########
File path: 
sql/core/src/main/java/org/apache/spark/sql/execution/datasources/parquet/ParquetColumn.java
##########
@@ -0,0 +1,238 @@
+/*
+ * 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.spark.sql.execution.datasources.parquet;
+
+import org.apache.spark.memory.MemoryMode;
+import org.apache.spark.sql.execution.vectorized.OffHeapColumnVector;
+import org.apache.spark.sql.execution.vectorized.OnHeapColumnVector;
+import org.apache.spark.sql.execution.vectorized.WritableColumnVector;
+import org.apache.spark.sql.types.ArrayType;
+import org.apache.spark.sql.types.DataType;
+import org.apache.spark.sql.types.DataTypes;
+import org.apache.spark.sql.types.MapType;
+import org.apache.spark.sql.types.StructType;
+
+import java.util.ArrayList;
+import java.util.List;
+
+/**
+ * Contains necessary information representing a Parquet column, either of 
primitive or nested type.
+ */
+final class ParquetColumn {
+  private final ParquetTypeInfo columnInfo;
+  private final List<ParquetColumn> children;
+  private final WritableColumnVector vector;
+
+  /**
+   * repetition & definition levels
+   * these are allocated only for leaf columns; for non-leaf columns, they 
simply maintain
+   * references to that of the former.
+   */
+  private WritableColumnVector repetitionLevels;
+  private WritableColumnVector definitionLevels;
+
+  /** whether this column is primitive (i.e., leaf column) */
+  private final boolean isPrimitive;
+
+  /** reader for this column - only set if 'isPrimitive' is true */
+  private VectorizedColumnReader columnReader;
+
+  ParquetColumn(
+      ParquetTypeInfo columnInfo,
+      WritableColumnVector vector,
+      int capacity,
+      MemoryMode memoryMode) {
+    if (!columnInfo.sparkType().sameType(vector.dataType())) {
+      throw new IllegalArgumentException("Spark type: " + 
columnInfo.sparkType() +
+        " doesn't match the type: " + vector.dataType() + " in column vector");
+    }
+    this.columnInfo = columnInfo;
+    this.vector = vector;
+    this.children = new ArrayList<>();
+    this.isPrimitive = columnInfo.isPrimitive();
+
+    if (isPrimitive) {
+      repetitionLevels = allocateLevelsVector(capacity, memoryMode);
+      definitionLevels = allocateLevelsVector(capacity, memoryMode);
+    } else {
+      DataType type = columnInfo.sparkType();

Review comment:
       hmm why? it is only used in the non-primitive case.




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



---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to