forked from apache/arrow
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
96d61c7
commit 1e141d7
Showing
3 changed files
with
89 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
// #include "arrow/compute/kernels/vector_gather_internal.h" | ||
#include "arrow/compute/function.h" | ||
#include "arrow/compute/kernels/codegen_internal.h" | ||
#include "arrow/compute/registry.h" | ||
#include "arrow/util/logging.h" | ||
|
||
namespace arrow::compute::internal { | ||
|
||
namespace { | ||
|
||
struct GatherKernelSignature { | ||
InputType indices_type; | ||
InputType value_type; | ||
ArrayKernelExec exec; | ||
}; | ||
|
||
std::unique_ptr<Function> MakeGatherFunction( | ||
std::string name, int min_args, std::vector<GatherKernelSignature>&& signatures, | ||
FunctionDoc doc) { | ||
auto func = std::make_unique<VectorFunction>(std::move(name), Arity::VarArgs(min_args), | ||
std::move(doc)); | ||
for (auto& signature : signatures) { | ||
auto kernel = VectorKernel{}; | ||
kernel.signature = KernelSignature::Make( | ||
{std::move(signature.indices_type), std::move(signature.value_type)}, | ||
OutputType(LastType), /*is_varargs=*/true); | ||
kernel.exec = signature.exec; | ||
kernel.can_execute_chunkwise = false; | ||
DCHECK_OK(func->AddKernel(std::move(kernel))); | ||
} | ||
return func; | ||
} | ||
|
||
const FunctionDoc gather_doc( | ||
"Gather values from a list of inputs with an indices vector", | ||
"The output is populated with values selected from the inputs, where each value is " | ||
"chosen based on the corresponding index from the indices that specifies which input " | ||
"in the list to use", | ||
{"indices", "*inputs"}); | ||
|
||
} // namespace | ||
|
||
void RegisterVectorGather(FunctionRegistry* registry) { | ||
std::vector<GatherKernelSignature> signatures = {}; | ||
DCHECK_OK(registry->AddFunction( | ||
MakeGatherFunction("gather", /*min_args=*/2, std::move(signatures), gather_doc))); | ||
} | ||
|
||
} // namespace arrow::compute::internal |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
#pragma once | ||
|
||
#include "arrow/compute/function.h" | ||
|
||
namespace arrow::compute::internal { | ||
|
||
// class GatherMetaFunction : public MetaFunction { | ||
// public: | ||
// GatherMetaFunction() : MetaFunction("gather", Arity::VarArgs(3), gather_doc) {} | ||
|
||
// Result<Datum> ExecuteImpl(const std::vector<Datum>& args, | ||
// const FunctionOptions* options, | ||
// ExecContext* ctx) const override { | ||
// for (const auto& arg : args) { | ||
// if (arg.kind() != Datum::ARRAY && arg.kind() != Datum::CHUNKED_ARRAY) { | ||
// return Status::TypeError("Gather arguments should be array-like"); | ||
// } | ||
// } | ||
|
||
// if (!is_integer(*args[0].type())) { | ||
// return Status::NotImplemented("Indices to gather must be integer type"); | ||
// } | ||
|
||
// if (args[0].kind() == Datum::RECORD_BATCH) { | ||
// ARROW_ASSIGN_OR_RAISE( | ||
// std::shared_ptr<RecordBatch> out_batch, | ||
// FilterRecordBatch(*args[0].record_batch(), args[1], options, ctx)); | ||
// return Datum(out_batch); | ||
// } else if (args[0].kind() == Datum::TABLE) { | ||
// ARROW_ASSIGN_OR_RAISE(std::shared_ptr<Table> out_table, | ||
// FilterTable(*args[0].table(), args[1], options, ctx)); | ||
// return Datum(out_table); | ||
// } else { | ||
// return CallFunction("array_filter", args, options, ctx); | ||
// } | ||
// } | ||
// }; | ||
|
||
} // namespace arrow::compute::internal |