mapleFU commented on code in PR #43945:
URL: https://github.com/apache/arrow/pull/43945#discussion_r1744748883
##########
cpp/src/parquet/arrow/reader_internal.cc:
##########
@@ -330,15 +331,39 @@ Status TransferInt(RecordReader* reader, MemoryPool* pool,
auto values = reinterpret_cast<const ParquetCType*>(reader->values());
auto out_ptr = reinterpret_cast<ArrowCType*>(data->mutable_data());
std::copy(values, values + length, out_ptr);
+ int64_t null_count = 0;
+ std::vector<std::shared_ptr<Buffer>> buffers = {nullptr, std::move(data)};
if (field->nullable()) {
- *out = std::make_shared<ArrayType<ArrowType>>(field->type(), length,
std::move(data),
- reader->ReleaseIsValid(),
- reader->null_count());
- } else {
- *out =
- std::make_shared<ArrayType<ArrowType>>(field->type(), length,
std::move(data),
- /*null_bitmap=*/nullptr,
/*null_count=*/0);
+ null_count = reader->null_count();
+ buffers[0] = reader->ReleaseIsValid();
+ }
+ auto array_data =
+ ::arrow::ArrayData::Make(field->type(), length, std::move(buffers),
null_count);
+ auto array_statistics = std::make_shared<::arrow::ArrayStatistics>();
+ array_statistics->null_count = null_count;
+ auto statistics = metadata->statistics().get();
+ if (statistics) {
+ if (statistics->HasDistinctCount()) {
+ array_statistics->distinct_count = statistics->distinct_count();
+ }
+ if (statistics->HasMinMax()) {
+ auto typed_statistics =
+ static_cast<::parquet::TypedStatistics<ParquetType>*>(statistics);
+ const ArrowCType min = typed_statistics->min();
+ const ArrowCType max = typed_statistics->max();
+ if (std::is_signed<ArrowCType>::value) {
+ array_statistics->min = static_cast<int64_t>(min);
+ array_statistics->max = static_cast<int64_t>(max);
+ } else {
+ array_statistics->min = static_cast<uint64_t>(min);
+ array_statistics->max = static_cast<uint64_t>(max);
+ }
+ array_statistics->is_min_exact = true;
+ array_statistics->is_max_exact = true;
Review Comment:
https://lists.apache.org/thread/zfnmg5p51b7oylft5w5k4670wgkd4zv4
--
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]