MCPcopy Create free account
hub / github.com/apache/arrow / MakeFirstOrLastKernel

Function MakeFirstOrLastKernel

cpp/src/arrow/compute/kernels/hash_aggregate.cc:1146–1170  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1144
1145template <FirstOrLast first_or_last>
1146HashAggregateKernel MakeFirstOrLastKernel(HashAggregateFunction* first_last_func) {
1147 HashAggregateKernel kernel;
1148 kernel.init = [first_last_func](
1149 KernelContext* ctx,
1150 const KernelInitArgs& args) -> Result<std::unique_ptr<KernelState>> {
1151 std::vector<TypeHolder> inputs = args.inputs;
1152 ARROW_ASSIGN_OR_RAISE(auto kernel, first_last_func->DispatchExact(args.inputs));
1153 KernelInitArgs new_args{kernel, inputs, args.options};
1154 return kernel->init(ctx, new_args);
1155 };
1156
1157 kernel.signature =
1158 KernelSignature::Make({InputType::Any(), Type::UINT32}, OutputType(FirstType));
1159 kernel.resize = HashAggregateResize;
1160 kernel.consume = HashAggregateConsume;
1161 kernel.merge = HashAggregateMerge;
1162 kernel.finalize = [](KernelContext* ctx, Datum* out) {
1163 ARROW_ASSIGN_OR_RAISE(Datum temp,
1164 checked_cast<GroupedAggregator*>(ctx->state())->Finalize());
1165 *out = temp.array_as<StructArray>()->field(static_cast<uint8_t>(first_or_last));
1166 return Status::OK();
1167 };
1168 kernel.ordered = true;
1169 return kernel;
1170}
1171
1172struct GroupedFirstLastFactory {
1173 template <typename T>

Callers

nothing calls this directly

Calls 6

OutputTypeFunction · 0.85
MakeFunction · 0.50
AnyFunction · 0.50
OKFunction · 0.50
initMethod · 0.45
fieldMethod · 0.45

Tested by

no test coverage detected