You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@iceberg.apache.org by "yabola (via GitHub)" <gi...@apache.org> on 2023/04/09 07:01:35 UTC

[GitHub] [iceberg] yabola commented on a diff in pull request #6962: Support vectorized reading int96 timestamps in imported data

yabola commented on code in PR #6962:
URL: https://github.com/apache/iceberg/pull/6962#discussion_r1161231668


##########
arrow/src/main/java/org/apache/iceberg/arrow/vectorized/parquet/VectorizedParquetDefinitionLevelReader.java:
##########
@@ -447,6 +449,50 @@ protected void nextDictEncodedVal(
     }
   }
 
+  class TimestampInt96Reader extends BaseReader {
+    @Override
+    protected void nextVal(
+        FieldVector vector,
+        int idx,
+        ValuesAsBytesReader valuesReader,
+        int typeWidth,
+        byte[] byteArray) {
+      // 8 bytes (time of day nanos) + 4 bytes(julianDay) = 12 bytes
+      ByteBuffer buffer = valuesReader.getBuffer(12).order(ByteOrder.LITTLE_ENDIAN);
+      long timestampInt96 = ParquetUtil.extractTimestampInt96(buffer);
+      vector.getDataBuffer().setLong((long) idx * typeWidth, timestampInt96);
+    }
+
+    @Override
+    protected void nextDictEncodedVal(
+        FieldVector vector,
+        int idx,
+        VectorizedDictionaryEncodedParquetValuesReader reader,
+        int numValuesToRead,
+        Dictionary dict,
+        NullabilityHolder nullabilityHolder,
+        int typeWidth,
+        Mode mode) {
+      switch (mode) {
+        case RLE:
+          reader
+              .timestampInt96DictEncodedReader()
+              .nextBatch(vector, idx, numValuesToRead, dict, nullabilityHolder, typeWidth);
+          break;
+        case PACKED:
+          ByteBuffer buffer =
+              dict.decodeToBinary(reader.readInteger())
+                  .toByteBuffer()
+                  .order(ByteOrder.LITTLE_ENDIAN);
+          long timestampInt96 = ParquetUtil.extractTimestampInt96(buffer);
+          vector.getDataBuffer().setLong(idx, timestampInt96);
+          break;
+        default:
+          throw new UnsupportedOperationException("Not a supported mode: " + mode);

Review Comment:
   done, thank you!



-- 
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: issues-unsubscribe@iceberg.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@iceberg.apache.org
For additional commands, e-mail: issues-help@iceberg.apache.org