Skip to content

Commit

Permalink
GH-38874: [C++][Parquet] Minor: making parquet TypedComparator operat…
Browse files Browse the repository at this point in the history
…ion as const method (#38875)

### Rationale for this change

`parquet::TypedComparator<DType>` is not const method, which should be const

### What changes are included in this PR?

Change `Compare`, `GetMinMax`, `GetMinMaxSpaced` to const

### Are these changes tested?

No

### Are there any user-facing changes?

No

* Closes: #38874

Authored-by: mwish <maplewish117@gmail.com>
Signed-off-by: mwish <maplewish117@gmail.com>
  • Loading branch information
mapleFU committed Nov 28, 2023
1 parent 7cdb768 commit c614014
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 11 deletions.
14 changes: 7 additions & 7 deletions cpp/src/parquet/statistics.cc
Original file line number Diff line number Diff line change
Expand Up @@ -438,9 +438,9 @@ class TypedComparatorImpl
return Helper::Compare(type_length_, a, b);
}

bool Compare(const T& a, const T& b) override { return CompareInline(a, b); }
bool Compare(const T& a, const T& b) const override { return CompareInline(a, b); }

std::pair<T, T> GetMinMax(const T* values, int64_t length) override {
std::pair<T, T> GetMinMax(const T* values, int64_t length) const override {
DCHECK_GT(length, 0);

T min = Helper::DefaultMin();
Expand All @@ -457,7 +457,7 @@ class TypedComparatorImpl

std::pair<T, T> GetMinMaxSpaced(const T* values, int64_t length,
const uint8_t* valid_bits,
int64_t valid_bits_offset) override {
int64_t valid_bits_offset) const override {
DCHECK_GT(length, 0);

T min = Helper::DefaultMin();
Expand All @@ -477,7 +477,7 @@ class TypedComparatorImpl
return {min, max};
}

std::pair<T, T> GetMinMax(const ::arrow::Array& values) override {
std::pair<T, T> GetMinMax(const ::arrow::Array& values) const override {
ParquetException::NYI(values.type()->ToString());
}

Expand All @@ -491,7 +491,7 @@ class TypedComparatorImpl
template <>
std::pair<int32_t, int32_t>
TypedComparatorImpl</*is_signed=*/false, Int32Type>::GetMinMax(const int32_t* values,
int64_t length) {
int64_t length) const {
DCHECK_GT(length, 0);

const uint32_t* unsigned_values = reinterpret_cast<const uint32_t*>(values);
Expand Down Expand Up @@ -537,13 +537,13 @@ std::pair<ByteArray, ByteArray> GetMinMaxBinaryHelper(

template <>
std::pair<ByteArray, ByteArray> TypedComparatorImpl<true, ByteArrayType>::GetMinMax(
const ::arrow::Array& values) {
const ::arrow::Array& values) const {
return GetMinMaxBinaryHelper<true>(*this, values);
}

template <>
std::pair<ByteArray, ByteArray> TypedComparatorImpl<false, ByteArrayType>::GetMinMax(
const ::arrow::Array& values) {
const ::arrow::Array& values) const {
return GetMinMaxBinaryHelper<false>(*this, values);
}

Expand Down
8 changes: 4 additions & 4 deletions cpp/src/parquet/statistics.h
Original file line number Diff line number Diff line change
Expand Up @@ -73,16 +73,16 @@ class TypedComparator : public Comparator {

/// \brief Scalar comparison of two elements, return true if first
/// is strictly less than the second
virtual bool Compare(const T& a, const T& b) = 0;
virtual bool Compare(const T& a, const T& b) const = 0;

/// \brief Compute maximum and minimum elements in a batch of
/// elements without any nulls
virtual std::pair<T, T> GetMinMax(const T* values, int64_t length) = 0;
virtual std::pair<T, T> GetMinMax(const T* values, int64_t length) const = 0;

/// \brief Compute minimum and maximum elements from an Arrow array. Only
/// valid for certain Parquet Type / Arrow Type combinations, like BYTE_ARRAY
/// / arrow::BinaryArray
virtual std::pair<T, T> GetMinMax(const ::arrow::Array& values) = 0;
virtual std::pair<T, T> GetMinMax(const ::arrow::Array& values) const = 0;

/// \brief Compute maximum and minimum elements in a batch of
/// elements with accompanying bitmap indicating which elements are
Expand All @@ -96,7 +96,7 @@ class TypedComparator : public Comparator {
/// the first element in the sequence
virtual std::pair<T, T> GetMinMaxSpaced(const T* values, int64_t length,
const uint8_t* valid_bits,
int64_t valid_bits_offset) = 0;
int64_t valid_bits_offset) const = 0;
};

/// \brief Typed version of Comparator::Make
Expand Down

0 comments on commit c614014

Please sign in to comment.