diff --git a/cpp/src/arrow/compute/kernels/vector_selection.cc b/cpp/src/arrow/compute/kernels/vector_selection.cc index 71ad39d15ab..8d57ad880f7 100644 --- a/cpp/src/arrow/compute/kernels/vector_selection.cc +++ b/cpp/src/arrow/compute/kernels/vector_selection.cc @@ -233,19 +233,18 @@ using FilterState = OptionsWrapper; using TakeState = OptionsWrapper; Status PreallocateData(KernelContext* ctx, int64_t length, int bit_width, - bool allocate_validity, Datum* out) { + bool allocate_validity, ArrayData* out) { // Preallocate memory - ArrayData* out_arr = out->mutable_array(); - out_arr->length = length; - out_arr->buffers.resize(2); + out->length = length; + out->buffers.resize(2); if (allocate_validity) { - ARROW_ASSIGN_OR_RAISE(out_arr->buffers[0], ctx->AllocateBitmap(length)); + ARROW_ASSIGN_OR_RAISE(out->buffers[0], ctx->AllocateBitmap(length)); } if (bit_width == 1) { - ARROW_ASSIGN_OR_RAISE(out_arr->buffers[1], ctx->AllocateBitmap(length)); + ARROW_ASSIGN_OR_RAISE(out->buffers[1], ctx->AllocateBitmap(length)); } else { - ARROW_ASSIGN_OR_RAISE(out_arr->buffers[1], ctx->Allocate(length * bit_width / 8)); + ARROW_ASSIGN_OR_RAISE(out->buffers[1], ctx->Allocate(length * bit_width / 8)); } return Status::OK(); } @@ -265,7 +264,7 @@ Status PreallocateData(KernelContext* ctx, int64_t length, int bit_width, template struct PrimitiveTakeImpl { static void Exec(const PrimitiveArg& values, const PrimitiveArg& indices, - Datum* out_datum) { + ArrayData* out_arr) { auto values_data = reinterpret_cast(values.data); auto values_is_valid = values.is_valid; auto values_offset = values.offset; @@ -274,7 +273,6 @@ struct PrimitiveTakeImpl { auto indices_is_valid = indices.is_valid; auto indices_offset = indices.offset; - ArrayData* out_arr = out_datum->mutable_array(); auto out = out_arr->GetMutableValues(1); auto out_is_valid = out_arr->buffers[0]->mutable_data(); auto out_offset = out_arr->offset; @@ -364,7 +362,7 @@ struct PrimitiveTakeImpl { template struct BooleanTakeImpl { static void Exec(const PrimitiveArg& values, const PrimitiveArg& indices, - Datum* out_datum) { + ArrayData* out_arr) { const uint8_t* values_data = values.data; auto values_is_valid = values.is_valid; auto values_offset = values.offset; @@ -373,7 +371,6 @@ struct BooleanTakeImpl { auto indices_is_valid = indices.is_valid; auto indices_offset = indices.offset; - ArrayData* out_arr = out_datum->mutable_array(); auto out = out_arr->buffers[1]->mutable_data(); auto out_is_valid = out_arr->buffers[0]->mutable_data(); auto out_offset = out_arr->offset; @@ -463,7 +460,7 @@ struct BooleanTakeImpl { template