splix commented on code in PR #530:
URL: https://github.com/apache/avro-rs/pull/530#discussion_r3039858339


##########
avro/src/reader/mod.rs:
##########
@@ -159,6 +164,41 @@ impl<R: Read> Iterator for Reader<'_, R> {
     }
 }
 
+impl<R: Read> Reader<'_, R> {
+    /// The currently loaded block's position and record count.
+    ///
+    /// Returns `None` only before the first block is loaded (via iteration or
+    /// [`seek_to_block`](Self::seek_to_block)). Always `Some` afterward.
+    pub fn current_block(&self) -> Option<BlockPosition> {
+        self.block.current_block_info
+    }
+
+    /// Byte offset where data blocks begin (right after the file header).
+    ///
+    /// This is the offset of the first data block — equivalent to the position
+    /// that would be returned by `current_block().offset` for block 0.
+    pub fn data_start(&self) -> u64 {
+        self.block.data_start
+    }
+}
+
+impl<R: Read + Seek> Reader<'_, R> {
+    /// Seek to the data block at the given byte offset and load it.
+    ///
+    /// The offset must point to the start of a valid data block (before its
+    /// object-count varint). The block is read, decompressed, and its sync
+    /// marker is validated against the file header. After this call, 
[`Iterator::next`]
+    /// yields the first record in that block.
+    ///
+    /// Typically the caller saves offsets from 
[`current_block`](Self::current_block)
+    /// during forward iteration and later passes them here to jump back.
+    pub fn seek_to_block(&mut self, offset: u64) -> AvroResult<()> {
+        self.block.seek_to_block(offset)?;

Review Comment:
   That makes sense. Please take a look at the update



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

Reply via email to