pitrou commented on code in PR #37874:
URL: https://github.com/apache/arrow/pull/37874#discussion_r1342708042
##########
cpp/src/parquet/encoding.cc:
##########
@@ -3369,6 +3369,9 @@ class DeltaByteArrayDecoderImpl : public DecoderImpl,
virtual public TypedDecode
if (ARROW_PREDICT_FALSE(prefix_len_ptr[i] < 0)) {
throw ParquetException("negative prefix length in DELTA_BYTE_ARRAY");
}
+ if (prefix_len_ptr[i] == 0) {
Review Comment:
You should probably move this just above the above `if`. Not sure it will
make a difference...
##########
cpp/src/parquet/encoding.cc:
##########
@@ -3382,6 +3385,17 @@ class DeltaByteArrayDecoderImpl : public DecoderImpl,
virtual public TypedDecode
if (ARROW_PREDICT_FALSE(static_cast<size_t>(prefix_len_ptr[i]) >
prefix.length())) {
throw ParquetException("prefix length too large in DELTA_BYTE_ARRAY");
}
+ if (prefix_len_ptr[i] == 0) {
Review Comment:
I think @mapleFU is right; `buffer[i]` is the result of running the suffix
decoder above (`suffix_decoder_.Decode(buffer, max_values)`), so this is
correct.
However, a comment would be welcome to clarify this.
##########
cpp/src/parquet/encoding.cc:
##########
@@ -3382,6 +3385,20 @@ class DeltaByteArrayDecoderImpl : public DecoderImpl,
virtual public TypedDecode
if (ARROW_PREDICT_FALSE(static_cast<size_t>(prefix_len_ptr[i]) >
prefix.length())) {
throw ParquetException("prefix length too large in DELTA_BYTE_ARRAY");
}
+ if (prefix_len_ptr[i] == 0) {
+ prefix = std::string_view{buffer[i]};
+ continue;
+ }
+ if (buffer[i].len == 0 && prefix.data() != last_value_.data()) {
Review Comment:
`prefix.data() == last_value_.data()` is only for the first loop iteration,
right?
If so, how about we move the first iteration before the loop? This would
probably simplify the loop itself, and may make performance better as well.
--
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]