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