Skip to content

Commit 48ee417

Browse files
committed
[C++] Extract the internals of the RunEndEncode kernel out of compute/
1 parent d6b4903 commit 48ee417

File tree

8 files changed

+854
-893
lines changed

8 files changed

+854
-893
lines changed

cpp/src/arrow/CMakeLists.txt

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -770,7 +770,6 @@ if(ARROW_COMPUTE)
770770
compute/kernels/hash_aggregate_numeric.cc
771771
compute/kernels/hash_aggregate_pivot.cc
772772
compute/kernels/pivot_internal.cc
773-
compute/kernels/ree_util_internal.cc
774773
compute/kernels/scalar_arithmetic.cc
775774
compute/kernels/scalar_boolean.cc
776775
compute/kernels/scalar_compare.cc

cpp/src/arrow/c/CMakeLists.txt

Lines changed: 1 addition & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -15,28 +15,7 @@
1515
# specific language governing permissions and limitations
1616
# under the License.
1717

18-
# TODO(GH-37221): Remove compute dependency for REE requirements on bridge_test
19-
set(ARROW_TEST_LINK_LIBS "")
20-
21-
if(ARROW_TEST_LINKAGE STREQUAL "static")
22-
list(APPEND ARROW_TEST_LINK_LIBS ${ARROW_TEST_STATIC_LINK_LIBS})
23-
else()
24-
list(APPEND ARROW_TEST_LINK_LIBS ${ARROW_TEST_SHARED_LINK_LIBS})
25-
endif()
26-
27-
if(ARROW_COMPUTE)
28-
if(ARROW_TEST_LINKAGE STREQUAL "static")
29-
list(APPEND ARROW_TEST_LINK_LIBS arrow_compute_static arrow_compute_testing)
30-
else()
31-
list(APPEND ARROW_TEST_LINK_LIBS arrow_compute_shared arrow_compute_testing)
32-
endif()
33-
endif()
34-
35-
add_arrow_test(bridge_test
36-
PREFIX
37-
"arrow-c"
38-
STATIC_LINK_LIBS
39-
${ARROW_TEST_LINK_LIBS})
18+
add_arrow_test(bridge_test PREFIX "arrow-c")
4019
add_arrow_test(dlpack_test)
4120

4221
add_arrow_benchmark(bridge_benchmark)

cpp/src/arrow/c/bridge_test.cc

Lines changed: 6 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -45,13 +45,9 @@
4545
#include "arrow/util/logging_internal.h"
4646
#include "arrow/util/macros.h"
4747
#include "arrow/util/range.h"
48+
#include "arrow/util/ree_util.h"
4849
#include "arrow/util/thread_pool.h"
4950

50-
// TODO(GH-37221): Remove these ifdef checks when compute dependency is removed
51-
#ifdef ARROW_COMPUTE
52-
# include "arrow/compute/api_vector.h"
53-
#endif
54-
5551
namespace arrow {
5652

5753
using internal::ArrayDeviceExportTraits;
@@ -472,7 +468,6 @@ TEST_F(TestSchemaExport, Union) {
472468
{ARROW_FLAG_NULLABLE});
473469
}
474470

475-
#ifdef ARROW_COMPUTE
476471
TEST_F(TestSchemaExport, RunEndEncoded) {
477472
TestNested(run_end_encoded(int16(), uint8()), {"+r", "s", "C"},
478473
{"", "run_ends", "values"}, {ARROW_FLAG_NULLABLE, 0, ARROW_FLAG_NULLABLE});
@@ -484,7 +479,6 @@ TEST_F(TestSchemaExport, RunEndEncoded) {
484479
{"", "run_ends", "values", "item"},
485480
{ARROW_FLAG_NULLABLE, 0, ARROW_FLAG_NULLABLE, ARROW_FLAG_NULLABLE});
486481
}
487-
#endif
488482

489483
std::string GetIndexFormat(Type::type type_id) {
490484
switch (type_id) {
@@ -1080,15 +1074,15 @@ TEST_F(TestArrayExport, Union) {
10801074
TestNested(type, data);
10811075
}
10821076

1083-
#ifdef ARROW_COMPUTE
1077+
// Helper to create a RunEndEncoded array from JSON for testing
10841078
Result<std::shared_ptr<Array>> REEFromJSON(const std::shared_ptr<DataType>& ree_type,
10851079
const std::string& json) {
10861080
auto ree_type_ptr = checked_cast<const RunEndEncodedType*>(ree_type.get());
10871081
auto array = ArrayFromJSON(ree_type_ptr->value_type(), json);
1088-
ARROW_ASSIGN_OR_RAISE(
1089-
auto datum,
1090-
RunEndEncode(array, compute::RunEndEncodeOptions{ree_type_ptr->run_end_type()}));
1091-
return datum.make_array();
1082+
ARROW_ASSIGN_OR_RAISE(auto array_data, ree_util::RunEndEncodeArray(
1083+
array->data(), ree_type_ptr->run_end_type(),
1084+
default_memory_pool()));
1085+
return MakeArray(array_data);
10921086
}
10931087

10941088
TEST_F(TestArrayExport, RunEndEncoded) {
@@ -1108,7 +1102,6 @@ TEST_F(TestArrayExport, RunEndEncodedSliced) {
11081102
};
11091103
TestNested(factory);
11101104
}
1111-
#endif
11121105

11131106
TEST_F(TestArrayExport, Dictionary) {
11141107
{
@@ -1432,7 +1425,6 @@ class TestDeviceArrayExport : public ::testing::Test {
14321425
return [=]() { return ToDevice(mm, *ArrayFromJSON(type, json)->data()); };
14331426
}
14341427

1435-
#ifdef ARROW_COMPUTE
14361428
static std::function<Result<std::shared_ptr<Array>>()> JSONREEArrayFactory(
14371429
const std::shared_ptr<MemoryManager>& mm, std::shared_ptr<DataType> type,
14381430
const char* json) {
@@ -1441,7 +1433,6 @@ class TestDeviceArrayExport : public ::testing::Test {
14411433
return ToDevice(mm, *result->data());
14421434
};
14431435
}
1444-
#endif
14451436

14461437
template <typename ArrayFactory, typename ExportCheckFunc>
14471438
void TestWithArrayFactory(ArrayFactory&& factory, ExportCheckFunc&& check_func) {
@@ -1680,7 +1671,6 @@ TEST_F(TestDeviceArrayExport, Union) {
16801671
TestNested(mm, type, data);
16811672
}
16821673

1683-
#ifdef ARROW_COMPUTE
16841674
TEST_F(TestDeviceArrayExport, RunEndEncoded) {
16851675
std::shared_ptr<Device> device = std::make_shared<MyDevice>(1);
16861676
auto mm = device->default_memory_manager();
@@ -1689,7 +1679,6 @@ TEST_F(TestDeviceArrayExport, RunEndEncoded) {
16891679
const char* data = "[1, null, 2, 2, 4, 5]";
16901680
TestNested(JSONREEArrayFactory(mm, type, data));
16911681
}
1692-
#endif
16931682

16941683
TEST_F(TestDeviceArrayExport, Extension) {
16951684
std::shared_ptr<Device> device = std::make_shared<MyDevice>(1);
@@ -2186,14 +2175,12 @@ TEST_F(TestSchemaImport, Map) {
21862175
CheckImport(expected);
21872176
}
21882177

2189-
#ifdef ARROW_COMPUTE
21902178
TEST_F(TestSchemaImport, RunEndEncoded) {
21912179
FillPrimitive(AddChild(), "s", "run_ends");
21922180
FillPrimitive(AddChild(), "I", "values");
21932181
FillRunEndEncoded("+r");
21942182
CheckImport(run_end_encoded(int16(), uint32()));
21952183
}
2196-
#endif
21972184

21982185
TEST_F(TestSchemaImport, Dictionary) {
21992186
FillPrimitive(AddChild(), "u");
@@ -3175,7 +3162,6 @@ TEST_F(TestArrayImport, Struct) {
31753162
CheckImport(expected);
31763163
}
31773164

3178-
#ifdef ARROW_COMPUTE
31793165
TEST_F(TestArrayImport, RunEndEncoded) {
31803166
FillPrimitive(AddChild(), 5, 0, 0, run_ends_buffers5);
31813167
FillPrimitive(AddChild(), 5, 0, 0, primitive_buffers_no_nulls5);
@@ -3218,7 +3204,6 @@ TEST_F(TestArrayImport, RunEndEncodedWithOffset) {
32183204
ASSERT_OK_AND_ASSIGN(expected, REEFromJSON(ree_type, "[-2.0, -2.0, 3.0, 3.0]"));
32193205
CheckImport(expected);
32203206
}
3221-
#endif
32223207

32233208
TEST_F(TestArrayImport, SparseUnion) {
32243209
auto type = sparse_union({field("strs", utf8()), field("ints", int8())}, {43, 42});
@@ -3749,12 +3734,10 @@ TEST_F(TestSchemaRoundtrip, Union) {
37493734
TestWithTypeFactory([&]() { return dense_union({f1, f2}, type_codes); });
37503735
}
37513736

3752-
#ifdef ARROW_COMPUTE
37533737
TEST_F(TestSchemaRoundtrip, RunEndEncoded) {
37543738
TestWithTypeFactory([]() { return run_end_encoded(int16(), float32()); });
37553739
TestWithTypeFactory([]() { return run_end_encoded(int32(), list(float32())); });
37563740
}
3757-
#endif
37583741

37593742
TEST_F(TestSchemaRoundtrip, Dictionary) {
37603743
for (auto index_ty : all_dictionary_index_types()) {
@@ -4104,7 +4087,6 @@ TEST_F(TestArrayRoundtrip, Union) {
41044087
}
41054088
}
41064089

4107-
#ifdef ARROW_COMPUTE
41084090
TEST_F(TestArrayRoundtrip, RunEndEncoded) {
41094091
{
41104092
auto factory = []() -> Result<std::shared_ptr<Array>> {
@@ -4130,7 +4112,6 @@ TEST_F(TestArrayRoundtrip, RunEndEncoded) {
41304112
TestWithArrayFactory(factory);
41314113
}
41324114
}
4133-
#endif
41344115

41354116
TEST_F(TestArrayRoundtrip, Dictionary) {
41364117
{

cpp/src/arrow/compute/kernels/ree_util_internal.cc

Lines changed: 0 additions & 142 deletions
This file was deleted.

0 commit comments

Comments
 (0)