Skip to content

Commit b598b04

Browse files
committed
post rebase fixes
1 parent 7032653 commit b598b04

File tree

5 files changed

+13
-75
lines changed

5 files changed

+13
-75
lines changed

cpp/src/arrow/compute/kernels/CMakeLists.txt

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,7 @@ arrow_install_all_headers("arrow/compute/kernels")
2222

2323
# Define arrow_compute_kernels_testing object library for common test files
2424
if(ARROW_TESTING)
25-
add_library(arrow_compute_kernels_testing OBJECT test_util_internal.cc)
26-
add_library(arrow_compute_kernels_testing OBJECT test_util.cc
25+
add_library(arrow_compute_kernels_testing OBJECT test_util_internal.cc
2726
../../extension/tensor_extension_array_test.cc)
2827
# Even though this is still just an object library we still need to "link" our
2928
# dependencies so that include paths are configured correctly

cpp/src/arrow/extension/tensor_extension_array_test.cc

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -29,9 +29,7 @@
2929
#include "arrow/tensor.h"
3030
#include "arrow/testing/gtest_util.h"
3131
#include "arrow/util/key_value_metadata.h"
32-
#include "arrow/util/sort.h"
33-
#include "arrow/util/logging.h"
34-
32+
#include "arrow/util/sort_internal.h"
3533

3634
namespace arrow {
3735

@@ -159,8 +157,7 @@ TEST_F(TestFixedShapeTensorType, CreateFromArray) {
159157
ASSERT_EQ(ext_arr->null_count(), 0);
160158
}
161159

162-
<<<<<<< HEAD
163-
TEST_F(TestExtensionType, MakeArrayCanGetCorrectScalarType) {
160+
TEST_F(TestFixedShapeTensorType, MakeArrayCanGetCorrectScalarType) {
164161
ASSERT_OK_AND_ASSIGN(auto tensor,
165162
Tensor::Make(value_type_, Buffer::Wrap(values_), shape_));
166163

@@ -182,7 +179,6 @@ TEST_F(TestExtensionType, MakeArrayCanGetCorrectScalarType) {
182179
ASSERT_TRUE(tensor->Equals(*tensor_from_array));
183180
}
184181

185-
template <typename T>
186182
void CheckSerializationRoundtrip(const std::shared_ptr<DataType>& ext_type) {
187183
auto type = internal::checked_pointer_cast<ExtensionType>(ext_type);
188184
auto serialized = type->Serialize();

cpp/src/arrow/extension/tensor_internal.cc

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -20,11 +20,10 @@
2020
#include "arrow/tensor.h"
2121
#include "arrow/util/checked_cast.h"
2222
#include "arrow/util/int_util_overflow.h"
23-
#include "arrow/util/sort.h"
23+
#include "arrow/util/sort_internal.h"
2424

2525
#include "arrow/status.h"
26-
#include "arrow/util/logging.h"
27-
#include "arrow/util/print.h"
26+
#include "arrow/util/print_internal.h"
2827

2928
namespace arrow::internal {
3029

@@ -84,4 +83,4 @@ Status ComputeStrides(const std::shared_ptr<DataType>& value_type,
8483
return Status::OK();
8584
}
8685

87-
} // namespace arrow::internal
86+
} // namespace arrow::internal

cpp/src/arrow/extension/tensor_internal.h

Lines changed: 4 additions & 60 deletions
Original file line numberDiff line numberDiff line change
@@ -16,77 +16,21 @@
1616
// under the License.
1717

1818
#pragma once
19-
#include "arrow/extension/tensor_internal.h"
2019

2120
#include <cstdint>
2221
#include <vector>
2322

2423
#include "arrow/array/array_nested.h"
25-
#include "arrow/tensor.h"
26-
#include "arrow/status.h"
27-
#include "arrow/util/checked_cast.h"
28-
#include "arrow/util/int_util_overflow.h"
29-
#include "arrow/util/sort_internal.h"
30-
#include "arrow/util/print_internal.h"
3124

3225
namespace arrow::internal {
3326

3427
ARROW_EXPORT
35-
inline Status IsPermutationValid(const std::vector<int64_t>& permutation) {
36-
const auto size = static_cast<int64_t>(permutation.size());
37-
std::vector<uint8_t> dim_seen(size, 0);
38-
39-
for (const auto p : permutation) {
40-
if (p < 0 || p >= size || dim_seen[p] != 0) {
41-
return Status::Invalid(
42-
"Permutation indices for ", size,
43-
" dimensional tensors must be unique and within [0, ", size - 1,
44-
"] range. Got: ", ::arrow::internal::PrintVector{permutation, ","});
45-
}
46-
dim_seen[p] = 1;
47-
}
48-
return Status::OK();
49-
}
28+
Status IsPermutationValid(const std::vector<int64_t>& permutation);
5029

5130
ARROW_EXPORT
52-
inline Status ComputeStrides(const std::shared_ptr<DataType>& value_type,
31+
Status ComputeStrides(const std::shared_ptr<DataType>& value_type,
5332
const std::vector<int64_t>& shape,
5433
const std::vector<int64_t>& permutation,
55-
std::vector<int64_t>* strides) {
56-
auto fixed_width_type = internal::checked_pointer_cast<FixedWidthType>(value_type);
57-
if (permutation.empty()) {
58-
return internal::ComputeRowMajorStrides(*fixed_width_type.get(), shape, strides);
59-
}
60-
const int byte_width = value_type->byte_width();
61-
62-
int64_t remaining = 0;
63-
if (!shape.empty() && shape.front() > 0) {
64-
remaining = byte_width;
65-
for (auto i : permutation) {
66-
if (i > 0) {
67-
if (internal::MultiplyWithOverflow(remaining, shape[i], &remaining)) {
68-
return Status::Invalid(
69-
"Strides computed from shape would not fit in 64-bit integer");
70-
}
71-
}
72-
}
73-
}
74-
75-
if (remaining == 0) {
76-
strides->assign(shape.size(), byte_width);
77-
return Status::OK();
78-
}
79-
80-
strides->push_back(remaining);
81-
for (auto i : permutation) {
82-
if (i > 0) {
83-
remaining /= shape[i];
84-
strides->push_back(remaining);
85-
}
86-
}
87-
Permute(permutation, strides);
88-
89-
return Status::OK();
90-
}
34+
std::vector<int64_t>* strides);
9135

92-
} // namespace arrow::internal
36+
} // namespace arrow::internal

cpp/src/arrow/extension/variable_shape_tensor.cc

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,9 +26,9 @@
2626
#include "arrow/scalar.h"
2727
#include "arrow/tensor.h"
2828
#include "arrow/util/int_util_overflow.h"
29-
#include "arrow/util/logging.h"
30-
#include "arrow/util/print.h"
31-
#include "arrow/util/sort.h"
29+
#include "arrow/util/logging_internal.h"
30+
#include "arrow/util/print_internal.h"
31+
#include "arrow/util/sort_internal.h"
3232
#include "arrow/util/string.h"
3333

3434
#include <rapidjson/document.h>

0 commit comments

Comments
 (0)