You are viewing a plain text version of this content. The canonical link for it is here.
Posted to github@arrow.apache.org by "viirya (via GitHub)" <gi...@apache.org> on 2023/05/22 20:57:33 UTC

[GitHub] [arrow-rs] viirya commented on a diff in pull request #4259: Extract IPC ArrayReader struct

viirya commented on code in PR #4259:
URL: https://github.com/apache/arrow-rs/pull/4259#discussion_r1201092414


##########
arrow-ipc/src/reader.rs:
##########
@@ -628,14 +395,108 @@ fn create_dictionary_array(
     }
 }
 
+/// State for decoding arrays from an encoded [`RecordBatch`]
+struct ArrayReader<'a> {
+    /// Decoded dictionaries indexed by dictionary id
+    dictionaries_by_id: &'a HashMap<i64, ArrayRef>,
+    /// Optional compression codec
+    compression: Option<CompressionCodec>,
+    /// The format version
+    version: MetadataVersion,
+    /// The raw data buffer
+    data: &'a Buffer,
+    /// The fields comprising this array
+    nodes: VectorIter<'a, FieldNode>,
+    /// The buffers comprising this array
+    buffers: VectorIter<'a, crate::Buffer>,
+}
+
+impl<'a> ArrayReader<'a> {
+    fn next_buffer(&mut self) -> Result<Buffer, ArrowError> {
+        read_buffer(self.buffers.next().unwrap(), &self.data, self.compression)
+    }
+
+    fn skip_buffer(&mut self) {
+        self.buffers.next().unwrap();
+    }
+
+    fn next_node(&mut self, field: &Field) -> Result<&'a FieldNode, ArrowError> {
+        self.nodes.next().ok_or_else(|| {
+            ArrowError::IoError(format!(
+                "Invalid data for schema. {} refers to node not found in schema",
+                field
+            ))
+        })
+    }
+
+    fn skip_node(&mut self, field: &Field) -> Result<(), ArrowError> {

Review Comment:
   I feel original name `skip_field` is more proper, but okay for `skip_node`.



-- 
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: github-unsubscribe@arrow.apache.org

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