yordan-pavlov commented on a change in pull request #709:
URL: https://github.com/apache/arrow-rs/pull/709#discussion_r696879688
##########
File path: parquet/src/arrow/arrow_array_reader.rs
##########
@@ -1074,6 +1079,39 @@ impl ValueDecoder for VariableLenDictionaryDecoder {
}
}
+pub(crate) struct DeltaByteArrayValueDecoder {
+ decoder: DeltaByteArrayDecoder<ByteArrayType>,
+}
+
+impl DeltaByteArrayValueDecoder {
+ pub fn new(data: ByteBufferPtr, num_values: usize) -> Result<Self> {
+ let mut decoder = DeltaByteArrayDecoder::new();
+ decoder.set_data(data, num_values)?;
+ Ok(Self { decoder })
+ }
+}
+
+impl ValueDecoder for DeltaByteArrayValueDecoder {
+ fn read_value_bytes(
+ &mut self,
+ mut num_values: usize,
+ read_bytes: &mut dyn FnMut(&[u8], usize),
+ ) -> Result<usize> {
+ num_values = std::cmp::min(num_values, self.decoder.values_left());
+ let mut values_read = 0;
+ let mut buf = [ByteArray::new()];
+ while values_read < num_values {
+ let num_read = self.decoder.get(&mut buf)?;
Review comment:
I think this needs a check if `self.decoder.get` was able to read any
values (`num_read > 0`), because at the moment the code assumes that the
decoder will always be able to read values, but it is possible than more values
might be requested than are left in the data page, in which case at some point
the inner decoder will not be able to read more value as requested. A unit test
would also be useful - have a look at other tests in the file that test reading
of batches across pages.
--
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]