Skip to content
Merged
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
2 changes: 1 addition & 1 deletion cpp/src/arrow/array/concatenate.cc
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@
#include "arrow/util/bitmap_ops.h"
#include "arrow/util/checked_cast.h"
#include "arrow/util/int_util.h"
#include "arrow/util/int_util_internal.h"
#include "arrow/util/int_util_overflow.h"
#include "arrow/util/logging.h"
#include "arrow/visit_type_inline.h"

Expand Down
2 changes: 1 addition & 1 deletion cpp/src/arrow/array/data.cc
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,9 @@
#include "arrow/status.h"
#include "arrow/type.h"
#include "arrow/util/bitmap_ops.h"
#include "arrow/util/int_util_internal.h"
#include "arrow/util/logging.h"
#include "arrow/util/macros.h"
#include "arrow/util/slice_util_internal.h"

namespace arrow {

Expand Down
2 changes: 1 addition & 1 deletion cpp/src/arrow/array/validate.cc
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
#include "arrow/util/bitmap_ops.h"
#include "arrow/util/checked_cast.h"
#include "arrow/util/decimal.h"
#include "arrow/util/int_util_internal.h"
#include "arrow/util/int_util_overflow.h"
#include "arrow/util/logging.h"
#include "arrow/util/utf8.h"
#include "arrow/visit_data_inline.h"
Expand Down
2 changes: 1 addition & 1 deletion cpp/src/arrow/buffer.cc
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,8 @@
#include "arrow/result.h"
#include "arrow/status.h"
#include "arrow/util/bit_util.h"
#include "arrow/util/int_util_internal.h"
#include "arrow/util/logging.h"
#include "arrow/util/slice_util_internal.h"
#include "arrow/util/string.h"

namespace arrow {
Expand Down
2 changes: 1 addition & 1 deletion cpp/src/arrow/compute/kernels/aggregate_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@
#include "arrow/type_traits.h"
#include "arrow/util/bitmap_reader.h"
#include "arrow/util/checked_cast.h"
#include "arrow/util/int_util_internal.h"
#include "arrow/util/int_util_overflow.h"

#include "arrow/testing/gtest_util.h"
#include "arrow/testing/matchers.h"
Expand Down
2 changes: 1 addition & 1 deletion cpp/src/arrow/compute/kernels/base_arithmetic_internal.h
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
#include "arrow/type.h"
#include "arrow/type_traits.h"
#include "arrow/util/decimal.h"
#include "arrow/util/int_util_internal.h"
#include "arrow/util/int_util_overflow.h"
#include "arrow/util/macros.h"

namespace arrow {
Expand Down
2 changes: 1 addition & 1 deletion cpp/src/arrow/compute/kernels/hash_aggregate.cc
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@
#include "arrow/util/checked_cast.h"
#include "arrow/util/cpu_info.h"
#include "arrow/util/int128_internal.h"
#include "arrow/util/int_util_internal.h"
#include "arrow/util/int_util_overflow.h"
#include "arrow/util/make_unique.h"
#include "arrow/util/task_group.h"
#include "arrow/util/tdigest.h"
Expand Down
2 changes: 1 addition & 1 deletion cpp/src/arrow/compute/kernels/hash_aggregate_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@
#include "arrow/util/async_generator.h"
#include "arrow/util/bitmap_reader.h"
#include "arrow/util/checked_cast.h"
#include "arrow/util/int_util_internal.h"
#include "arrow/util/int_util_overflow.h"
#include "arrow/util/key_value_metadata.h"
#include "arrow/util/logging.h"
#include "arrow/util/thread_pool.h"
Expand Down
2 changes: 1 addition & 1 deletion cpp/src/arrow/compute/kernels/scalar_arithmetic.cc
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
#include "arrow/type.h"
#include "arrow/type_traits.h"
#include "arrow/util/decimal.h"
#include "arrow/util/int_util_internal.h"
#include "arrow/util/int_util_overflow.h"
#include "arrow/util/macros.h"
#include "arrow/visit_scalar_inline.h"

Expand Down
2 changes: 1 addition & 1 deletion cpp/src/arrow/dataset/partition.cc
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
#include "arrow/dataset/dataset_internal.h"
#include "arrow/filesystem/path_util.h"
#include "arrow/scalar.h"
#include "arrow/util/int_util_internal.h"
#include "arrow/util/int_util_overflow.h"
#include "arrow/util/logging.h"
#include "arrow/util/make_unique.h"
#include "arrow/util/string_view.h"
Expand Down
2 changes: 1 addition & 1 deletion cpp/src/arrow/memory_pool.cc
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@
#include "arrow/status.h"
#include "arrow/util/bit_util.h"
#include "arrow/util/debug.h"
#include "arrow/util/int_util_internal.h"
#include "arrow/util/int_util_overflow.h"
#include "arrow/util/io_util.h"
#include "arrow/util/logging.h" // IWYU pragma: keep
#include "arrow/util/optional.h"
Expand Down
2 changes: 1 addition & 1 deletion cpp/src/arrow/pretty_print.cc
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@
#include "arrow/type_traits.h"
#include "arrow/util/checked_cast.h"
#include "arrow/util/formatting.h"
#include "arrow/util/int_util_internal.h"
#include "arrow/util/int_util_overflow.h"
#include "arrow/util/key_value_metadata.h"
#include "arrow/util/string.h"
#include "arrow/util/string_view.h"
Expand Down
2 changes: 1 addition & 1 deletion cpp/src/arrow/python/python_to_arrow.cc
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@
#include "arrow/util/checked_cast.h"
#include "arrow/util/converter.h"
#include "arrow/util/decimal.h"
#include "arrow/util/int_util_internal.h"
#include "arrow/util/int_util_overflow.h"
#include "arrow/util/logging.h"

#include "arrow/python/datetime.h"
Expand Down
2 changes: 1 addition & 1 deletion cpp/src/arrow/tensor.cc
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
#include "arrow/type.h"
#include "arrow/type_traits.h"
#include "arrow/util/checked_cast.h"
#include "arrow/util/int_util_internal.h"
#include "arrow/util/int_util_overflow.h"
#include "arrow/util/logging.h"
#include "arrow/visit_type_inline.h"

Expand Down
2 changes: 1 addition & 1 deletion cpp/src/arrow/util/basic_decimal.cc
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
#include "arrow/util/config.h" // for ARROW_USE_NATIVE_INT128
#include "arrow/util/endian.h"
#include "arrow/util/int128_internal.h"
#include "arrow/util/int_util_internal.h"
#include "arrow/util/int_util_overflow.h"
#include "arrow/util/logging.h"
#include "arrow/util/macros.h"

Expand Down
2 changes: 1 addition & 1 deletion cpp/src/arrow/util/decimal.cc
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
#include "arrow/util/endian.h"
#include "arrow/util/formatting.h"
#include "arrow/util/int128_internal.h"
#include "arrow/util/int_util_internal.h"
#include "arrow/util/int_util_overflow.h"
#include "arrow/util/logging.h"
#include "arrow/util/macros.h"
#include "arrow/util/value_parsing.h"
Expand Down
17 changes: 17 additions & 0 deletions cpp/src/arrow/util/int_util.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
#include <type_traits>

#include "arrow/status.h"

#include "arrow/util/visibility.h"

namespace arrow {
Expand Down Expand Up @@ -113,5 +114,21 @@ Status CheckIntegersInRange(const Datum& datum, const Scalar& bound_lower,
ARROW_EXPORT
Status IntegersCanFit(const Datum& datum, const DataType& target_type);

/// Upcast an integer to the largest possible width (currently 64 bits)

template <typename Integer>
typename std::enable_if<
std::is_integral<Integer>::value && std::is_signed<Integer>::value, int64_t>::type
UpcastInt(Integer v) {
return v;
}

template <typename Integer>
typename std::enable_if<
std::is_integral<Integer>::value && std::is_unsigned<Integer>::value, uint64_t>::type
UpcastInt(Integer v) {
return v;
}

} // namespace internal
} // namespace arrow
Original file line number Diff line number Diff line change
Expand Up @@ -114,41 +114,5 @@ SignedInt SafeLeftShift(SignedInt u, Shift shift) {
return static_cast<SignedInt>(static_cast<UnsignedInt>(u) << shift);
}

/// Upcast an integer to the largest possible width (currently 64 bits)

template <typename Integer>
typename std::enable_if<
std::is_integral<Integer>::value && std::is_signed<Integer>::value, int64_t>::type
UpcastInt(Integer v) {
return v;
}

template <typename Integer>
typename std::enable_if<
std::is_integral<Integer>::value && std::is_unsigned<Integer>::value, uint64_t>::type
UpcastInt(Integer v) {
return v;
}

static inline Status CheckSliceParams(int64_t object_length, int64_t slice_offset,
int64_t slice_length, const char* object_name) {
if (ARROW_PREDICT_FALSE(slice_offset < 0)) {
return Status::IndexError("Negative ", object_name, " slice offset");
}
if (ARROW_PREDICT_FALSE(slice_length < 0)) {
return Status::IndexError("Negative ", object_name, " slice length");
}
int64_t offset_plus_length;
if (ARROW_PREDICT_FALSE(
internal::AddWithOverflow(slice_offset, slice_length, &offset_plus_length))) {
return Status::IndexError(object_name, " slice would overflow");
}
if (ARROW_PREDICT_FALSE(offset_plus_length > object_length)) {
return Status::IndexError(object_name, " slice would exceed ", object_name,
" length");
}
return Status::OK();
}

} // namespace internal
} // namespace arrow
2 changes: 1 addition & 1 deletion cpp/src/arrow/util/int_util_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
#include "arrow/testing/random.h"
#include "arrow/type.h"
#include "arrow/util/int_util.h"
#include "arrow/util/int_util_internal.h"
#include "arrow/util/int_util_overflow.h"

namespace arrow {
namespace internal {
Expand Down
46 changes: 46 additions & 0 deletions cpp/src/arrow/util/slice_util_internal.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
// Licensed to the Apache Software Foundation (ASF) under one
// or more contributor license agreements. See the NOTICE file
// distributed with this work for additional information
// regarding copyright ownership. The ASF licenses this file
// to you under the Apache License, Version 2.0 (the
// "License"); you may not use this file except in compliance
// with the License. You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing,
// software distributed under the License is distributed on an
// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
// KIND, either express or implied. See the License for the
// specific language governing permissions and limitations
// under the License.

#pragma once

#include "arrow/util/int_util_overflow.h"

namespace arrow {
namespace internal {

static inline Status CheckSliceParams(int64_t object_length, int64_t slice_offset,
int64_t slice_length, const char* object_name) {
if (ARROW_PREDICT_FALSE(slice_offset < 0)) {
return Status::IndexError("Negative ", object_name, " slice offset");
}
if (ARROW_PREDICT_FALSE(slice_length < 0)) {
return Status::IndexError("Negative ", object_name, " slice length");
}
int64_t offset_plus_length;
if (ARROW_PREDICT_FALSE(
internal::AddWithOverflow(slice_offset, slice_length, &offset_plus_length))) {
return Status::IndexError(object_name, " slice would overflow");
}
if (ARROW_PREDICT_FALSE(offset_plus_length > object_length)) {
return Status::IndexError(object_name, " slice would exceed ", object_name,
" length");
}
return Status::OK();
}

} // namespace internal
} // namespace arrow
2 changes: 2 additions & 0 deletions cpp/src/arrow/vendored/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -20,3 +20,5 @@ arrow_install_all_headers("arrow/vendored")
add_subdirectory(datetime)
add_subdirectory(double-conversion)
add_subdirectory(pcg)
add_subdirectory(portable-snippets)
add_subdirectory(xxhash)
18 changes: 18 additions & 0 deletions cpp/src/arrow/vendored/portable-snippets/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# Licensed to the Apache Software Foundation (ASF) under one
# or more contributor license agreements. See the NOTICE file
# distributed with this work for additional information
# regarding copyright ownership. The ASF licenses this file
# to you under the Apache License, Version 2.0 (the
# "License"); you may not use this file except in compliance
# with the License. You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing,
# software distributed under the License is distributed on an
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
# KIND, either express or implied. See the License for the
# specific language governing permissions and limitations
# under the License.

arrow_install_all_headers("arrow/vendored/portable-snippets")
18 changes: 18 additions & 0 deletions cpp/src/arrow/vendored/xxhash/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# Licensed to the Apache Software Foundation (ASF) under one
# or more contributor license agreements. See the NOTICE file
# distributed with this work for additional information
# regarding copyright ownership. The ASF licenses this file
# to you under the Apache License, Version 2.0 (the
# "License"); you may not use this file except in compliance
# with the License. You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing,
# software distributed under the License is distributed on an
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
# KIND, either express or implied. See the License for the
# specific language governing permissions and limitations
# under the License.

arrow_install_all_headers("arrow/vendored/xxhash")
2 changes: 1 addition & 1 deletion cpp/src/parquet/arrow/reader_internal.cc
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@
#include "arrow/util/bit_util.h"
#include "arrow/util/checked_cast.h"
#include "arrow/util/endian.h"
#include "arrow/util/int_util_internal.h"
#include "arrow/util/int_util_overflow.h"
#include "arrow/util/logging.h"
#include "arrow/util/string_view.h"
#include "arrow/util/ubsan.h"
Expand Down
2 changes: 1 addition & 1 deletion cpp/src/parquet/column_reader.cc
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@
#include "arrow/util/bit_util.h"
#include "arrow/util/checked_cast.h"
#include "arrow/util/compression.h"
#include "arrow/util/int_util_internal.h"
#include "arrow/util/int_util_overflow.h"
#include "arrow/util/logging.h"
#include "arrow/util/rle_encoding.h"
#include "parquet/column_page.h"
Expand Down
2 changes: 1 addition & 1 deletion cpp/src/parquet/encoding.cc
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@
#include "arrow/util/byte_stream_split.h"
#include "arrow/util/checked_cast.h"
#include "arrow/util/hashing.h"
#include "arrow/util/int_util_internal.h"
#include "arrow/util/int_util_overflow.h"
#include "arrow/util/logging.h"
#include "arrow/util/rle_encoding.h"
#include "arrow/util/string_view.h"
Expand Down
2 changes: 1 addition & 1 deletion cpp/src/parquet/file_reader.cc
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
#include "arrow/io/memory.h"
#include "arrow/util/checked_cast.h"
#include "arrow/util/future.h"
#include "arrow/util/int_util_internal.h"
#include "arrow/util/int_util_overflow.h"
#include "arrow/util/logging.h"
#include "arrow/util/ubsan.h"
#include "parquet/column_reader.h"
Expand Down