Punisheroot commented on code in PR #50710:
URL: https://github.com/apache/arrow/pull/50710#discussion_r3674583258
##########
cpp/src/parquet/decoder.cc:
##########
@@ -1295,12 +1294,80 @@ class DictByteArrayDecoderImpl : public
DictDecoderImpl<ByteArrayType> {
int64_t valid_bits_offset,
typename EncodingTraits<ByteArrayType>::Accumulator*
out,
int* out_num_values) {
+ const auto* dict_values = dictionary_->data_as<ByteArray>();
+ const int values_to_decode = num_values - null_count;
+
+ switch (out->builder->type()->id()) {
+ case ::arrow::Type::BINARY:
+ case ::arrow::Type::STRING:
+ case ::arrow::Type::LARGE_BINARY:
+ case ::arrow::Type::LARGE_STRING: {
+ if (values_to_decode > 0) {
+ RETURN_NOT_OK(indices_scratch_space_->TypedResize<int32_t>(
+ values_to_decode, /*shrink_to_fit=*/false));
+ }
+ auto* decoded_indices =
indices_scratch_space_->mutable_data_as<int32_t>();
+ const int num_indices = idx_decoder_.GetBatch(decoded_indices,
values_to_decode);
+ if (ARROW_PREDICT_FALSE(num_indices != values_to_decode)) {
+ return Status::Invalid("Invalid number of indices: ", num_indices);
+ }
Review Comment:
Good point. I agree that reporting both counts will make truncated or
corrupt index streams easier to diagnose. I’ll update the error message to
include the expected and actual number of decoded dictionary indices.
--
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]