You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@arrow.apache.org by ma...@apache.org on 2023/11/28 10:26:34 UTC
(arrow) branch main updated: GH-38874: [C++][Parquet] Minor: making parquet TypedComparator operation as const method (#38875)
This is an automated email from the ASF dual-hosted git repository.
maplefu pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/arrow.git
The following commit(s) were added to refs/heads/main by this push:
new c614014db8 GH-38874: [C++][Parquet] Minor: making parquet TypedComparator operation as const method (#38875)
c614014db8 is described below
commit c614014db805caf3bbc4d5270bd990c095bf8725
Author: mwish <ma...@gmail.com>
AuthorDate: Tue Nov 28 18:26:23 2023 +0800
GH-38874: [C++][Parquet] Minor: making parquet TypedComparator operation 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 <ma...@gmail.com>
Signed-off-by: mwish <ma...@gmail.com>
---
cpp/src/parquet/statistics.cc | 14 +++++++-------
cpp/src/parquet/statistics.h | 8 ++++----
2 files changed, 11 insertions(+), 11 deletions(-)
diff --git a/cpp/src/parquet/statistics.cc b/cpp/src/parquet/statistics.cc
index 37b245e0dd..e54b94f1a8 100644
--- a/cpp/src/parquet/statistics.cc
+++ b/cpp/src/parquet/statistics.cc
@@ -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();
@@ -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();
@@ -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());
}
@@ -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);
@@ -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);
}
diff --git a/cpp/src/parquet/statistics.h b/cpp/src/parquet/statistics.h
index ae6c1ca29b..6730e6bcdc 100644
--- a/cpp/src/parquet/statistics.h
+++ b/cpp/src/parquet/statistics.h
@@ -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
@@ -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