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