| 780 | } // namespace |
| 781 | |
| 782 | void RegisterVectorHash(FunctionRegistry* registry) { |
| 783 | VectorKernel base; |
| 784 | base.exec = HashExec; |
| 785 | |
| 786 | // ---------------------------------------------------------------------- |
| 787 | // unique |
| 788 | |
| 789 | base.finalize = UniqueFinalize; |
| 790 | base.output_chunked = false; |
| 791 | auto unique = std::make_shared<VectorFunction>("unique", Arity::Unary(), unique_doc); |
| 792 | AddHashKernels<UniqueAction>(unique.get(), base, FirstType); |
| 793 | |
| 794 | // Dictionary unique |
| 795 | base.init = DictionaryHashInit<UniqueAction>; |
| 796 | base.finalize = UniqueFinalizeDictionary; |
| 797 | base.signature = KernelSignature::Make({Type::DICTIONARY}, FirstType); |
| 798 | DCHECK_OK(unique->AddKernel(base)); |
| 799 | |
| 800 | DCHECK_OK(registry->AddFunction(std::move(unique))); |
| 801 | |
| 802 | // ---------------------------------------------------------------------- |
| 803 | // value_counts |
| 804 | |
| 805 | base.finalize = ValueCountsFinalize; |
| 806 | auto value_counts = |
| 807 | std::make_shared<VectorFunction>("value_counts", Arity::Unary(), value_counts_doc); |
| 808 | AddHashKernels<ValueCountsAction>(value_counts.get(), base, ValueCountsOutput); |
| 809 | |
| 810 | // Dictionary value counts |
| 811 | base.init = DictionaryHashInit<ValueCountsAction>; |
| 812 | base.finalize = ValueCountsFinalizeDictionary; |
| 813 | base.signature = KernelSignature::Make({Type::DICTIONARY}, ValueCountsOutput); |
| 814 | DCHECK_OK(value_counts->AddKernel(base)); |
| 815 | |
| 816 | DCHECK_OK(registry->AddFunction(std::move(value_counts))); |
| 817 | |
| 818 | // ---------------------------------------------------------------------- |
| 819 | // dictionary_encode |
| 820 | |
| 821 | base.finalize = DictEncodeFinalize; |
| 822 | // Unique and ValueCounts output unchunked arrays |
| 823 | base.output_chunked = true; |
| 824 | |
| 825 | auto dict_encode = std::make_shared<VectorFunction>( |
| 826 | "dictionary_encode", Arity::Unary(), dictionary_encode_doc, |
| 827 | GetDefaultDictionaryEncodeOptions()); |
| 828 | AddHashKernels<DictEncodeAction>(dict_encode.get(), base, DictEncodeOutput); |
| 829 | |
| 830 | auto no_op = [](KernelContext*, const ExecSpan& span, ExecResult* out) { |
| 831 | out->value = span[0].array.ToArrayData(); |
| 832 | return Status::OK(); |
| 833 | }; |
| 834 | DCHECK_OK(dict_encode->AddKernel({Type::DICTIONARY}, OutputType(FirstType), no_op)); |
| 835 | |
| 836 | DCHECK_OK(registry->AddFunction(std::move(dict_encode))); |
| 837 | } |
| 838 | |
| 839 | void RegisterDictionaryDecode(FunctionRegistry* registry) { |
no test coverage detected