Uh oh!
There was an error while loading. Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork 4.3k
ARROW-1572: [C++] Implement "value counts" kernels for tabulating value frequencies#1970
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Uh oh!
There was an error while loading. Please reload this page.
Changes from all commits
3e87f77bcbcf025f10067cdc347c27f7eba81bfb38d52f2ffc2865d02f016583e3f7c2cca4a74e2dd864c0b0e332fd8f0a27d8339655eb745521bcf564fefe8c493cde50a8ece0328b0c017a63a5c5ad2887e893482fc581a92846d3fabe0524b5220a672bc1d9b834671b53c3d5880a5321582af2047e8b3bbaeb2eb6acbfac60d99899d629495cef403804599409434c33f18b1c8116e699d703db8a39ceda35b89c12449f1d0055bdae5c6359cb45f5da201a099c06e9fb457e4dd851e117dcde18a6a58bd725f8a79360c80819effbedfb2316cc372dfb5e945a3f3f91b034b18f704f4e6bf56fdc940a000823d08b77354a1981674723511c65c7c2393fc9f89ad0284cb412bb91907a27d2f718d7d64a231dc45a1ac7b3c058f2ff303917e8558fa873317b5436fc9922171340f0b28dc57c7b09f33d1091a430758385656ce25e3ef98012cbb185951630ce5e019a56060749b220ea781e29df7d79e19c382c8b6f95ba6ef7be8d37c695a5dbb17a0da50ef9f60848c0607c7fa948cb4af45abf007beb5147fcef3d623567eecb1bcf50d85829268ec0c8d164e6d8eeda0ca9b4777f9867b2c797af6e3ec29f744f9c7e06b6156b1d27f5a42f9f83203d4b6c1f29e5a1866e9b897f5ec0ba0cea33f72d143975de500b334fbe049fad2d4cc77e27cf58fdad1811b15a5fff992ab6e8b4bfce183c4c68eca65d255865493a69fc4d89b0f376a82d4555933b32b806979b7081752cf3968626bc4ab640fc8376edf43486d59202b0c72045470c9515fe929c376d83bfb39946517de3f7edcf9c070187284a5f88949b408aa5ab4dafa555c1075b09599457db8b57376aabca3dbbbabf4ed25030e23ad39d1f1bb7fbaf56d76527417b2e941af833d92a0ca277aec5574f46633cc991ec792265142b42e195b1ee7d11ed7db7c4009b626e8ecb5db036639ad8602f177404685147c0f87c12c96747b7de126498d250eb2167e43eee3e42d0fbf172c7f5d66d0ad12876a3ff1ef708d7d319672df18c4c31b3725eff99d58057bc2e0d4218999bb12999317eeca3a09be7b446fe09ac19b1f0249e0394c71f30c9ad33e54df19d2452a463b69c5a1ba7d515381295138717aa6c9d30a5ae13403251e977a5c597545e3eb65205e2abc889a6093092d278ab3d7a5a65f9cf9cc8a3ed8c574006c8f17dd16820a23f5819ae8d45ebe3fafaef93a6352d99fc695da385File filter
Filter by extension
Conversations
Uh oh!
There was an error while loading. Please reload this page.
Jump to
Uh oh!
There was an error while loading. Please reload this page.
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -51,6 +51,10 @@ Status GetDictionaryEncodeKernel(FunctionContext* ctx, | ||
| const std::shared_ptr<DataType>& type, | ||
| std::unique_ptr<HashKernel>* kernel); | ||
| ARROW_EXPORT | ||
| Status GetCountValuesKernel(FunctionContext* ctx, const std::shared_ptr<DataType>& type, | ||
| std::unique_ptr<HashKernel>* kernel); | ||
| /// \brief Compute unique elements from an array-like object | ||
| /// \param[in] context the FunctionContext | ||
| /// \param[in] datum array-like input | ||
| @@ -71,6 +75,19 @@ Status Unique(FunctionContext* context, const Datum& datum, std::shared_ptr<Arra | ||
| ARROW_EXPORT | ||
| Status DictionaryEncode(FunctionContext* context, const Datum& data, Datum* out); | ||
| /// \brief Return counts of unique elements from an array-like object | ||
| /// \param[in] context the FunctionContext | ||
| /// \param[in] value array-like input | ||
| /// \param[out] out_uniques unique elements as Array | ||
| /// \param[out] out_counts counts per element as Array, same shape as out_uniques | ||
| /// | ||
| /// \since 0.10.0 | ||
| /// \note API not yet finalized | ||
| ARROW_EXPORT | ||
| Status CountValues(FunctionContext* context, const Datum& value, | ||
| std::shared_ptr<Array>* out_uniques, | ||
Contributor There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. it seems more natural to me to have the output type be a struct (but maybe there was discussion on this previously, I guess the existing API had this)? | ||
| std::shared_ptr<Array>* out_counts); | ||
| // TODO(wesm): Define API for incremental dictionary encoding | ||
| // TODO(wesm): Define API for regularizing DictionaryArray objects with | ||
| @@ -95,11 +112,6 @@ Status DictionaryEncode(FunctionContext* context, const Datum& data, Datum* out) | ||
| // Status IsIn(FunctionContext* context, const Datum& values, const Datum& member_set, | ||
| // Datum* out); | ||
| // ARROW_EXPORT | ||
| // Status CountValues(FunctionContext* context, const Datum& values, | ||
| // std::shared_ptr<Array>* out_uniques, | ||
| // std::shared_ptr<Array>* out_counts); | ||
| } // namespace compute | ||
| } // namespace arrow | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is there a way to promote some code reuse with the other unary (single-argument) hash kernels?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think so, although I am not sure how to do it. Maybe moving everything to a macro? I am willing to try if somebody could give me some pointers on what's the best way to do it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The pattern described here might be useful: https://mortoray.com/2014/09/10/using-macros-to-simplify-type-visitors-and-enums/