Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions cpp/src/arrow/adapters/orc/util.cc
Original file line number Diff line number Diff line change
Expand Up @@ -295,7 +295,7 @@ Status AppendUnionBatchInternal(const liborc::Type* type,
RETURN_NOT_OK(AppendBatch(child_type, child_batch, start, /*length=*/1,
builder->child_builder(child_id).get()));

if constexpr (std::is_same_v<UnionBuilderType, SparseUnionBuilder>) {
if constexpr (std::same_as<UnionBuilderType, SparseUnionBuilder>) {
// Append null value to other child builders for sparse union type.
for (int8_t field_id = 0; field_id < union_type->num_fields(); field_id++) {
if (field_id != child_id) {
Expand Down Expand Up @@ -844,10 +844,10 @@ Status WriteUnionBatch(const Array& array, int64_t orc_offset,
int64_t child_array_orc_offset = batch->offsets[running_orc_offset];
int64_t child_array_arrow_offset;

if constexpr (std::is_same_v<UnionArrayType, DenseUnionArray>) {
if constexpr (std::same_as<UnionArrayType, DenseUnionArray>) {
child_array_arrow_offset = union_array->value_offset(running_arrow_offset);
} else {
static_assert(std::is_same_v<UnionArrayType, SparseUnionArray>);
static_assert(std::same_as<UnionArrayType, SparseUnionArray>);
child_array_arrow_offset = running_arrow_offset;
}
child_batch->resize(child_array_orc_offset + 1);
Expand Down
4 changes: 2 additions & 2 deletions cpp/src/arrow/array/array_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -2494,10 +2494,10 @@ void CheckFloatApproxEqualsWithUlpDistance() {
if constexpr (is_half_float_type<TYPE>::value) {
a.push_back(Float16(1.00097656));
b.push_back(Float16(0.999511719f));
} else if constexpr (std::is_same_v<TYPE, DoubleType>) {
} else if constexpr (std::same_as<TYPE, DoubleType>) {
a.push_back(CType(0.9999999999999999));
b.push_back(CType(1.0000000000000002));
} else if constexpr (std::is_same_v<TYPE, FloatType>) {
} else if constexpr (std::same_as<TYPE, FloatType>) {
a.push_back(CType(1.0000001f));
b.push_back(CType(0.99999994f));
}
Expand Down
6 changes: 3 additions & 3 deletions cpp/src/arrow/array/builder_primitive.h
Original file line number Diff line number Diff line change
Expand Up @@ -473,9 +473,9 @@ class ARROW_EXPORT HalfFloatBuilder : public NumericBuilder<HalfFloatType> {
/// @tparam T arrow::util::Float16 or value_type (uint16_t)
template <typename T = BaseClass::value_type>
T GetValue(int64_t index) const {
static_assert(std::is_same_v<T, BaseClass::value_type> ||
std::is_same_v<T, arrow::util::Float16>);
if constexpr (std::is_same_v<T, BaseClass::value_type>) {
static_assert(std::same_as<T, BaseClass::value_type> ||
std::same_as<T, arrow::util::Float16>);
if constexpr (std::same_as<T, BaseClass::value_type>) {
return BaseClass::GetValue(index);
} else {
return Float16::FromBits(BaseClass::GetValue(index));
Expand Down
4 changes: 2 additions & 2 deletions cpp/src/arrow/array/data_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ TEST(ArrayData, GetSpanRespectsOffset) {
/*offset=*/1);
auto span = data->GetSpan<uint16_t>(1, 3);

const bool is_const_pointer = std::is_same_v<decltype(span)::pointer, const uint16_t*>;
const bool is_const_pointer = std::same_as<decltype(span)::pointer, const uint16_t*>;
ASSERT_TRUE(is_const_pointer);

EXPECT_EQ(span.size(), 3);
Expand All @@ -73,7 +73,7 @@ TEST(ArrayData, GetMutableSpanRespectsOffset) {
ArrayData::Make(uint16(), /*length=*/3, buffers, /*null_count=*/0, /*offset=*/1);
auto span = data->GetMutableSpan<uint16_t>(1, 3);

const bool is_mut_pointer = std::is_same_v<decltype(span)::pointer, uint16_t*>;
const bool is_mut_pointer = std::same_as<decltype(span)::pointer, uint16_t*>;
ASSERT_TRUE(is_mut_pointer);

EXPECT_EQ(span.size(), 3);
Expand Down
2 changes: 1 addition & 1 deletion cpp/src/arrow/array/dict_internal.h
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,7 @@ template <typename T>
struct DictionaryTraits<T, enable_if_binary_view_like<T>> {
using MemoTableType = typename HashTraits<T>::MemoTableType;

static_assert(std::is_same_v<MemoTableType, BinaryMemoTable<BinaryBuilder>>);
static_assert(std::same_as<MemoTableType, BinaryMemoTable<BinaryBuilder>>);

// Instead of defining a custom memo table for StringView we reuse BinaryType's,
// then convert to views when we copy data out of the memo table.
Expand Down
4 changes: 2 additions & 2 deletions cpp/src/arrow/array/validate.cc
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,8 @@ struct UTF8DataValidator {

template <typename T>
Status Visit(const T&) {
if constexpr (std::is_same_v<T, StringType> || std::is_same_v<T, LargeStringType> ||
std::is_same_v<T, StringViewType>) {
if constexpr (std::same_as<T, StringType> || std::same_as<T, LargeStringType> ||
std::same_as<T, StringViewType>) {
util::InitializeUTF8();

int64_t i = 0;
Expand Down
2 changes: 1 addition & 1 deletion cpp/src/arrow/c/dlpack.cc
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ DT* ExportBuffer(ExportBufferParams<Vec>&& p) {
ctx->tensor.dl_tensor.byte_offset = 0;
// Strides must be non-null when ndim > 0
ctx->tensor.dl_tensor.strides = ctx->strides.data();
if constexpr (std::is_same_v<DT, DLManagedTensorVersioned>) {
if constexpr (std::same_as<DT, DLManagedTensorVersioned>) {
ctx->tensor.version = kVersion;
ctx->tensor.flags = p.flags;
}
Expand Down
6 changes: 3 additions & 3 deletions cpp/src/arrow/c/dlpack_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ void CheckDLTensor(const std::shared_ptr<Array>& arr,
ASSERT_EQ(DLDeviceType::kDLCPU, device.device_type);
ASSERT_EQ(0, device.device_id);

if constexpr (std::is_same_v<decltype(dlmtensor), DLManagedTensorVersioned*>) {
if constexpr (std::same_as<decltype(dlmtensor), DLManagedTensorVersioned*>) {
ASSERT_EQ(DLPACK_MAJOR_VERSION, dlmtensor->version.major);
ASSERT_EQ(DLPACK_MINOR_VERSION, dlmtensor->version.minor);
if constexpr (Producer::copy) {
Expand Down Expand Up @@ -234,7 +234,7 @@ void CheckDLTensor(const std::shared_ptr<Tensor>& t,
ASSERT_EQ(DLDeviceType::kDLCPU, device.device_type);
ASSERT_EQ(0, device.device_id);

if constexpr (std::is_same_v<decltype(dlmtensor), DLManagedTensorVersioned*>) {
if constexpr (std::same_as<decltype(dlmtensor), DLManagedTensorVersioned*>) {
ASSERT_EQ(DLPACK_MAJOR_VERSION, dlmtensor->version.major);
ASSERT_EQ(DLPACK_MINOR_VERSION, dlmtensor->version.minor);
if constexpr (Producer::copy) {
Expand Down Expand Up @@ -296,7 +296,7 @@ TYPED_TEST(TestExportTensor, TestTensorReadOnly) {
Tensor::Make(float32(), read_only_buffer, shape));
ASSERT_FALSE(read_only_tensor->is_mutable());

if constexpr (std::is_same_v<typename TypeParam::ManagedTensor, DLManagedTensor>) {
if constexpr (std::same_as<typename TypeParam::ManagedTensor, DLManagedTensor>) {
ASSERT_RAISES_WITH_MESSAGE(
NotImplemented,
"NotImplemented: Legacy DLPack support is not implemented for immutable tensors."
Expand Down
4 changes: 2 additions & 2 deletions cpp/src/arrow/compare.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1540,7 +1540,7 @@ bool ArrayStatisticsOptionalValueEquals(const std::optional<Type>& left,
const EqualOptions& options) {
if (!left.has_value() || !right.has_value()) {
return left.has_value() == right.has_value();
} else if constexpr (std::is_same_v<Type, double>) {
} else if constexpr (std::same_as<Type, double>) {
return DoubleEquals(left.value(), right.value(), options);
} else if (left->index() != right->index()) {
return false;
Expand All @@ -1551,7 +1551,7 @@ bool ArrayStatisticsOptionalValueEquals(const std::optional<Type>& left,
if constexpr (std::conjunction_v<std::is_same<type_1, double>,
std::is_same<type_2, double>>) {
return DoubleEquals(v1, v2, options);
} else if constexpr (std::is_same_v<type_1, type_2>) {
} else if constexpr (std::same_as<type_1, type_2>) {
return v1 == v2;
}
Unreachable("The types are different.");
Expand Down
2 changes: 1 addition & 1 deletion cpp/src/arrow/compute/kernels/aggregate_basic.inc.cc
Original file line number Diff line number Diff line change
Expand Up @@ -274,7 +274,7 @@ struct MeanImpl<ArrowType, SimdLevel,
(this->count < options.min_count)) {
out->value = std::make_shared<DoubleScalar>();
} else {
static_assert(std::is_same_v<decltype(this->sum), double>,
static_assert(std::same_as<decltype(this->sum), double>,
"SumCType must be double for numeric inputs");
const double mean = this->sum / this->count;
out->value = std::make_shared<DoubleScalar>(mean);
Expand Down
8 changes: 4 additions & 4 deletions cpp/src/arrow/compute/kernels/base_arithmetic_internal.h
Original file line number Diff line number Diff line change
Expand Up @@ -729,7 +729,7 @@ template <>
struct Identity<Add> {
template <typename Value>
static constexpr Value value() {
if constexpr (std::is_same_v<Float16, Value>) {
if constexpr (std::same_as<Float16, Value>) {
return Float16::zero();
} else {
return 0;
Expand All @@ -744,7 +744,7 @@ template <>
struct Identity<Multiply> {
template <typename Value>
static constexpr Value value() {
if constexpr (std::is_same_v<Float16, Value>) {
if constexpr (std::same_as<Float16, Value>) {
return Float16::one();
} else {
return 1;
Expand All @@ -762,7 +762,7 @@ struct Identity<Max> {
// Note that `min()` returns the smallest positive value for
// floating-point types, and `lowest()` doesn't satisfy the identity
// property for -inf inputs, so use -infinity for those types.
if constexpr (std::is_floating_point_v<Value> || std::is_same_v<Float16, Value>) {
if constexpr (std::is_floating_point_v<Value> || std::same_as<Float16, Value>) {
return -std::numeric_limits<Value>::infinity();
} else {
return std::numeric_limits<Value>::lowest();
Expand All @@ -775,7 +775,7 @@ struct Identity<Min> {
template <typename Value>
static constexpr Value value() {
// Mirror of Identity<Max>: use +infinity for floating-point types.
if constexpr (std::is_floating_point_v<Value> || std::is_same_v<Float16, Value>) {
if constexpr (std::is_floating_point_v<Value> || std::same_as<Float16, Value>) {
return std::numeric_limits<Value>::infinity();
} else {
return std::numeric_limits<Value>::max();
Expand Down
8 changes: 4 additions & 4 deletions cpp/src/arrow/compute/kernels/codegen_internal.h
Original file line number Diff line number Diff line change
Expand Up @@ -276,7 +276,7 @@ template <typename T, typename R = T>
using enable_if_not_floating_value = enable_if_t<!std::is_floating_point<T>::value, R>;

template <typename T, typename R = T>
using enable_if_half_float_value = enable_if_t<std::is_same_v<T, Float16>, R>;
using enable_if_half_float_value = enable_if_t<std::same_as<T, Float16>, R>;

template <typename T, typename R = T>
using enable_if_decimal_value =
Expand Down Expand Up @@ -492,8 +492,8 @@ void VisitArrayValuesInline(const ArraySpan& arr, VisitFunc&& valid_func,
}

template <typename T, typename VisitFunc, typename NullFunc>
requires std::is_same_v<std::invoke_result_t<VisitFunc, typename GetViewType<T>::T>,
Status>
requires std::same_as<std::invoke_result_t<VisitFunc, typename GetViewType<T>::T>,
Status>
Status VisitArrayValuesInline(const ArraySpan& arr, VisitFunc&& valid_func,
NullFunc&& null_func) {
return VisitArraySpanInline<T>(
Expand Down Expand Up @@ -622,7 +622,7 @@ struct OutputAdapter<Type, enable_if_boolean<Type>> {

template <typename Type>
struct OutputAdapter<Type, enable_if_c_number_or_decimal<Type>> {
using T = std::conditional_t<std::is_same_v<Type, HalfFloatType>, Float16,
using T = std::conditional_t<std::same_as<Type, HalfFloatType>, Float16,
typename TypeTraits<Type>::ScalarType::ValueType>;

template <typename Generator>
Expand Down
2 changes: 1 addition & 1 deletion cpp/src/arrow/compute/kernels/hash_aggregate_internal.h
Original file line number Diff line number Diff line change
Expand Up @@ -176,7 +176,7 @@ void VisitGroupedValues(const ExecSpan& batch, ConsumeValue&& valid_func,
}

template <typename Type, typename ConsumeValue, typename ConsumeNull>
requires std::is_same_v<
requires std::same_as<
std::invoke_result_t<ConsumeValue, uint32_t, typename GetViewType<Type>::T>, Status>
Status VisitGroupedValues(const ExecSpan& batch, ConsumeValue&& valid_func,
ConsumeNull&& null_func) {
Expand Down
8 changes: 4 additions & 4 deletions cpp/src/arrow/compute/kernels/ree_util_internal.h
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ class ReadWriteValue<ArrowType, in_has_validity_buffer, out_has_validity_buffer,
if constexpr (in_has_validity_buffer) {
valid = bit_util::GetBit(input_validity_, read_offset);
}
if constexpr (std::is_same_v<ArrowType, BooleanType>) {
if constexpr (std::same_as<ArrowType, BooleanType>) {
*out = bit_util::GetBit(input_values_, read_offset);
} else {
*out = (reinterpret_cast<const ValueRepr*>(input_values_))[read_offset];
Expand All @@ -88,7 +88,7 @@ class ReadWriteValue<ArrowType, in_has_validity_buffer, out_has_validity_buffer,
/// - i and j are valid indices into the values buffer
/// - the values in i and j are valid
bool CompareValuesAt(int64_t i, int64_t j) const {
if constexpr (std::is_same_v<ArrowType, BooleanType>) {
if constexpr (std::same_as<ArrowType, BooleanType>) {
return bit_util::GetBit(input_values_, i) == bit_util::GetBit(input_values_, j);
} else {
return (reinterpret_cast<const ValueRepr*>(input_values_))[i] ==
Expand All @@ -111,7 +111,7 @@ class ReadWriteValue<ArrowType, in_has_validity_buffer, out_has_validity_buffer,
bit_util::SetBitTo(output_validity_, write_offset, valid);
}
if (valid) {
if constexpr (std::is_same_v<ArrowType, BooleanType>) {
if constexpr (std::same_as<ArrowType, BooleanType>) {
bit_util::SetBitTo(output_values_, write_offset, value);
} else {
(reinterpret_cast<ValueRepr*>(output_values_))[write_offset] = value;
Expand All @@ -125,7 +125,7 @@ class ReadWriteValue<ArrowType, in_has_validity_buffer, out_has_validity_buffer,
bit_util::SetBitsTo(output_validity_, write_offset, run_length, valid);
}
if (valid) {
if constexpr (std::is_same_v<ArrowType, BooleanType>) {
if constexpr (std::same_as<ArrowType, BooleanType>) {
bit_util::SetBitsTo(reinterpret_cast<uint8_t*>(output_values_), write_offset,
run_length, value);
} else {
Expand Down
8 changes: 4 additions & 4 deletions cpp/src/arrow/compute/kernels/scalar_arithmetic_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ template <typename T>
class TestBaseArithmetic : public ::testing::Test {
protected:
using ArrowType = T;
using CType = std::conditional_t<std::is_same_v<T, HalfFloatType>, Float16,
using CType = std::conditional_t<std::same_as<T, HalfFloatType>, Float16,
typename ArrowType::c_type>;

static std::shared_ptr<DataType> type_singleton() {
Expand All @@ -104,14 +104,14 @@ class TestBaseArithmetic : public ::testing::Test {

template <typename V>
std::shared_ptr<Scalar> MakeScalar(V value) {
if constexpr (std::is_same_v<T, HalfFloatType>) {
if constexpr (std::same_as<T, HalfFloatType>) {
return std::make_shared<HalfFloatScalar>(Float16(value).bits());
} else {
return *arrow::MakeScalar(type_singleton(), value);
}
}

static constexpr bool is_half_float() { return std::is_same_v<T, HalfFloatType>; }
static constexpr bool is_half_float() { return std::same_as<T, HalfFloatType>; }
};

// This has to be a macro, the test wouldn't be skipped from a helper function
Expand All @@ -122,7 +122,7 @@ class TestBaseArithmetic : public ::testing::Test {

template <typename T, typename R = void>
using enable_if_numeric_value =
std::enable_if_t<std::is_arithmetic_v<T> || std::is_same_v<T, Float16>, R>;
std::enable_if_t<std::is_arithmetic_v<T> || std::same_as<T, Float16>, R>;

template <typename T, typename OptionsType>
class TestBaseUnaryArithmetic : public TestBaseArithmetic<T> {
Expand Down
8 changes: 4 additions & 4 deletions cpp/src/arrow/compute/kernels/scalar_nested.cc
Original file line number Diff line number Diff line change
Expand Up @@ -249,7 +249,7 @@ struct ListSlice {
RETURN_NOT_OK(MakeBuilder(pool, output_type, &builder));
auto* list_builder = checked_cast<BuilderType*>(builder.get());
RETURN_NOT_OK(list_builder->Resize(batch[0].array.length));
if constexpr (std::is_same_v<InListType, FixedSizeListType>) {
if constexpr (std::same_as<InListType, FixedSizeListType>) {
RETURN_NOT_OK(BuildArrayFromFixedSizeListType(opts.start, opts.step, opts.stop,
batch, list_builder));
} else {
Expand All @@ -267,8 +267,8 @@ struct ListSlice {
std::optional<int64_t> stop,
const ExecSpan& batch,
BuilderType* out_list_builder) {
static_assert(std::is_same_v<InListType, FixedSizeListType>);
constexpr bool kIsFixedSizeOutput = std::is_same_v<BuilderType, FixedSizeListBuilder>;
static_assert(std::same_as<InListType, FixedSizeListType>);
constexpr bool kIsFixedSizeOutput = std::same_as<BuilderType, FixedSizeListBuilder>;
const auto& fsl_type = checked_cast<const FixedSizeListType&>(*batch[0].type());
const ArraySpan& list_array = batch[0].array;
const ArraySpan& values_array = list_array.child_data[0];
Expand Down Expand Up @@ -315,7 +315,7 @@ struct ListSlice {
const ExecSpan& batch,
BuilderType* out_list_builder) {
constexpr bool kIsListViewInput = is_list_view(InListType::type_id);
constexpr bool kIsFixedSizeOutput = std::is_same_v<BuilderType, FixedSizeListBuilder>;
constexpr bool kIsFixedSizeOutput = std::same_as<BuilderType, FixedSizeListBuilder>;
const ArraySpan& list_array = batch[0].array;
const ArraySpan& values_array = list_array.child_data[0];
ArrayBuilder* value_builder = out_list_builder->value_builder();
Expand Down
Loading
Loading