yaooqinn commented on a change in pull request #31921:
URL: https://github.com/apache/spark/pull/31921#discussion_r598500388



##########
File path: 
sql/core/src/main/java/org/apache/spark/sql/execution/datasources/parquet/VectorizedRleValuesReader.java
##########
@@ -203,6 +203,41 @@ public void readIntegers(
     }
   }
 
+  // A fork of `readIntegers`, reading the signed integers as unsigned in long 
type
+  public void readIntegersAsUnsigned(
+    int total,
+    WritableColumnVector c,
+    int rowId,
+    int level,
+    VectorizedValuesReader data) throws IOException {
+    int left = total;
+    while (left > 0) {
+      if (this.currentCount == 0) this.readNextGroup();
+      int n = Math.min(left, this.currentCount);
+      switch (mode) {
+        case RLE:
+          if (currentValue == level) {
+            data.readIntegersAsUnsigned(n, c, rowId);
+          } else {
+            c.putNulls(rowId, n);
+          }
+          break;
+        case PACKED:
+          for (int i = 0; i < n; ++i) {
+            if (currentBuffer[currentBufferIdx++] == level) {
+              c.putLong(rowId + i, Integer.toUnsignedLong(data.readInteger()));

Review comment:
       Yes, in Parquet, `8, 16, and 32 bit values are stored using the INT32 
physical type`, we read them by `readInteger` and cast them based on Catalyst 
type later. The [0, Int.MaxValue] is enough for uint 8, and 16, while 
[Int.MinValue, 0) is needed for uint32




-- 
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:
us...@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscr...@spark.apache.org
For additional commands, e-mail: reviews-h...@spark.apache.org

Reply via email to