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

Function MakeCompareFunction

cpp/src/arrow/compute/kernels/scalar_compare.cc:391–457  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

389
390template <typename Op>
391std::shared_ptr<ScalarFunction> MakeCompareFunction(std::string name, FunctionDoc doc) {
392 auto func = std::make_shared<CompareFunction>(name, Arity::Binary(), std::move(doc));
393
394 DCHECK_OK(func->AddKernel(
395 {boolean(), boolean()}, boolean(),
396 applicator::ScalarBinary<BooleanType, BooleanType, BooleanType, Op>::Exec));
397
398 for (const std::shared_ptr<DataType>& ty : NumericTypes()) {
399 AddPrimitiveCompare<Op>(ty, func.get());
400 }
401 AddPrimitiveCompare<Op>(date32(), func.get());
402 AddPrimitiveCompare<Op>(date64(), func.get());
403
404 // Add timestamp kernels
405 for (auto unit : TimeUnit::values()) {
406 InputType in_type(match::TimestampTypeUnit(unit));
407 ScalarKernel kernel =
408 GetCompareKernel<Op>(in_type, Type::INT64, CompareTimestamps<Op>::Exec);
409 DCHECK_OK(func->AddKernel(kernel));
410 }
411
412 // Duration
413 for (auto unit : TimeUnit::values()) {
414 InputType in_type(match::DurationTypeUnit(unit));
415 ArrayKernelExec exec = GeneratePhysicalNumeric<CompareKernel>(int64());
416 DCHECK_OK(func->AddKernel(GetCompareKernel<Op>(in_type, Type::INT64, exec)));
417 }
418
419 // Time32 and Time64
420 for (auto unit : {TimeUnit::SECOND, TimeUnit::MILLI}) {
421 InputType in_type(match::Time32TypeUnit(unit));
422 ArrayKernelExec exec = GeneratePhysicalNumeric<CompareKernel>(int32());
423 DCHECK_OK(func->AddKernel(GetCompareKernel<Op>(in_type, Type::INT32, exec)));
424 }
425 for (auto unit : {TimeUnit::MICRO, TimeUnit::NANO}) {
426 InputType in_type(match::Time64TypeUnit(unit));
427 ArrayKernelExec exec = GeneratePhysicalNumeric<CompareKernel>(int64());
428 DCHECK_OK(func->AddKernel(GetCompareKernel<Op>(in_type, Type::INT64, exec)));
429 }
430
431 for (const std::shared_ptr<DataType>& ty : BaseBinaryTypes()) {
432 auto exec =
433 GenerateVarBinaryBase<applicator::ScalarBinaryEqualTypes, BooleanType, Op>(*ty);
434 DCHECK_OK(func->AddKernel({ty, ty}, boolean(), std::move(exec)));
435 }
436 for (const auto& ty : BinaryViewTypes()) {
437 auto exec =
438 GenerateVarBinaryViewBase<applicator::ScalarBinaryEqualTypes, BooleanType, Op>(
439 *ty);
440 DCHECK_OK(func->AddKernel({ty, ty}, boolean(), std::move(exec)));
441 }
442
443 for (const auto id : {Type::DECIMAL128, Type::DECIMAL256}) {
444 auto exec = GenerateDecimal<applicator::ScalarBinaryEqualTypes, BooleanType, Op>(id);
445 DCHECK_OK(func->AddKernel({InputType(id), InputType(id)}, boolean(), std::move(exec),
446 /*init=*/nullptr, DecimalsHaveSameScale()));
447 }
448

Callers

nothing calls this directly

Calls 10

TimestampTypeUnitFunction · 0.85
DurationTypeUnitFunction · 0.85
Time32TypeUnitFunction · 0.85
Time64TypeUnitFunction · 0.85
InputTypeFunction · 0.85
DecimalsHaveSameScaleFunction · 0.85
BinaryFunction · 0.50
valuesFunction · 0.50
AddKernelMethod · 0.45
getMethod · 0.45

Tested by

no test coverage detected