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
Original file line number Diff line number Diff line change
Expand Up @@ -581,6 +581,11 @@ class TakeMetaFunction : public MetaFunction {
const std::shared_ptr<ChunkedArray>& values,
const std::shared_ptr<ChunkedArray>& indices, const TakeOptions& options,
ExecContext* ctx) {
const auto num_chunks = indices->num_chunks();
if (num_chunks == 0) {
return std::make_shared<ChunkedArray>(ArrayVector{}, values->type());
}

// XXX: for every chunk in indices, values are gathered from all chunks in values to
// form a new chunk in the result. Performing this concatenation is not ideal, but
// greatly simplifies the implementation before something more efficient is
Expand All @@ -589,8 +594,8 @@ class TakeMetaFunction : public MetaFunction {
ChunkedArrayAsArray(values, ctx->memory_pool()));
std::vector<Datum> args = {std::move(values_array), {}};
std::vector<std::shared_ptr<Array>> new_chunks;
new_chunks.resize(indices->num_chunks());
for (int i = 0; i < indices->num_chunks(); i++) {
new_chunks.resize(num_chunks);
for (int i = 0; i < num_chunks; i++) {
args[1] = indices->chunk(i);
// XXX: this loop can use TakeCAA once it can handle ChunkedArray
// without concatenating first
Expand Down
2 changes: 2 additions & 0 deletions cpp/src/arrow/compute/kernels/vector_selection_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -2213,6 +2213,8 @@ TEST(TestTakeKernelWithChunkedIndices, TakeChunkedArray) {
ASSERT_RAISES(IndexError, TakeCCC(int_ty, {}, {"[0]"}).Value(&chunked_arr));
ASSERT_RAISES(IndexError, TakeCCC(int_ty, {"[]"}, {"[0]"}).Value(&chunked_arr));
}

AssertTakeCCC(int64(), {"[1, 2]", "[3, 4]"}, {}, {});
}

TEST(TestTakeKernelWithTable, TakeTable) {
Expand Down
Loading