diff --git a/cpp/src/parquet/encoding.cc b/cpp/src/parquet/encoding.cc index 27473c932fa30..af0e543c3e794 100644 --- a/cpp/src/parquet/encoding.cc +++ b/cpp/src/parquet/encoding.cc @@ -2109,9 +2109,9 @@ class DeltaBitPackDecoder : public DecoderImpl, virtual public TypedDecoder values(num_values); - GetInternal(values.data(), num_values); - PARQUET_THROW_NOT_OK(out->AppendValues(values)); - return num_values; + int decoded_count = GetInternal(values.data(), num_values); + PARQUET_THROW_NOT_OK(out->AppendValues(values.data(), decoded_count)); + return decoded_count; } int DecodeArrow(int num_values, int null_count, const uint8_t* valid_bits, @@ -2121,12 +2121,12 @@ class DeltaBitPackDecoder : public DecoderImpl, virtual public TypedDecoder values(num_values); - GetInternal(values.data(), num_values); - PARQUET_THROW_NOT_OK(out->Reserve(num_values)); - for (T value : values) { - PARQUET_THROW_NOT_OK(out->Append(value)); + int decoded_count = GetInternal(values.data(), num_values); + PARQUET_THROW_NOT_OK(out->Reserve(decoded_count)); + for (int i = 0; i < decoded_count; ++i) { + PARQUET_THROW_NOT_OK(out->Append(values[i])); } - return num_values; + return decoded_count; } private: @@ -2181,12 +2181,11 @@ class DeltaBitPackDecoder : public DecoderImpl, virtual public TypedDecodernum_values_); + max_values = static_cast(std::min(max_values, total_value_count_)); if (max_values == 0) { return 0; } - DCHECK_LE(static_cast(max_values), total_value_count_); int i = 0; while (i < max_values) { if (ARROW_PREDICT_FALSE(values_current_mini_block_ == 0)) { @@ -2424,7 +2423,12 @@ class DeltaByteArrayDecoder : public DecoderImpl, return max_values; } - suffix_decoder_.Decode(buffer, max_values); + int suffix_read = suffix_decoder_.Decode(buffer, max_values); + if (ARROW_PREDICT_FALSE(suffix_read != max_values)) { + ParquetException::EofException("Read " + std::to_string(suffix_read) + + ", expecting " + std::to_string(max_values) + + " from suffix decoder"); + } int64_t data_size = 0; const int32_t* prefix_len_ptr = diff --git a/testing b/testing index 634739c664433..d9e7237f4f71c 160000 --- a/testing +++ b/testing @@ -1 +1 @@ -Subproject commit 634739c664433cec366b4b9a81d1e1044a8c5eda +Subproject commit d9e7237f4f71c91acb8daeda97354b073d28ac5b