2121#include " parquet/encoding-internal.h"
2222#include " parquet/exception.h"
2323#include " parquet/statistics.h"
24- #include " parquet/util/comparison.h"
2524#include " parquet/util/memory.h"
2625
2726using arrow::default_memory_pool;
@@ -35,6 +34,7 @@ TypedRowGroupStatistics<DType>::TypedRowGroupStatistics(const ColumnDescriptor*
3534 : pool_(pool),
3635 min_buffer_ (AllocateBuffer(pool_, 0 )),
3736 max_buffer_(AllocateBuffer(pool_, 0 )) {
37+ comparator_ = std::static_pointer_cast<CompareDefault<DType> >(Compare::getComparator (schema));
3838 SetDescr (schema);
3939 Reset ();
4040}
@@ -69,6 +69,7 @@ TypedRowGroupStatistics<DType>::TypedRowGroupStatistics(
6969 IncrementNullCount (null_count);
7070 IncrementDistinctCount (distinct_count);
7171
72+ comparator_ = std::static_pointer_cast<CompareDefault<DType> >(Compare::getComparator (schema));
7273 SetDescr (schema);
7374
7475 if (!encoded_min.empty ()) {
@@ -102,15 +103,14 @@ void TypedRowGroupStatistics<DType>::Update(const T* values, int64_t num_not_nul
102103 // TODO: support distinct count?
103104 if (num_not_null == 0 ) return ;
104105
105- Compare<T> compare (descr_);
106- auto batch_minmax = std::minmax_element (values, values + num_not_null, compare);
106+ auto batch_minmax = std::minmax_element (values, values + num_not_null, std::ref (*(this ->comparator_ )));
107107 if (!has_min_max_) {
108108 has_min_max_ = true ;
109109 Copy (*batch_minmax.first , &min_, min_buffer_.get ());
110110 Copy (*batch_minmax.second , &max_, max_buffer_.get ());
111111 } else {
112- Copy (std::min (min_, *batch_minmax.first , compare ), &min_, min_buffer_.get ());
113- Copy (std::max (max_, *batch_minmax.second , compare ), &max_, max_buffer_.get ());
112+ Copy (std::min (min_, *batch_minmax.first , std::ref (*( this -> comparator_ )) ), &min_, min_buffer_.get ());
113+ Copy (std::max (max_, *batch_minmax.second , std::ref (*( this -> comparator_ )) ), &max_, max_buffer_.get ());
114114 }
115115}
116116
@@ -128,7 +128,6 @@ void TypedRowGroupStatistics<DType>::UpdateSpaced(const T* values,
128128 // TODO: support distinct count?
129129 if (num_not_null == 0 ) return ;
130130
131- Compare<T> compare (descr_);
132131 INIT_BITSET (valid_bits, static_cast <int >(valid_bits_offset));
133132 // Find first valid entry and use that for min/max
134133 // As (num_not_null != 0) there must be one
@@ -144,9 +143,9 @@ void TypedRowGroupStatistics<DType>::UpdateSpaced(const T* values,
144143 T max = values[i];
145144 for (; i < length; i++) {
146145 if (bitset_valid_bits & (1 << bit_offset_valid_bits)) {
147- if (compare (values[i], min)) {
146+ if (( std::ref (*( this -> comparator_ ))) (values[i], min)) {
148147 min = values[i];
149- } else if (compare (max, values[i])) {
148+ } else if (( std::ref (*( this -> comparator_ ))) (max, values[i])) {
150149 max = values[i];
151150 }
152151 }
@@ -157,8 +156,8 @@ void TypedRowGroupStatistics<DType>::UpdateSpaced(const T* values,
157156 Copy (min, &min_, min_buffer_.get ());
158157 Copy (max, &max_, max_buffer_.get ());
159158 } else {
160- Copy (std::min (min_, min, compare ), &min_, min_buffer_.get ());
161- Copy (std::max (max_, max, compare ), &max_, max_buffer_.get ());
159+ Copy (std::min (min_, min, std::ref (*( this -> comparator_ )) ), &min_, min_buffer_.get ());
160+ Copy (std::max (max_, max, std::ref (*( this -> comparator_ )) ), &max_, max_buffer_.get ());
162161 }
163162}
164163
@@ -185,9 +184,8 @@ void TypedRowGroupStatistics<DType>::Merge(const TypedRowGroupStatistics<DType>&
185184 return ;
186185 }
187186
188- Compare<T> compare (descr_);
189- Copy (std::min (this ->min_ , other.min_ , compare), &this ->min_ , min_buffer_.get ());
190- Copy (std::max (this ->max_ , other.max_ , compare), &this ->max_ , max_buffer_.get ());
187+ Copy (std::min (this ->min_ , other.min_ , std::ref (*(this ->comparator_ ))), &this ->min_ , min_buffer_.get ());
188+ Copy (std::max (this ->max_ , other.max_ , std::ref (*(this ->comparator_ ))), &this ->max_ , max_buffer_.get ());
191189}
192190
193191template <typename DType>
0 commit comments