alamb commented on a change in pull request #709:
URL: https://github.com/apache/arrow-rs/pull/709#discussion_r694807823
##########
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;
+ while values_read < num_values {
+ let mut buf = [ByteArray::new()];
+ let num_read = self.decoder.get(&mut buf)?;
+ assert_eq!(num_read, 1);
Review comment:
Perhaps `debug_assert_eq` might be more appropriate here so as not to do
the check in release builds?
##########
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;
+ while values_read < num_values {
+ let mut buf = [ByteArray::new()];
Review comment:
Two performance questions:
1. I wonder if allocating a new `ByteArray` on each iteration of the loop
(aka each value read from the file) will be overly slow. What about allocating
`buf` outside of the loop?
2. Why only read one value at a time (aka why use `buf` with a size of `1`?
Why not some other value (100?))
--
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]