pitrou commented on a change in pull request #12365:
URL: https://github.com/apache/arrow/pull/12365#discussion_r801589517
##########
File path: cpp/src/parquet/encoding.cc
##########
@@ -2424,7 +2426,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");
Review comment:
```suggestion
ParquetException::EofException("Read " + std::to_string(suffix_read) +
", expecting " +
std::to_string(max_values) +
" from suffix decoder");
```
##########
File path: cpp/src/parquet/encoding.cc
##########
@@ -2181,12 +2181,14 @@ class DeltaBitPackDecoder : public DecoderImpl, virtual
public TypedDecoder<DTyp
}
int GetInternal(T* buffer, int max_values) {
- max_values = std::min(max_values, this->num_values_);
+ int total_value_count = static_cast<int>(std::min(
+ total_value_count_,
static_cast<uint32_t>(std::numeric_limits<int>::max())));
+ max_values = std::min(max_values, total_value_count);
+ DCHECK_GE(max_values, 0);
Review comment:
What is this check for? Is there a situation where `max_values` can be
negative (except the caller passing a negative value)?
##########
File path: cpp/src/parquet/encoding.cc
##########
@@ -2181,12 +2181,14 @@ class DeltaBitPackDecoder : public DecoderImpl, virtual
public TypedDecoder<DTyp
}
int GetInternal(T* buffer, int max_values) {
- max_values = std::min(max_values, this->num_values_);
+ int total_value_count = static_cast<int>(std::min(
+ total_value_count_,
static_cast<uint32_t>(std::numeric_limits<int>::max())));
+ max_values = std::min(max_values, total_value_count);
Review comment:
This is extremely convoluted. How about:
```suggestion
max_values = static_cast<int>(std::min<int64_t>(max_values,
total_value_count_));
```
--
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]