You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@iceberg.apache.org by "amogh-jahagirdar (via GitHub)" <gi...@apache.org> on 2025/04/18 18:50:28 UTC

Re: [PR] Spark: Add _row_id and _last_updated_sequence_number readers [iceberg]

amogh-jahagirdar commented on code in PR #12836:
URL: https://github.com/apache/iceberg/pull/12836#discussion_r2050851734


##########
parquet/src/main/java/org/apache/iceberg/parquet/ParquetValueReaders.java:
##########
@@ -322,6 +333,88 @@ public void setPageSource(PageReadStore pageStore) {
     }
   }
 
+  private static class RowIdReader implements ParquetValueReader<Long> {
+    private final long firstRowId;
+    private final ParquetValueReader<Long> idReader;
+    private long rowOffset = -1;
+    private long rowGroupStart;
+
+    private RowIdReader(long firstRowId, ParquetValueReader<Long> idReader) {
+      this.firstRowId = firstRowId;
+      this.idReader = idReader != null ? idReader : nulls();
+    }
+
+    @Override
+    public Long read(Long reuse) {
+      rowOffset += 1;
+
+      Long idFromFile = idReader.read(null);
+      if (idFromFile != null) {
+        return idFromFile;
+      }
+
+      return firstRowId + rowGroupStart + rowOffset;

Review Comment:
   Did we look at plumbing through the existing position reader? That way I think we don't have to keep track of the rowGroupStart, rowOffset ourselves. Though this is clean enough, so I think it's fine! 
   



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