c21 commented on code in PR #37228:
URL: https://github.com/apache/spark/pull/37228#discussion_r928221554


##########
sql/core/src/main/scala/org/apache/spark/sql/execution/datasources/parquet/ParquetRowIndexUtil.scala:
##########
@@ -0,0 +1,120 @@
+/*
+ * 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 java.io.IOException
+
+import scala.collection.JavaConverters._
+
+import org.apache.hadoop.mapreduce.{InputSplit, RecordReader, 
TaskAttemptContext}
+import org.apache.parquet.column.page.PageReadStore
+import org.apache.parquet.hadoop.ParquetRecordReader
+
+import org.apache.spark.sql.catalyst.InternalRow
+import org.apache.spark.sql.execution.datasources.{FileFormat, RowIndexUtil}
+import 
org.apache.spark.sql.execution.datasources.RowIndexUtil.findColumnIndexInSchema
+import org.apache.spark.sql.execution.vectorized.WritableColumnVector
+import org.apache.spark.sql.types.StructType
+
+
+object ParquetRowIndexUtil {
+  /**
+   * Generate row indexes for vectorized readers.
+  */
+  class RowIndexGenerator(rowIndexColumnIdx: Int) {
+    var rowIndexIterator: Iterator[Long] = _
+
+    /** For Parquet only: initialize the generator using provided 
PageReadStore. */
+    def initFromPageReadStore(pages: PageReadStore): Unit = {
+      if (!pages.getRowIndexOffset.isPresent) {
+        throw new IOException("PageReadStore returned no row index offset.")
+      }
+      val startingRowIdx: Long = pages.getRowIndexOffset.get()
+      if (pages.getRowIndexes.isPresent) {
+        // The presence of `getRowIndexes` indicates that page skipping is 
effective and only
+        // a subset of rows in the row group is going to be read. Note that 
there is a name
+        // collision here: these row indexes (unlike ones this class is 
generating) are counted
+        // starting from 0 in each of the row groups.
+        rowIndexIterator = pages.getRowIndexes.get.asScala.map(idx => idx + 
startingRowIdx)

Review Comment:
   wondering is `PageReadStore.getRowIndexes()` would return continuous row 
indexes or not? 
   
   If the row indexes are continuous, then we don't need to store a long value 
per row. We can have something like `RangeColumnVector(startIdx, length)` to 
save cost to compute and store the row index vector (similar idea to 
`ConstantColumnVector`). cc @cloud-fan.



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