You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@pinot.apache.org by GitBox <gi...@apache.org> on 2021/08/18 11:39:48 UTC
[GitHub] [pinot] mr-agrwal opened a new pull request #7318: add mode aggregation function
mr-agrwal opened a new pull request #7318:
URL: https://github.com/apache/pinot/pull/7318
## Description
Add support for [Mode](https://en.wikipedia.org/wiki/Mode_(statistics)) Function. #6439
`Mode` accepts an additional paramenter to reduce multiple modes to a single value.
1. MIN
2. MAX
3. AVG
## Upgrade Notes
Does this PR prevent a zero down-time upgrade? (Assume upgrade order: Controller, Broker, Server, Minion)
* [ ] Yes (Please label as **<code>backward-incompat</code>**, and complete the section below on Release Notes)
Does this PR fix a zero-downtime upgrade introduced earlier?
* [ ] Yes (Please label this as **<code>backward-incompat</code>**, and complete the section below on Release Notes)
Does this PR otherwise need attention when creating release notes? Things to consider:
- New configuration options
- Deprecation of configurations
- Signature changes to public methods/interfaces
- New plugins added or old plugins removed
* [ ] Yes (Please label this PR as **<code>release-notes</code>** and complete the section on Release Notes)
## Release Notes
Add support for Mode Aggregation Function
## Documentation
TODO
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@pinot.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@pinot.apache.org
For additional commands, e-mail: commits-help@pinot.apache.org
[GitHub] [pinot] codecov-commenter edited a comment on pull request #7318: add mode aggregation function
Posted by GitBox <gi...@apache.org>.
codecov-commenter edited a comment on pull request #7318:
URL: https://github.com/apache/pinot/pull/7318#issuecomment-901092615
# [Codecov](https://codecov.io/gh/apache/pinot/pull/7318?src=pr&el=h1&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation) Report
> Merging [#7318](https://codecov.io/gh/apache/pinot/pull/7318?src=pr&el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation) (a7def22) into [master](https://codecov.io/gh/apache/pinot/commit/a539958eef8480cf95e39ed4788543e3d094c7bf?el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation) (a539958) will **decrease** coverage by `1.24%`.
> The diff coverage is `79.95%`.
[](https://codecov.io/gh/apache/pinot/pull/7318?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation)
```diff
@@ Coverage Diff @@
## master #7318 +/- ##
============================================
- Coverage 71.47% 70.23% -1.25%
+ Complexity 3283 3280 -3
============================================
Files 1504 1504
Lines 73975 74310 +335
Branches 10704 10797 +93
============================================
- Hits 52876 52191 -685
- Misses 17505 18492 +987
- Partials 3594 3627 +33
```
| Flag | Coverage Δ | |
|---|---|---|
| integration1 | `?` | |
| integration2 | `29.08% <2.00%> (-0.23%)` | :arrow_down: |
| unittests1 | `69.18% <79.95%> (+0.10%)` | :arrow_up: |
| unittests2 | `14.51% <0.00%> (-0.14%)` | :arrow_down: |
Flags with carried forward coverage won't be shown. [Click here](https://docs.codecov.io/docs/carryforward-flags?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#carryforward-flags-in-the-pull-request-comment) to find out more.
| [Impacted Files](https://codecov.io/gh/apache/pinot/pull/7318?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation) | Coverage Δ | |
|---|---|---|
| [.../aggregation/function/ModeAggregationFunction.java](https://codecov.io/gh/apache/pinot/pull/7318/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-cGlub3QtY29yZS9zcmMvbWFpbi9qYXZhL29yZy9hcGFjaGUvcGlub3QvY29yZS9xdWVyeS9hZ2dyZWdhdGlvbi9mdW5jdGlvbi9Nb2RlQWdncmVnYXRpb25GdW5jdGlvbi5qYXZh) | `75.67% <75.67%> (ø)` | |
| [...org/apache/pinot/core/common/ObjectSerDeUtils.java](https://codecov.io/gh/apache/pinot/pull/7318/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-cGlub3QtY29yZS9zcmMvbWFpbi9qYXZhL29yZy9hcGFjaGUvcGlub3QvY29yZS9jb21tb24vT2JqZWN0U2VyRGVVdGlscy5qYXZh) | `89.75% <100.00%> (+2.08%)` | :arrow_up: |
| [...gregation/function/AggregationFunctionFactory.java](https://codecov.io/gh/apache/pinot/pull/7318/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-cGlub3QtY29yZS9zcmMvbWFpbi9qYXZhL29yZy9hcGFjaGUvcGlub3QvY29yZS9xdWVyeS9hZ2dyZWdhdGlvbi9mdW5jdGlvbi9BZ2dyZWdhdGlvbkZ1bmN0aW9uRmFjdG9yeS5qYXZh) | `88.60% <100.00%> (+0.14%)` | :arrow_up: |
| [...che/pinot/segment/spi/AggregationFunctionType.java](https://codecov.io/gh/apache/pinot/pull/7318/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-cGlub3Qtc2VnbWVudC1zcGkvc3JjL21haW4vamF2YS9vcmcvYXBhY2hlL3Bpbm90L3NlZ21lbnQvc3BpL0FnZ3JlZ2F0aW9uRnVuY3Rpb25UeXBlLmphdmE=) | `100.00% <100.00%> (ø)` | |
| [...pinot/minion/exception/TaskCancelledException.java](https://codecov.io/gh/apache/pinot/pull/7318/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-cGlub3QtbWluaW9uL3NyYy9tYWluL2phdmEvb3JnL2FwYWNoZS9waW5vdC9taW5pb24vZXhjZXB0aW9uL1Rhc2tDYW5jZWxsZWRFeGNlcHRpb24uamF2YQ==) | `0.00% <0.00%> (-100.00%)` | :arrow_down: |
| [...ore/startree/executor/StarTreeGroupByExecutor.java](https://codecov.io/gh/apache/pinot/pull/7318/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-cGlub3QtY29yZS9zcmMvbWFpbi9qYXZhL29yZy9hcGFjaGUvcGlub3QvY29yZS9zdGFydHJlZS9leGVjdXRvci9TdGFyVHJlZUdyb3VwQnlFeGVjdXRvci5qYXZh) | `0.00% <0.00%> (-86.67%)` | :arrow_down: |
| [.../transform/function/MapValueTransformFunction.java](https://codecov.io/gh/apache/pinot/pull/7318/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-cGlub3QtY29yZS9zcmMvbWFpbi9qYXZhL29yZy9hcGFjaGUvcGlub3QvY29yZS9vcGVyYXRvci90cmFuc2Zvcm0vZnVuY3Rpb24vTWFwVmFsdWVUcmFuc2Zvcm1GdW5jdGlvbi5qYXZh) | `0.00% <0.00%> (-85.30%)` | :arrow_down: |
| [...plugin/segmentuploader/SegmentUploaderDefault.java](https://codecov.io/gh/apache/pinot/pull/7318/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-cGlub3QtcGx1Z2lucy9waW5vdC1zZWdtZW50LXVwbG9hZGVyL3Bpbm90LXNlZ21lbnQtdXBsb2FkZXItZGVmYXVsdC9zcmMvbWFpbi9qYXZhL29yZy9hcGFjaGUvcGlub3QvcGx1Z2luL3NlZ21lbnR1cGxvYWRlci9TZWdtZW50VXBsb2FkZXJEZWZhdWx0LmphdmE=) | `0.00% <0.00%> (-85.19%)` | :arrow_down: |
| [...ot/common/messages/RoutingTableRebuildMessage.java](https://codecov.io/gh/apache/pinot/pull/7318/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-cGlub3QtY29tbW9uL3NyYy9tYWluL2phdmEvb3JnL2FwYWNoZS9waW5vdC9jb21tb24vbWVzc2FnZXMvUm91dGluZ1RhYmxlUmVidWlsZE1lc3NhZ2UuamF2YQ==) | `0.00% <0.00%> (-81.82%)` | :arrow_down: |
| [...e/pinot/common/minion/MergeRollupTaskMetadata.java](https://codecov.io/gh/apache/pinot/pull/7318/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-cGlub3QtY29tbW9uL3NyYy9tYWluL2phdmEvb3JnL2FwYWNoZS9waW5vdC9jb21tb24vbWluaW9uL01lcmdlUm9sbHVwVGFza01ldGFkYXRhLmphdmE=) | `0.00% <0.00%> (-78.27%)` | :arrow_down: |
| ... and [150 more](https://codecov.io/gh/apache/pinot/pull/7318/diff?src=pr&el=tree-more&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation) | |
------
[Continue to review full report at Codecov](https://codecov.io/gh/apache/pinot/pull/7318?src=pr&el=continue&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation).
> **Legend** - [Click here to learn more](https://docs.codecov.io/docs/codecov-delta?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation)
> `Δ = absolute <relative> (impact)`, `ø = not affected`, `? = missing data`
> Powered by [Codecov](https://codecov.io/gh/apache/pinot/pull/7318?src=pr&el=footer&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation). Last update [a539958...a7def22](https://codecov.io/gh/apache/pinot/pull/7318?src=pr&el=lastupdated&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation). Read the [comment docs](https://docs.codecov.io/docs/pull-request-comments?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation).
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@pinot.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@pinot.apache.org
For additional commands, e-mail: commits-help@pinot.apache.org
[GitHub] [pinot] codecov-commenter edited a comment on pull request #7318: add mode aggregation function
Posted by GitBox <gi...@apache.org>.
codecov-commenter edited a comment on pull request #7318:
URL: https://github.com/apache/pinot/pull/7318#issuecomment-901092615
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@pinot.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@pinot.apache.org
For additional commands, e-mail: commits-help@pinot.apache.org
[GitHub] [pinot] codecov-commenter edited a comment on pull request #7318: add mode aggregation function
Posted by GitBox <gi...@apache.org>.
codecov-commenter edited a comment on pull request #7318:
URL: https://github.com/apache/pinot/pull/7318#issuecomment-901092615
# [Codecov](https://codecov.io/gh/apache/pinot/pull/7318?src=pr&el=h1&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation) Report
> Merging [#7318](https://codecov.io/gh/apache/pinot/pull/7318?src=pr&el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation) (22a43af) into [master](https://codecov.io/gh/apache/pinot/commit/a539958eef8480cf95e39ed4788543e3d094c7bf?el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation) (a539958) will **decrease** coverage by `39.17%`.
> The diff coverage is `22.46%`.
> :exclamation: Current head 22a43af differs from pull request most recent head 60f7b0a. Consider uploading reports for the commit 60f7b0a to get more accurate results
[](https://codecov.io/gh/apache/pinot/pull/7318?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation)
```diff
@@ Coverage Diff @@
## master #7318 +/- ##
=============================================
- Coverage 71.47% 32.30% -39.18%
+ Complexity 3283 91 -3192
=============================================
Files 1504 1495 -9
Lines 73975 73972 -3
Branches 10704 10762 +58
=============================================
- Hits 52876 23897 -28979
- Misses 17505 48021 +30516
+ Partials 3594 2054 -1540
```
| Flag | Coverage Δ | |
|---|---|---|
| integration1 | `30.59% <22.20%> (-0.31%)` | :arrow_down: |
| integration2 | `29.12% <13.95%> (-0.20%)` | :arrow_down: |
| unittests1 | `?` | |
| unittests2 | `?` | |
Flags with carried forward coverage won't be shown. [Click here](https://docs.codecov.io/docs/carryforward-flags?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#carryforward-flags-in-the-pull-request-comment) to find out more.
| [Impacted Files](https://codecov.io/gh/apache/pinot/pull/7318?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation) | Coverage Δ | |
|---|---|---|
| [...gregation/function/AggregationFunctionFactory.java](https://codecov.io/gh/apache/pinot/pull/7318/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-cGlub3QtY29yZS9zcmMvbWFpbi9qYXZhL29yZy9hcGFjaGUvcGlub3QvY29yZS9xdWVyeS9hZ2dyZWdhdGlvbi9mdW5jdGlvbi9BZ2dyZWdhdGlvbkZ1bmN0aW9uRmFjdG9yeS5qYXZh) | `20.25% <0.00%> (-68.21%)` | :arrow_down: |
| [.../aggregation/function/ModeAggregationFunction.java](https://codecov.io/gh/apache/pinot/pull/7318/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-cGlub3QtY29yZS9zcmMvbWFpbi9qYXZhL29yZy9hcGFjaGUvcGlub3QvY29yZS9xdWVyeS9hZ2dyZWdhdGlvbi9mdW5jdGlvbi9Nb2RlQWdncmVnYXRpb25GdW5jdGlvbi5qYXZh) | `0.00% <0.00%> (ø)` | |
| [...estion/batch/common/SegmentGenerationJobUtils.java](https://codecov.io/gh/apache/pinot/pull/7318/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-cGlub3QtcGx1Z2lucy9waW5vdC1iYXRjaC1pbmdlc3Rpb24vcGlub3QtYmF0Y2gtaW5nZXN0aW9uLWNvbW1vbi9zcmMvbWFpbi9qYXZhL29yZy9hcGFjaGUvcGlub3QvcGx1Z2luL2luZ2VzdGlvbi9iYXRjaC9jb21tb24vU2VnbWVudEdlbmVyYXRpb25Kb2JVdGlscy5qYXZh) | `0.00% <ø> (-81.82%)` | :arrow_down: |
| [...ot/plugin/ingestion/batch/standalone/JobUtils.java](https://codecov.io/gh/apache/pinot/pull/7318/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-cGlub3QtcGx1Z2lucy9waW5vdC1iYXRjaC1pbmdlc3Rpb24vcGlub3QtYmF0Y2gtaW5nZXN0aW9uLXN0YW5kYWxvbmUvc3JjL21haW4vamF2YS9vcmcvYXBhY2hlL3Bpbm90L3BsdWdpbi9pbmdlc3Rpb24vYmF0Y2gvc3RhbmRhbG9uZS9Kb2JVdGlscy5qYXZh) | `0.00% <ø> (-40.00%)` | :arrow_down: |
| [.../org/apache/pinot/plugin/filesystem/S3PinotFS.java](https://codecov.io/gh/apache/pinot/pull/7318/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-cGlub3QtcGx1Z2lucy9waW5vdC1maWxlLXN5c3RlbS9waW5vdC1zMy9zcmMvbWFpbi9qYXZhL29yZy9hcGFjaGUvcGlub3QvcGx1Z2luL2ZpbGVzeXN0ZW0vUzNQaW5vdEZTLmphdmE=) | `0.00% <0.00%> (-38.71%)` | :arrow_down: |
| [...inputformat/avro/AvroIngestionSchemaValidator.java](https://codecov.io/gh/apache/pinot/pull/7318/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-cGlub3QtcGx1Z2lucy9waW5vdC1pbnB1dC1mb3JtYXQvcGlub3QtYXZyby1iYXNlL3NyYy9tYWluL2phdmEvb3JnL2FwYWNoZS9waW5vdC9wbHVnaW4vaW5wdXRmb3JtYXQvYXZyby9BdnJvSW5nZXN0aW9uU2NoZW1hVmFsaWRhdG9yLmphdmE=) | `0.00% <0.00%> (ø)` | |
| [.../pinot/plugin/inputformat/avro/AvroSchemaUtil.java](https://codecov.io/gh/apache/pinot/pull/7318/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-cGlub3QtcGx1Z2lucy9waW5vdC1pbnB1dC1mb3JtYXQvcGlub3QtYXZyby1iYXNlL3NyYy9tYWluL2phdmEvb3JnL2FwYWNoZS9waW5vdC9wbHVnaW4vaW5wdXRmb3JtYXQvYXZyby9BdnJvU2NoZW1hVXRpbC5qYXZh) | `0.00% <ø> (-18.19%)` | :arrow_down: |
| [...pache/pinot/plugin/inputformat/avro/AvroUtils.java](https://codecov.io/gh/apache/pinot/pull/7318/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-cGlub3QtcGx1Z2lucy9waW5vdC1pbnB1dC1mb3JtYXQvcGlub3QtYXZyby1iYXNlL3NyYy9tYWluL2phdmEvb3JnL2FwYWNoZS9waW5vdC9wbHVnaW4vaW5wdXRmb3JtYXQvYXZyby9BdnJvVXRpbHMuamF2YQ==) | `0.00% <0.00%> (-69.79%)` | :arrow_down: |
| [...ugin/inputformat/avro/KafkaAvroMessageDecoder.java](https://codecov.io/gh/apache/pinot/pull/7318/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-cGlub3QtcGx1Z2lucy9waW5vdC1pbnB1dC1mb3JtYXQvcGlub3QtYXZyby9zcmMvbWFpbi9qYXZhL29yZy9hcGFjaGUvcGlub3QvcGx1Z2luL2lucHV0Zm9ybWF0L2F2cm8vS2Fma2FBdnJvTWVzc2FnZURlY29kZXIuamF2YQ==) | `0.00% <0.00%> (ø)` | |
| [...ugin/inputformat/csv/CSVRecordExtractorConfig.java](https://codecov.io/gh/apache/pinot/pull/7318/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-cGlub3QtcGx1Z2lucy9waW5vdC1pbnB1dC1mb3JtYXQvcGlub3QtY3N2L3NyYy9tYWluL2phdmEvb3JnL2FwYWNoZS9waW5vdC9wbHVnaW4vaW5wdXRmb3JtYXQvY3N2L0NTVlJlY29yZEV4dHJhY3RvckNvbmZpZy5qYXZh) | `0.00% <0.00%> (ø)` | |
| ... and [1030 more](https://codecov.io/gh/apache/pinot/pull/7318/diff?src=pr&el=tree-more&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation) | |
------
[Continue to review full report at Codecov](https://codecov.io/gh/apache/pinot/pull/7318?src=pr&el=continue&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation).
> **Legend** - [Click here to learn more](https://docs.codecov.io/docs/codecov-delta?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation)
> `Δ = absolute <relative> (impact)`, `ø = not affected`, `? = missing data`
> Powered by [Codecov](https://codecov.io/gh/apache/pinot/pull/7318?src=pr&el=footer&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation). Last update [a539958...60f7b0a](https://codecov.io/gh/apache/pinot/pull/7318?src=pr&el=lastupdated&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation). Read the [comment docs](https://docs.codecov.io/docs/pull-request-comments?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation).
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@pinot.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@pinot.apache.org
For additional commands, e-mail: commits-help@pinot.apache.org
[GitHub] [pinot] codecov-commenter commented on pull request #7318: add mode aggregation function
Posted by GitBox <gi...@apache.org>.
codecov-commenter commented on pull request #7318:
URL: https://github.com/apache/pinot/pull/7318#issuecomment-901092615
# [Codecov](https://codecov.io/gh/apache/pinot/pull/7318?src=pr&el=h1&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation) Report
> Merging [#7318](https://codecov.io/gh/apache/pinot/pull/7318?src=pr&el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation) (57e0c97) into [master](https://codecov.io/gh/apache/pinot/commit/a539958eef8480cf95e39ed4788543e3d094c7bf?el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation) (a539958) will **decrease** coverage by `6.90%`.
> The diff coverage is `66.81%`.
[](https://codecov.io/gh/apache/pinot/pull/7318?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation)
```diff
@@ Coverage Diff @@
## master #7318 +/- ##
============================================
- Coverage 71.47% 64.57% -6.91%
- Complexity 3283 3290 +7
============================================
Files 1504 1458 -46
Lines 73975 72403 -1572
Branches 10704 10594 -110
============================================
- Hits 52876 46754 -6122
- Misses 17505 22283 +4778
+ Partials 3594 3366 -228
```
| Flag | Coverage Δ | |
|---|---|---|
| integration1 | `?` | |
| integration2 | `?` | |
| unittests1 | `69.13% <66.81%> (+0.05%)` | :arrow_up: |
| unittests2 | `14.49% <0.00%> (-0.16%)` | :arrow_down: |
Flags with carried forward coverage won't be shown. [Click here](https://docs.codecov.io/docs/carryforward-flags?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#carryforward-flags-in-the-pull-request-comment) to find out more.
| [Impacted Files](https://codecov.io/gh/apache/pinot/pull/7318?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation) | Coverage Δ | |
|---|---|---|
| [.../aggregation/function/ModeAggregationFunction.java](https://codecov.io/gh/apache/pinot/pull/7318/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-cGlub3QtY29yZS9zcmMvbWFpbi9qYXZhL29yZy9hcGFjaGUvcGlub3QvY29yZS9xdWVyeS9hZ2dyZWdhdGlvbi9mdW5jdGlvbi9Nb2RlQWdncmVnYXRpb25GdW5jdGlvbi5qYXZh) | `59.72% <59.72%> (ø)` | |
| [...org/apache/pinot/core/common/ObjectSerDeUtils.java](https://codecov.io/gh/apache/pinot/pull/7318/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-cGlub3QtY29yZS9zcmMvbWFpbi9qYXZhL29yZy9hcGFjaGUvcGlub3QvY29yZS9jb21tb24vT2JqZWN0U2VyRGVVdGlscy5qYXZh) | `89.75% <100.00%> (+2.08%)` | :arrow_up: |
| [...gregation/function/AggregationFunctionFactory.java](https://codecov.io/gh/apache/pinot/pull/7318/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-cGlub3QtY29yZS9zcmMvbWFpbi9qYXZhL29yZy9hcGFjaGUvcGlub3QvY29yZS9xdWVyeS9hZ2dyZWdhdGlvbi9mdW5jdGlvbi9BZ2dyZWdhdGlvbkZ1bmN0aW9uRmFjdG9yeS5qYXZh) | `88.60% <100.00%> (+0.14%)` | :arrow_up: |
| [...che/pinot/segment/spi/AggregationFunctionType.java](https://codecov.io/gh/apache/pinot/pull/7318/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-cGlub3Qtc2VnbWVudC1zcGkvc3JjL21haW4vamF2YS9vcmcvYXBhY2hlL3Bpbm90L3NlZ21lbnQvc3BpL0FnZ3JlZ2F0aW9uRnVuY3Rpb25UeXBlLmphdmE=) | `100.00% <100.00%> (ø)` | |
| [...a/org/apache/pinot/common/metrics/MinionMeter.java](https://codecov.io/gh/apache/pinot/pull/7318/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-cGlub3QtY29tbW9uL3NyYy9tYWluL2phdmEvb3JnL2FwYWNoZS9waW5vdC9jb21tb24vbWV0cmljcy9NaW5pb25NZXRlci5qYXZh) | `0.00% <0.00%> (-100.00%)` | :arrow_down: |
| [...g/apache/pinot/common/metrics/ControllerMeter.java](https://codecov.io/gh/apache/pinot/pull/7318/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-cGlub3QtY29tbW9uL3NyYy9tYWluL2phdmEvb3JnL2FwYWNoZS9waW5vdC9jb21tb24vbWV0cmljcy9Db250cm9sbGVyTWV0ZXIuamF2YQ==) | `0.00% <0.00%> (-100.00%)` | :arrow_down: |
| [.../apache/pinot/common/metrics/BrokerQueryPhase.java](https://codecov.io/gh/apache/pinot/pull/7318/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-cGlub3QtY29tbW9uL3NyYy9tYWluL2phdmEvb3JnL2FwYWNoZS9waW5vdC9jb21tb24vbWV0cmljcy9Ccm9rZXJRdWVyeVBoYXNlLmphdmE=) | `0.00% <0.00%> (-100.00%)` | :arrow_down: |
| [.../apache/pinot/common/metrics/MinionQueryPhase.java](https://codecov.io/gh/apache/pinot/pull/7318/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-cGlub3QtY29tbW9uL3NyYy9tYWluL2phdmEvb3JnL2FwYWNoZS9waW5vdC9jb21tb24vbWV0cmljcy9NaW5pb25RdWVyeVBoYXNlLmphdmE=) | `0.00% <0.00%> (-100.00%)` | :arrow_down: |
| [...pache/pinot/common/utils/grpc/GrpcQueryClient.java](https://codecov.io/gh/apache/pinot/pull/7318/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-cGlub3QtY29tbW9uL3NyYy9tYWluL2phdmEvb3JnL2FwYWNoZS9waW5vdC9jb21tb24vdXRpbHMvZ3JwYy9HcnBjUXVlcnlDbGllbnQuamF2YQ==) | `0.00% <0.00%> (-100.00%)` | :arrow_down: |
| [...he/pinot/common/messages/SegmentReloadMessage.java](https://codecov.io/gh/apache/pinot/pull/7318/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-cGlub3QtY29tbW9uL3NyYy9tYWluL2phdmEvb3JnL2FwYWNoZS9waW5vdC9jb21tb24vbWVzc2FnZXMvU2VnbWVudFJlbG9hZE1lc3NhZ2UuamF2YQ==) | `0.00% <0.00%> (-100.00%)` | :arrow_down: |
| ... and [401 more](https://codecov.io/gh/apache/pinot/pull/7318/diff?src=pr&el=tree-more&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation) | |
------
[Continue to review full report at Codecov](https://codecov.io/gh/apache/pinot/pull/7318?src=pr&el=continue&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation).
> **Legend** - [Click here to learn more](https://docs.codecov.io/docs/codecov-delta?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation)
> `Δ = absolute <relative> (impact)`, `ø = not affected`, `? = missing data`
> Powered by [Codecov](https://codecov.io/gh/apache/pinot/pull/7318?src=pr&el=footer&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation). Last update [a539958...57e0c97](https://codecov.io/gh/apache/pinot/pull/7318?src=pr&el=lastupdated&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation). Read the [comment docs](https://docs.codecov.io/docs/pull-request-comments?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation).
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@pinot.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@pinot.apache.org
For additional commands, e-mail: commits-help@pinot.apache.org
[GitHub] [pinot] codecov-commenter edited a comment on pull request #7318: add mode aggregation function
Posted by GitBox <gi...@apache.org>.
codecov-commenter edited a comment on pull request #7318:
URL: https://github.com/apache/pinot/pull/7318#issuecomment-901092615
# [Codecov](https://codecov.io/gh/apache/pinot/pull/7318?src=pr&el=h1&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation) Report
> Merging [#7318](https://codecov.io/gh/apache/pinot/pull/7318?src=pr&el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation) (b0f2bdf) into [master](https://codecov.io/gh/apache/pinot/commit/a539958eef8480cf95e39ed4788543e3d094c7bf?el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation) (a539958) will **decrease** coverage by `2.21%`.
> The diff coverage is `84.92%`.
> :exclamation: Current head b0f2bdf differs from pull request most recent head 7597ed1. Consider uploading reports for the commit 7597ed1 to get more accurate results
[](https://codecov.io/gh/apache/pinot/pull/7318?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation)
```diff
@@ Coverage Diff @@
## master #7318 +/- ##
============================================
- Coverage 71.47% 69.26% -2.22%
+ Complexity 3283 3194 -89
============================================
Files 1504 1111 -393
Lines 73975 52442 -21533
Branches 10704 7870 -2834
============================================
- Hits 52876 36323 -16553
+ Misses 17505 13512 -3993
+ Partials 3594 2607 -987
```
| Flag | Coverage Δ | |
|---|---|---|
| integration1 | `?` | |
| integration2 | `?` | |
| unittests1 | `69.26% <84.92%> (+0.18%)` | :arrow_up: |
| unittests2 | `?` | |
Flags with carried forward coverage won't be shown. [Click here](https://docs.codecov.io/docs/carryforward-flags?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#carryforward-flags-in-the-pull-request-comment) to find out more.
| [Impacted Files](https://codecov.io/gh/apache/pinot/pull/7318?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation) | Coverage Δ | |
|---|---|---|
| [...inputformat/avro/AvroIngestionSchemaValidator.java](https://codecov.io/gh/apache/pinot/pull/7318/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-cGlub3QtcGx1Z2lucy9waW5vdC1pbnB1dC1mb3JtYXQvcGlub3QtYXZyby1iYXNlL3NyYy9tYWluL2phdmEvb3JnL2FwYWNoZS9waW5vdC9wbHVnaW4vaW5wdXRmb3JtYXQvYXZyby9BdnJvSW5nZXN0aW9uU2NoZW1hVmFsaWRhdG9yLmphdmE=) | `0.00% <0.00%> (ø)` | |
| [.../pinot/plugin/inputformat/avro/AvroSchemaUtil.java](https://codecov.io/gh/apache/pinot/pull/7318/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-cGlub3QtcGx1Z2lucy9waW5vdC1pbnB1dC1mb3JtYXQvcGlub3QtYXZyby1iYXNlL3NyYy9tYWluL2phdmEvb3JnL2FwYWNoZS9waW5vdC9wbHVnaW4vaW5wdXRmb3JtYXQvYXZyby9BdnJvU2NoZW1hVXRpbC5qYXZh) | `18.75% <ø> (+0.56%)` | :arrow_up: |
| [.../aggregation/function/ModeAggregationFunction.java](https://codecov.io/gh/apache/pinot/pull/7318/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-cGlub3QtY29yZS9zcmMvbWFpbi9qYXZhL29yZy9hcGFjaGUvcGlub3QvY29yZS9xdWVyeS9hZ2dyZWdhdGlvbi9mdW5jdGlvbi9Nb2RlQWdncmVnYXRpb25GdW5jdGlvbi5qYXZh) | `84.32% <84.32%> (ø)` | |
| [...pache/pinot/plugin/inputformat/avro/AvroUtils.java](https://codecov.io/gh/apache/pinot/pull/7318/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-cGlub3QtcGx1Z2lucy9waW5vdC1pbnB1dC1mb3JtYXQvcGlub3QtYXZyby1iYXNlL3NyYy9tYWluL2phdmEvb3JnL2FwYWNoZS9waW5vdC9wbHVnaW4vaW5wdXRmb3JtYXQvYXZyby9BdnJvVXRpbHMuamF2YQ==) | `69.56% <90.00%> (-0.22%)` | :arrow_down: |
| [...org/apache/pinot/core/common/ObjectSerDeUtils.java](https://codecov.io/gh/apache/pinot/pull/7318/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-cGlub3QtY29yZS9zcmMvbWFpbi9qYXZhL29yZy9hcGFjaGUvcGlub3QvY29yZS9jb21tb24vT2JqZWN0U2VyRGVVdGlscy5qYXZh) | `89.75% <100.00%> (+2.08%)` | :arrow_up: |
| [...gregation/function/AggregationFunctionFactory.java](https://codecov.io/gh/apache/pinot/pull/7318/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-cGlub3QtY29yZS9zcmMvbWFpbi9qYXZhL29yZy9hcGFjaGUvcGlub3QvY29yZS9xdWVyeS9hZ2dyZWdhdGlvbi9mdW5jdGlvbi9BZ2dyZWdhdGlvbkZ1bmN0aW9uRmFjdG9yeS5qYXZh) | `88.60% <100.00%> (+0.14%)` | :arrow_up: |
| [...che/pinot/segment/spi/AggregationFunctionType.java](https://codecov.io/gh/apache/pinot/pull/7318/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-cGlub3Qtc2VnbWVudC1zcGkvc3JjL21haW4vamF2YS9vcmcvYXBhY2hlL3Bpbm90L3NlZ21lbnQvc3BpL0FnZ3JlZ2F0aW9uRnVuY3Rpb25UeXBlLmphdmE=) | `100.00% <100.00%> (ø)` | |
| [...a/org/apache/pinot/common/metrics/MinionMeter.java](https://codecov.io/gh/apache/pinot/pull/7318/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-cGlub3QtY29tbW9uL3NyYy9tYWluL2phdmEvb3JnL2FwYWNoZS9waW5vdC9jb21tb24vbWV0cmljcy9NaW5pb25NZXRlci5qYXZh) | `0.00% <0.00%> (-100.00%)` | :arrow_down: |
| [...g/apache/pinot/common/metrics/ControllerMeter.java](https://codecov.io/gh/apache/pinot/pull/7318/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-cGlub3QtY29tbW9uL3NyYy9tYWluL2phdmEvb3JnL2FwYWNoZS9waW5vdC9jb21tb24vbWV0cmljcy9Db250cm9sbGVyTWV0ZXIuamF2YQ==) | `0.00% <0.00%> (-100.00%)` | :arrow_down: |
| [.../apache/pinot/common/metrics/BrokerQueryPhase.java](https://codecov.io/gh/apache/pinot/pull/7318/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-cGlub3QtY29tbW9uL3NyYy9tYWluL2phdmEvb3JnL2FwYWNoZS9waW5vdC9jb21tb24vbWV0cmljcy9Ccm9rZXJRdWVyeVBoYXNlLmphdmE=) | `0.00% <0.00%> (-100.00%)` | :arrow_down: |
| ... and [551 more](https://codecov.io/gh/apache/pinot/pull/7318/diff?src=pr&el=tree-more&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation) | |
------
[Continue to review full report at Codecov](https://codecov.io/gh/apache/pinot/pull/7318?src=pr&el=continue&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation).
> **Legend** - [Click here to learn more](https://docs.codecov.io/docs/codecov-delta?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation)
> `Δ = absolute <relative> (impact)`, `ø = not affected`, `? = missing data`
> Powered by [Codecov](https://codecov.io/gh/apache/pinot/pull/7318?src=pr&el=footer&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation). Last update [a539958...7597ed1](https://codecov.io/gh/apache/pinot/pull/7318?src=pr&el=lastupdated&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation). Read the [comment docs](https://docs.codecov.io/docs/pull-request-comments?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation).
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@pinot.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@pinot.apache.org
For additional commands, e-mail: commits-help@pinot.apache.org
[GitHub] [pinot] codecov-commenter edited a comment on pull request #7318: add mode aggregation function
Posted by GitBox <gi...@apache.org>.
codecov-commenter edited a comment on pull request #7318:
URL: https://github.com/apache/pinot/pull/7318#issuecomment-901092615
# [Codecov](https://codecov.io/gh/apache/pinot/pull/7318?src=pr&el=h1&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation) Report
> Merging [#7318](https://codecov.io/gh/apache/pinot/pull/7318?src=pr&el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation) (22a43af) into [master](https://codecov.io/gh/apache/pinot/commit/a539958eef8480cf95e39ed4788543e3d094c7bf?el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation) (a539958) will **decrease** coverage by `40.88%`.
> The diff coverage is `22.20%`.
> :exclamation: Current head 22a43af differs from pull request most recent head 60f7b0a. Consider uploading reports for the commit 60f7b0a to get more accurate results
[](https://codecov.io/gh/apache/pinot/pull/7318?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation)
```diff
@@ Coverage Diff @@
## master #7318 +/- ##
=============================================
- Coverage 71.47% 30.59% -40.89%
+ Complexity 3283 86 -3197
=============================================
Files 1504 1495 -9
Lines 73975 73972 -3
Branches 10704 10762 +58
=============================================
- Hits 52876 22634 -30242
- Misses 17505 49324 +31819
+ Partials 3594 2014 -1580
```
| Flag | Coverage Δ | |
|---|---|---|
| integration1 | `30.59% <22.20%> (-0.31%)` | :arrow_down: |
| integration2 | `?` | |
| unittests1 | `?` | |
| unittests2 | `?` | |
Flags with carried forward coverage won't be shown. [Click here](https://docs.codecov.io/docs/carryforward-flags?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#carryforward-flags-in-the-pull-request-comment) to find out more.
| [Impacted Files](https://codecov.io/gh/apache/pinot/pull/7318?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation) | Coverage Δ | |
|---|---|---|
| [...manager/realtime/LLRealtimeSegmentDataManager.java](https://codecov.io/gh/apache/pinot/pull/7318/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-cGlub3QtY29yZS9zcmMvbWFpbi9qYXZhL29yZy9hcGFjaGUvcGlub3QvY29yZS9kYXRhL21hbmFnZXIvcmVhbHRpbWUvTExSZWFsdGltZVNlZ21lbnREYXRhTWFuYWdlci5qYXZh) | `57.70% <0.00%> (-15.51%)` | :arrow_down: |
| [...gregation/function/AggregationFunctionFactory.java](https://codecov.io/gh/apache/pinot/pull/7318/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-cGlub3QtY29yZS9zcmMvbWFpbi9qYXZhL29yZy9hcGFjaGUvcGlub3QvY29yZS9xdWVyeS9hZ2dyZWdhdGlvbi9mdW5jdGlvbi9BZ2dyZWdhdGlvbkZ1bmN0aW9uRmFjdG9yeS5qYXZh) | `18.98% <0.00%> (-69.48%)` | :arrow_down: |
| [.../aggregation/function/ModeAggregationFunction.java](https://codecov.io/gh/apache/pinot/pull/7318/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-cGlub3QtY29yZS9zcmMvbWFpbi9qYXZhL29yZy9hcGFjaGUvcGlub3QvY29yZS9xdWVyeS9hZ2dyZWdhdGlvbi9mdW5jdGlvbi9Nb2RlQWdncmVnYXRpb25GdW5jdGlvbi5qYXZh) | `0.00% <0.00%> (ø)` | |
| [...estion/batch/common/SegmentGenerationJobUtils.java](https://codecov.io/gh/apache/pinot/pull/7318/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-cGlub3QtcGx1Z2lucy9waW5vdC1iYXRjaC1pbmdlc3Rpb24vcGlub3QtYmF0Y2gtaW5nZXN0aW9uLWNvbW1vbi9zcmMvbWFpbi9qYXZhL29yZy9hcGFjaGUvcGlub3QvcGx1Z2luL2luZ2VzdGlvbi9iYXRjaC9jb21tb24vU2VnbWVudEdlbmVyYXRpb25Kb2JVdGlscy5qYXZh) | `0.00% <ø> (-81.82%)` | :arrow_down: |
| [...ot/plugin/ingestion/batch/standalone/JobUtils.java](https://codecov.io/gh/apache/pinot/pull/7318/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-cGlub3QtcGx1Z2lucy9waW5vdC1iYXRjaC1pbmdlc3Rpb24vcGlub3QtYmF0Y2gtaW5nZXN0aW9uLXN0YW5kYWxvbmUvc3JjL21haW4vamF2YS9vcmcvYXBhY2hlL3Bpbm90L3BsdWdpbi9pbmdlc3Rpb24vYmF0Y2gvc3RhbmRhbG9uZS9Kb2JVdGlscy5qYXZh) | `0.00% <ø> (-40.00%)` | :arrow_down: |
| [.../org/apache/pinot/plugin/filesystem/S3PinotFS.java](https://codecov.io/gh/apache/pinot/pull/7318/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-cGlub3QtcGx1Z2lucy9waW5vdC1maWxlLXN5c3RlbS9waW5vdC1zMy9zcmMvbWFpbi9qYXZhL29yZy9hcGFjaGUvcGlub3QvcGx1Z2luL2ZpbGVzeXN0ZW0vUzNQaW5vdEZTLmphdmE=) | `0.00% <0.00%> (-38.71%)` | :arrow_down: |
| [...inputformat/avro/AvroIngestionSchemaValidator.java](https://codecov.io/gh/apache/pinot/pull/7318/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-cGlub3QtcGx1Z2lucy9waW5vdC1pbnB1dC1mb3JtYXQvcGlub3QtYXZyby1iYXNlL3NyYy9tYWluL2phdmEvb3JnL2FwYWNoZS9waW5vdC9wbHVnaW4vaW5wdXRmb3JtYXQvYXZyby9BdnJvSW5nZXN0aW9uU2NoZW1hVmFsaWRhdG9yLmphdmE=) | `0.00% <0.00%> (ø)` | |
| [.../pinot/plugin/inputformat/avro/AvroSchemaUtil.java](https://codecov.io/gh/apache/pinot/pull/7318/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-cGlub3QtcGx1Z2lucy9waW5vdC1pbnB1dC1mb3JtYXQvcGlub3QtYXZyby1iYXNlL3NyYy9tYWluL2phdmEvb3JnL2FwYWNoZS9waW5vdC9wbHVnaW4vaW5wdXRmb3JtYXQvYXZyby9BdnJvU2NoZW1hVXRpbC5qYXZh) | `0.00% <ø> (-18.19%)` | :arrow_down: |
| [...pache/pinot/plugin/inputformat/avro/AvroUtils.java](https://codecov.io/gh/apache/pinot/pull/7318/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-cGlub3QtcGx1Z2lucy9waW5vdC1pbnB1dC1mb3JtYXQvcGlub3QtYXZyby1iYXNlL3NyYy9tYWluL2phdmEvb3JnL2FwYWNoZS9waW5vdC9wbHVnaW4vaW5wdXRmb3JtYXQvYXZyby9BdnJvVXRpbHMuamF2YQ==) | `0.00% <0.00%> (-69.79%)` | :arrow_down: |
| [...ugin/inputformat/avro/KafkaAvroMessageDecoder.java](https://codecov.io/gh/apache/pinot/pull/7318/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-cGlub3QtcGx1Z2lucy9waW5vdC1pbnB1dC1mb3JtYXQvcGlub3QtYXZyby9zcmMvbWFpbi9qYXZhL29yZy9hcGFjaGUvcGlub3QvcGx1Z2luL2lucHV0Zm9ybWF0L2F2cm8vS2Fma2FBdnJvTWVzc2FnZURlY29kZXIuamF2YQ==) | `0.00% <0.00%> (ø)` | |
| ... and [1079 more](https://codecov.io/gh/apache/pinot/pull/7318/diff?src=pr&el=tree-more&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation) | |
------
[Continue to review full report at Codecov](https://codecov.io/gh/apache/pinot/pull/7318?src=pr&el=continue&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation).
> **Legend** - [Click here to learn more](https://docs.codecov.io/docs/codecov-delta?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation)
> `Δ = absolute <relative> (impact)`, `ø = not affected`, `? = missing data`
> Powered by [Codecov](https://codecov.io/gh/apache/pinot/pull/7318?src=pr&el=footer&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation). Last update [a539958...60f7b0a](https://codecov.io/gh/apache/pinot/pull/7318?src=pr&el=lastupdated&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation). Read the [comment docs](https://docs.codecov.io/docs/pull-request-comments?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation).
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@pinot.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@pinot.apache.org
For additional commands, e-mail: commits-help@pinot.apache.org
[GitHub] [pinot] codecov-commenter edited a comment on pull request #7318: add mode aggregation function
Posted by GitBox <gi...@apache.org>.
codecov-commenter edited a comment on pull request #7318:
URL: https://github.com/apache/pinot/pull/7318#issuecomment-901092615
# [Codecov](https://codecov.io/gh/apache/pinot/pull/7318?src=pr&el=h1&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation) Report
> Merging [#7318](https://codecov.io/gh/apache/pinot/pull/7318?src=pr&el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation) (60f7b0a) into [master](https://codecov.io/gh/apache/pinot/commit/a539958eef8480cf95e39ed4788543e3d094c7bf?el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation) (a539958) will **decrease** coverage by `6.79%`.
> The diff coverage is `90.44%`.
[](https://codecov.io/gh/apache/pinot/pull/7318?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation)
```diff
@@ Coverage Diff @@
## master #7318 +/- ##
============================================
- Coverage 71.47% 64.67% -6.80%
+ Complexity 3283 3282 -1
============================================
Files 1504 1458 -46
Lines 73975 72405 -1570
Branches 10704 10596 -108
============================================
- Hits 52876 46831 -6045
- Misses 17505 22206 +4701
+ Partials 3594 3368 -226
```
| Flag | Coverage Δ | |
|---|---|---|
| integration1 | `?` | |
| integration2 | `?` | |
| unittests1 | `69.27% <90.44%> (+0.19%)` | :arrow_up: |
| unittests2 | `14.50% <0.00%> (-0.16%)` | :arrow_down: |
Flags with carried forward coverage won't be shown. [Click here](https://docs.codecov.io/docs/carryforward-flags?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#carryforward-flags-in-the-pull-request-comment) to find out more.
| [Impacted Files](https://codecov.io/gh/apache/pinot/pull/7318?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation) | Coverage Δ | |
|---|---|---|
| [.../aggregation/function/ModeAggregationFunction.java](https://codecov.io/gh/apache/pinot/pull/7318/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-cGlub3QtY29yZS9zcmMvbWFpbi9qYXZhL29yZy9hcGFjaGUvcGlub3QvY29yZS9xdWVyeS9hZ2dyZWdhdGlvbi9mdW5jdGlvbi9Nb2RlQWdncmVnYXRpb25GdW5jdGlvbi5qYXZh) | `88.40% <88.40%> (ø)` | |
| [...org/apache/pinot/core/common/ObjectSerDeUtils.java](https://codecov.io/gh/apache/pinot/pull/7318/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-cGlub3QtY29yZS9zcmMvbWFpbi9qYXZhL29yZy9hcGFjaGUvcGlub3QvY29yZS9jb21tb24vT2JqZWN0U2VyRGVVdGlscy5qYXZh) | `89.75% <100.00%> (+2.08%)` | :arrow_up: |
| [...gregation/function/AggregationFunctionFactory.java](https://codecov.io/gh/apache/pinot/pull/7318/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-cGlub3QtY29yZS9zcmMvbWFpbi9qYXZhL29yZy9hcGFjaGUvcGlub3QvY29yZS9xdWVyeS9hZ2dyZWdhdGlvbi9mdW5jdGlvbi9BZ2dyZWdhdGlvbkZ1bmN0aW9uRmFjdG9yeS5qYXZh) | `88.60% <100.00%> (+0.14%)` | :arrow_up: |
| [...che/pinot/segment/spi/AggregationFunctionType.java](https://codecov.io/gh/apache/pinot/pull/7318/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-cGlub3Qtc2VnbWVudC1zcGkvc3JjL21haW4vamF2YS9vcmcvYXBhY2hlL3Bpbm90L3NlZ21lbnQvc3BpL0FnZ3JlZ2F0aW9uRnVuY3Rpb25UeXBlLmphdmE=) | `100.00% <100.00%> (ø)` | |
| [...a/org/apache/pinot/common/metrics/MinionMeter.java](https://codecov.io/gh/apache/pinot/pull/7318/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-cGlub3QtY29tbW9uL3NyYy9tYWluL2phdmEvb3JnL2FwYWNoZS9waW5vdC9jb21tb24vbWV0cmljcy9NaW5pb25NZXRlci5qYXZh) | `0.00% <0.00%> (-100.00%)` | :arrow_down: |
| [...g/apache/pinot/common/metrics/ControllerMeter.java](https://codecov.io/gh/apache/pinot/pull/7318/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-cGlub3QtY29tbW9uL3NyYy9tYWluL2phdmEvb3JnL2FwYWNoZS9waW5vdC9jb21tb24vbWV0cmljcy9Db250cm9sbGVyTWV0ZXIuamF2YQ==) | `0.00% <0.00%> (-100.00%)` | :arrow_down: |
| [.../apache/pinot/common/metrics/BrokerQueryPhase.java](https://codecov.io/gh/apache/pinot/pull/7318/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-cGlub3QtY29tbW9uL3NyYy9tYWluL2phdmEvb3JnL2FwYWNoZS9waW5vdC9jb21tb24vbWV0cmljcy9Ccm9rZXJRdWVyeVBoYXNlLmphdmE=) | `0.00% <0.00%> (-100.00%)` | :arrow_down: |
| [.../apache/pinot/common/metrics/MinionQueryPhase.java](https://codecov.io/gh/apache/pinot/pull/7318/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-cGlub3QtY29tbW9uL3NyYy9tYWluL2phdmEvb3JnL2FwYWNoZS9waW5vdC9jb21tb24vbWV0cmljcy9NaW5pb25RdWVyeVBoYXNlLmphdmE=) | `0.00% <0.00%> (-100.00%)` | :arrow_down: |
| [...pache/pinot/common/utils/grpc/GrpcQueryClient.java](https://codecov.io/gh/apache/pinot/pull/7318/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-cGlub3QtY29tbW9uL3NyYy9tYWluL2phdmEvb3JnL2FwYWNoZS9waW5vdC9jb21tb24vdXRpbHMvZ3JwYy9HcnBjUXVlcnlDbGllbnQuamF2YQ==) | `0.00% <0.00%> (-100.00%)` | :arrow_down: |
| [...he/pinot/common/messages/SegmentReloadMessage.java](https://codecov.io/gh/apache/pinot/pull/7318/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-cGlub3QtY29tbW9uL3NyYy9tYWluL2phdmEvb3JnL2FwYWNoZS9waW5vdC9jb21tb24vbWVzc2FnZXMvU2VnbWVudFJlbG9hZE1lc3NhZ2UuamF2YQ==) | `0.00% <0.00%> (-100.00%)` | :arrow_down: |
| ... and [398 more](https://codecov.io/gh/apache/pinot/pull/7318/diff?src=pr&el=tree-more&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation) | |
------
[Continue to review full report at Codecov](https://codecov.io/gh/apache/pinot/pull/7318?src=pr&el=continue&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation).
> **Legend** - [Click here to learn more](https://docs.codecov.io/docs/codecov-delta?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation)
> `Δ = absolute <relative> (impact)`, `ø = not affected`, `? = missing data`
> Powered by [Codecov](https://codecov.io/gh/apache/pinot/pull/7318?src=pr&el=footer&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation). Last update [a539958...60f7b0a](https://codecov.io/gh/apache/pinot/pull/7318?src=pr&el=lastupdated&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation). Read the [comment docs](https://docs.codecov.io/docs/pull-request-comments?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation).
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@pinot.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@pinot.apache.org
For additional commands, e-mail: commits-help@pinot.apache.org
[GitHub] [pinot] mr-agrwal commented on a change in pull request #7318: add mode aggregation function
Posted by GitBox <gi...@apache.org>.
mr-agrwal commented on a change in pull request #7318:
URL: https://github.com/apache/pinot/pull/7318#discussion_r691609055
##########
File path: pinot-core/src/main/java/org/apache/pinot/core/query/aggregation/function/ModeAggregationFunction.java
##########
@@ -0,0 +1,704 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.pinot.core.query.aggregation.function;
+
+import com.google.common.base.Preconditions;
+import it.unimi.dsi.fastutil.doubles.Double2LongMap;
+import it.unimi.dsi.fastutil.doubles.Double2LongOpenHashMap;
+import it.unimi.dsi.fastutil.floats.Float2LongMap;
+import it.unimi.dsi.fastutil.floats.Float2LongOpenHashMap;
+import it.unimi.dsi.fastutil.ints.Int2LongMap;
+import it.unimi.dsi.fastutil.ints.Int2LongMaps;
+import it.unimi.dsi.fastutil.ints.Int2LongOpenHashMap;
+import it.unimi.dsi.fastutil.longs.Long2LongMap;
+import it.unimi.dsi.fastutil.longs.Long2LongOpenHashMap;
+import it.unimi.dsi.fastutil.objects.ObjectIterator;
+import java.util.List;
+import java.util.Map;
+import javax.annotation.Nullable;
+import org.apache.pinot.common.request.context.ExpressionContext;
+import org.apache.pinot.common.utils.DataSchema.ColumnDataType;
+import org.apache.pinot.core.common.BlockValSet;
+import org.apache.pinot.core.query.aggregation.AggregationResultHolder;
+import org.apache.pinot.core.query.aggregation.ObjectAggregationResultHolder;
+import org.apache.pinot.core.query.aggregation.groupby.GroupByResultHolder;
+import org.apache.pinot.core.query.aggregation.groupby.ObjectGroupByResultHolder;
+import org.apache.pinot.segment.spi.AggregationFunctionType;
+import org.apache.pinot.segment.spi.index.reader.Dictionary;
+import org.apache.pinot.spi.data.FieldSpec.DataType;
+
+
+/**
+ * This function is used for Mode calculations.
+ * <p>The function can be used as MODE(expression, multiModeReducerType)
+ * <p>Following arguments are supported:
+ * <ul>
+ * <li>Expression: expression that contains the column to be calculated mode on, can be any Numeric column</li>
+ * <li>MultiModeReducerType (optional): the reducer to use in case of multiple modes present in data</li>
+ * </ul>
+ */
+@SuppressWarnings({"rawtypes", "unchecked"})
+public class ModeAggregationFunction extends BaseSingleInputAggregationFunction<Map<? extends Number, Long>, Double> {
+
+ private static final double DEFAULT_FINAL_RESULT = Double.NEGATIVE_INFINITY;
+
+ private final MultiModeReducerType _multiModeReducerType;
+
+ public ModeAggregationFunction(List<ExpressionContext> arguments) {
+ super(arguments.get(0));
+
+ int numArguments = arguments.size();
+ Preconditions.checkArgument(numArguments <= 2, "Mode expects at most 2 arguments, got: %s", numArguments);
+ if (numArguments > 1) {
+ _multiModeReducerType = MultiModeReducerType.valueOf(arguments.get(1).getLiteral());
+ } else {
+ _multiModeReducerType = MultiModeReducerType.MIN;
+ }
+ }
+
+ /**
+ * Helper method to create a value map for the given value type.
+ */
+ private static Map<? extends Number, Long> getValueMap(DataType valueType) {
+ switch (valueType) {
+ case INT:
+ return new Int2LongOpenHashMap();
+ case LONG:
+ return new Long2LongOpenHashMap();
+ case FLOAT:
+ return new Float2LongOpenHashMap();
+ case DOUBLE:
+ return new Double2LongOpenHashMap();
+ default:
+ throw new IllegalStateException("Illegal data type for MODE aggregation function: " + valueType);
+ }
+ }
+
+ /**
+ * Returns the value map from the result holder or creates a new one if it does not exist.
+ */
+ protected static Map<? extends Number, Long> getValueMap(AggregationResultHolder aggregationResultHolder,
+ DataType valueType) {
+ Map<? extends Number, Long> valueMap = aggregationResultHolder.getResult();
+ if (valueMap == null) {
+ valueMap = getValueMap(valueType);
+ aggregationResultHolder.setValue(valueMap);
+ }
+ return valueMap;
+ }
+
+ /**
+ * Returns the value set for the given group key or creates a new one if it does not exist.
+ */
+ protected static Map<? extends Number, Long> getValueMap(GroupByResultHolder groupByResultHolder, int groupKey,
+ DataType valueType) {
+ Map<? extends Number, Long> valueMap = groupByResultHolder.getResult(groupKey);
+ if (valueMap == null) {
+ valueMap = getValueMap(valueType);
+ groupByResultHolder.setValueForKey(groupKey, valueMap);
+ }
+ return valueMap;
+ }
+
+ /**
+ * Helper method to set INT value for the given group keys into the result holder.
+ */
+ private static void setValueForGroupKeys(GroupByResultHolder groupByResultHolder, int groupKey, int value) {
+ ((Int2LongOpenHashMap) getValueMap(groupByResultHolder, groupKey, DataType.INT)).merge(value, 1, Long::sum);
+ }
+
+ /**
+ * Helper method to set LONG value for the given group keys into the result holder.
+ */
+ private static void setValueForGroupKeys(GroupByResultHolder groupByResultHolder, int groupKey, long value) {
+ ((Long2LongOpenHashMap) getValueMap(groupByResultHolder, groupKey, DataType.LONG)).merge(value, 1, Long::sum);
+ }
+
+ /**
+ * Helper method to set FLOAT value for the given group keys into the result holder.
+ */
+ private static void setValueForGroupKeys(GroupByResultHolder groupByResultHolder, int groupKey, float value) {
+ ((Float2LongOpenHashMap) getValueMap(groupByResultHolder, groupKey, DataType.FLOAT)).merge(value, 1, Long::sum);
+ }
+
+ /**
+ * Helper method to set DOUBLE value for the given group keys into the result holder.
+ */
+ private static void setValueForGroupKeys(GroupByResultHolder groupByResultHolder, int groupKey, double value) {
+ ((Double2LongOpenHashMap) getValueMap(groupByResultHolder, groupKey, DataType.DOUBLE)).merge(value, 1, Long::sum);
+ }
+
+ /**
+ * Returns the dictionary id count map from the result holder or creates a new one if it does not exist.
+ */
+ protected static Int2LongOpenHashMap getDictIdCountMap(AggregationResultHolder aggregationResultHolder,
+ Dictionary dictionary) {
+ ModeAggregationFunction.DictIdsWrapper dictIdsWrapper = aggregationResultHolder.getResult();
+ if (dictIdsWrapper == null) {
+ dictIdsWrapper = new ModeAggregationFunction.DictIdsWrapper(dictionary);
+ aggregationResultHolder.setValue(dictIdsWrapper);
+ }
+ return dictIdsWrapper._dictIdCountMap;
+ }
+
+ /**
+ * Returns the dictionary id count map for the given group key or creates a new one if it does not exist.
+ */
+ protected static Int2LongOpenHashMap getDictIdCountMap(GroupByResultHolder groupByResultHolder, int groupKey,
+ Dictionary dictionary) {
+ ModeAggregationFunction.DictIdsWrapper dictIdsWrapper = groupByResultHolder.getResult(groupKey);
+ if (dictIdsWrapper == null) {
+ dictIdsWrapper = new ModeAggregationFunction.DictIdsWrapper(dictionary);
+ groupByResultHolder.setValueForKey(groupKey, dictIdsWrapper);
+ }
+ return dictIdsWrapper._dictIdCountMap;
+ }
+
+ /**
+ * Helper method to read dictionary and convert dictionary ids to values for dictionary-encoded expression.
+ */
+ private static Map<? extends Number, Long> convertToValueMap(DictIdsWrapper dictIdsWrapper) {
+ Dictionary dictionary = dictIdsWrapper._dictionary;
+ Int2LongOpenHashMap dictIdCountMap = dictIdsWrapper._dictIdCountMap;
+ int numValues = dictIdCountMap.size();
+ ObjectIterator<Int2LongMap.Entry> iterator = Int2LongMaps.fastIterator(dictIdCountMap);
+ DataType storedType = dictionary.getValueType();
+ switch (storedType) {
+ case INT:
+ Int2LongOpenHashMap intValueMap = new Int2LongOpenHashMap(numValues);
+ while (iterator.hasNext()) {
+ Int2LongMap.Entry next = iterator.next();
+ intValueMap.put(dictionary.getIntValue(next.getIntKey()), next.getLongValue());
+ }
+ return intValueMap;
+ case LONG:
+ Long2LongOpenHashMap longValueMap = new Long2LongOpenHashMap(numValues);
+ while (iterator.hasNext()) {
+ Int2LongMap.Entry next = iterator.next();
+ longValueMap.put(dictionary.getLongValue(next.getIntKey()), next.getLongValue());
+ }
+ return longValueMap;
+ case FLOAT:
+ Float2LongOpenHashMap floatValueMap = new Float2LongOpenHashMap(numValues);
+ while (iterator.hasNext()) {
+ Int2LongMap.Entry next = iterator.next();
+ floatValueMap.put(dictionary.getFloatValue(next.getIntKey()), next.getLongValue());
+ }
+ return floatValueMap;
+ case DOUBLE:
+ Double2LongOpenHashMap doubleValueMap = new Double2LongOpenHashMap(numValues);
+ while (iterator.hasNext()) {
+ Int2LongMap.Entry next = iterator.next();
+ doubleValueMap.put(dictionary.getFloatValue(next.getIntKey()), next.getLongValue());
+ }
+ return doubleValueMap;
+ default:
+ throw new IllegalStateException("Illegal data type for MODE aggregation function: " + storedType);
+ }
+ }
+
+ /**
+ * Helper method to extract segment level intermediate result from the inner segment result.
+ */
+ private static Map<? extends Number, Long> extractIntermediateResult(@Nullable Object result) {
+ if (result == null) {
+ // NOTE: Return an empty Int2LongOpenHashMap for empty result.
+ return new Int2LongOpenHashMap();
+ }
+
+ if (result instanceof DictIdsWrapper) {
+ // For dictionary-encoded expression, convert dictionary ids to values
+ return convertToValueMap((DictIdsWrapper) result);
+ }
+ assert result instanceof Map;
+ // For non-dictionary-encoded expression, directly return the value set
+ return (Map) result;
+ }
+
+ @Override
+ public AggregationFunctionType getType() {
+ return AggregationFunctionType.MODE;
+ }
+
+ @Override
+ public AggregationResultHolder createAggregationResultHolder() {
+ return new ObjectAggregationResultHolder();
+ }
+
+ @Override
+ public GroupByResultHolder createGroupByResultHolder(int initialCapacity, int maxCapacity) {
+ return new ObjectGroupByResultHolder(initialCapacity, maxCapacity);
+ }
+
+ @Override
+ public void aggregate(int length, AggregationResultHolder aggregationResultHolder,
+ Map<ExpressionContext, BlockValSet> blockValSetMap) {
+ BlockValSet blockValSet = blockValSetMap.get(_expression);
+
+ // For dictionary-encoded expression, store dictionary ids into the dictId map
+ Dictionary dictionary = blockValSet.getDictionary();
+ if (dictionary != null) {
+ int[] dictIds = blockValSet.getDictionaryIdsSV();
+ Int2LongOpenHashMap dictIdValueMap = getDictIdCountMap(aggregationResultHolder, dictionary);
+ for (int i = 0; i < length; i++) {
+ dictIdValueMap.merge(dictIds[i], 1, Long::sum);
+ }
+ return;
+ }
+
+ // For non-dictionary-encoded expression, store values into the value map
+ DataType storedType = blockValSet.getValueType().getStoredType();
+ Map<? extends Number, Long> valueMap = getValueMap(aggregationResultHolder, storedType);
+ switch (storedType) {
+ case INT:
+ Int2LongOpenHashMap intMap = (Int2LongOpenHashMap) valueMap;
+ int[] intValues = blockValSet.getIntValuesSV();
+ for (int i = 0; i < length; i++) {
+ intMap.merge(intValues[i], 1, Long::sum);
+ }
+ break;
+ case LONG:
+ Long2LongOpenHashMap longMap = (Long2LongOpenHashMap) valueMap;
+ long[] longValues = blockValSet.getLongValuesSV();
+ for (int i = 0; i < length; i++) {
+ longMap.merge(longValues[i], 1, Long::sum);
+ }
+ break;
+ case FLOAT:
+ Float2LongOpenHashMap floatMap = (Float2LongOpenHashMap) valueMap;
+ float[] floatValues = blockValSet.getFloatValuesSV();
+ for (int i = 0; i < length; i++) {
+ floatMap.merge(floatValues[i], 1, Long::sum);
+ }
+ break;
+ case DOUBLE:
+ Double2LongOpenHashMap doubleMap = (Double2LongOpenHashMap) valueMap;
+ double[] doubleValues = blockValSet.getDoubleValuesSV();
+ for (int i = 0; i < length; i++) {
+ doubleMap.merge(doubleValues[i], 1, Long::sum);
+ }
+ break;
+ default:
+ throw new IllegalStateException("Illegal data type for MODE aggregation function: " + storedType);
+ }
+ }
+
+ @Override
+ public void aggregateGroupBySV(int length, int[] groupKeyArray, GroupByResultHolder groupByResultHolder,
+ Map<ExpressionContext, BlockValSet> blockValSetMap) {
+ BlockValSet blockValSet = blockValSetMap.get(_expression);
+
+ // For dictionary-encoded expression, store dictionary ids into the dictId map
+ Dictionary dictionary = blockValSet.getDictionary();
+ if (dictionary != null) {
+ int[] dictIds = blockValSet.getDictionaryIdsSV();
+ for (int i = 0; i < length; i++) {
+ getDictIdCountMap(groupByResultHolder, groupKeyArray[i], dictionary).merge(dictIds[i], 1, Long::sum);
+ }
+ return;
+ }
+
+ // For non-dictionary-encoded expression, store values into the value map
+ DataType storedType = blockValSet.getValueType().getStoredType();
+ switch (storedType) {
+ case INT:
+ int[] intValues = blockValSet.getIntValuesSV();
+ for (int i = 0; i < length; i++) {
+ setValueForGroupKeys(groupByResultHolder, groupKeyArray[i], intValues[i]);
+ }
+ break;
+ case LONG:
+ long[] longValues = blockValSet.getLongValuesSV();
+ for (int i = 0; i < length; i++) {
+ setValueForGroupKeys(groupByResultHolder, groupKeyArray[i], longValues[i]);
+ }
+ break;
+ case FLOAT:
+ float[] floatValues = blockValSet.getFloatValuesSV();
+ for (int i = 0; i < length; i++) {
+ setValueForGroupKeys(groupByResultHolder, groupKeyArray[i], floatValues[i]);
+ }
+ break;
+ case DOUBLE:
+ double[] doubleValues = blockValSet.getDoubleValuesSV();
+ for (int i = 0; i < length; i++) {
+ setValueForGroupKeys(groupByResultHolder, groupKeyArray[i], doubleValues[i]);
+ }
+ break;
+ default:
+ throw new IllegalStateException("Illegal data type for MODE aggregation function: " + storedType);
+ }
+ }
+
+ @Override
+ public void aggregateGroupByMV(int length, int[][] groupKeysArray, GroupByResultHolder groupByResultHolder,
+ Map<ExpressionContext, BlockValSet> blockValSetMap) {
+ BlockValSet blockValSet = blockValSetMap.get(_expression);
+
+ // For dictionary-encoded expression, store dictionary ids into the dictId map
+ Dictionary dictionary = blockValSet.getDictionary();
+ if (dictionary != null) {
+ int[] dictIds = blockValSet.getDictionaryIdsSV();
+ for (int i = 0; i < length; i++) {
+ for (int groupKey : groupKeysArray[i]) {
+ getDictIdCountMap(groupByResultHolder, groupKey, dictionary).merge(dictIds[i], 1, Long::sum);
+ }
+ }
+ return;
+ }
+
+ // For non-dictionary-encoded expression, store values into the value map
+ DataType storedType = blockValSet.getValueType().getStoredType();
+ switch (storedType) {
+ case INT:
+ int[] intValues = blockValSet.getIntValuesSV();
+ for (int i = 0; i < length; i++) {
+ for (int groupKey : groupKeysArray[i]) {
+ setValueForGroupKeys(groupByResultHolder, groupKey, intValues[i]);
+ }
+ }
+ break;
+ case LONG:
+ long[] longValues = blockValSet.getLongValuesSV();
+ for (int i = 0; i < length; i++) {
+ for (int groupKey : groupKeysArray[i]) {
+ setValueForGroupKeys(groupByResultHolder, groupKey, longValues[i]);
+ }
+ }
+ break;
+ case FLOAT:
+ float[] floatValues = blockValSet.getFloatValuesSV();
+ for (int i = 0; i < length; i++) {
+ for (int groupKey : groupKeysArray[i]) {
+ setValueForGroupKeys(groupByResultHolder, groupKey, floatValues[i]);
+ }
+ }
+ break;
+ case DOUBLE:
+ double[] doubleValues = blockValSet.getDoubleValuesSV();
+ for (int i = 0; i < length; i++) {
+ for (int groupKey : groupKeysArray[i]) {
+ setValueForGroupKeys(groupByResultHolder, groupKey, doubleValues[i]);
+ }
+ }
+ break;
+ default:
+ throw new IllegalStateException("Illegal data type for MODE aggregation function: " + storedType);
+ }
+ }
+
+ @Override
+ public Map<? extends Number, Long> extractAggregationResult(AggregationResultHolder aggregationResultHolder) {
+ return extractIntermediateResult(aggregationResultHolder.getResult());
+ }
+
+ @Override
+ public Map<? extends Number, Long> extractGroupByResult(GroupByResultHolder groupByResultHolder, int groupKey) {
+ return extractIntermediateResult(groupByResultHolder.getResult(groupKey));
+ }
+
+ @Override
+ public Map<? extends Number, Long> merge(Map<? extends Number, Long> intermediateResult1,
+ Map<? extends Number, Long> intermediateResult2) {
+ if (intermediateResult1.isEmpty()) {
+ return intermediateResult2;
+ }
+ if (intermediateResult2.isEmpty()) {
+ return intermediateResult1;
+ }
+ if (intermediateResult1 instanceof Int2LongOpenHashMap && intermediateResult2 instanceof Int2LongOpenHashMap) {
+ ((Int2LongOpenHashMap) intermediateResult2).int2LongEntrySet().fastForEach(
+ e -> ((Int2LongOpenHashMap) intermediateResult1).merge(e.getIntKey(), e.getLongValue(), Long::sum));
+ } else if (intermediateResult1 instanceof Long2LongOpenHashMap
+ && intermediateResult2 instanceof Long2LongOpenHashMap) {
+ ((Long2LongOpenHashMap) intermediateResult2).long2LongEntrySet().fastForEach(
+ e -> ((Long2LongOpenHashMap) intermediateResult1).merge(e.getLongKey(), e.getLongValue(), Long::sum));
+ } else if (intermediateResult1 instanceof Float2LongOpenHashMap
+ && intermediateResult2 instanceof Float2LongOpenHashMap) {
+ ((Float2LongOpenHashMap) intermediateResult2).float2LongEntrySet().fastForEach(
+ e -> ((Float2LongOpenHashMap) intermediateResult1).merge(e.getFloatKey(), e.getLongValue(), Long::sum));
+ } else if (intermediateResult1 instanceof Double2LongOpenHashMap
+ && intermediateResult2 instanceof Double2LongOpenHashMap) {
+ ((Double2LongOpenHashMap) intermediateResult2).double2LongEntrySet().fastForEach(
+ e -> ((Double2LongOpenHashMap) intermediateResult1).merge(e.getDoubleKey(), e.getLongValue(), Long::sum));
+ } else {
+ throw new IllegalStateException(
+ "Illegal data type for Intermediate Result of MODE aggregation function: " + intermediateResult1.getClass()
+ .getSimpleName() + ", " + intermediateResult2.getClass().getSimpleName());
+ }
+ return intermediateResult1;
+ }
+
+ @Override
+ public boolean isIntermediateResultComparable() {
+ return false;
+ }
+
+ @Override
+ public ColumnDataType getIntermediateResultColumnType() {
+ return ColumnDataType.OBJECT;
+ }
+
+ @Override
+ public ColumnDataType getFinalResultColumnType() {
+ return ColumnDataType.DOUBLE;
+ }
+
+ @Override
+ public Double extractFinalResult(Map<? extends Number, Long> intermediateResult) {
+ if (intermediateResult.isEmpty()) {
+ return DEFAULT_FINAL_RESULT;
+ } else if (intermediateResult instanceof Int2LongOpenHashMap) {
+ return extractFinalResult((Int2LongOpenHashMap) intermediateResult);
+ } else if (intermediateResult instanceof Long2LongOpenHashMap) {
+ return extractFinalResult((Long2LongOpenHashMap) intermediateResult);
+ } else if (intermediateResult instanceof Float2LongOpenHashMap) {
+ return extractFinalResult((Float2LongOpenHashMap) intermediateResult);
+ } else if (intermediateResult instanceof Double2LongOpenHashMap) {
+ return extractFinalResult((Double2LongOpenHashMap) intermediateResult);
+ } else {
+ throw new IllegalStateException(
+ "Illegal data type for Intermediate Result of MODE aggregation function: " + intermediateResult.getClass()
+ .getSimpleName());
+ }
+ }
+
+ public Double extractFinalResult(Int2LongOpenHashMap intermediateResult) {
+ if (intermediateResult.isEmpty()) {
+ return DEFAULT_FINAL_RESULT;
+ } else {
+ ObjectIterator<Int2LongMap.Entry> iterator = intermediateResult.int2LongEntrySet().fastIterator();
+ Int2LongMap.Entry first = iterator.next();
+ long maxFrequency = first.getLongValue();
+ switch (_multiModeReducerType) {
+ case MIN:
+ double min = first.getIntKey();
+ while (iterator.hasNext()) {
+ Int2LongMap.Entry next = iterator.next();
+ if ((next.getLongValue() > maxFrequency) || (next.getLongValue() == maxFrequency
+ && min > next.getIntKey())) {
+ maxFrequency = next.getLongValue();
+ min = next.getIntKey();
+ }
+ }
+ return min;
+ case MAX:
+ double max = first.getIntKey();
+ while (iterator.hasNext()) {
+ Int2LongMap.Entry next = iterator.next();
+ if ((next.getLongValue() > maxFrequency) || (next.getLongValue() == maxFrequency
+ && max < next.getIntKey())) {
+ maxFrequency = next.getLongValue();
+ max = next.getIntKey();
+ }
+ }
+ return max;
+ case AVG:
+ double sum = first.getIntKey();
+ long count = 1;
+ while (iterator.hasNext()) {
+ Int2LongMap.Entry next = iterator.next();
+ if ((next.getLongValue() > maxFrequency)) {
+ maxFrequency = next.getLongValue();
+ sum = next.getIntKey();
+ count = 1;
+ } else if (next.getLongValue() == maxFrequency) {
+ sum += next.getIntKey();
+ count += 1;
+ }
+ }
+ return sum / count;
+ default:
+ throw new IllegalStateException(
+ "Illegal reducer type for MODE aggregation function: " + _multiModeReducerType);
+ }
+ }
+ }
+
+ public Double extractFinalResult(Long2LongOpenHashMap intermediateResult) {
+ if (intermediateResult.isEmpty()) {
+ return DEFAULT_FINAL_RESULT;
+ } else {
+ ObjectIterator<Long2LongMap.Entry> iterator = intermediateResult.long2LongEntrySet().fastIterator();
+ Long2LongMap.Entry first = iterator.next();
+ long maxFrequency = first.getLongValue();
+ switch (_multiModeReducerType) {
+ case MIN:
+ double min = first.getLongKey();
+ while (iterator.hasNext()) {
+ Long2LongMap.Entry next = iterator.next();
+ if ((next.getLongValue() > maxFrequency) || (next.getLongValue() == maxFrequency
+ && min > next.getLongKey())) {
+ maxFrequency = next.getLongValue();
+ min = next.getLongKey();
+ }
+ }
+ return min;
+ case MAX:
+ double max = first.getLongKey();
+ while (iterator.hasNext()) {
+ Long2LongMap.Entry next = iterator.next();
+ if ((next.getLongValue() > maxFrequency) || (next.getLongValue() == maxFrequency
+ && max < next.getLongKey())) {
+ maxFrequency = next.getLongValue();
+ max = next.getLongKey();
+ }
+ }
+ return max;
+ case AVG:
+ double sum = first.getLongKey();
+ long count = 1;
+ while (iterator.hasNext()) {
+ Long2LongMap.Entry next = iterator.next();
+ if ((next.getLongValue() > maxFrequency)) {
+ maxFrequency = next.getLongValue();
+ sum = next.getLongKey();
+ count = 1;
+ } else if (next.getLongValue() == maxFrequency) {
+ sum += next.getLongKey();
+ count += 1;
+ }
+ }
+ return sum / count;
+ default:
+ throw new IllegalStateException(
+ "Illegal reducer type for MODE aggregation function: " + _multiModeReducerType);
+ }
+ }
+ }
+
+ public Double extractFinalResult(Float2LongOpenHashMap intermediateResult) {
+ if (intermediateResult.isEmpty()) {
+ return DEFAULT_FINAL_RESULT;
+ } else {
+ ObjectIterator<Float2LongMap.Entry> iterator = intermediateResult.float2LongEntrySet().fastIterator();
+ Float2LongMap.Entry first = iterator.next();
+ long maxFrequency = first.getLongValue();
+ switch (_multiModeReducerType) {
+ case MIN:
+ double min = first.getFloatKey();
+ while (iterator.hasNext()) {
+ Float2LongMap.Entry next = iterator.next();
+ if ((next.getLongValue() > maxFrequency) || (next.getLongValue() == maxFrequency
+ && min > next.getFloatKey())) {
+ maxFrequency = next.getLongValue();
+ min = next.getFloatKey();
+ }
+ }
+ return min;
+ case MAX:
+ double max = first.getFloatKey();
+ while (iterator.hasNext()) {
+ Float2LongMap.Entry next = iterator.next();
+ if ((next.getLongValue() > maxFrequency) || (next.getLongValue() == maxFrequency
+ && max < next.getFloatKey())) {
+ maxFrequency = next.getLongValue();
+ max = next.getFloatKey();
+ }
+ }
+ return max;
+ case AVG:
+ double sum = first.getFloatKey();
+ long count = 1;
+ while (iterator.hasNext()) {
+ Float2LongMap.Entry next = iterator.next();
+ if ((next.getLongValue() > maxFrequency)) {
+ maxFrequency = next.getLongValue();
+ sum = next.getFloatKey();
+ count = 1;
+ } else if (next.getLongValue() == maxFrequency) {
+ sum += next.getFloatKey();
+ count += 1;
+ }
+ }
+ return sum / count;
+ default:
+ throw new IllegalStateException(
+ "Illegal reducer type for MODE aggregation function: " + _multiModeReducerType);
+ }
+ }
+ }
+
+ public Double extractFinalResult(Double2LongOpenHashMap intermediateResult) {
+ if (intermediateResult.isEmpty()) {
+ return DEFAULT_FINAL_RESULT;
+ } else {
+ ObjectIterator<Double2LongMap.Entry> iterator = intermediateResult.double2LongEntrySet().fastIterator();
+ Double2LongMap.Entry first = iterator.next();
+ long maxFrequency = first.getLongValue();
+ switch (_multiModeReducerType) {
+ case MIN:
+ double min = first.getDoubleKey();
+ while (iterator.hasNext()) {
+ Double2LongMap.Entry next = iterator.next();
+ if ((next.getLongValue() > maxFrequency) || (next.getLongValue() == maxFrequency
+ && min > next.getDoubleKey())) {
+ maxFrequency = next.getLongValue();
+ min = next.getDoubleKey();
+ }
+ }
+ return min;
+ case MAX:
+ double max = first.getDoubleKey();
+ while (iterator.hasNext()) {
+ Double2LongMap.Entry next = iterator.next();
+ if ((next.getLongValue() > maxFrequency) || (next.getLongValue() == maxFrequency
+ && max < next.getDoubleKey())) {
+ maxFrequency = next.getLongValue();
+ max = next.getDoubleKey();
+ }
+ }
+ return max;
+ case AVG:
+ double sum = first.getDoubleKey();
+ long count = 1;
+ while (iterator.hasNext()) {
+ Double2LongMap.Entry next = iterator.next();
+ if ((next.getLongValue() > maxFrequency)) {
+ maxFrequency = next.getLongValue();
+ sum = next.getDoubleKey();
+ count = 1;
+ } else if (next.getLongValue() == maxFrequency) {
+ sum += next.getDoubleKey();
+ count += 1;
+ }
+ }
+ return sum / count;
+ default:
+ throw new IllegalStateException(
+ "Illegal reducer type for MODE aggregation function: " + _multiModeReducerType);
+ }
+ }
+ }
+
+ private enum MultiModeReducerType {
+ MIN, MAX, AVG
+ }
+
+ private static final class DictIdsWrapper {
+
+ final Dictionary _dictionary;
+ final Int2LongOpenHashMap _dictIdCountMap;
Review comment:
Updated
##########
File path: pinot-core/src/main/java/org/apache/pinot/core/query/aggregation/function/ModeAggregationFunction.java
##########
@@ -0,0 +1,704 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.pinot.core.query.aggregation.function;
+
+import com.google.common.base.Preconditions;
+import it.unimi.dsi.fastutil.doubles.Double2LongMap;
+import it.unimi.dsi.fastutil.doubles.Double2LongOpenHashMap;
+import it.unimi.dsi.fastutil.floats.Float2LongMap;
+import it.unimi.dsi.fastutil.floats.Float2LongOpenHashMap;
+import it.unimi.dsi.fastutil.ints.Int2LongMap;
+import it.unimi.dsi.fastutil.ints.Int2LongMaps;
+import it.unimi.dsi.fastutil.ints.Int2LongOpenHashMap;
+import it.unimi.dsi.fastutil.longs.Long2LongMap;
+import it.unimi.dsi.fastutil.longs.Long2LongOpenHashMap;
+import it.unimi.dsi.fastutil.objects.ObjectIterator;
+import java.util.List;
+import java.util.Map;
+import javax.annotation.Nullable;
+import org.apache.pinot.common.request.context.ExpressionContext;
+import org.apache.pinot.common.utils.DataSchema.ColumnDataType;
+import org.apache.pinot.core.common.BlockValSet;
+import org.apache.pinot.core.query.aggregation.AggregationResultHolder;
+import org.apache.pinot.core.query.aggregation.ObjectAggregationResultHolder;
+import org.apache.pinot.core.query.aggregation.groupby.GroupByResultHolder;
+import org.apache.pinot.core.query.aggregation.groupby.ObjectGroupByResultHolder;
+import org.apache.pinot.segment.spi.AggregationFunctionType;
+import org.apache.pinot.segment.spi.index.reader.Dictionary;
+import org.apache.pinot.spi.data.FieldSpec.DataType;
+
+
+/**
+ * This function is used for Mode calculations.
+ * <p>The function can be used as MODE(expression, multiModeReducerType)
+ * <p>Following arguments are supported:
+ * <ul>
+ * <li>Expression: expression that contains the column to be calculated mode on, can be any Numeric column</li>
+ * <li>MultiModeReducerType (optional): the reducer to use in case of multiple modes present in data</li>
+ * </ul>
+ */
+@SuppressWarnings({"rawtypes", "unchecked"})
+public class ModeAggregationFunction extends BaseSingleInputAggregationFunction<Map<? extends Number, Long>, Double> {
+
+ private static final double DEFAULT_FINAL_RESULT = Double.NEGATIVE_INFINITY;
+
+ private final MultiModeReducerType _multiModeReducerType;
+
+ public ModeAggregationFunction(List<ExpressionContext> arguments) {
+ super(arguments.get(0));
+
+ int numArguments = arguments.size();
+ Preconditions.checkArgument(numArguments <= 2, "Mode expects at most 2 arguments, got: %s", numArguments);
+ if (numArguments > 1) {
+ _multiModeReducerType = MultiModeReducerType.valueOf(arguments.get(1).getLiteral());
+ } else {
+ _multiModeReducerType = MultiModeReducerType.MIN;
+ }
+ }
+
+ /**
+ * Helper method to create a value map for the given value type.
+ */
+ private static Map<? extends Number, Long> getValueMap(DataType valueType) {
+ switch (valueType) {
+ case INT:
+ return new Int2LongOpenHashMap();
+ case LONG:
+ return new Long2LongOpenHashMap();
+ case FLOAT:
+ return new Float2LongOpenHashMap();
+ case DOUBLE:
+ return new Double2LongOpenHashMap();
+ default:
+ throw new IllegalStateException("Illegal data type for MODE aggregation function: " + valueType);
+ }
+ }
+
+ /**
+ * Returns the value map from the result holder or creates a new one if it does not exist.
+ */
+ protected static Map<? extends Number, Long> getValueMap(AggregationResultHolder aggregationResultHolder,
Review comment:
Updated
##########
File path: pinot-core/src/main/java/org/apache/pinot/core/query/aggregation/function/ModeAggregationFunction.java
##########
@@ -0,0 +1,704 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.pinot.core.query.aggregation.function;
+
+import com.google.common.base.Preconditions;
+import it.unimi.dsi.fastutil.doubles.Double2LongMap;
+import it.unimi.dsi.fastutil.doubles.Double2LongOpenHashMap;
+import it.unimi.dsi.fastutil.floats.Float2LongMap;
+import it.unimi.dsi.fastutil.floats.Float2LongOpenHashMap;
+import it.unimi.dsi.fastutil.ints.Int2LongMap;
+import it.unimi.dsi.fastutil.ints.Int2LongMaps;
+import it.unimi.dsi.fastutil.ints.Int2LongOpenHashMap;
+import it.unimi.dsi.fastutil.longs.Long2LongMap;
+import it.unimi.dsi.fastutil.longs.Long2LongOpenHashMap;
+import it.unimi.dsi.fastutil.objects.ObjectIterator;
+import java.util.List;
+import java.util.Map;
+import javax.annotation.Nullable;
+import org.apache.pinot.common.request.context.ExpressionContext;
+import org.apache.pinot.common.utils.DataSchema.ColumnDataType;
+import org.apache.pinot.core.common.BlockValSet;
+import org.apache.pinot.core.query.aggregation.AggregationResultHolder;
+import org.apache.pinot.core.query.aggregation.ObjectAggregationResultHolder;
+import org.apache.pinot.core.query.aggregation.groupby.GroupByResultHolder;
+import org.apache.pinot.core.query.aggregation.groupby.ObjectGroupByResultHolder;
+import org.apache.pinot.segment.spi.AggregationFunctionType;
+import org.apache.pinot.segment.spi.index.reader.Dictionary;
+import org.apache.pinot.spi.data.FieldSpec.DataType;
+
+
+/**
+ * This function is used for Mode calculations.
+ * <p>The function can be used as MODE(expression, multiModeReducerType)
+ * <p>Following arguments are supported:
+ * <ul>
+ * <li>Expression: expression that contains the column to be calculated mode on, can be any Numeric column</li>
+ * <li>MultiModeReducerType (optional): the reducer to use in case of multiple modes present in data</li>
+ * </ul>
+ */
+@SuppressWarnings({"rawtypes", "unchecked"})
+public class ModeAggregationFunction extends BaseSingleInputAggregationFunction<Map<? extends Number, Long>, Double> {
+
+ private static final double DEFAULT_FINAL_RESULT = Double.NEGATIVE_INFINITY;
+
+ private final MultiModeReducerType _multiModeReducerType;
+
+ public ModeAggregationFunction(List<ExpressionContext> arguments) {
+ super(arguments.get(0));
+
+ int numArguments = arguments.size();
+ Preconditions.checkArgument(numArguments <= 2, "Mode expects at most 2 arguments, got: %s", numArguments);
+ if (numArguments > 1) {
+ _multiModeReducerType = MultiModeReducerType.valueOf(arguments.get(1).getLiteral());
+ } else {
+ _multiModeReducerType = MultiModeReducerType.MIN;
+ }
+ }
+
+ /**
+ * Helper method to create a value map for the given value type.
+ */
+ private static Map<? extends Number, Long> getValueMap(DataType valueType) {
+ switch (valueType) {
+ case INT:
+ return new Int2LongOpenHashMap();
+ case LONG:
+ return new Long2LongOpenHashMap();
+ case FLOAT:
+ return new Float2LongOpenHashMap();
+ case DOUBLE:
+ return new Double2LongOpenHashMap();
+ default:
+ throw new IllegalStateException("Illegal data type for MODE aggregation function: " + valueType);
+ }
+ }
+
+ /**
+ * Returns the value map from the result holder or creates a new one if it does not exist.
+ */
+ protected static Map<? extends Number, Long> getValueMap(AggregationResultHolder aggregationResultHolder,
+ DataType valueType) {
+ Map<? extends Number, Long> valueMap = aggregationResultHolder.getResult();
+ if (valueMap == null) {
+ valueMap = getValueMap(valueType);
+ aggregationResultHolder.setValue(valueMap);
+ }
+ return valueMap;
+ }
+
+ /**
+ * Returns the value set for the given group key or creates a new one if it does not exist.
+ */
+ protected static Map<? extends Number, Long> getValueMap(GroupByResultHolder groupByResultHolder, int groupKey,
Review comment:
Updated
##########
File path: pinot-core/src/main/java/org/apache/pinot/core/query/aggregation/function/ModeAggregationFunction.java
##########
@@ -0,0 +1,704 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.pinot.core.query.aggregation.function;
+
+import com.google.common.base.Preconditions;
+import it.unimi.dsi.fastutil.doubles.Double2LongMap;
+import it.unimi.dsi.fastutil.doubles.Double2LongOpenHashMap;
+import it.unimi.dsi.fastutil.floats.Float2LongMap;
+import it.unimi.dsi.fastutil.floats.Float2LongOpenHashMap;
+import it.unimi.dsi.fastutil.ints.Int2LongMap;
+import it.unimi.dsi.fastutil.ints.Int2LongMaps;
+import it.unimi.dsi.fastutil.ints.Int2LongOpenHashMap;
+import it.unimi.dsi.fastutil.longs.Long2LongMap;
+import it.unimi.dsi.fastutil.longs.Long2LongOpenHashMap;
+import it.unimi.dsi.fastutil.objects.ObjectIterator;
+import java.util.List;
+import java.util.Map;
+import javax.annotation.Nullable;
+import org.apache.pinot.common.request.context.ExpressionContext;
+import org.apache.pinot.common.utils.DataSchema.ColumnDataType;
+import org.apache.pinot.core.common.BlockValSet;
+import org.apache.pinot.core.query.aggregation.AggregationResultHolder;
+import org.apache.pinot.core.query.aggregation.ObjectAggregationResultHolder;
+import org.apache.pinot.core.query.aggregation.groupby.GroupByResultHolder;
+import org.apache.pinot.core.query.aggregation.groupby.ObjectGroupByResultHolder;
+import org.apache.pinot.segment.spi.AggregationFunctionType;
+import org.apache.pinot.segment.spi.index.reader.Dictionary;
+import org.apache.pinot.spi.data.FieldSpec.DataType;
+
+
+/**
+ * This function is used for Mode calculations.
+ * <p>The function can be used as MODE(expression, multiModeReducerType)
+ * <p>Following arguments are supported:
+ * <ul>
+ * <li>Expression: expression that contains the column to be calculated mode on, can be any Numeric column</li>
+ * <li>MultiModeReducerType (optional): the reducer to use in case of multiple modes present in data</li>
+ * </ul>
+ */
+@SuppressWarnings({"rawtypes", "unchecked"})
+public class ModeAggregationFunction extends BaseSingleInputAggregationFunction<Map<? extends Number, Long>, Double> {
+
+ private static final double DEFAULT_FINAL_RESULT = Double.NEGATIVE_INFINITY;
+
+ private final MultiModeReducerType _multiModeReducerType;
+
+ public ModeAggregationFunction(List<ExpressionContext> arguments) {
+ super(arguments.get(0));
+
+ int numArguments = arguments.size();
+ Preconditions.checkArgument(numArguments <= 2, "Mode expects at most 2 arguments, got: %s", numArguments);
+ if (numArguments > 1) {
+ _multiModeReducerType = MultiModeReducerType.valueOf(arguments.get(1).getLiteral());
+ } else {
+ _multiModeReducerType = MultiModeReducerType.MIN;
+ }
+ }
+
+ /**
+ * Helper method to create a value map for the given value type.
+ */
+ private static Map<? extends Number, Long> getValueMap(DataType valueType) {
+ switch (valueType) {
+ case INT:
+ return new Int2LongOpenHashMap();
+ case LONG:
+ return new Long2LongOpenHashMap();
+ case FLOAT:
+ return new Float2LongOpenHashMap();
+ case DOUBLE:
+ return new Double2LongOpenHashMap();
+ default:
+ throw new IllegalStateException("Illegal data type for MODE aggregation function: " + valueType);
+ }
+ }
+
+ /**
+ * Returns the value map from the result holder or creates a new one if it does not exist.
+ */
+ protected static Map<? extends Number, Long> getValueMap(AggregationResultHolder aggregationResultHolder,
+ DataType valueType) {
+ Map<? extends Number, Long> valueMap = aggregationResultHolder.getResult();
+ if (valueMap == null) {
+ valueMap = getValueMap(valueType);
+ aggregationResultHolder.setValue(valueMap);
+ }
+ return valueMap;
+ }
+
+ /**
+ * Returns the value set for the given group key or creates a new one if it does not exist.
+ */
+ protected static Map<? extends Number, Long> getValueMap(GroupByResultHolder groupByResultHolder, int groupKey,
+ DataType valueType) {
+ Map<? extends Number, Long> valueMap = groupByResultHolder.getResult(groupKey);
+ if (valueMap == null) {
+ valueMap = getValueMap(valueType);
+ groupByResultHolder.setValueForKey(groupKey, valueMap);
+ }
+ return valueMap;
+ }
+
+ /**
+ * Helper method to set INT value for the given group keys into the result holder.
+ */
+ private static void setValueForGroupKeys(GroupByResultHolder groupByResultHolder, int groupKey, int value) {
+ ((Int2LongOpenHashMap) getValueMap(groupByResultHolder, groupKey, DataType.INT)).merge(value, 1, Long::sum);
Review comment:
Updated
##########
File path: pinot-core/src/main/java/org/apache/pinot/core/query/aggregation/function/ModeAggregationFunction.java
##########
@@ -0,0 +1,704 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.pinot.core.query.aggregation.function;
+
+import com.google.common.base.Preconditions;
+import it.unimi.dsi.fastutil.doubles.Double2LongMap;
+import it.unimi.dsi.fastutil.doubles.Double2LongOpenHashMap;
+import it.unimi.dsi.fastutil.floats.Float2LongMap;
+import it.unimi.dsi.fastutil.floats.Float2LongOpenHashMap;
+import it.unimi.dsi.fastutil.ints.Int2LongMap;
+import it.unimi.dsi.fastutil.ints.Int2LongMaps;
+import it.unimi.dsi.fastutil.ints.Int2LongOpenHashMap;
+import it.unimi.dsi.fastutil.longs.Long2LongMap;
+import it.unimi.dsi.fastutil.longs.Long2LongOpenHashMap;
+import it.unimi.dsi.fastutil.objects.ObjectIterator;
+import java.util.List;
+import java.util.Map;
+import javax.annotation.Nullable;
+import org.apache.pinot.common.request.context.ExpressionContext;
+import org.apache.pinot.common.utils.DataSchema.ColumnDataType;
+import org.apache.pinot.core.common.BlockValSet;
+import org.apache.pinot.core.query.aggregation.AggregationResultHolder;
+import org.apache.pinot.core.query.aggregation.ObjectAggregationResultHolder;
+import org.apache.pinot.core.query.aggregation.groupby.GroupByResultHolder;
+import org.apache.pinot.core.query.aggregation.groupby.ObjectGroupByResultHolder;
+import org.apache.pinot.segment.spi.AggregationFunctionType;
+import org.apache.pinot.segment.spi.index.reader.Dictionary;
+import org.apache.pinot.spi.data.FieldSpec.DataType;
+
+
+/**
+ * This function is used for Mode calculations.
+ * <p>The function can be used as MODE(expression, multiModeReducerType)
+ * <p>Following arguments are supported:
+ * <ul>
+ * <li>Expression: expression that contains the column to be calculated mode on, can be any Numeric column</li>
+ * <li>MultiModeReducerType (optional): the reducer to use in case of multiple modes present in data</li>
+ * </ul>
+ */
+@SuppressWarnings({"rawtypes", "unchecked"})
+public class ModeAggregationFunction extends BaseSingleInputAggregationFunction<Map<? extends Number, Long>, Double> {
+
+ private static final double DEFAULT_FINAL_RESULT = Double.NEGATIVE_INFINITY;
+
+ private final MultiModeReducerType _multiModeReducerType;
+
+ public ModeAggregationFunction(List<ExpressionContext> arguments) {
+ super(arguments.get(0));
+
+ int numArguments = arguments.size();
+ Preconditions.checkArgument(numArguments <= 2, "Mode expects at most 2 arguments, got: %s", numArguments);
+ if (numArguments > 1) {
+ _multiModeReducerType = MultiModeReducerType.valueOf(arguments.get(1).getLiteral());
+ } else {
+ _multiModeReducerType = MultiModeReducerType.MIN;
+ }
+ }
+
+ /**
+ * Helper method to create a value map for the given value type.
+ */
+ private static Map<? extends Number, Long> getValueMap(DataType valueType) {
+ switch (valueType) {
+ case INT:
+ return new Int2LongOpenHashMap();
+ case LONG:
+ return new Long2LongOpenHashMap();
+ case FLOAT:
+ return new Float2LongOpenHashMap();
+ case DOUBLE:
+ return new Double2LongOpenHashMap();
+ default:
+ throw new IllegalStateException("Illegal data type for MODE aggregation function: " + valueType);
+ }
+ }
+
+ /**
+ * Returns the value map from the result holder or creates a new one if it does not exist.
+ */
+ protected static Map<? extends Number, Long> getValueMap(AggregationResultHolder aggregationResultHolder,
+ DataType valueType) {
+ Map<? extends Number, Long> valueMap = aggregationResultHolder.getResult();
+ if (valueMap == null) {
+ valueMap = getValueMap(valueType);
+ aggregationResultHolder.setValue(valueMap);
+ }
+ return valueMap;
+ }
+
+ /**
+ * Returns the value set for the given group key or creates a new one if it does not exist.
+ */
+ protected static Map<? extends Number, Long> getValueMap(GroupByResultHolder groupByResultHolder, int groupKey,
+ DataType valueType) {
+ Map<? extends Number, Long> valueMap = groupByResultHolder.getResult(groupKey);
+ if (valueMap == null) {
+ valueMap = getValueMap(valueType);
+ groupByResultHolder.setValueForKey(groupKey, valueMap);
+ }
+ return valueMap;
+ }
+
+ /**
+ * Helper method to set INT value for the given group keys into the result holder.
+ */
+ private static void setValueForGroupKeys(GroupByResultHolder groupByResultHolder, int groupKey, int value) {
+ ((Int2LongOpenHashMap) getValueMap(groupByResultHolder, groupKey, DataType.INT)).merge(value, 1, Long::sum);
+ }
+
+ /**
+ * Helper method to set LONG value for the given group keys into the result holder.
+ */
+ private static void setValueForGroupKeys(GroupByResultHolder groupByResultHolder, int groupKey, long value) {
+ ((Long2LongOpenHashMap) getValueMap(groupByResultHolder, groupKey, DataType.LONG)).merge(value, 1, Long::sum);
+ }
+
+ /**
+ * Helper method to set FLOAT value for the given group keys into the result holder.
+ */
+ private static void setValueForGroupKeys(GroupByResultHolder groupByResultHolder, int groupKey, float value) {
+ ((Float2LongOpenHashMap) getValueMap(groupByResultHolder, groupKey, DataType.FLOAT)).merge(value, 1, Long::sum);
+ }
+
+ /**
+ * Helper method to set DOUBLE value for the given group keys into the result holder.
+ */
+ private static void setValueForGroupKeys(GroupByResultHolder groupByResultHolder, int groupKey, double value) {
+ ((Double2LongOpenHashMap) getValueMap(groupByResultHolder, groupKey, DataType.DOUBLE)).merge(value, 1, Long::sum);
+ }
+
+ /**
+ * Returns the dictionary id count map from the result holder or creates a new one if it does not exist.
+ */
+ protected static Int2LongOpenHashMap getDictIdCountMap(AggregationResultHolder aggregationResultHolder,
+ Dictionary dictionary) {
+ ModeAggregationFunction.DictIdsWrapper dictIdsWrapper = aggregationResultHolder.getResult();
+ if (dictIdsWrapper == null) {
+ dictIdsWrapper = new ModeAggregationFunction.DictIdsWrapper(dictionary);
+ aggregationResultHolder.setValue(dictIdsWrapper);
+ }
+ return dictIdsWrapper._dictIdCountMap;
+ }
+
+ /**
+ * Returns the dictionary id count map for the given group key or creates a new one if it does not exist.
+ */
+ protected static Int2LongOpenHashMap getDictIdCountMap(GroupByResultHolder groupByResultHolder, int groupKey,
+ Dictionary dictionary) {
+ ModeAggregationFunction.DictIdsWrapper dictIdsWrapper = groupByResultHolder.getResult(groupKey);
+ if (dictIdsWrapper == null) {
+ dictIdsWrapper = new ModeAggregationFunction.DictIdsWrapper(dictionary);
+ groupByResultHolder.setValueForKey(groupKey, dictIdsWrapper);
+ }
+ return dictIdsWrapper._dictIdCountMap;
+ }
+
+ /**
+ * Helper method to read dictionary and convert dictionary ids to values for dictionary-encoded expression.
+ */
+ private static Map<? extends Number, Long> convertToValueMap(DictIdsWrapper dictIdsWrapper) {
+ Dictionary dictionary = dictIdsWrapper._dictionary;
+ Int2LongOpenHashMap dictIdCountMap = dictIdsWrapper._dictIdCountMap;
+ int numValues = dictIdCountMap.size();
+ ObjectIterator<Int2LongMap.Entry> iterator = Int2LongMaps.fastIterator(dictIdCountMap);
+ DataType storedType = dictionary.getValueType();
+ switch (storedType) {
+ case INT:
+ Int2LongOpenHashMap intValueMap = new Int2LongOpenHashMap(numValues);
+ while (iterator.hasNext()) {
+ Int2LongMap.Entry next = iterator.next();
+ intValueMap.put(dictionary.getIntValue(next.getIntKey()), next.getLongValue());
+ }
+ return intValueMap;
+ case LONG:
+ Long2LongOpenHashMap longValueMap = new Long2LongOpenHashMap(numValues);
+ while (iterator.hasNext()) {
+ Int2LongMap.Entry next = iterator.next();
+ longValueMap.put(dictionary.getLongValue(next.getIntKey()), next.getLongValue());
+ }
+ return longValueMap;
+ case FLOAT:
+ Float2LongOpenHashMap floatValueMap = new Float2LongOpenHashMap(numValues);
+ while (iterator.hasNext()) {
+ Int2LongMap.Entry next = iterator.next();
+ floatValueMap.put(dictionary.getFloatValue(next.getIntKey()), next.getLongValue());
+ }
+ return floatValueMap;
+ case DOUBLE:
+ Double2LongOpenHashMap doubleValueMap = new Double2LongOpenHashMap(numValues);
+ while (iterator.hasNext()) {
+ Int2LongMap.Entry next = iterator.next();
+ doubleValueMap.put(dictionary.getFloatValue(next.getIntKey()), next.getLongValue());
Review comment:
Updated
##########
File path: pinot-core/src/main/java/org/apache/pinot/core/query/aggregation/function/ModeAggregationFunction.java
##########
@@ -0,0 +1,704 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.pinot.core.query.aggregation.function;
+
+import com.google.common.base.Preconditions;
+import it.unimi.dsi.fastutil.doubles.Double2LongMap;
+import it.unimi.dsi.fastutil.doubles.Double2LongOpenHashMap;
+import it.unimi.dsi.fastutil.floats.Float2LongMap;
+import it.unimi.dsi.fastutil.floats.Float2LongOpenHashMap;
+import it.unimi.dsi.fastutil.ints.Int2LongMap;
+import it.unimi.dsi.fastutil.ints.Int2LongMaps;
+import it.unimi.dsi.fastutil.ints.Int2LongOpenHashMap;
+import it.unimi.dsi.fastutil.longs.Long2LongMap;
+import it.unimi.dsi.fastutil.longs.Long2LongOpenHashMap;
+import it.unimi.dsi.fastutil.objects.ObjectIterator;
+import java.util.List;
+import java.util.Map;
+import javax.annotation.Nullable;
+import org.apache.pinot.common.request.context.ExpressionContext;
+import org.apache.pinot.common.utils.DataSchema.ColumnDataType;
+import org.apache.pinot.core.common.BlockValSet;
+import org.apache.pinot.core.query.aggregation.AggregationResultHolder;
+import org.apache.pinot.core.query.aggregation.ObjectAggregationResultHolder;
+import org.apache.pinot.core.query.aggregation.groupby.GroupByResultHolder;
+import org.apache.pinot.core.query.aggregation.groupby.ObjectGroupByResultHolder;
+import org.apache.pinot.segment.spi.AggregationFunctionType;
+import org.apache.pinot.segment.spi.index.reader.Dictionary;
+import org.apache.pinot.spi.data.FieldSpec.DataType;
+
+
+/**
+ * This function is used for Mode calculations.
+ * <p>The function can be used as MODE(expression, multiModeReducerType)
+ * <p>Following arguments are supported:
+ * <ul>
+ * <li>Expression: expression that contains the column to be calculated mode on, can be any Numeric column</li>
+ * <li>MultiModeReducerType (optional): the reducer to use in case of multiple modes present in data</li>
+ * </ul>
+ */
+@SuppressWarnings({"rawtypes", "unchecked"})
+public class ModeAggregationFunction extends BaseSingleInputAggregationFunction<Map<? extends Number, Long>, Double> {
+
+ private static final double DEFAULT_FINAL_RESULT = Double.NEGATIVE_INFINITY;
+
+ private final MultiModeReducerType _multiModeReducerType;
+
+ public ModeAggregationFunction(List<ExpressionContext> arguments) {
+ super(arguments.get(0));
+
+ int numArguments = arguments.size();
+ Preconditions.checkArgument(numArguments <= 2, "Mode expects at most 2 arguments, got: %s", numArguments);
+ if (numArguments > 1) {
+ _multiModeReducerType = MultiModeReducerType.valueOf(arguments.get(1).getLiteral());
+ } else {
+ _multiModeReducerType = MultiModeReducerType.MIN;
+ }
+ }
+
+ /**
+ * Helper method to create a value map for the given value type.
+ */
+ private static Map<? extends Number, Long> getValueMap(DataType valueType) {
+ switch (valueType) {
+ case INT:
+ return new Int2LongOpenHashMap();
+ case LONG:
+ return new Long2LongOpenHashMap();
+ case FLOAT:
+ return new Float2LongOpenHashMap();
+ case DOUBLE:
+ return new Double2LongOpenHashMap();
+ default:
+ throw new IllegalStateException("Illegal data type for MODE aggregation function: " + valueType);
+ }
+ }
+
+ /**
+ * Returns the value map from the result holder or creates a new one if it does not exist.
+ */
+ protected static Map<? extends Number, Long> getValueMap(AggregationResultHolder aggregationResultHolder,
+ DataType valueType) {
+ Map<? extends Number, Long> valueMap = aggregationResultHolder.getResult();
+ if (valueMap == null) {
+ valueMap = getValueMap(valueType);
+ aggregationResultHolder.setValue(valueMap);
+ }
+ return valueMap;
+ }
+
+ /**
+ * Returns the value set for the given group key or creates a new one if it does not exist.
+ */
+ protected static Map<? extends Number, Long> getValueMap(GroupByResultHolder groupByResultHolder, int groupKey,
+ DataType valueType) {
+ Map<? extends Number, Long> valueMap = groupByResultHolder.getResult(groupKey);
+ if (valueMap == null) {
+ valueMap = getValueMap(valueType);
+ groupByResultHolder.setValueForKey(groupKey, valueMap);
+ }
+ return valueMap;
+ }
+
+ /**
+ * Helper method to set INT value for the given group keys into the result holder.
+ */
+ private static void setValueForGroupKeys(GroupByResultHolder groupByResultHolder, int groupKey, int value) {
+ ((Int2LongOpenHashMap) getValueMap(groupByResultHolder, groupKey, DataType.INT)).merge(value, 1, Long::sum);
+ }
+
+ /**
+ * Helper method to set LONG value for the given group keys into the result holder.
+ */
+ private static void setValueForGroupKeys(GroupByResultHolder groupByResultHolder, int groupKey, long value) {
+ ((Long2LongOpenHashMap) getValueMap(groupByResultHolder, groupKey, DataType.LONG)).merge(value, 1, Long::sum);
+ }
+
+ /**
+ * Helper method to set FLOAT value for the given group keys into the result holder.
+ */
+ private static void setValueForGroupKeys(GroupByResultHolder groupByResultHolder, int groupKey, float value) {
+ ((Float2LongOpenHashMap) getValueMap(groupByResultHolder, groupKey, DataType.FLOAT)).merge(value, 1, Long::sum);
+ }
+
+ /**
+ * Helper method to set DOUBLE value for the given group keys into the result holder.
+ */
+ private static void setValueForGroupKeys(GroupByResultHolder groupByResultHolder, int groupKey, double value) {
+ ((Double2LongOpenHashMap) getValueMap(groupByResultHolder, groupKey, DataType.DOUBLE)).merge(value, 1, Long::sum);
+ }
+
+ /**
+ * Returns the dictionary id count map from the result holder or creates a new one if it does not exist.
+ */
+ protected static Int2LongOpenHashMap getDictIdCountMap(AggregationResultHolder aggregationResultHolder,
+ Dictionary dictionary) {
+ ModeAggregationFunction.DictIdsWrapper dictIdsWrapper = aggregationResultHolder.getResult();
+ if (dictIdsWrapper == null) {
+ dictIdsWrapper = new ModeAggregationFunction.DictIdsWrapper(dictionary);
+ aggregationResultHolder.setValue(dictIdsWrapper);
+ }
+ return dictIdsWrapper._dictIdCountMap;
+ }
+
+ /**
+ * Returns the dictionary id count map for the given group key or creates a new one if it does not exist.
+ */
+ protected static Int2LongOpenHashMap getDictIdCountMap(GroupByResultHolder groupByResultHolder, int groupKey,
+ Dictionary dictionary) {
+ ModeAggregationFunction.DictIdsWrapper dictIdsWrapper = groupByResultHolder.getResult(groupKey);
+ if (dictIdsWrapper == null) {
+ dictIdsWrapper = new ModeAggregationFunction.DictIdsWrapper(dictionary);
+ groupByResultHolder.setValueForKey(groupKey, dictIdsWrapper);
+ }
+ return dictIdsWrapper._dictIdCountMap;
+ }
+
+ /**
+ * Helper method to read dictionary and convert dictionary ids to values for dictionary-encoded expression.
+ */
+ private static Map<? extends Number, Long> convertToValueMap(DictIdsWrapper dictIdsWrapper) {
+ Dictionary dictionary = dictIdsWrapper._dictionary;
+ Int2LongOpenHashMap dictIdCountMap = dictIdsWrapper._dictIdCountMap;
+ int numValues = dictIdCountMap.size();
+ ObjectIterator<Int2LongMap.Entry> iterator = Int2LongMaps.fastIterator(dictIdCountMap);
+ DataType storedType = dictionary.getValueType();
+ switch (storedType) {
+ case INT:
+ Int2LongOpenHashMap intValueMap = new Int2LongOpenHashMap(numValues);
+ while (iterator.hasNext()) {
+ Int2LongMap.Entry next = iterator.next();
+ intValueMap.put(dictionary.getIntValue(next.getIntKey()), next.getLongValue());
+ }
+ return intValueMap;
+ case LONG:
+ Long2LongOpenHashMap longValueMap = new Long2LongOpenHashMap(numValues);
+ while (iterator.hasNext()) {
+ Int2LongMap.Entry next = iterator.next();
+ longValueMap.put(dictionary.getLongValue(next.getIntKey()), next.getLongValue());
+ }
+ return longValueMap;
+ case FLOAT:
+ Float2LongOpenHashMap floatValueMap = new Float2LongOpenHashMap(numValues);
+ while (iterator.hasNext()) {
+ Int2LongMap.Entry next = iterator.next();
+ floatValueMap.put(dictionary.getFloatValue(next.getIntKey()), next.getLongValue());
+ }
+ return floatValueMap;
+ case DOUBLE:
+ Double2LongOpenHashMap doubleValueMap = new Double2LongOpenHashMap(numValues);
+ while (iterator.hasNext()) {
+ Int2LongMap.Entry next = iterator.next();
+ doubleValueMap.put(dictionary.getFloatValue(next.getIntKey()), next.getLongValue());
+ }
+ return doubleValueMap;
+ default:
+ throw new IllegalStateException("Illegal data type for MODE aggregation function: " + storedType);
+ }
+ }
+
+ /**
+ * Helper method to extract segment level intermediate result from the inner segment result.
+ */
+ private static Map<? extends Number, Long> extractIntermediateResult(@Nullable Object result) {
+ if (result == null) {
+ // NOTE: Return an empty Int2LongOpenHashMap for empty result.
+ return new Int2LongOpenHashMap();
+ }
+
+ if (result instanceof DictIdsWrapper) {
+ // For dictionary-encoded expression, convert dictionary ids to values
+ return convertToValueMap((DictIdsWrapper) result);
+ }
+ assert result instanceof Map;
+ // For non-dictionary-encoded expression, directly return the value set
+ return (Map) result;
+ }
+
+ @Override
+ public AggregationFunctionType getType() {
+ return AggregationFunctionType.MODE;
+ }
+
+ @Override
+ public AggregationResultHolder createAggregationResultHolder() {
+ return new ObjectAggregationResultHolder();
+ }
+
+ @Override
+ public GroupByResultHolder createGroupByResultHolder(int initialCapacity, int maxCapacity) {
+ return new ObjectGroupByResultHolder(initialCapacity, maxCapacity);
+ }
+
+ @Override
+ public void aggregate(int length, AggregationResultHolder aggregationResultHolder,
+ Map<ExpressionContext, BlockValSet> blockValSetMap) {
+ BlockValSet blockValSet = blockValSetMap.get(_expression);
+
+ // For dictionary-encoded expression, store dictionary ids into the dictId map
+ Dictionary dictionary = blockValSet.getDictionary();
+ if (dictionary != null) {
+ int[] dictIds = blockValSet.getDictionaryIdsSV();
+ Int2LongOpenHashMap dictIdValueMap = getDictIdCountMap(aggregationResultHolder, dictionary);
+ for (int i = 0; i < length; i++) {
+ dictIdValueMap.merge(dictIds[i], 1, Long::sum);
+ }
+ return;
+ }
+
+ // For non-dictionary-encoded expression, store values into the value map
+ DataType storedType = blockValSet.getValueType().getStoredType();
+ Map<? extends Number, Long> valueMap = getValueMap(aggregationResultHolder, storedType);
+ switch (storedType) {
+ case INT:
+ Int2LongOpenHashMap intMap = (Int2LongOpenHashMap) valueMap;
+ int[] intValues = blockValSet.getIntValuesSV();
+ for (int i = 0; i < length; i++) {
+ intMap.merge(intValues[i], 1, Long::sum);
+ }
+ break;
+ case LONG:
+ Long2LongOpenHashMap longMap = (Long2LongOpenHashMap) valueMap;
+ long[] longValues = blockValSet.getLongValuesSV();
+ for (int i = 0; i < length; i++) {
+ longMap.merge(longValues[i], 1, Long::sum);
+ }
+ break;
+ case FLOAT:
+ Float2LongOpenHashMap floatMap = (Float2LongOpenHashMap) valueMap;
+ float[] floatValues = blockValSet.getFloatValuesSV();
+ for (int i = 0; i < length; i++) {
+ floatMap.merge(floatValues[i], 1, Long::sum);
+ }
+ break;
+ case DOUBLE:
+ Double2LongOpenHashMap doubleMap = (Double2LongOpenHashMap) valueMap;
+ double[] doubleValues = blockValSet.getDoubleValuesSV();
+ for (int i = 0; i < length; i++) {
+ doubleMap.merge(doubleValues[i], 1, Long::sum);
+ }
+ break;
+ default:
+ throw new IllegalStateException("Illegal data type for MODE aggregation function: " + storedType);
+ }
+ }
+
+ @Override
+ public void aggregateGroupBySV(int length, int[] groupKeyArray, GroupByResultHolder groupByResultHolder,
+ Map<ExpressionContext, BlockValSet> blockValSetMap) {
+ BlockValSet blockValSet = blockValSetMap.get(_expression);
+
+ // For dictionary-encoded expression, store dictionary ids into the dictId map
+ Dictionary dictionary = blockValSet.getDictionary();
+ if (dictionary != null) {
+ int[] dictIds = blockValSet.getDictionaryIdsSV();
+ for (int i = 0; i < length; i++) {
+ getDictIdCountMap(groupByResultHolder, groupKeyArray[i], dictionary).merge(dictIds[i], 1, Long::sum);
+ }
+ return;
+ }
+
+ // For non-dictionary-encoded expression, store values into the value map
+ DataType storedType = blockValSet.getValueType().getStoredType();
+ switch (storedType) {
+ case INT:
+ int[] intValues = blockValSet.getIntValuesSV();
+ for (int i = 0; i < length; i++) {
+ setValueForGroupKeys(groupByResultHolder, groupKeyArray[i], intValues[i]);
+ }
+ break;
+ case LONG:
+ long[] longValues = blockValSet.getLongValuesSV();
+ for (int i = 0; i < length; i++) {
+ setValueForGroupKeys(groupByResultHolder, groupKeyArray[i], longValues[i]);
+ }
+ break;
+ case FLOAT:
+ float[] floatValues = blockValSet.getFloatValuesSV();
+ for (int i = 0; i < length; i++) {
+ setValueForGroupKeys(groupByResultHolder, groupKeyArray[i], floatValues[i]);
+ }
+ break;
+ case DOUBLE:
+ double[] doubleValues = blockValSet.getDoubleValuesSV();
+ for (int i = 0; i < length; i++) {
+ setValueForGroupKeys(groupByResultHolder, groupKeyArray[i], doubleValues[i]);
+ }
+ break;
+ default:
+ throw new IllegalStateException("Illegal data type for MODE aggregation function: " + storedType);
+ }
+ }
+
+ @Override
+ public void aggregateGroupByMV(int length, int[][] groupKeysArray, GroupByResultHolder groupByResultHolder,
+ Map<ExpressionContext, BlockValSet> blockValSetMap) {
+ BlockValSet blockValSet = blockValSetMap.get(_expression);
+
+ // For dictionary-encoded expression, store dictionary ids into the dictId map
+ Dictionary dictionary = blockValSet.getDictionary();
+ if (dictionary != null) {
+ int[] dictIds = blockValSet.getDictionaryIdsSV();
+ for (int i = 0; i < length; i++) {
+ for (int groupKey : groupKeysArray[i]) {
+ getDictIdCountMap(groupByResultHolder, groupKey, dictionary).merge(dictIds[i], 1, Long::sum);
+ }
+ }
+ return;
+ }
+
+ // For non-dictionary-encoded expression, store values into the value map
+ DataType storedType = blockValSet.getValueType().getStoredType();
+ switch (storedType) {
+ case INT:
+ int[] intValues = blockValSet.getIntValuesSV();
+ for (int i = 0; i < length; i++) {
+ for (int groupKey : groupKeysArray[i]) {
+ setValueForGroupKeys(groupByResultHolder, groupKey, intValues[i]);
+ }
+ }
+ break;
+ case LONG:
+ long[] longValues = blockValSet.getLongValuesSV();
+ for (int i = 0; i < length; i++) {
+ for (int groupKey : groupKeysArray[i]) {
+ setValueForGroupKeys(groupByResultHolder, groupKey, longValues[i]);
+ }
+ }
+ break;
+ case FLOAT:
+ float[] floatValues = blockValSet.getFloatValuesSV();
+ for (int i = 0; i < length; i++) {
+ for (int groupKey : groupKeysArray[i]) {
+ setValueForGroupKeys(groupByResultHolder, groupKey, floatValues[i]);
+ }
+ }
+ break;
+ case DOUBLE:
+ double[] doubleValues = blockValSet.getDoubleValuesSV();
+ for (int i = 0; i < length; i++) {
+ for (int groupKey : groupKeysArray[i]) {
+ setValueForGroupKeys(groupByResultHolder, groupKey, doubleValues[i]);
+ }
+ }
+ break;
+ default:
+ throw new IllegalStateException("Illegal data type for MODE aggregation function: " + storedType);
+ }
+ }
+
+ @Override
+ public Map<? extends Number, Long> extractAggregationResult(AggregationResultHolder aggregationResultHolder) {
+ return extractIntermediateResult(aggregationResultHolder.getResult());
+ }
+
+ @Override
+ public Map<? extends Number, Long> extractGroupByResult(GroupByResultHolder groupByResultHolder, int groupKey) {
+ return extractIntermediateResult(groupByResultHolder.getResult(groupKey));
+ }
+
+ @Override
+ public Map<? extends Number, Long> merge(Map<? extends Number, Long> intermediateResult1,
+ Map<? extends Number, Long> intermediateResult2) {
+ if (intermediateResult1.isEmpty()) {
+ return intermediateResult2;
+ }
+ if (intermediateResult2.isEmpty()) {
+ return intermediateResult1;
+ }
+ if (intermediateResult1 instanceof Int2LongOpenHashMap && intermediateResult2 instanceof Int2LongOpenHashMap) {
+ ((Int2LongOpenHashMap) intermediateResult2).int2LongEntrySet().fastForEach(
+ e -> ((Int2LongOpenHashMap) intermediateResult1).merge(e.getIntKey(), e.getLongValue(), Long::sum));
+ } else if (intermediateResult1 instanceof Long2LongOpenHashMap
+ && intermediateResult2 instanceof Long2LongOpenHashMap) {
+ ((Long2LongOpenHashMap) intermediateResult2).long2LongEntrySet().fastForEach(
+ e -> ((Long2LongOpenHashMap) intermediateResult1).merge(e.getLongKey(), e.getLongValue(), Long::sum));
+ } else if (intermediateResult1 instanceof Float2LongOpenHashMap
+ && intermediateResult2 instanceof Float2LongOpenHashMap) {
+ ((Float2LongOpenHashMap) intermediateResult2).float2LongEntrySet().fastForEach(
+ e -> ((Float2LongOpenHashMap) intermediateResult1).merge(e.getFloatKey(), e.getLongValue(), Long::sum));
+ } else if (intermediateResult1 instanceof Double2LongOpenHashMap
+ && intermediateResult2 instanceof Double2LongOpenHashMap) {
+ ((Double2LongOpenHashMap) intermediateResult2).double2LongEntrySet().fastForEach(
+ e -> ((Double2LongOpenHashMap) intermediateResult1).merge(e.getDoubleKey(), e.getLongValue(), Long::sum));
+ } else {
+ throw new IllegalStateException(
+ "Illegal data type for Intermediate Result of MODE aggregation function: " + intermediateResult1.getClass()
+ .getSimpleName() + ", " + intermediateResult2.getClass().getSimpleName());
+ }
+ return intermediateResult1;
+ }
+
+ @Override
+ public boolean isIntermediateResultComparable() {
+ return false;
+ }
+
+ @Override
+ public ColumnDataType getIntermediateResultColumnType() {
+ return ColumnDataType.OBJECT;
+ }
+
+ @Override
+ public ColumnDataType getFinalResultColumnType() {
+ return ColumnDataType.DOUBLE;
+ }
+
+ @Override
+ public Double extractFinalResult(Map<? extends Number, Long> intermediateResult) {
+ if (intermediateResult.isEmpty()) {
+ return DEFAULT_FINAL_RESULT;
+ } else if (intermediateResult instanceof Int2LongOpenHashMap) {
+ return extractFinalResult((Int2LongOpenHashMap) intermediateResult);
+ } else if (intermediateResult instanceof Long2LongOpenHashMap) {
+ return extractFinalResult((Long2LongOpenHashMap) intermediateResult);
+ } else if (intermediateResult instanceof Float2LongOpenHashMap) {
+ return extractFinalResult((Float2LongOpenHashMap) intermediateResult);
+ } else if (intermediateResult instanceof Double2LongOpenHashMap) {
+ return extractFinalResult((Double2LongOpenHashMap) intermediateResult);
+ } else {
+ throw new IllegalStateException(
+ "Illegal data type for Intermediate Result of MODE aggregation function: " + intermediateResult.getClass()
+ .getSimpleName());
+ }
+ }
+
+ public Double extractFinalResult(Int2LongOpenHashMap intermediateResult) {
+ if (intermediateResult.isEmpty()) {
+ return DEFAULT_FINAL_RESULT;
+ } else {
+ ObjectIterator<Int2LongMap.Entry> iterator = intermediateResult.int2LongEntrySet().fastIterator();
+ Int2LongMap.Entry first = iterator.next();
+ long maxFrequency = first.getLongValue();
+ switch (_multiModeReducerType) {
+ case MIN:
+ double min = first.getIntKey();
Review comment:
Updated
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@pinot.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@pinot.apache.org
For additional commands, e-mail: commits-help@pinot.apache.org
[GitHub] [pinot] codecov-commenter edited a comment on pull request #7318: add mode aggregation function
Posted by GitBox <gi...@apache.org>.
codecov-commenter edited a comment on pull request #7318:
URL: https://github.com/apache/pinot/pull/7318#issuecomment-901092615
# [Codecov](https://codecov.io/gh/apache/pinot/pull/7318?src=pr&el=h1&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation) Report
> Merging [#7318](https://codecov.io/gh/apache/pinot/pull/7318?src=pr&el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation) (60f7b0a) into [master](https://codecov.io/gh/apache/pinot/commit/a539958eef8480cf95e39ed4788543e3d094c7bf?el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation) (a539958) will **decrease** coverage by `1.02%`.
> The diff coverage is `90.44%`.
[](https://codecov.io/gh/apache/pinot/pull/7318?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation)
```diff
@@ Coverage Diff @@
## master #7318 +/- ##
============================================
- Coverage 71.47% 70.45% -1.03%
+ Complexity 3283 3282 -1
============================================
Files 1504 1504
Lines 73975 74320 +345
Branches 10704 10800 +96
============================================
- Hits 52876 52361 -515
- Misses 17505 18343 +838
- Partials 3594 3616 +22
```
| Flag | Coverage Δ | |
|---|---|---|
| integration1 | `30.38% <2.00%> (-0.52%)` | :arrow_down: |
| integration2 | `?` | |
| unittests1 | `69.27% <90.44%> (+0.19%)` | :arrow_up: |
| unittests2 | `14.50% <0.00%> (-0.16%)` | :arrow_down: |
Flags with carried forward coverage won't be shown. [Click here](https://docs.codecov.io/docs/carryforward-flags?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#carryforward-flags-in-the-pull-request-comment) to find out more.
| [Impacted Files](https://codecov.io/gh/apache/pinot/pull/7318?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation) | Coverage Δ | |
|---|---|---|
| [.../aggregation/function/ModeAggregationFunction.java](https://codecov.io/gh/apache/pinot/pull/7318/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-cGlub3QtY29yZS9zcmMvbWFpbi9qYXZhL29yZy9hcGFjaGUvcGlub3QvY29yZS9xdWVyeS9hZ2dyZWdhdGlvbi9mdW5jdGlvbi9Nb2RlQWdncmVnYXRpb25GdW5jdGlvbi5qYXZh) | `88.40% <88.40%> (ø)` | |
| [...org/apache/pinot/core/common/ObjectSerDeUtils.java](https://codecov.io/gh/apache/pinot/pull/7318/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-cGlub3QtY29yZS9zcmMvbWFpbi9qYXZhL29yZy9hcGFjaGUvcGlub3QvY29yZS9jb21tb24vT2JqZWN0U2VyRGVVdGlscy5qYXZh) | `89.75% <100.00%> (+2.08%)` | :arrow_up: |
| [...gregation/function/AggregationFunctionFactory.java](https://codecov.io/gh/apache/pinot/pull/7318/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-cGlub3QtY29yZS9zcmMvbWFpbi9qYXZhL29yZy9hcGFjaGUvcGlub3QvY29yZS9xdWVyeS9hZ2dyZWdhdGlvbi9mdW5jdGlvbi9BZ2dyZWdhdGlvbkZ1bmN0aW9uRmFjdG9yeS5qYXZh) | `88.60% <100.00%> (+0.14%)` | :arrow_up: |
| [...che/pinot/segment/spi/AggregationFunctionType.java](https://codecov.io/gh/apache/pinot/pull/7318/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-cGlub3Qtc2VnbWVudC1zcGkvc3JjL21haW4vamF2YS9vcmcvYXBhY2hlL3Bpbm90L3NlZ21lbnQvc3BpL0FnZ3JlZ2F0aW9uRnVuY3Rpb25UeXBlLmphdmE=) | `100.00% <100.00%> (ø)` | |
| [...pache/pinot/common/utils/grpc/GrpcQueryClient.java](https://codecov.io/gh/apache/pinot/pull/7318/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-cGlub3QtY29tbW9uL3NyYy9tYWluL2phdmEvb3JnL2FwYWNoZS9waW5vdC9jb21tb24vdXRpbHMvZ3JwYy9HcnBjUXVlcnlDbGllbnQuamF2YQ==) | `0.00% <0.00%> (-100.00%)` | :arrow_down: |
| [...ore/operator/streaming/StreamingResponseUtils.java](https://codecov.io/gh/apache/pinot/pull/7318/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-cGlub3QtY29yZS9zcmMvbWFpbi9qYXZhL29yZy9hcGFjaGUvcGlub3QvY29yZS9vcGVyYXRvci9zdHJlYW1pbmcvU3RyZWFtaW5nUmVzcG9uc2VVdGlscy5qYXZh) | `0.00% <0.00%> (-100.00%)` | :arrow_down: |
| [...ager/realtime/PeerSchemeSplitSegmentCommitter.java](https://codecov.io/gh/apache/pinot/pull/7318/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-cGlub3QtY29yZS9zcmMvbWFpbi9qYXZhL29yZy9hcGFjaGUvcGlub3QvY29yZS9kYXRhL21hbmFnZXIvcmVhbHRpbWUvUGVlclNjaGVtZVNwbGl0U2VnbWVudENvbW1pdHRlci5qYXZh) | `0.00% <0.00%> (-100.00%)` | :arrow_down: |
| [...ator/streaming/StreamingSelectionOnlyOperator.java](https://codecov.io/gh/apache/pinot/pull/7318/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-cGlub3QtY29yZS9zcmMvbWFpbi9qYXZhL29yZy9hcGFjaGUvcGlub3QvY29yZS9vcGVyYXRvci9zdHJlYW1pbmcvU3RyZWFtaW5nU2VsZWN0aW9uT25seU9wZXJhdG9yLmphdmE=) | `0.00% <0.00%> (-92.31%)` | :arrow_down: |
| [...he/pinot/core/plan/StreamingSelectionPlanNode.java](https://codecov.io/gh/apache/pinot/pull/7318/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-cGlub3QtY29yZS9zcmMvbWFpbi9qYXZhL29yZy9hcGFjaGUvcGlub3QvY29yZS9wbGFuL1N0cmVhbWluZ1NlbGVjdGlvblBsYW5Ob2RlLmphdmE=) | `0.00% <0.00%> (-90.00%)` | :arrow_down: |
| [...ller/api/access/BasicAuthAccessControlFactory.java](https://codecov.io/gh/apache/pinot/pull/7318/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-cGlub3QtY29udHJvbGxlci9zcmMvbWFpbi9qYXZhL29yZy9hcGFjaGUvcGlub3QvY29udHJvbGxlci9hcGkvYWNjZXNzL0Jhc2ljQXV0aEFjY2Vzc0NvbnRyb2xGYWN0b3J5LmphdmE=) | `0.00% <0.00%> (-80.00%)` | :arrow_down: |
| ... and [150 more](https://codecov.io/gh/apache/pinot/pull/7318/diff?src=pr&el=tree-more&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation) | |
------
[Continue to review full report at Codecov](https://codecov.io/gh/apache/pinot/pull/7318?src=pr&el=continue&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation).
> **Legend** - [Click here to learn more](https://docs.codecov.io/docs/codecov-delta?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation)
> `Δ = absolute <relative> (impact)`, `ø = not affected`, `? = missing data`
> Powered by [Codecov](https://codecov.io/gh/apache/pinot/pull/7318?src=pr&el=footer&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation). Last update [a539958...60f7b0a](https://codecov.io/gh/apache/pinot/pull/7318?src=pr&el=lastupdated&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation). Read the [comment docs](https://docs.codecov.io/docs/pull-request-comments?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation).
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@pinot.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@pinot.apache.org
For additional commands, e-mail: commits-help@pinot.apache.org
[GitHub] [pinot] codecov-commenter edited a comment on pull request #7318: add mode aggregation function
Posted by GitBox <gi...@apache.org>.
codecov-commenter edited a comment on pull request #7318:
URL: https://github.com/apache/pinot/pull/7318#issuecomment-901092615
# [Codecov](https://codecov.io/gh/apache/pinot/pull/7318?src=pr&el=h1&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation) Report
> Merging [#7318](https://codecov.io/gh/apache/pinot/pull/7318?src=pr&el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation) (7597ed1) into [master](https://codecov.io/gh/apache/pinot/commit/a539958eef8480cf95e39ed4788543e3d094c7bf?el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation) (a539958) will **decrease** coverage by `33.86%`.
> The diff coverage is `2.00%`.
[](https://codecov.io/gh/apache/pinot/pull/7318?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation)
```diff
@@ Coverage Diff @@
## master #7318 +/- ##
=============================================
- Coverage 71.47% 37.61% -33.87%
+ Complexity 3283 92 -3191
=============================================
Files 1504 1504
Lines 73975 74318 +343
Branches 10704 10798 +94
=============================================
- Hits 52876 27952 -24924
- Misses 17505 44129 +26624
+ Partials 3594 2237 -1357
```
| Flag | Coverage Δ | |
|---|---|---|
| integration1 | `?` | |
| integration2 | `29.22% <2.00%> (-0.09%)` | :arrow_down: |
| unittests1 | `?` | |
| unittests2 | `14.50% <0.00%> (-0.15%)` | :arrow_down: |
Flags with carried forward coverage won't be shown. [Click here](https://docs.codecov.io/docs/carryforward-flags?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#carryforward-flags-in-the-pull-request-comment) to find out more.
| [Impacted Files](https://codecov.io/gh/apache/pinot/pull/7318?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation) | Coverage Δ | |
|---|---|---|
| [...gregation/function/AggregationFunctionFactory.java](https://codecov.io/gh/apache/pinot/pull/7318/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-cGlub3QtY29yZS9zcmMvbWFpbi9qYXZhL29yZy9hcGFjaGUvcGlub3QvY29yZS9xdWVyeS9hZ2dyZWdhdGlvbi9mdW5jdGlvbi9BZ2dyZWdhdGlvbkZ1bmN0aW9uRmFjdG9yeS5qYXZh) | `18.98% <0.00%> (-69.48%)` | :arrow_down: |
| [.../aggregation/function/ModeAggregationFunction.java](https://codecov.io/gh/apache/pinot/pull/7318/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-cGlub3QtY29yZS9zcmMvbWFpbi9qYXZhL29yZy9hcGFjaGUvcGlub3QvY29yZS9xdWVyeS9hZ2dyZWdhdGlvbi9mdW5jdGlvbi9Nb2RlQWdncmVnYXRpb25GdW5jdGlvbi5qYXZh) | `0.00% <0.00%> (ø)` | |
| [...che/pinot/segment/spi/AggregationFunctionType.java](https://codecov.io/gh/apache/pinot/pull/7318/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-cGlub3Qtc2VnbWVudC1zcGkvc3JjL21haW4vamF2YS9vcmcvYXBhY2hlL3Bpbm90L3NlZ21lbnQvc3BpL0FnZ3JlZ2F0aW9uRnVuY3Rpb25UeXBlLmphdmE=) | `0.00% <0.00%> (-100.00%)` | :arrow_down: |
| [...org/apache/pinot/core/common/ObjectSerDeUtils.java](https://codecov.io/gh/apache/pinot/pull/7318/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-cGlub3QtY29yZS9zcmMvbWFpbi9qYXZhL29yZy9hcGFjaGUvcGlub3QvY29yZS9jb21tb24vT2JqZWN0U2VyRGVVdGlscy5qYXZh) | `44.54% <11.68%> (-43.13%)` | :arrow_down: |
| [...c/main/java/org/apache/pinot/common/tier/Tier.java](https://codecov.io/gh/apache/pinot/pull/7318/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-cGlub3QtY29tbW9uL3NyYy9tYWluL2phdmEvb3JnL2FwYWNoZS9waW5vdC9jb21tb24vdGllci9UaWVyLmphdmE=) | `0.00% <0.00%> (-100.00%)` | :arrow_down: |
| [.../java/org/apache/pinot/spi/utils/BooleanUtils.java](https://codecov.io/gh/apache/pinot/pull/7318/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-cGlub3Qtc3BpL3NyYy9tYWluL2phdmEvb3JnL2FwYWNoZS9waW5vdC9zcGkvdXRpbHMvQm9vbGVhblV0aWxzLmphdmE=) | `0.00% <0.00%> (-100.00%)` | :arrow_down: |
| [...ava/org/apache/pinot/spi/data/MetricFieldSpec.java](https://codecov.io/gh/apache/pinot/pull/7318/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-cGlub3Qtc3BpL3NyYy9tYWluL2phdmEvb3JnL2FwYWNoZS9waW5vdC9zcGkvZGF0YS9NZXRyaWNGaWVsZFNwZWMuamF2YQ==) | `0.00% <0.00%> (-100.00%)` | :arrow_down: |
| [...va/org/apache/pinot/spi/utils/BigDecimalUtils.java](https://codecov.io/gh/apache/pinot/pull/7318/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-cGlub3Qtc3BpL3NyYy9tYWluL2phdmEvb3JnL2FwYWNoZS9waW5vdC9zcGkvdXRpbHMvQmlnRGVjaW1hbFV0aWxzLmphdmE=) | `0.00% <0.00%> (-100.00%)` | :arrow_down: |
| [...java/org/apache/pinot/common/tier/TierFactory.java](https://codecov.io/gh/apache/pinot/pull/7318/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-cGlub3QtY29tbW9uL3NyYy9tYWluL2phdmEvb3JnL2FwYWNoZS9waW5vdC9jb21tb24vdGllci9UaWVyRmFjdG9yeS5qYXZh) | `0.00% <0.00%> (-100.00%)` | :arrow_down: |
| [...a/org/apache/pinot/spi/config/table/TableType.java](https://codecov.io/gh/apache/pinot/pull/7318/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-cGlub3Qtc3BpL3NyYy9tYWluL2phdmEvb3JnL2FwYWNoZS9waW5vdC9zcGkvY29uZmlnL3RhYmxlL1RhYmxlVHlwZS5qYXZh) | `0.00% <0.00%> (-100.00%)` | :arrow_down: |
| ... and [924 more](https://codecov.io/gh/apache/pinot/pull/7318/diff?src=pr&el=tree-more&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation) | |
------
[Continue to review full report at Codecov](https://codecov.io/gh/apache/pinot/pull/7318?src=pr&el=continue&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation).
> **Legend** - [Click here to learn more](https://docs.codecov.io/docs/codecov-delta?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation)
> `Δ = absolute <relative> (impact)`, `ø = not affected`, `? = missing data`
> Powered by [Codecov](https://codecov.io/gh/apache/pinot/pull/7318?src=pr&el=footer&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation). Last update [a539958...7597ed1](https://codecov.io/gh/apache/pinot/pull/7318?src=pr&el=lastupdated&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation). Read the [comment docs](https://docs.codecov.io/docs/pull-request-comments?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation).
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@pinot.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@pinot.apache.org
For additional commands, e-mail: commits-help@pinot.apache.org
[GitHub] [pinot] Jackie-Jiang commented on a change in pull request #7318: add mode aggregation function
Posted by GitBox <gi...@apache.org>.
Jackie-Jiang commented on a change in pull request #7318:
URL: https://github.com/apache/pinot/pull/7318#discussion_r691555279
##########
File path: pinot-core/src/main/java/org/apache/pinot/core/query/aggregation/function/ModeAggregationFunction.java
##########
@@ -0,0 +1,704 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.pinot.core.query.aggregation.function;
+
+import com.google.common.base.Preconditions;
+import it.unimi.dsi.fastutil.doubles.Double2LongMap;
+import it.unimi.dsi.fastutil.doubles.Double2LongOpenHashMap;
+import it.unimi.dsi.fastutil.floats.Float2LongMap;
+import it.unimi.dsi.fastutil.floats.Float2LongOpenHashMap;
+import it.unimi.dsi.fastutil.ints.Int2LongMap;
+import it.unimi.dsi.fastutil.ints.Int2LongMaps;
+import it.unimi.dsi.fastutil.ints.Int2LongOpenHashMap;
+import it.unimi.dsi.fastutil.longs.Long2LongMap;
+import it.unimi.dsi.fastutil.longs.Long2LongOpenHashMap;
+import it.unimi.dsi.fastutil.objects.ObjectIterator;
+import java.util.List;
+import java.util.Map;
+import javax.annotation.Nullable;
+import org.apache.pinot.common.request.context.ExpressionContext;
+import org.apache.pinot.common.utils.DataSchema.ColumnDataType;
+import org.apache.pinot.core.common.BlockValSet;
+import org.apache.pinot.core.query.aggregation.AggregationResultHolder;
+import org.apache.pinot.core.query.aggregation.ObjectAggregationResultHolder;
+import org.apache.pinot.core.query.aggregation.groupby.GroupByResultHolder;
+import org.apache.pinot.core.query.aggregation.groupby.ObjectGroupByResultHolder;
+import org.apache.pinot.segment.spi.AggregationFunctionType;
+import org.apache.pinot.segment.spi.index.reader.Dictionary;
+import org.apache.pinot.spi.data.FieldSpec.DataType;
+
+
+/**
+ * This function is used for Mode calculations.
+ * <p>The function can be used as MODE(expression, multiModeReducerType)
+ * <p>Following arguments are supported:
+ * <ul>
+ * <li>Expression: expression that contains the column to be calculated mode on, can be any Numeric column</li>
+ * <li>MultiModeReducerType (optional): the reducer to use in case of multiple modes present in data</li>
+ * </ul>
+ */
+@SuppressWarnings({"rawtypes", "unchecked"})
+public class ModeAggregationFunction extends BaseSingleInputAggregationFunction<Map<? extends Number, Long>, Double> {
+
+ private static final double DEFAULT_FINAL_RESULT = Double.NEGATIVE_INFINITY;
+
+ private final MultiModeReducerType _multiModeReducerType;
+
+ public ModeAggregationFunction(List<ExpressionContext> arguments) {
+ super(arguments.get(0));
+
+ int numArguments = arguments.size();
+ Preconditions.checkArgument(numArguments <= 2, "Mode expects at most 2 arguments, got: %s", numArguments);
+ if (numArguments > 1) {
+ _multiModeReducerType = MultiModeReducerType.valueOf(arguments.get(1).getLiteral());
+ } else {
+ _multiModeReducerType = MultiModeReducerType.MIN;
+ }
+ }
+
+ /**
+ * Helper method to create a value map for the given value type.
+ */
+ private static Map<? extends Number, Long> getValueMap(DataType valueType) {
+ switch (valueType) {
+ case INT:
+ return new Int2LongOpenHashMap();
+ case LONG:
+ return new Long2LongOpenHashMap();
+ case FLOAT:
+ return new Float2LongOpenHashMap();
+ case DOUBLE:
+ return new Double2LongOpenHashMap();
+ default:
+ throw new IllegalStateException("Illegal data type for MODE aggregation function: " + valueType);
+ }
+ }
+
+ /**
+ * Returns the value map from the result holder or creates a new one if it does not exist.
+ */
+ protected static Map<? extends Number, Long> getValueMap(AggregationResultHolder aggregationResultHolder,
+ DataType valueType) {
+ Map<? extends Number, Long> valueMap = aggregationResultHolder.getResult();
+ if (valueMap == null) {
+ valueMap = getValueMap(valueType);
+ aggregationResultHolder.setValue(valueMap);
+ }
+ return valueMap;
+ }
+
+ /**
+ * Returns the value set for the given group key or creates a new one if it does not exist.
+ */
+ protected static Map<? extends Number, Long> getValueMap(GroupByResultHolder groupByResultHolder, int groupKey,
+ DataType valueType) {
+ Map<? extends Number, Long> valueMap = groupByResultHolder.getResult(groupKey);
+ if (valueMap == null) {
+ valueMap = getValueMap(valueType);
+ groupByResultHolder.setValueForKey(groupKey, valueMap);
+ }
+ return valueMap;
+ }
+
+ /**
+ * Helper method to set INT value for the given group keys into the result holder.
+ */
+ private static void setValueForGroupKeys(GroupByResultHolder groupByResultHolder, int groupKey, int value) {
+ ((Int2LongOpenHashMap) getValueMap(groupByResultHolder, groupKey, DataType.INT)).merge(value, 1, Long::sum);
+ }
+
+ /**
+ * Helper method to set LONG value for the given group keys into the result holder.
+ */
+ private static void setValueForGroupKeys(GroupByResultHolder groupByResultHolder, int groupKey, long value) {
+ ((Long2LongOpenHashMap) getValueMap(groupByResultHolder, groupKey, DataType.LONG)).merge(value, 1, Long::sum);
+ }
+
+ /**
+ * Helper method to set FLOAT value for the given group keys into the result holder.
+ */
+ private static void setValueForGroupKeys(GroupByResultHolder groupByResultHolder, int groupKey, float value) {
+ ((Float2LongOpenHashMap) getValueMap(groupByResultHolder, groupKey, DataType.FLOAT)).merge(value, 1, Long::sum);
+ }
+
+ /**
+ * Helper method to set DOUBLE value for the given group keys into the result holder.
+ */
+ private static void setValueForGroupKeys(GroupByResultHolder groupByResultHolder, int groupKey, double value) {
+ ((Double2LongOpenHashMap) getValueMap(groupByResultHolder, groupKey, DataType.DOUBLE)).merge(value, 1, Long::sum);
+ }
+
+ /**
+ * Returns the dictionary id count map from the result holder or creates a new one if it does not exist.
+ */
+ protected static Int2LongOpenHashMap getDictIdCountMap(AggregationResultHolder aggregationResultHolder,
+ Dictionary dictionary) {
+ ModeAggregationFunction.DictIdsWrapper dictIdsWrapper = aggregationResultHolder.getResult();
+ if (dictIdsWrapper == null) {
+ dictIdsWrapper = new ModeAggregationFunction.DictIdsWrapper(dictionary);
+ aggregationResultHolder.setValue(dictIdsWrapper);
+ }
+ return dictIdsWrapper._dictIdCountMap;
+ }
+
+ /**
+ * Returns the dictionary id count map for the given group key or creates a new one if it does not exist.
+ */
+ protected static Int2LongOpenHashMap getDictIdCountMap(GroupByResultHolder groupByResultHolder, int groupKey,
+ Dictionary dictionary) {
+ ModeAggregationFunction.DictIdsWrapper dictIdsWrapper = groupByResultHolder.getResult(groupKey);
+ if (dictIdsWrapper == null) {
+ dictIdsWrapper = new ModeAggregationFunction.DictIdsWrapper(dictionary);
+ groupByResultHolder.setValueForKey(groupKey, dictIdsWrapper);
+ }
+ return dictIdsWrapper._dictIdCountMap;
+ }
+
+ /**
+ * Helper method to read dictionary and convert dictionary ids to values for dictionary-encoded expression.
+ */
+ private static Map<? extends Number, Long> convertToValueMap(DictIdsWrapper dictIdsWrapper) {
+ Dictionary dictionary = dictIdsWrapper._dictionary;
+ Int2LongOpenHashMap dictIdCountMap = dictIdsWrapper._dictIdCountMap;
+ int numValues = dictIdCountMap.size();
+ ObjectIterator<Int2LongMap.Entry> iterator = Int2LongMaps.fastIterator(dictIdCountMap);
+ DataType storedType = dictionary.getValueType();
+ switch (storedType) {
+ case INT:
+ Int2LongOpenHashMap intValueMap = new Int2LongOpenHashMap(numValues);
+ while (iterator.hasNext()) {
+ Int2LongMap.Entry next = iterator.next();
+ intValueMap.put(dictionary.getIntValue(next.getIntKey()), next.getLongValue());
+ }
+ return intValueMap;
+ case LONG:
+ Long2LongOpenHashMap longValueMap = new Long2LongOpenHashMap(numValues);
+ while (iterator.hasNext()) {
+ Int2LongMap.Entry next = iterator.next();
+ longValueMap.put(dictionary.getLongValue(next.getIntKey()), next.getLongValue());
+ }
+ return longValueMap;
+ case FLOAT:
+ Float2LongOpenHashMap floatValueMap = new Float2LongOpenHashMap(numValues);
+ while (iterator.hasNext()) {
+ Int2LongMap.Entry next = iterator.next();
+ floatValueMap.put(dictionary.getFloatValue(next.getIntKey()), next.getLongValue());
+ }
+ return floatValueMap;
+ case DOUBLE:
+ Double2LongOpenHashMap doubleValueMap = new Double2LongOpenHashMap(numValues);
+ while (iterator.hasNext()) {
+ Int2LongMap.Entry next = iterator.next();
+ doubleValueMap.put(dictionary.getFloatValue(next.getIntKey()), next.getLongValue());
+ }
+ return doubleValueMap;
+ default:
+ throw new IllegalStateException("Illegal data type for MODE aggregation function: " + storedType);
+ }
+ }
+
+ /**
+ * Helper method to extract segment level intermediate result from the inner segment result.
+ */
+ private static Map<? extends Number, Long> extractIntermediateResult(@Nullable Object result) {
+ if (result == null) {
+ // NOTE: Return an empty Int2LongOpenHashMap for empty result.
+ return new Int2LongOpenHashMap();
+ }
+
+ if (result instanceof DictIdsWrapper) {
+ // For dictionary-encoded expression, convert dictionary ids to values
+ return convertToValueMap((DictIdsWrapper) result);
+ }
+ assert result instanceof Map;
+ // For non-dictionary-encoded expression, directly return the value set
+ return (Map) result;
+ }
+
+ @Override
+ public AggregationFunctionType getType() {
+ return AggregationFunctionType.MODE;
+ }
+
+ @Override
+ public AggregationResultHolder createAggregationResultHolder() {
+ return new ObjectAggregationResultHolder();
+ }
+
+ @Override
+ public GroupByResultHolder createGroupByResultHolder(int initialCapacity, int maxCapacity) {
+ return new ObjectGroupByResultHolder(initialCapacity, maxCapacity);
+ }
+
+ @Override
+ public void aggregate(int length, AggregationResultHolder aggregationResultHolder,
+ Map<ExpressionContext, BlockValSet> blockValSetMap) {
+ BlockValSet blockValSet = blockValSetMap.get(_expression);
+
+ // For dictionary-encoded expression, store dictionary ids into the dictId map
+ Dictionary dictionary = blockValSet.getDictionary();
+ if (dictionary != null) {
+ int[] dictIds = blockValSet.getDictionaryIdsSV();
+ Int2LongOpenHashMap dictIdValueMap = getDictIdCountMap(aggregationResultHolder, dictionary);
+ for (int i = 0; i < length; i++) {
+ dictIdValueMap.merge(dictIds[i], 1, Long::sum);
+ }
+ return;
+ }
+
+ // For non-dictionary-encoded expression, store values into the value map
+ DataType storedType = blockValSet.getValueType().getStoredType();
+ Map<? extends Number, Long> valueMap = getValueMap(aggregationResultHolder, storedType);
+ switch (storedType) {
+ case INT:
+ Int2LongOpenHashMap intMap = (Int2LongOpenHashMap) valueMap;
+ int[] intValues = blockValSet.getIntValuesSV();
+ for (int i = 0; i < length; i++) {
+ intMap.merge(intValues[i], 1, Long::sum);
+ }
+ break;
+ case LONG:
+ Long2LongOpenHashMap longMap = (Long2LongOpenHashMap) valueMap;
+ long[] longValues = blockValSet.getLongValuesSV();
+ for (int i = 0; i < length; i++) {
+ longMap.merge(longValues[i], 1, Long::sum);
+ }
+ break;
+ case FLOAT:
+ Float2LongOpenHashMap floatMap = (Float2LongOpenHashMap) valueMap;
+ float[] floatValues = blockValSet.getFloatValuesSV();
+ for (int i = 0; i < length; i++) {
+ floatMap.merge(floatValues[i], 1, Long::sum);
+ }
+ break;
+ case DOUBLE:
+ Double2LongOpenHashMap doubleMap = (Double2LongOpenHashMap) valueMap;
+ double[] doubleValues = blockValSet.getDoubleValuesSV();
+ for (int i = 0; i < length; i++) {
+ doubleMap.merge(doubleValues[i], 1, Long::sum);
+ }
+ break;
+ default:
+ throw new IllegalStateException("Illegal data type for MODE aggregation function: " + storedType);
+ }
+ }
+
+ @Override
+ public void aggregateGroupBySV(int length, int[] groupKeyArray, GroupByResultHolder groupByResultHolder,
+ Map<ExpressionContext, BlockValSet> blockValSetMap) {
+ BlockValSet blockValSet = blockValSetMap.get(_expression);
+
+ // For dictionary-encoded expression, store dictionary ids into the dictId map
+ Dictionary dictionary = blockValSet.getDictionary();
+ if (dictionary != null) {
+ int[] dictIds = blockValSet.getDictionaryIdsSV();
+ for (int i = 0; i < length; i++) {
+ getDictIdCountMap(groupByResultHolder, groupKeyArray[i], dictionary).merge(dictIds[i], 1, Long::sum);
+ }
+ return;
+ }
+
+ // For non-dictionary-encoded expression, store values into the value map
+ DataType storedType = blockValSet.getValueType().getStoredType();
+ switch (storedType) {
+ case INT:
+ int[] intValues = blockValSet.getIntValuesSV();
+ for (int i = 0; i < length; i++) {
+ setValueForGroupKeys(groupByResultHolder, groupKeyArray[i], intValues[i]);
+ }
+ break;
+ case LONG:
+ long[] longValues = blockValSet.getLongValuesSV();
+ for (int i = 0; i < length; i++) {
+ setValueForGroupKeys(groupByResultHolder, groupKeyArray[i], longValues[i]);
+ }
+ break;
+ case FLOAT:
+ float[] floatValues = blockValSet.getFloatValuesSV();
+ for (int i = 0; i < length; i++) {
+ setValueForGroupKeys(groupByResultHolder, groupKeyArray[i], floatValues[i]);
+ }
+ break;
+ case DOUBLE:
+ double[] doubleValues = blockValSet.getDoubleValuesSV();
+ for (int i = 0; i < length; i++) {
+ setValueForGroupKeys(groupByResultHolder, groupKeyArray[i], doubleValues[i]);
+ }
+ break;
+ default:
+ throw new IllegalStateException("Illegal data type for MODE aggregation function: " + storedType);
+ }
+ }
+
+ @Override
+ public void aggregateGroupByMV(int length, int[][] groupKeysArray, GroupByResultHolder groupByResultHolder,
+ Map<ExpressionContext, BlockValSet> blockValSetMap) {
+ BlockValSet blockValSet = blockValSetMap.get(_expression);
+
+ // For dictionary-encoded expression, store dictionary ids into the dictId map
+ Dictionary dictionary = blockValSet.getDictionary();
+ if (dictionary != null) {
+ int[] dictIds = blockValSet.getDictionaryIdsSV();
+ for (int i = 0; i < length; i++) {
+ for (int groupKey : groupKeysArray[i]) {
+ getDictIdCountMap(groupByResultHolder, groupKey, dictionary).merge(dictIds[i], 1, Long::sum);
+ }
+ }
+ return;
+ }
+
+ // For non-dictionary-encoded expression, store values into the value map
+ DataType storedType = blockValSet.getValueType().getStoredType();
+ switch (storedType) {
+ case INT:
+ int[] intValues = blockValSet.getIntValuesSV();
+ for (int i = 0; i < length; i++) {
+ for (int groupKey : groupKeysArray[i]) {
+ setValueForGroupKeys(groupByResultHolder, groupKey, intValues[i]);
+ }
+ }
+ break;
+ case LONG:
+ long[] longValues = blockValSet.getLongValuesSV();
+ for (int i = 0; i < length; i++) {
+ for (int groupKey : groupKeysArray[i]) {
+ setValueForGroupKeys(groupByResultHolder, groupKey, longValues[i]);
+ }
+ }
+ break;
+ case FLOAT:
+ float[] floatValues = blockValSet.getFloatValuesSV();
+ for (int i = 0; i < length; i++) {
+ for (int groupKey : groupKeysArray[i]) {
+ setValueForGroupKeys(groupByResultHolder, groupKey, floatValues[i]);
+ }
+ }
+ break;
+ case DOUBLE:
+ double[] doubleValues = blockValSet.getDoubleValuesSV();
+ for (int i = 0; i < length; i++) {
+ for (int groupKey : groupKeysArray[i]) {
+ setValueForGroupKeys(groupByResultHolder, groupKey, doubleValues[i]);
+ }
+ }
+ break;
+ default:
+ throw new IllegalStateException("Illegal data type for MODE aggregation function: " + storedType);
+ }
+ }
+
+ @Override
+ public Map<? extends Number, Long> extractAggregationResult(AggregationResultHolder aggregationResultHolder) {
+ return extractIntermediateResult(aggregationResultHolder.getResult());
+ }
+
+ @Override
+ public Map<? extends Number, Long> extractGroupByResult(GroupByResultHolder groupByResultHolder, int groupKey) {
+ return extractIntermediateResult(groupByResultHolder.getResult(groupKey));
+ }
+
+ @Override
+ public Map<? extends Number, Long> merge(Map<? extends Number, Long> intermediateResult1,
+ Map<? extends Number, Long> intermediateResult2) {
+ if (intermediateResult1.isEmpty()) {
+ return intermediateResult2;
+ }
+ if (intermediateResult2.isEmpty()) {
+ return intermediateResult1;
+ }
+ if (intermediateResult1 instanceof Int2LongOpenHashMap && intermediateResult2 instanceof Int2LongOpenHashMap) {
+ ((Int2LongOpenHashMap) intermediateResult2).int2LongEntrySet().fastForEach(
+ e -> ((Int2LongOpenHashMap) intermediateResult1).merge(e.getIntKey(), e.getLongValue(), Long::sum));
+ } else if (intermediateResult1 instanceof Long2LongOpenHashMap
+ && intermediateResult2 instanceof Long2LongOpenHashMap) {
+ ((Long2LongOpenHashMap) intermediateResult2).long2LongEntrySet().fastForEach(
+ e -> ((Long2LongOpenHashMap) intermediateResult1).merge(e.getLongKey(), e.getLongValue(), Long::sum));
+ } else if (intermediateResult1 instanceof Float2LongOpenHashMap
+ && intermediateResult2 instanceof Float2LongOpenHashMap) {
+ ((Float2LongOpenHashMap) intermediateResult2).float2LongEntrySet().fastForEach(
+ e -> ((Float2LongOpenHashMap) intermediateResult1).merge(e.getFloatKey(), e.getLongValue(), Long::sum));
+ } else if (intermediateResult1 instanceof Double2LongOpenHashMap
+ && intermediateResult2 instanceof Double2LongOpenHashMap) {
+ ((Double2LongOpenHashMap) intermediateResult2).double2LongEntrySet().fastForEach(
+ e -> ((Double2LongOpenHashMap) intermediateResult1).merge(e.getDoubleKey(), e.getLongValue(), Long::sum));
+ } else {
+ throw new IllegalStateException(
+ "Illegal data type for Intermediate Result of MODE aggregation function: " + intermediateResult1.getClass()
+ .getSimpleName() + ", " + intermediateResult2.getClass().getSimpleName());
+ }
+ return intermediateResult1;
+ }
+
+ @Override
+ public boolean isIntermediateResultComparable() {
+ return false;
+ }
+
+ @Override
+ public ColumnDataType getIntermediateResultColumnType() {
+ return ColumnDataType.OBJECT;
+ }
+
+ @Override
+ public ColumnDataType getFinalResultColumnType() {
+ return ColumnDataType.DOUBLE;
+ }
+
+ @Override
+ public Double extractFinalResult(Map<? extends Number, Long> intermediateResult) {
+ if (intermediateResult.isEmpty()) {
+ return DEFAULT_FINAL_RESULT;
+ } else if (intermediateResult instanceof Int2LongOpenHashMap) {
+ return extractFinalResult((Int2LongOpenHashMap) intermediateResult);
+ } else if (intermediateResult instanceof Long2LongOpenHashMap) {
+ return extractFinalResult((Long2LongOpenHashMap) intermediateResult);
+ } else if (intermediateResult instanceof Float2LongOpenHashMap) {
+ return extractFinalResult((Float2LongOpenHashMap) intermediateResult);
+ } else if (intermediateResult instanceof Double2LongOpenHashMap) {
+ return extractFinalResult((Double2LongOpenHashMap) intermediateResult);
+ } else {
+ throw new IllegalStateException(
+ "Illegal data type for Intermediate Result of MODE aggregation function: " + intermediateResult.getClass()
+ .getSimpleName());
+ }
+ }
+
+ public Double extractFinalResult(Int2LongOpenHashMap intermediateResult) {
+ if (intermediateResult.isEmpty()) {
+ return DEFAULT_FINAL_RESULT;
+ } else {
+ ObjectIterator<Int2LongMap.Entry> iterator = intermediateResult.int2LongEntrySet().fastIterator();
+ Int2LongMap.Entry first = iterator.next();
+ long maxFrequency = first.getLongValue();
+ switch (_multiModeReducerType) {
+ case MIN:
+ double min = first.getIntKey();
+ while (iterator.hasNext()) {
+ Int2LongMap.Entry next = iterator.next();
+ if ((next.getLongValue() > maxFrequency) || (next.getLongValue() == maxFrequency
+ && min > next.getIntKey())) {
+ maxFrequency = next.getLongValue();
+ min = next.getIntKey();
+ }
+ }
+ return min;
+ case MAX:
+ double max = first.getIntKey();
+ while (iterator.hasNext()) {
+ Int2LongMap.Entry next = iterator.next();
+ if ((next.getLongValue() > maxFrequency) || (next.getLongValue() == maxFrequency
+ && max < next.getIntKey())) {
+ maxFrequency = next.getLongValue();
+ max = next.getIntKey();
+ }
+ }
+ return max;
+ case AVG:
+ double sum = first.getIntKey();
+ long count = 1;
+ while (iterator.hasNext()) {
+ Int2LongMap.Entry next = iterator.next();
+ if ((next.getLongValue() > maxFrequency)) {
+ maxFrequency = next.getLongValue();
+ sum = next.getIntKey();
+ count = 1;
+ } else if (next.getLongValue() == maxFrequency) {
+ sum += next.getIntKey();
+ count += 1;
+ }
+ }
+ return sum / count;
+ default:
+ throw new IllegalStateException(
+ "Illegal reducer type for MODE aggregation function: " + _multiModeReducerType);
+ }
+ }
+ }
+
+ public Double extractFinalResult(Long2LongOpenHashMap intermediateResult) {
+ if (intermediateResult.isEmpty()) {
+ return DEFAULT_FINAL_RESULT;
+ } else {
+ ObjectIterator<Long2LongMap.Entry> iterator = intermediateResult.long2LongEntrySet().fastIterator();
+ Long2LongMap.Entry first = iterator.next();
+ long maxFrequency = first.getLongValue();
+ switch (_multiModeReducerType) {
+ case MIN:
+ double min = first.getLongKey();
+ while (iterator.hasNext()) {
+ Long2LongMap.Entry next = iterator.next();
+ if ((next.getLongValue() > maxFrequency) || (next.getLongValue() == maxFrequency
+ && min > next.getLongKey())) {
+ maxFrequency = next.getLongValue();
+ min = next.getLongKey();
+ }
+ }
+ return min;
+ case MAX:
+ double max = first.getLongKey();
+ while (iterator.hasNext()) {
+ Long2LongMap.Entry next = iterator.next();
+ if ((next.getLongValue() > maxFrequency) || (next.getLongValue() == maxFrequency
+ && max < next.getLongKey())) {
+ maxFrequency = next.getLongValue();
+ max = next.getLongKey();
+ }
+ }
+ return max;
+ case AVG:
+ double sum = first.getLongKey();
+ long count = 1;
+ while (iterator.hasNext()) {
+ Long2LongMap.Entry next = iterator.next();
+ if ((next.getLongValue() > maxFrequency)) {
+ maxFrequency = next.getLongValue();
+ sum = next.getLongKey();
+ count = 1;
+ } else if (next.getLongValue() == maxFrequency) {
+ sum += next.getLongKey();
+ count += 1;
+ }
+ }
+ return sum / count;
+ default:
+ throw new IllegalStateException(
+ "Illegal reducer type for MODE aggregation function: " + _multiModeReducerType);
+ }
+ }
+ }
+
+ public Double extractFinalResult(Float2LongOpenHashMap intermediateResult) {
+ if (intermediateResult.isEmpty()) {
+ return DEFAULT_FINAL_RESULT;
+ } else {
+ ObjectIterator<Float2LongMap.Entry> iterator = intermediateResult.float2LongEntrySet().fastIterator();
+ Float2LongMap.Entry first = iterator.next();
+ long maxFrequency = first.getLongValue();
+ switch (_multiModeReducerType) {
+ case MIN:
+ double min = first.getFloatKey();
+ while (iterator.hasNext()) {
+ Float2LongMap.Entry next = iterator.next();
+ if ((next.getLongValue() > maxFrequency) || (next.getLongValue() == maxFrequency
+ && min > next.getFloatKey())) {
+ maxFrequency = next.getLongValue();
+ min = next.getFloatKey();
+ }
+ }
+ return min;
+ case MAX:
+ double max = first.getFloatKey();
+ while (iterator.hasNext()) {
+ Float2LongMap.Entry next = iterator.next();
+ if ((next.getLongValue() > maxFrequency) || (next.getLongValue() == maxFrequency
+ && max < next.getFloatKey())) {
+ maxFrequency = next.getLongValue();
+ max = next.getFloatKey();
+ }
+ }
+ return max;
+ case AVG:
+ double sum = first.getFloatKey();
+ long count = 1;
+ while (iterator.hasNext()) {
+ Float2LongMap.Entry next = iterator.next();
+ if ((next.getLongValue() > maxFrequency)) {
+ maxFrequency = next.getLongValue();
+ sum = next.getFloatKey();
+ count = 1;
+ } else if (next.getLongValue() == maxFrequency) {
+ sum += next.getFloatKey();
+ count += 1;
+ }
+ }
+ return sum / count;
+ default:
+ throw new IllegalStateException(
+ "Illegal reducer type for MODE aggregation function: " + _multiModeReducerType);
+ }
+ }
+ }
+
+ public Double extractFinalResult(Double2LongOpenHashMap intermediateResult) {
+ if (intermediateResult.isEmpty()) {
+ return DEFAULT_FINAL_RESULT;
+ } else {
+ ObjectIterator<Double2LongMap.Entry> iterator = intermediateResult.double2LongEntrySet().fastIterator();
+ Double2LongMap.Entry first = iterator.next();
+ long maxFrequency = first.getLongValue();
+ switch (_multiModeReducerType) {
+ case MIN:
+ double min = first.getDoubleKey();
+ while (iterator.hasNext()) {
+ Double2LongMap.Entry next = iterator.next();
+ if ((next.getLongValue() > maxFrequency) || (next.getLongValue() == maxFrequency
+ && min > next.getDoubleKey())) {
+ maxFrequency = next.getLongValue();
+ min = next.getDoubleKey();
+ }
+ }
+ return min;
+ case MAX:
+ double max = first.getDoubleKey();
+ while (iterator.hasNext()) {
+ Double2LongMap.Entry next = iterator.next();
+ if ((next.getLongValue() > maxFrequency) || (next.getLongValue() == maxFrequency
+ && max < next.getDoubleKey())) {
+ maxFrequency = next.getLongValue();
+ max = next.getDoubleKey();
+ }
+ }
+ return max;
+ case AVG:
+ double sum = first.getDoubleKey();
+ long count = 1;
+ while (iterator.hasNext()) {
+ Double2LongMap.Entry next = iterator.next();
+ if ((next.getLongValue() > maxFrequency)) {
+ maxFrequency = next.getLongValue();
+ sum = next.getDoubleKey();
+ count = 1;
+ } else if (next.getLongValue() == maxFrequency) {
+ sum += next.getDoubleKey();
+ count += 1;
+ }
+ }
+ return sum / count;
+ default:
+ throw new IllegalStateException(
+ "Illegal reducer type for MODE aggregation function: " + _multiModeReducerType);
+ }
+ }
+ }
+
+ private enum MultiModeReducerType {
+ MIN, MAX, AVG
+ }
+
+ private static final class DictIdsWrapper {
+
+ final Dictionary _dictionary;
+ final Int2LongOpenHashMap _dictIdCountMap;
Review comment:
We can use `Int2IntOpenHashMap` here to reduce memory usage because this only stores the result for one segment
##########
File path: pinot-core/src/main/java/org/apache/pinot/core/query/aggregation/function/ModeAggregationFunction.java
##########
@@ -0,0 +1,704 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.pinot.core.query.aggregation.function;
+
+import com.google.common.base.Preconditions;
+import it.unimi.dsi.fastutil.doubles.Double2LongMap;
+import it.unimi.dsi.fastutil.doubles.Double2LongOpenHashMap;
+import it.unimi.dsi.fastutil.floats.Float2LongMap;
+import it.unimi.dsi.fastutil.floats.Float2LongOpenHashMap;
+import it.unimi.dsi.fastutil.ints.Int2LongMap;
+import it.unimi.dsi.fastutil.ints.Int2LongMaps;
+import it.unimi.dsi.fastutil.ints.Int2LongOpenHashMap;
+import it.unimi.dsi.fastutil.longs.Long2LongMap;
+import it.unimi.dsi.fastutil.longs.Long2LongOpenHashMap;
+import it.unimi.dsi.fastutil.objects.ObjectIterator;
+import java.util.List;
+import java.util.Map;
+import javax.annotation.Nullable;
+import org.apache.pinot.common.request.context.ExpressionContext;
+import org.apache.pinot.common.utils.DataSchema.ColumnDataType;
+import org.apache.pinot.core.common.BlockValSet;
+import org.apache.pinot.core.query.aggregation.AggregationResultHolder;
+import org.apache.pinot.core.query.aggregation.ObjectAggregationResultHolder;
+import org.apache.pinot.core.query.aggregation.groupby.GroupByResultHolder;
+import org.apache.pinot.core.query.aggregation.groupby.ObjectGroupByResultHolder;
+import org.apache.pinot.segment.spi.AggregationFunctionType;
+import org.apache.pinot.segment.spi.index.reader.Dictionary;
+import org.apache.pinot.spi.data.FieldSpec.DataType;
+
+
+/**
+ * This function is used for Mode calculations.
+ * <p>The function can be used as MODE(expression, multiModeReducerType)
+ * <p>Following arguments are supported:
+ * <ul>
+ * <li>Expression: expression that contains the column to be calculated mode on, can be any Numeric column</li>
+ * <li>MultiModeReducerType (optional): the reducer to use in case of multiple modes present in data</li>
+ * </ul>
+ */
+@SuppressWarnings({"rawtypes", "unchecked"})
+public class ModeAggregationFunction extends BaseSingleInputAggregationFunction<Map<? extends Number, Long>, Double> {
+
+ private static final double DEFAULT_FINAL_RESULT = Double.NEGATIVE_INFINITY;
+
+ private final MultiModeReducerType _multiModeReducerType;
+
+ public ModeAggregationFunction(List<ExpressionContext> arguments) {
+ super(arguments.get(0));
+
+ int numArguments = arguments.size();
+ Preconditions.checkArgument(numArguments <= 2, "Mode expects at most 2 arguments, got: %s", numArguments);
+ if (numArguments > 1) {
+ _multiModeReducerType = MultiModeReducerType.valueOf(arguments.get(1).getLiteral());
+ } else {
+ _multiModeReducerType = MultiModeReducerType.MIN;
+ }
+ }
+
+ /**
+ * Helper method to create a value map for the given value type.
+ */
+ private static Map<? extends Number, Long> getValueMap(DataType valueType) {
+ switch (valueType) {
+ case INT:
+ return new Int2LongOpenHashMap();
+ case LONG:
+ return new Long2LongOpenHashMap();
+ case FLOAT:
+ return new Float2LongOpenHashMap();
+ case DOUBLE:
+ return new Double2LongOpenHashMap();
+ default:
+ throw new IllegalStateException("Illegal data type for MODE aggregation function: " + valueType);
+ }
+ }
+
+ /**
+ * Returns the value map from the result holder or creates a new one if it does not exist.
+ */
+ protected static Map<? extends Number, Long> getValueMap(AggregationResultHolder aggregationResultHolder,
+ DataType valueType) {
+ Map<? extends Number, Long> valueMap = aggregationResultHolder.getResult();
+ if (valueMap == null) {
+ valueMap = getValueMap(valueType);
+ aggregationResultHolder.setValue(valueMap);
+ }
+ return valueMap;
+ }
+
+ /**
+ * Returns the value set for the given group key or creates a new one if it does not exist.
+ */
+ protected static Map<? extends Number, Long> getValueMap(GroupByResultHolder groupByResultHolder, int groupKey,
Review comment:
`private`?
##########
File path: pinot-core/src/main/java/org/apache/pinot/core/query/aggregation/function/ModeAggregationFunction.java
##########
@@ -0,0 +1,704 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.pinot.core.query.aggregation.function;
+
+import com.google.common.base.Preconditions;
+import it.unimi.dsi.fastutil.doubles.Double2LongMap;
+import it.unimi.dsi.fastutil.doubles.Double2LongOpenHashMap;
+import it.unimi.dsi.fastutil.floats.Float2LongMap;
+import it.unimi.dsi.fastutil.floats.Float2LongOpenHashMap;
+import it.unimi.dsi.fastutil.ints.Int2LongMap;
+import it.unimi.dsi.fastutil.ints.Int2LongMaps;
+import it.unimi.dsi.fastutil.ints.Int2LongOpenHashMap;
+import it.unimi.dsi.fastutil.longs.Long2LongMap;
+import it.unimi.dsi.fastutil.longs.Long2LongOpenHashMap;
+import it.unimi.dsi.fastutil.objects.ObjectIterator;
+import java.util.List;
+import java.util.Map;
+import javax.annotation.Nullable;
+import org.apache.pinot.common.request.context.ExpressionContext;
+import org.apache.pinot.common.utils.DataSchema.ColumnDataType;
+import org.apache.pinot.core.common.BlockValSet;
+import org.apache.pinot.core.query.aggregation.AggregationResultHolder;
+import org.apache.pinot.core.query.aggregation.ObjectAggregationResultHolder;
+import org.apache.pinot.core.query.aggregation.groupby.GroupByResultHolder;
+import org.apache.pinot.core.query.aggregation.groupby.ObjectGroupByResultHolder;
+import org.apache.pinot.segment.spi.AggregationFunctionType;
+import org.apache.pinot.segment.spi.index.reader.Dictionary;
+import org.apache.pinot.spi.data.FieldSpec.DataType;
+
+
+/**
+ * This function is used for Mode calculations.
+ * <p>The function can be used as MODE(expression, multiModeReducerType)
+ * <p>Following arguments are supported:
+ * <ul>
+ * <li>Expression: expression that contains the column to be calculated mode on, can be any Numeric column</li>
+ * <li>MultiModeReducerType (optional): the reducer to use in case of multiple modes present in data</li>
+ * </ul>
+ */
+@SuppressWarnings({"rawtypes", "unchecked"})
+public class ModeAggregationFunction extends BaseSingleInputAggregationFunction<Map<? extends Number, Long>, Double> {
+
+ private static final double DEFAULT_FINAL_RESULT = Double.NEGATIVE_INFINITY;
+
+ private final MultiModeReducerType _multiModeReducerType;
+
+ public ModeAggregationFunction(List<ExpressionContext> arguments) {
+ super(arguments.get(0));
+
+ int numArguments = arguments.size();
+ Preconditions.checkArgument(numArguments <= 2, "Mode expects at most 2 arguments, got: %s", numArguments);
+ if (numArguments > 1) {
+ _multiModeReducerType = MultiModeReducerType.valueOf(arguments.get(1).getLiteral());
+ } else {
+ _multiModeReducerType = MultiModeReducerType.MIN;
+ }
+ }
+
+ /**
+ * Helper method to create a value map for the given value type.
+ */
+ private static Map<? extends Number, Long> getValueMap(DataType valueType) {
+ switch (valueType) {
+ case INT:
+ return new Int2LongOpenHashMap();
+ case LONG:
+ return new Long2LongOpenHashMap();
+ case FLOAT:
+ return new Float2LongOpenHashMap();
+ case DOUBLE:
+ return new Double2LongOpenHashMap();
+ default:
+ throw new IllegalStateException("Illegal data type for MODE aggregation function: " + valueType);
+ }
+ }
+
+ /**
+ * Returns the value map from the result holder or creates a new one if it does not exist.
+ */
+ protected static Map<? extends Number, Long> getValueMap(AggregationResultHolder aggregationResultHolder,
Review comment:
Should this be `private`?
##########
File path: pinot-core/src/main/java/org/apache/pinot/core/query/aggregation/function/ModeAggregationFunction.java
##########
@@ -0,0 +1,704 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.pinot.core.query.aggregation.function;
+
+import com.google.common.base.Preconditions;
+import it.unimi.dsi.fastutil.doubles.Double2LongMap;
+import it.unimi.dsi.fastutil.doubles.Double2LongOpenHashMap;
+import it.unimi.dsi.fastutil.floats.Float2LongMap;
+import it.unimi.dsi.fastutil.floats.Float2LongOpenHashMap;
+import it.unimi.dsi.fastutil.ints.Int2LongMap;
+import it.unimi.dsi.fastutil.ints.Int2LongMaps;
+import it.unimi.dsi.fastutil.ints.Int2LongOpenHashMap;
+import it.unimi.dsi.fastutil.longs.Long2LongMap;
+import it.unimi.dsi.fastutil.longs.Long2LongOpenHashMap;
+import it.unimi.dsi.fastutil.objects.ObjectIterator;
+import java.util.List;
+import java.util.Map;
+import javax.annotation.Nullable;
+import org.apache.pinot.common.request.context.ExpressionContext;
+import org.apache.pinot.common.utils.DataSchema.ColumnDataType;
+import org.apache.pinot.core.common.BlockValSet;
+import org.apache.pinot.core.query.aggregation.AggregationResultHolder;
+import org.apache.pinot.core.query.aggregation.ObjectAggregationResultHolder;
+import org.apache.pinot.core.query.aggregation.groupby.GroupByResultHolder;
+import org.apache.pinot.core.query.aggregation.groupby.ObjectGroupByResultHolder;
+import org.apache.pinot.segment.spi.AggregationFunctionType;
+import org.apache.pinot.segment.spi.index.reader.Dictionary;
+import org.apache.pinot.spi.data.FieldSpec.DataType;
+
+
+/**
+ * This function is used for Mode calculations.
+ * <p>The function can be used as MODE(expression, multiModeReducerType)
+ * <p>Following arguments are supported:
+ * <ul>
+ * <li>Expression: expression that contains the column to be calculated mode on, can be any Numeric column</li>
+ * <li>MultiModeReducerType (optional): the reducer to use in case of multiple modes present in data</li>
+ * </ul>
+ */
+@SuppressWarnings({"rawtypes", "unchecked"})
+public class ModeAggregationFunction extends BaseSingleInputAggregationFunction<Map<? extends Number, Long>, Double> {
+
+ private static final double DEFAULT_FINAL_RESULT = Double.NEGATIVE_INFINITY;
+
+ private final MultiModeReducerType _multiModeReducerType;
+
+ public ModeAggregationFunction(List<ExpressionContext> arguments) {
+ super(arguments.get(0));
+
+ int numArguments = arguments.size();
+ Preconditions.checkArgument(numArguments <= 2, "Mode expects at most 2 arguments, got: %s", numArguments);
+ if (numArguments > 1) {
+ _multiModeReducerType = MultiModeReducerType.valueOf(arguments.get(1).getLiteral());
+ } else {
+ _multiModeReducerType = MultiModeReducerType.MIN;
+ }
+ }
+
+ /**
+ * Helper method to create a value map for the given value type.
+ */
+ private static Map<? extends Number, Long> getValueMap(DataType valueType) {
+ switch (valueType) {
+ case INT:
+ return new Int2LongOpenHashMap();
+ case LONG:
+ return new Long2LongOpenHashMap();
+ case FLOAT:
+ return new Float2LongOpenHashMap();
+ case DOUBLE:
+ return new Double2LongOpenHashMap();
+ default:
+ throw new IllegalStateException("Illegal data type for MODE aggregation function: " + valueType);
+ }
+ }
+
+ /**
+ * Returns the value map from the result holder or creates a new one if it does not exist.
+ */
+ protected static Map<? extends Number, Long> getValueMap(AggregationResultHolder aggregationResultHolder,
+ DataType valueType) {
+ Map<? extends Number, Long> valueMap = aggregationResultHolder.getResult();
+ if (valueMap == null) {
+ valueMap = getValueMap(valueType);
+ aggregationResultHolder.setValue(valueMap);
+ }
+ return valueMap;
+ }
+
+ /**
+ * Returns the value set for the given group key or creates a new one if it does not exist.
+ */
+ protected static Map<? extends Number, Long> getValueMap(GroupByResultHolder groupByResultHolder, int groupKey,
+ DataType valueType) {
+ Map<? extends Number, Long> valueMap = groupByResultHolder.getResult(groupKey);
+ if (valueMap == null) {
+ valueMap = getValueMap(valueType);
+ groupByResultHolder.setValueForKey(groupKey, valueMap);
+ }
+ return valueMap;
+ }
+
+ /**
+ * Helper method to set INT value for the given group keys into the result holder.
+ */
+ private static void setValueForGroupKeys(GroupByResultHolder groupByResultHolder, int groupKey, int value) {
+ ((Int2LongOpenHashMap) getValueMap(groupByResultHolder, groupKey, DataType.INT)).merge(value, 1, Long::sum);
+ }
+
+ /**
+ * Helper method to set LONG value for the given group keys into the result holder.
+ */
+ private static void setValueForGroupKeys(GroupByResultHolder groupByResultHolder, int groupKey, long value) {
+ ((Long2LongOpenHashMap) getValueMap(groupByResultHolder, groupKey, DataType.LONG)).merge(value, 1, Long::sum);
+ }
+
+ /**
+ * Helper method to set FLOAT value for the given group keys into the result holder.
+ */
+ private static void setValueForGroupKeys(GroupByResultHolder groupByResultHolder, int groupKey, float value) {
+ ((Float2LongOpenHashMap) getValueMap(groupByResultHolder, groupKey, DataType.FLOAT)).merge(value, 1, Long::sum);
+ }
+
+ /**
+ * Helper method to set DOUBLE value for the given group keys into the result holder.
+ */
+ private static void setValueForGroupKeys(GroupByResultHolder groupByResultHolder, int groupKey, double value) {
+ ((Double2LongOpenHashMap) getValueMap(groupByResultHolder, groupKey, DataType.DOUBLE)).merge(value, 1, Long::sum);
+ }
+
+ /**
+ * Returns the dictionary id count map from the result holder or creates a new one if it does not exist.
+ */
+ protected static Int2LongOpenHashMap getDictIdCountMap(AggregationResultHolder aggregationResultHolder,
+ Dictionary dictionary) {
+ ModeAggregationFunction.DictIdsWrapper dictIdsWrapper = aggregationResultHolder.getResult();
+ if (dictIdsWrapper == null) {
+ dictIdsWrapper = new ModeAggregationFunction.DictIdsWrapper(dictionary);
+ aggregationResultHolder.setValue(dictIdsWrapper);
+ }
+ return dictIdsWrapper._dictIdCountMap;
+ }
+
+ /**
+ * Returns the dictionary id count map for the given group key or creates a new one if it does not exist.
+ */
+ protected static Int2LongOpenHashMap getDictIdCountMap(GroupByResultHolder groupByResultHolder, int groupKey,
+ Dictionary dictionary) {
+ ModeAggregationFunction.DictIdsWrapper dictIdsWrapper = groupByResultHolder.getResult(groupKey);
+ if (dictIdsWrapper == null) {
+ dictIdsWrapper = new ModeAggregationFunction.DictIdsWrapper(dictionary);
+ groupByResultHolder.setValueForKey(groupKey, dictIdsWrapper);
+ }
+ return dictIdsWrapper._dictIdCountMap;
+ }
+
+ /**
+ * Helper method to read dictionary and convert dictionary ids to values for dictionary-encoded expression.
+ */
+ private static Map<? extends Number, Long> convertToValueMap(DictIdsWrapper dictIdsWrapper) {
+ Dictionary dictionary = dictIdsWrapper._dictionary;
+ Int2LongOpenHashMap dictIdCountMap = dictIdsWrapper._dictIdCountMap;
+ int numValues = dictIdCountMap.size();
+ ObjectIterator<Int2LongMap.Entry> iterator = Int2LongMaps.fastIterator(dictIdCountMap);
+ DataType storedType = dictionary.getValueType();
+ switch (storedType) {
+ case INT:
+ Int2LongOpenHashMap intValueMap = new Int2LongOpenHashMap(numValues);
+ while (iterator.hasNext()) {
+ Int2LongMap.Entry next = iterator.next();
+ intValueMap.put(dictionary.getIntValue(next.getIntKey()), next.getLongValue());
+ }
+ return intValueMap;
+ case LONG:
+ Long2LongOpenHashMap longValueMap = new Long2LongOpenHashMap(numValues);
+ while (iterator.hasNext()) {
+ Int2LongMap.Entry next = iterator.next();
+ longValueMap.put(dictionary.getLongValue(next.getIntKey()), next.getLongValue());
+ }
+ return longValueMap;
+ case FLOAT:
+ Float2LongOpenHashMap floatValueMap = new Float2LongOpenHashMap(numValues);
+ while (iterator.hasNext()) {
+ Int2LongMap.Entry next = iterator.next();
+ floatValueMap.put(dictionary.getFloatValue(next.getIntKey()), next.getLongValue());
+ }
+ return floatValueMap;
+ case DOUBLE:
+ Double2LongOpenHashMap doubleValueMap = new Double2LongOpenHashMap(numValues);
+ while (iterator.hasNext()) {
+ Int2LongMap.Entry next = iterator.next();
+ doubleValueMap.put(dictionary.getFloatValue(next.getIntKey()), next.getLongValue());
+ }
+ return doubleValueMap;
+ default:
+ throw new IllegalStateException("Illegal data type for MODE aggregation function: " + storedType);
+ }
+ }
+
+ /**
+ * Helper method to extract segment level intermediate result from the inner segment result.
+ */
+ private static Map<? extends Number, Long> extractIntermediateResult(@Nullable Object result) {
+ if (result == null) {
+ // NOTE: Return an empty Int2LongOpenHashMap for empty result.
+ return new Int2LongOpenHashMap();
+ }
+
+ if (result instanceof DictIdsWrapper) {
+ // For dictionary-encoded expression, convert dictionary ids to values
+ return convertToValueMap((DictIdsWrapper) result);
+ }
+ assert result instanceof Map;
+ // For non-dictionary-encoded expression, directly return the value set
+ return (Map) result;
+ }
+
+ @Override
+ public AggregationFunctionType getType() {
+ return AggregationFunctionType.MODE;
+ }
+
+ @Override
+ public AggregationResultHolder createAggregationResultHolder() {
+ return new ObjectAggregationResultHolder();
+ }
+
+ @Override
+ public GroupByResultHolder createGroupByResultHolder(int initialCapacity, int maxCapacity) {
+ return new ObjectGroupByResultHolder(initialCapacity, maxCapacity);
+ }
+
+ @Override
+ public void aggregate(int length, AggregationResultHolder aggregationResultHolder,
+ Map<ExpressionContext, BlockValSet> blockValSetMap) {
+ BlockValSet blockValSet = blockValSetMap.get(_expression);
+
+ // For dictionary-encoded expression, store dictionary ids into the dictId map
+ Dictionary dictionary = blockValSet.getDictionary();
+ if (dictionary != null) {
+ int[] dictIds = blockValSet.getDictionaryIdsSV();
+ Int2LongOpenHashMap dictIdValueMap = getDictIdCountMap(aggregationResultHolder, dictionary);
+ for (int i = 0; i < length; i++) {
+ dictIdValueMap.merge(dictIds[i], 1, Long::sum);
+ }
+ return;
+ }
+
+ // For non-dictionary-encoded expression, store values into the value map
+ DataType storedType = blockValSet.getValueType().getStoredType();
+ Map<? extends Number, Long> valueMap = getValueMap(aggregationResultHolder, storedType);
+ switch (storedType) {
+ case INT:
+ Int2LongOpenHashMap intMap = (Int2LongOpenHashMap) valueMap;
+ int[] intValues = blockValSet.getIntValuesSV();
+ for (int i = 0; i < length; i++) {
+ intMap.merge(intValues[i], 1, Long::sum);
+ }
+ break;
+ case LONG:
+ Long2LongOpenHashMap longMap = (Long2LongOpenHashMap) valueMap;
+ long[] longValues = blockValSet.getLongValuesSV();
+ for (int i = 0; i < length; i++) {
+ longMap.merge(longValues[i], 1, Long::sum);
+ }
+ break;
+ case FLOAT:
+ Float2LongOpenHashMap floatMap = (Float2LongOpenHashMap) valueMap;
+ float[] floatValues = blockValSet.getFloatValuesSV();
+ for (int i = 0; i < length; i++) {
+ floatMap.merge(floatValues[i], 1, Long::sum);
+ }
+ break;
+ case DOUBLE:
+ Double2LongOpenHashMap doubleMap = (Double2LongOpenHashMap) valueMap;
+ double[] doubleValues = blockValSet.getDoubleValuesSV();
+ for (int i = 0; i < length; i++) {
+ doubleMap.merge(doubleValues[i], 1, Long::sum);
+ }
+ break;
+ default:
+ throw new IllegalStateException("Illegal data type for MODE aggregation function: " + storedType);
+ }
+ }
+
+ @Override
+ public void aggregateGroupBySV(int length, int[] groupKeyArray, GroupByResultHolder groupByResultHolder,
+ Map<ExpressionContext, BlockValSet> blockValSetMap) {
+ BlockValSet blockValSet = blockValSetMap.get(_expression);
+
+ // For dictionary-encoded expression, store dictionary ids into the dictId map
+ Dictionary dictionary = blockValSet.getDictionary();
+ if (dictionary != null) {
+ int[] dictIds = blockValSet.getDictionaryIdsSV();
+ for (int i = 0; i < length; i++) {
+ getDictIdCountMap(groupByResultHolder, groupKeyArray[i], dictionary).merge(dictIds[i], 1, Long::sum);
+ }
+ return;
+ }
+
+ // For non-dictionary-encoded expression, store values into the value map
+ DataType storedType = blockValSet.getValueType().getStoredType();
+ switch (storedType) {
+ case INT:
+ int[] intValues = blockValSet.getIntValuesSV();
+ for (int i = 0; i < length; i++) {
+ setValueForGroupKeys(groupByResultHolder, groupKeyArray[i], intValues[i]);
+ }
+ break;
+ case LONG:
+ long[] longValues = blockValSet.getLongValuesSV();
+ for (int i = 0; i < length; i++) {
+ setValueForGroupKeys(groupByResultHolder, groupKeyArray[i], longValues[i]);
+ }
+ break;
+ case FLOAT:
+ float[] floatValues = blockValSet.getFloatValuesSV();
+ for (int i = 0; i < length; i++) {
+ setValueForGroupKeys(groupByResultHolder, groupKeyArray[i], floatValues[i]);
+ }
+ break;
+ case DOUBLE:
+ double[] doubleValues = blockValSet.getDoubleValuesSV();
+ for (int i = 0; i < length; i++) {
+ setValueForGroupKeys(groupByResultHolder, groupKeyArray[i], doubleValues[i]);
+ }
+ break;
+ default:
+ throw new IllegalStateException("Illegal data type for MODE aggregation function: " + storedType);
+ }
+ }
+
+ @Override
+ public void aggregateGroupByMV(int length, int[][] groupKeysArray, GroupByResultHolder groupByResultHolder,
+ Map<ExpressionContext, BlockValSet> blockValSetMap) {
+ BlockValSet blockValSet = blockValSetMap.get(_expression);
+
+ // For dictionary-encoded expression, store dictionary ids into the dictId map
+ Dictionary dictionary = blockValSet.getDictionary();
+ if (dictionary != null) {
+ int[] dictIds = blockValSet.getDictionaryIdsSV();
+ for (int i = 0; i < length; i++) {
+ for (int groupKey : groupKeysArray[i]) {
+ getDictIdCountMap(groupByResultHolder, groupKey, dictionary).merge(dictIds[i], 1, Long::sum);
+ }
+ }
+ return;
+ }
+
+ // For non-dictionary-encoded expression, store values into the value map
+ DataType storedType = blockValSet.getValueType().getStoredType();
+ switch (storedType) {
+ case INT:
+ int[] intValues = blockValSet.getIntValuesSV();
+ for (int i = 0; i < length; i++) {
+ for (int groupKey : groupKeysArray[i]) {
+ setValueForGroupKeys(groupByResultHolder, groupKey, intValues[i]);
+ }
+ }
+ break;
+ case LONG:
+ long[] longValues = blockValSet.getLongValuesSV();
+ for (int i = 0; i < length; i++) {
+ for (int groupKey : groupKeysArray[i]) {
+ setValueForGroupKeys(groupByResultHolder, groupKey, longValues[i]);
+ }
+ }
+ break;
+ case FLOAT:
+ float[] floatValues = blockValSet.getFloatValuesSV();
+ for (int i = 0; i < length; i++) {
+ for (int groupKey : groupKeysArray[i]) {
+ setValueForGroupKeys(groupByResultHolder, groupKey, floatValues[i]);
+ }
+ }
+ break;
+ case DOUBLE:
+ double[] doubleValues = blockValSet.getDoubleValuesSV();
+ for (int i = 0; i < length; i++) {
+ for (int groupKey : groupKeysArray[i]) {
+ setValueForGroupKeys(groupByResultHolder, groupKey, doubleValues[i]);
+ }
+ }
+ break;
+ default:
+ throw new IllegalStateException("Illegal data type for MODE aggregation function: " + storedType);
+ }
+ }
+
+ @Override
+ public Map<? extends Number, Long> extractAggregationResult(AggregationResultHolder aggregationResultHolder) {
+ return extractIntermediateResult(aggregationResultHolder.getResult());
+ }
+
+ @Override
+ public Map<? extends Number, Long> extractGroupByResult(GroupByResultHolder groupByResultHolder, int groupKey) {
+ return extractIntermediateResult(groupByResultHolder.getResult(groupKey));
+ }
+
+ @Override
+ public Map<? extends Number, Long> merge(Map<? extends Number, Long> intermediateResult1,
+ Map<? extends Number, Long> intermediateResult2) {
+ if (intermediateResult1.isEmpty()) {
+ return intermediateResult2;
+ }
+ if (intermediateResult2.isEmpty()) {
+ return intermediateResult1;
+ }
+ if (intermediateResult1 instanceof Int2LongOpenHashMap && intermediateResult2 instanceof Int2LongOpenHashMap) {
+ ((Int2LongOpenHashMap) intermediateResult2).int2LongEntrySet().fastForEach(
+ e -> ((Int2LongOpenHashMap) intermediateResult1).merge(e.getIntKey(), e.getLongValue(), Long::sum));
+ } else if (intermediateResult1 instanceof Long2LongOpenHashMap
+ && intermediateResult2 instanceof Long2LongOpenHashMap) {
+ ((Long2LongOpenHashMap) intermediateResult2).long2LongEntrySet().fastForEach(
+ e -> ((Long2LongOpenHashMap) intermediateResult1).merge(e.getLongKey(), e.getLongValue(), Long::sum));
+ } else if (intermediateResult1 instanceof Float2LongOpenHashMap
+ && intermediateResult2 instanceof Float2LongOpenHashMap) {
+ ((Float2LongOpenHashMap) intermediateResult2).float2LongEntrySet().fastForEach(
+ e -> ((Float2LongOpenHashMap) intermediateResult1).merge(e.getFloatKey(), e.getLongValue(), Long::sum));
+ } else if (intermediateResult1 instanceof Double2LongOpenHashMap
+ && intermediateResult2 instanceof Double2LongOpenHashMap) {
+ ((Double2LongOpenHashMap) intermediateResult2).double2LongEntrySet().fastForEach(
+ e -> ((Double2LongOpenHashMap) intermediateResult1).merge(e.getDoubleKey(), e.getLongValue(), Long::sum));
+ } else {
+ throw new IllegalStateException(
+ "Illegal data type for Intermediate Result of MODE aggregation function: " + intermediateResult1.getClass()
+ .getSimpleName() + ", " + intermediateResult2.getClass().getSimpleName());
+ }
+ return intermediateResult1;
+ }
+
+ @Override
+ public boolean isIntermediateResultComparable() {
+ return false;
+ }
+
+ @Override
+ public ColumnDataType getIntermediateResultColumnType() {
+ return ColumnDataType.OBJECT;
+ }
+
+ @Override
+ public ColumnDataType getFinalResultColumnType() {
+ return ColumnDataType.DOUBLE;
+ }
+
+ @Override
+ public Double extractFinalResult(Map<? extends Number, Long> intermediateResult) {
+ if (intermediateResult.isEmpty()) {
+ return DEFAULT_FINAL_RESULT;
+ } else if (intermediateResult instanceof Int2LongOpenHashMap) {
+ return extractFinalResult((Int2LongOpenHashMap) intermediateResult);
+ } else if (intermediateResult instanceof Long2LongOpenHashMap) {
+ return extractFinalResult((Long2LongOpenHashMap) intermediateResult);
+ } else if (intermediateResult instanceof Float2LongOpenHashMap) {
+ return extractFinalResult((Float2LongOpenHashMap) intermediateResult);
+ } else if (intermediateResult instanceof Double2LongOpenHashMap) {
+ return extractFinalResult((Double2LongOpenHashMap) intermediateResult);
+ } else {
+ throw new IllegalStateException(
+ "Illegal data type for Intermediate Result of MODE aggregation function: " + intermediateResult.getClass()
+ .getSimpleName());
+ }
+ }
+
+ public Double extractFinalResult(Int2LongOpenHashMap intermediateResult) {
+ if (intermediateResult.isEmpty()) {
+ return DEFAULT_FINAL_RESULT;
+ } else {
+ ObjectIterator<Int2LongMap.Entry> iterator = intermediateResult.int2LongEntrySet().fastIterator();
+ Int2LongMap.Entry first = iterator.next();
+ long maxFrequency = first.getLongValue();
+ switch (_multiModeReducerType) {
+ case MIN:
+ double min = first.getIntKey();
Review comment:
Use `int`? Same for other types
##########
File path: pinot-core/src/main/java/org/apache/pinot/core/query/aggregation/function/ModeAggregationFunction.java
##########
@@ -0,0 +1,704 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.pinot.core.query.aggregation.function;
+
+import com.google.common.base.Preconditions;
+import it.unimi.dsi.fastutil.doubles.Double2LongMap;
+import it.unimi.dsi.fastutil.doubles.Double2LongOpenHashMap;
+import it.unimi.dsi.fastutil.floats.Float2LongMap;
+import it.unimi.dsi.fastutil.floats.Float2LongOpenHashMap;
+import it.unimi.dsi.fastutil.ints.Int2LongMap;
+import it.unimi.dsi.fastutil.ints.Int2LongMaps;
+import it.unimi.dsi.fastutil.ints.Int2LongOpenHashMap;
+import it.unimi.dsi.fastutil.longs.Long2LongMap;
+import it.unimi.dsi.fastutil.longs.Long2LongOpenHashMap;
+import it.unimi.dsi.fastutil.objects.ObjectIterator;
+import java.util.List;
+import java.util.Map;
+import javax.annotation.Nullable;
+import org.apache.pinot.common.request.context.ExpressionContext;
+import org.apache.pinot.common.utils.DataSchema.ColumnDataType;
+import org.apache.pinot.core.common.BlockValSet;
+import org.apache.pinot.core.query.aggregation.AggregationResultHolder;
+import org.apache.pinot.core.query.aggregation.ObjectAggregationResultHolder;
+import org.apache.pinot.core.query.aggregation.groupby.GroupByResultHolder;
+import org.apache.pinot.core.query.aggregation.groupby.ObjectGroupByResultHolder;
+import org.apache.pinot.segment.spi.AggregationFunctionType;
+import org.apache.pinot.segment.spi.index.reader.Dictionary;
+import org.apache.pinot.spi.data.FieldSpec.DataType;
+
+
+/**
+ * This function is used for Mode calculations.
+ * <p>The function can be used as MODE(expression, multiModeReducerType)
+ * <p>Following arguments are supported:
+ * <ul>
+ * <li>Expression: expression that contains the column to be calculated mode on, can be any Numeric column</li>
+ * <li>MultiModeReducerType (optional): the reducer to use in case of multiple modes present in data</li>
+ * </ul>
+ */
+@SuppressWarnings({"rawtypes", "unchecked"})
+public class ModeAggregationFunction extends BaseSingleInputAggregationFunction<Map<? extends Number, Long>, Double> {
+
+ private static final double DEFAULT_FINAL_RESULT = Double.NEGATIVE_INFINITY;
+
+ private final MultiModeReducerType _multiModeReducerType;
+
+ public ModeAggregationFunction(List<ExpressionContext> arguments) {
+ super(arguments.get(0));
+
+ int numArguments = arguments.size();
+ Preconditions.checkArgument(numArguments <= 2, "Mode expects at most 2 arguments, got: %s", numArguments);
+ if (numArguments > 1) {
+ _multiModeReducerType = MultiModeReducerType.valueOf(arguments.get(1).getLiteral());
+ } else {
+ _multiModeReducerType = MultiModeReducerType.MIN;
+ }
+ }
+
+ /**
+ * Helper method to create a value map for the given value type.
+ */
+ private static Map<? extends Number, Long> getValueMap(DataType valueType) {
+ switch (valueType) {
+ case INT:
+ return new Int2LongOpenHashMap();
+ case LONG:
+ return new Long2LongOpenHashMap();
+ case FLOAT:
+ return new Float2LongOpenHashMap();
+ case DOUBLE:
+ return new Double2LongOpenHashMap();
+ default:
+ throw new IllegalStateException("Illegal data type for MODE aggregation function: " + valueType);
+ }
+ }
+
+ /**
+ * Returns the value map from the result holder or creates a new one if it does not exist.
+ */
+ protected static Map<? extends Number, Long> getValueMap(AggregationResultHolder aggregationResultHolder,
+ DataType valueType) {
+ Map<? extends Number, Long> valueMap = aggregationResultHolder.getResult();
+ if (valueMap == null) {
+ valueMap = getValueMap(valueType);
+ aggregationResultHolder.setValue(valueMap);
+ }
+ return valueMap;
+ }
+
+ /**
+ * Returns the value set for the given group key or creates a new one if it does not exist.
+ */
+ protected static Map<? extends Number, Long> getValueMap(GroupByResultHolder groupByResultHolder, int groupKey,
+ DataType valueType) {
+ Map<? extends Number, Long> valueMap = groupByResultHolder.getResult(groupKey);
+ if (valueMap == null) {
+ valueMap = getValueMap(valueType);
+ groupByResultHolder.setValueForKey(groupKey, valueMap);
+ }
+ return valueMap;
+ }
+
+ /**
+ * Helper method to set INT value for the given group keys into the result holder.
+ */
+ private static void setValueForGroupKeys(GroupByResultHolder groupByResultHolder, int groupKey, int value) {
+ ((Int2LongOpenHashMap) getValueMap(groupByResultHolder, groupKey, DataType.INT)).merge(value, 1, Long::sum);
Review comment:
For the best performance, we can directly construct the map here to avoid the unnecessary switch case in `getValueMap()`
##########
File path: pinot-core/src/main/java/org/apache/pinot/core/query/aggregation/function/ModeAggregationFunction.java
##########
@@ -0,0 +1,704 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.pinot.core.query.aggregation.function;
+
+import com.google.common.base.Preconditions;
+import it.unimi.dsi.fastutil.doubles.Double2LongMap;
+import it.unimi.dsi.fastutil.doubles.Double2LongOpenHashMap;
+import it.unimi.dsi.fastutil.floats.Float2LongMap;
+import it.unimi.dsi.fastutil.floats.Float2LongOpenHashMap;
+import it.unimi.dsi.fastutil.ints.Int2LongMap;
+import it.unimi.dsi.fastutil.ints.Int2LongMaps;
+import it.unimi.dsi.fastutil.ints.Int2LongOpenHashMap;
+import it.unimi.dsi.fastutil.longs.Long2LongMap;
+import it.unimi.dsi.fastutil.longs.Long2LongOpenHashMap;
+import it.unimi.dsi.fastutil.objects.ObjectIterator;
+import java.util.List;
+import java.util.Map;
+import javax.annotation.Nullable;
+import org.apache.pinot.common.request.context.ExpressionContext;
+import org.apache.pinot.common.utils.DataSchema.ColumnDataType;
+import org.apache.pinot.core.common.BlockValSet;
+import org.apache.pinot.core.query.aggregation.AggregationResultHolder;
+import org.apache.pinot.core.query.aggregation.ObjectAggregationResultHolder;
+import org.apache.pinot.core.query.aggregation.groupby.GroupByResultHolder;
+import org.apache.pinot.core.query.aggregation.groupby.ObjectGroupByResultHolder;
+import org.apache.pinot.segment.spi.AggregationFunctionType;
+import org.apache.pinot.segment.spi.index.reader.Dictionary;
+import org.apache.pinot.spi.data.FieldSpec.DataType;
+
+
+/**
+ * This function is used for Mode calculations.
+ * <p>The function can be used as MODE(expression, multiModeReducerType)
+ * <p>Following arguments are supported:
+ * <ul>
+ * <li>Expression: expression that contains the column to be calculated mode on, can be any Numeric column</li>
+ * <li>MultiModeReducerType (optional): the reducer to use in case of multiple modes present in data</li>
+ * </ul>
+ */
+@SuppressWarnings({"rawtypes", "unchecked"})
+public class ModeAggregationFunction extends BaseSingleInputAggregationFunction<Map<? extends Number, Long>, Double> {
+
+ private static final double DEFAULT_FINAL_RESULT = Double.NEGATIVE_INFINITY;
+
+ private final MultiModeReducerType _multiModeReducerType;
+
+ public ModeAggregationFunction(List<ExpressionContext> arguments) {
+ super(arguments.get(0));
+
+ int numArguments = arguments.size();
+ Preconditions.checkArgument(numArguments <= 2, "Mode expects at most 2 arguments, got: %s", numArguments);
+ if (numArguments > 1) {
+ _multiModeReducerType = MultiModeReducerType.valueOf(arguments.get(1).getLiteral());
+ } else {
+ _multiModeReducerType = MultiModeReducerType.MIN;
+ }
+ }
+
+ /**
+ * Helper method to create a value map for the given value type.
+ */
+ private static Map<? extends Number, Long> getValueMap(DataType valueType) {
+ switch (valueType) {
+ case INT:
+ return new Int2LongOpenHashMap();
+ case LONG:
+ return new Long2LongOpenHashMap();
+ case FLOAT:
+ return new Float2LongOpenHashMap();
+ case DOUBLE:
+ return new Double2LongOpenHashMap();
+ default:
+ throw new IllegalStateException("Illegal data type for MODE aggregation function: " + valueType);
+ }
+ }
+
+ /**
+ * Returns the value map from the result holder or creates a new one if it does not exist.
+ */
+ protected static Map<? extends Number, Long> getValueMap(AggregationResultHolder aggregationResultHolder,
+ DataType valueType) {
+ Map<? extends Number, Long> valueMap = aggregationResultHolder.getResult();
+ if (valueMap == null) {
+ valueMap = getValueMap(valueType);
+ aggregationResultHolder.setValue(valueMap);
+ }
+ return valueMap;
+ }
+
+ /**
+ * Returns the value set for the given group key or creates a new one if it does not exist.
+ */
+ protected static Map<? extends Number, Long> getValueMap(GroupByResultHolder groupByResultHolder, int groupKey,
+ DataType valueType) {
+ Map<? extends Number, Long> valueMap = groupByResultHolder.getResult(groupKey);
+ if (valueMap == null) {
+ valueMap = getValueMap(valueType);
+ groupByResultHolder.setValueForKey(groupKey, valueMap);
+ }
+ return valueMap;
+ }
+
+ /**
+ * Helper method to set INT value for the given group keys into the result holder.
+ */
+ private static void setValueForGroupKeys(GroupByResultHolder groupByResultHolder, int groupKey, int value) {
+ ((Int2LongOpenHashMap) getValueMap(groupByResultHolder, groupKey, DataType.INT)).merge(value, 1, Long::sum);
+ }
+
+ /**
+ * Helper method to set LONG value for the given group keys into the result holder.
+ */
+ private static void setValueForGroupKeys(GroupByResultHolder groupByResultHolder, int groupKey, long value) {
+ ((Long2LongOpenHashMap) getValueMap(groupByResultHolder, groupKey, DataType.LONG)).merge(value, 1, Long::sum);
+ }
+
+ /**
+ * Helper method to set FLOAT value for the given group keys into the result holder.
+ */
+ private static void setValueForGroupKeys(GroupByResultHolder groupByResultHolder, int groupKey, float value) {
+ ((Float2LongOpenHashMap) getValueMap(groupByResultHolder, groupKey, DataType.FLOAT)).merge(value, 1, Long::sum);
+ }
+
+ /**
+ * Helper method to set DOUBLE value for the given group keys into the result holder.
+ */
+ private static void setValueForGroupKeys(GroupByResultHolder groupByResultHolder, int groupKey, double value) {
+ ((Double2LongOpenHashMap) getValueMap(groupByResultHolder, groupKey, DataType.DOUBLE)).merge(value, 1, Long::sum);
+ }
+
+ /**
+ * Returns the dictionary id count map from the result holder or creates a new one if it does not exist.
+ */
+ protected static Int2LongOpenHashMap getDictIdCountMap(AggregationResultHolder aggregationResultHolder,
+ Dictionary dictionary) {
+ ModeAggregationFunction.DictIdsWrapper dictIdsWrapper = aggregationResultHolder.getResult();
+ if (dictIdsWrapper == null) {
+ dictIdsWrapper = new ModeAggregationFunction.DictIdsWrapper(dictionary);
+ aggregationResultHolder.setValue(dictIdsWrapper);
+ }
+ return dictIdsWrapper._dictIdCountMap;
+ }
+
+ /**
+ * Returns the dictionary id count map for the given group key or creates a new one if it does not exist.
+ */
+ protected static Int2LongOpenHashMap getDictIdCountMap(GroupByResultHolder groupByResultHolder, int groupKey,
+ Dictionary dictionary) {
+ ModeAggregationFunction.DictIdsWrapper dictIdsWrapper = groupByResultHolder.getResult(groupKey);
+ if (dictIdsWrapper == null) {
+ dictIdsWrapper = new ModeAggregationFunction.DictIdsWrapper(dictionary);
+ groupByResultHolder.setValueForKey(groupKey, dictIdsWrapper);
+ }
+ return dictIdsWrapper._dictIdCountMap;
+ }
+
+ /**
+ * Helper method to read dictionary and convert dictionary ids to values for dictionary-encoded expression.
+ */
+ private static Map<? extends Number, Long> convertToValueMap(DictIdsWrapper dictIdsWrapper) {
+ Dictionary dictionary = dictIdsWrapper._dictionary;
+ Int2LongOpenHashMap dictIdCountMap = dictIdsWrapper._dictIdCountMap;
+ int numValues = dictIdCountMap.size();
+ ObjectIterator<Int2LongMap.Entry> iterator = Int2LongMaps.fastIterator(dictIdCountMap);
+ DataType storedType = dictionary.getValueType();
+ switch (storedType) {
+ case INT:
+ Int2LongOpenHashMap intValueMap = new Int2LongOpenHashMap(numValues);
+ while (iterator.hasNext()) {
+ Int2LongMap.Entry next = iterator.next();
+ intValueMap.put(dictionary.getIntValue(next.getIntKey()), next.getLongValue());
+ }
+ return intValueMap;
+ case LONG:
+ Long2LongOpenHashMap longValueMap = new Long2LongOpenHashMap(numValues);
+ while (iterator.hasNext()) {
+ Int2LongMap.Entry next = iterator.next();
+ longValueMap.put(dictionary.getLongValue(next.getIntKey()), next.getLongValue());
+ }
+ return longValueMap;
+ case FLOAT:
+ Float2LongOpenHashMap floatValueMap = new Float2LongOpenHashMap(numValues);
+ while (iterator.hasNext()) {
+ Int2LongMap.Entry next = iterator.next();
+ floatValueMap.put(dictionary.getFloatValue(next.getIntKey()), next.getLongValue());
+ }
+ return floatValueMap;
+ case DOUBLE:
+ Double2LongOpenHashMap doubleValueMap = new Double2LongOpenHashMap(numValues);
+ while (iterator.hasNext()) {
+ Int2LongMap.Entry next = iterator.next();
+ doubleValueMap.put(dictionary.getFloatValue(next.getIntKey()), next.getLongValue());
Review comment:
(Critical)
```suggestion
doubleValueMap.put(dictionary.getDoubleValue(next.getIntKey()), next.getLongValue());
```
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@pinot.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@pinot.apache.org
For additional commands, e-mail: commits-help@pinot.apache.org
[GitHub] [pinot] codecov-commenter edited a comment on pull request #7318: add mode aggregation function
Posted by GitBox <gi...@apache.org>.
codecov-commenter edited a comment on pull request #7318:
URL: https://github.com/apache/pinot/pull/7318#issuecomment-901092615
# [Codecov](https://codecov.io/gh/apache/pinot/pull/7318?src=pr&el=h1&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation) Report
> Merging [#7318](https://codecov.io/gh/apache/pinot/pull/7318?src=pr&el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation) (a7def22) into [master](https://codecov.io/gh/apache/pinot/commit/a539958eef8480cf95e39ed4788543e3d094c7bf?el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation) (a539958) will **increase** coverage by `0.03%`.
> The diff coverage is `79.95%`.
[](https://codecov.io/gh/apache/pinot/pull/7318?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation)
```diff
@@ Coverage Diff @@
## master #7318 +/- ##
============================================
+ Coverage 71.47% 71.51% +0.03%
+ Complexity 3283 3280 -3
============================================
Files 1504 1504
Lines 73975 74310 +335
Branches 10704 10797 +93
============================================
+ Hits 52876 53140 +264
- Misses 17505 17545 +40
- Partials 3594 3625 +31
```
| Flag | Coverage Δ | |
|---|---|---|
| integration1 | `30.64% <2.00%> (-0.27%)` | :arrow_down: |
| integration2 | `29.08% <2.00%> (-0.23%)` | :arrow_down: |
| unittests1 | `69.18% <79.95%> (+0.10%)` | :arrow_up: |
| unittests2 | `14.51% <0.00%> (-0.14%)` | :arrow_down: |
Flags with carried forward coverage won't be shown. [Click here](https://docs.codecov.io/docs/carryforward-flags?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#carryforward-flags-in-the-pull-request-comment) to find out more.
| [Impacted Files](https://codecov.io/gh/apache/pinot/pull/7318?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation) | Coverage Δ | |
|---|---|---|
| [.../aggregation/function/ModeAggregationFunction.java](https://codecov.io/gh/apache/pinot/pull/7318/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-cGlub3QtY29yZS9zcmMvbWFpbi9qYXZhL29yZy9hcGFjaGUvcGlub3QvY29yZS9xdWVyeS9hZ2dyZWdhdGlvbi9mdW5jdGlvbi9Nb2RlQWdncmVnYXRpb25GdW5jdGlvbi5qYXZh) | `75.67% <75.67%> (ø)` | |
| [...org/apache/pinot/core/common/ObjectSerDeUtils.java](https://codecov.io/gh/apache/pinot/pull/7318/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-cGlub3QtY29yZS9zcmMvbWFpbi9qYXZhL29yZy9hcGFjaGUvcGlub3QvY29yZS9jb21tb24vT2JqZWN0U2VyRGVVdGlscy5qYXZh) | `89.75% <100.00%> (+2.08%)` | :arrow_up: |
| [...gregation/function/AggregationFunctionFactory.java](https://codecov.io/gh/apache/pinot/pull/7318/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-cGlub3QtY29yZS9zcmMvbWFpbi9qYXZhL29yZy9hcGFjaGUvcGlub3QvY29yZS9xdWVyeS9hZ2dyZWdhdGlvbi9mdW5jdGlvbi9BZ2dyZWdhdGlvbkZ1bmN0aW9uRmFjdG9yeS5qYXZh) | `88.60% <100.00%> (+0.14%)` | :arrow_up: |
| [...che/pinot/segment/spi/AggregationFunctionType.java](https://codecov.io/gh/apache/pinot/pull/7318/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-cGlub3Qtc2VnbWVudC1zcGkvc3JjL21haW4vamF2YS9vcmcvYXBhY2hlL3Bpbm90L3NlZ21lbnQvc3BpL0FnZ3JlZ2F0aW9uRnVuY3Rpb25UeXBlLmphdmE=) | `100.00% <100.00%> (ø)` | |
| [...ller/helix/core/minion/TaskTypeMetricsUpdater.java](https://codecov.io/gh/apache/pinot/pull/7318/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-cGlub3QtY29udHJvbGxlci9zcmMvbWFpbi9qYXZhL29yZy9hcGFjaGUvcGlub3QvY29udHJvbGxlci9oZWxpeC9jb3JlL21pbmlvbi9UYXNrVHlwZU1ldHJpY3NVcGRhdGVyLmphdmE=) | `80.00% <0.00%> (-20.00%)` | :arrow_down: |
| [...r/helix/SegmentOnlineOfflineStateModelFactory.java](https://codecov.io/gh/apache/pinot/pull/7318/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-cGlub3Qtc2VydmVyL3NyYy9tYWluL2phdmEvb3JnL2FwYWNoZS9waW5vdC9zZXJ2ZXIvc3RhcnRlci9oZWxpeC9TZWdtZW50T25saW5lT2ZmbGluZVN0YXRlTW9kZWxGYWN0b3J5LmphdmE=) | `58.87% <0.00%> (-6.55%)` | :arrow_down: |
| [.../startree/v2/builder/OffHeapSingleTreeBuilder.java](https://codecov.io/gh/apache/pinot/pull/7318/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-cGlub3Qtc2VnbWVudC1sb2NhbC9zcmMvbWFpbi9qYXZhL29yZy9hcGFjaGUvcGlub3Qvc2VnbWVudC9sb2NhbC9zdGFydHJlZS92Mi9idWlsZGVyL09mZkhlYXBTaW5nbGVUcmVlQnVpbGRlci5qYXZh) | `83.23% <0.00%> (-4.20%)` | :arrow_down: |
| [...pinot/plugin/inputformat/parquet/ParquetUtils.java](https://codecov.io/gh/apache/pinot/pull/7318/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-cGlub3QtcGx1Z2lucy9waW5vdC1pbnB1dC1mb3JtYXQvcGlub3QtcGFycXVldC9zcmMvbWFpbi9qYXZhL29yZy9hcGFjaGUvcGlub3QvcGx1Z2luL2lucHV0Zm9ybWF0L3BhcnF1ZXQvUGFycXVldFV0aWxzLmphdmE=) | `43.75% <0.00%> (-3.31%)` | :arrow_down: |
| [...lix/core/realtime/PinotRealtimeSegmentManager.java](https://codecov.io/gh/apache/pinot/pull/7318/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-cGlub3QtY29udHJvbGxlci9zcmMvbWFpbi9qYXZhL29yZy9hcGFjaGUvcGlub3QvY29udHJvbGxlci9oZWxpeC9jb3JlL3JlYWx0aW1lL1Bpbm90UmVhbHRpbWVTZWdtZW50TWFuYWdlci5qYXZh) | `80.82% <0.00%> (-3.11%)` | :arrow_down: |
| [...he/pinot/plugin/minion/tasks/BaseTaskExecutor.java](https://codecov.io/gh/apache/pinot/pull/7318/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-cGlub3QtcGx1Z2lucy9waW5vdC1taW5pb24tdGFza3MvcGlub3QtbWluaW9uLWJ1aWx0aW4tdGFza3Mvc3JjL21haW4vamF2YS9vcmcvYXBhY2hlL3Bpbm90L3BsdWdpbi9taW5pb24vdGFza3MvQmFzZVRhc2tFeGVjdXRvci5qYXZh) | `76.92% <0.00%> (-3.08%)` | :arrow_down: |
| ... and [76 more](https://codecov.io/gh/apache/pinot/pull/7318/diff?src=pr&el=tree-more&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation) | |
------
[Continue to review full report at Codecov](https://codecov.io/gh/apache/pinot/pull/7318?src=pr&el=continue&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation).
> **Legend** - [Click here to learn more](https://docs.codecov.io/docs/codecov-delta?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation)
> `Δ = absolute <relative> (impact)`, `ø = not affected`, `? = missing data`
> Powered by [Codecov](https://codecov.io/gh/apache/pinot/pull/7318?src=pr&el=footer&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation). Last update [a539958...a7def22](https://codecov.io/gh/apache/pinot/pull/7318?src=pr&el=lastupdated&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation). Read the [comment docs](https://docs.codecov.io/docs/pull-request-comments?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation).
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@pinot.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@pinot.apache.org
For additional commands, e-mail: commits-help@pinot.apache.org
[GitHub] [pinot] codecov-commenter commented on pull request #7318: add mode aggregation function
Posted by GitBox <gi...@apache.org>.
codecov-commenter commented on pull request #7318:
URL: https://github.com/apache/pinot/pull/7318#issuecomment-901092615
# [Codecov](https://codecov.io/gh/apache/pinot/pull/7318?src=pr&el=h1&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation) Report
> Merging [#7318](https://codecov.io/gh/apache/pinot/pull/7318?src=pr&el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation) (57e0c97) into [master](https://codecov.io/gh/apache/pinot/commit/a539958eef8480cf95e39ed4788543e3d094c7bf?el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation) (a539958) will **decrease** coverage by `6.90%`.
> The diff coverage is `66.81%`.
[](https://codecov.io/gh/apache/pinot/pull/7318?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation)
```diff
@@ Coverage Diff @@
## master #7318 +/- ##
============================================
- Coverage 71.47% 64.57% -6.91%
- Complexity 3283 3290 +7
============================================
Files 1504 1458 -46
Lines 73975 72403 -1572
Branches 10704 10594 -110
============================================
- Hits 52876 46754 -6122
- Misses 17505 22283 +4778
+ Partials 3594 3366 -228
```
| Flag | Coverage Δ | |
|---|---|---|
| integration1 | `?` | |
| integration2 | `?` | |
| unittests1 | `69.13% <66.81%> (+0.05%)` | :arrow_up: |
| unittests2 | `14.49% <0.00%> (-0.16%)` | :arrow_down: |
Flags with carried forward coverage won't be shown. [Click here](https://docs.codecov.io/docs/carryforward-flags?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#carryforward-flags-in-the-pull-request-comment) to find out more.
| [Impacted Files](https://codecov.io/gh/apache/pinot/pull/7318?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation) | Coverage Δ | |
|---|---|---|
| [.../aggregation/function/ModeAggregationFunction.java](https://codecov.io/gh/apache/pinot/pull/7318/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-cGlub3QtY29yZS9zcmMvbWFpbi9qYXZhL29yZy9hcGFjaGUvcGlub3QvY29yZS9xdWVyeS9hZ2dyZWdhdGlvbi9mdW5jdGlvbi9Nb2RlQWdncmVnYXRpb25GdW5jdGlvbi5qYXZh) | `59.72% <59.72%> (ø)` | |
| [...org/apache/pinot/core/common/ObjectSerDeUtils.java](https://codecov.io/gh/apache/pinot/pull/7318/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-cGlub3QtY29yZS9zcmMvbWFpbi9qYXZhL29yZy9hcGFjaGUvcGlub3QvY29yZS9jb21tb24vT2JqZWN0U2VyRGVVdGlscy5qYXZh) | `89.75% <100.00%> (+2.08%)` | :arrow_up: |
| [...gregation/function/AggregationFunctionFactory.java](https://codecov.io/gh/apache/pinot/pull/7318/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-cGlub3QtY29yZS9zcmMvbWFpbi9qYXZhL29yZy9hcGFjaGUvcGlub3QvY29yZS9xdWVyeS9hZ2dyZWdhdGlvbi9mdW5jdGlvbi9BZ2dyZWdhdGlvbkZ1bmN0aW9uRmFjdG9yeS5qYXZh) | `88.60% <100.00%> (+0.14%)` | :arrow_up: |
| [...che/pinot/segment/spi/AggregationFunctionType.java](https://codecov.io/gh/apache/pinot/pull/7318/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-cGlub3Qtc2VnbWVudC1zcGkvc3JjL21haW4vamF2YS9vcmcvYXBhY2hlL3Bpbm90L3NlZ21lbnQvc3BpL0FnZ3JlZ2F0aW9uRnVuY3Rpb25UeXBlLmphdmE=) | `100.00% <100.00%> (ø)` | |
| [...a/org/apache/pinot/common/metrics/MinionMeter.java](https://codecov.io/gh/apache/pinot/pull/7318/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-cGlub3QtY29tbW9uL3NyYy9tYWluL2phdmEvb3JnL2FwYWNoZS9waW5vdC9jb21tb24vbWV0cmljcy9NaW5pb25NZXRlci5qYXZh) | `0.00% <0.00%> (-100.00%)` | :arrow_down: |
| [...g/apache/pinot/common/metrics/ControllerMeter.java](https://codecov.io/gh/apache/pinot/pull/7318/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-cGlub3QtY29tbW9uL3NyYy9tYWluL2phdmEvb3JnL2FwYWNoZS9waW5vdC9jb21tb24vbWV0cmljcy9Db250cm9sbGVyTWV0ZXIuamF2YQ==) | `0.00% <0.00%> (-100.00%)` | :arrow_down: |
| [.../apache/pinot/common/metrics/BrokerQueryPhase.java](https://codecov.io/gh/apache/pinot/pull/7318/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-cGlub3QtY29tbW9uL3NyYy9tYWluL2phdmEvb3JnL2FwYWNoZS9waW5vdC9jb21tb24vbWV0cmljcy9Ccm9rZXJRdWVyeVBoYXNlLmphdmE=) | `0.00% <0.00%> (-100.00%)` | :arrow_down: |
| [.../apache/pinot/common/metrics/MinionQueryPhase.java](https://codecov.io/gh/apache/pinot/pull/7318/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-cGlub3QtY29tbW9uL3NyYy9tYWluL2phdmEvb3JnL2FwYWNoZS9waW5vdC9jb21tb24vbWV0cmljcy9NaW5pb25RdWVyeVBoYXNlLmphdmE=) | `0.00% <0.00%> (-100.00%)` | :arrow_down: |
| [...pache/pinot/common/utils/grpc/GrpcQueryClient.java](https://codecov.io/gh/apache/pinot/pull/7318/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-cGlub3QtY29tbW9uL3NyYy9tYWluL2phdmEvb3JnL2FwYWNoZS9waW5vdC9jb21tb24vdXRpbHMvZ3JwYy9HcnBjUXVlcnlDbGllbnQuamF2YQ==) | `0.00% <0.00%> (-100.00%)` | :arrow_down: |
| [...he/pinot/common/messages/SegmentReloadMessage.java](https://codecov.io/gh/apache/pinot/pull/7318/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-cGlub3QtY29tbW9uL3NyYy9tYWluL2phdmEvb3JnL2FwYWNoZS9waW5vdC9jb21tb24vbWVzc2FnZXMvU2VnbWVudFJlbG9hZE1lc3NhZ2UuamF2YQ==) | `0.00% <0.00%> (-100.00%)` | :arrow_down: |
| ... and [401 more](https://codecov.io/gh/apache/pinot/pull/7318/diff?src=pr&el=tree-more&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation) | |
------
[Continue to review full report at Codecov](https://codecov.io/gh/apache/pinot/pull/7318?src=pr&el=continue&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation).
> **Legend** - [Click here to learn more](https://docs.codecov.io/docs/codecov-delta?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation)
> `Δ = absolute <relative> (impact)`, `ø = not affected`, `? = missing data`
> Powered by [Codecov](https://codecov.io/gh/apache/pinot/pull/7318?src=pr&el=footer&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation). Last update [a539958...57e0c97](https://codecov.io/gh/apache/pinot/pull/7318?src=pr&el=lastupdated&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation). Read the [comment docs](https://docs.codecov.io/docs/pull-request-comments?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation).
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@pinot.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@pinot.apache.org
For additional commands, e-mail: commits-help@pinot.apache.org
[GitHub] [pinot] codecov-commenter edited a comment on pull request #7318: add mode aggregation function
Posted by GitBox <gi...@apache.org>.
codecov-commenter edited a comment on pull request #7318:
URL: https://github.com/apache/pinot/pull/7318#issuecomment-901092615
# [Codecov](https://codecov.io/gh/apache/pinot/pull/7318?src=pr&el=h1&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation) Report
> Merging [#7318](https://codecov.io/gh/apache/pinot/pull/7318?src=pr&el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation) (60f7b0a) into [master](https://codecov.io/gh/apache/pinot/commit/a539958eef8480cf95e39ed4788543e3d094c7bf?el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation) (a539958) will **decrease** coverage by `1.00%`.
> The diff coverage is `90.44%`.
[](https://codecov.io/gh/apache/pinot/pull/7318?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation)
```diff
@@ Coverage Diff @@
## master #7318 +/- ##
============================================
- Coverage 71.47% 70.47% -1.01%
- Complexity 3283 3286 +3
============================================
Files 1504 1504
Lines 73975 74320 +345
Branches 10704 10800 +96
============================================
- Hits 52876 52378 -498
- Misses 17505 18329 +824
- Partials 3594 3613 +19
```
| Flag | Coverage Δ | |
|---|---|---|
| integration1 | `30.38% <2.00%> (-0.52%)` | :arrow_down: |
| integration2 | `?` | |
| unittests1 | `69.30% <90.44%> (+0.22%)` | :arrow_up: |
| unittests2 | `14.51% <0.00%> (-0.14%)` | :arrow_down: |
Flags with carried forward coverage won't be shown. [Click here](https://docs.codecov.io/docs/carryforward-flags?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#carryforward-flags-in-the-pull-request-comment) to find out more.
| [Impacted Files](https://codecov.io/gh/apache/pinot/pull/7318?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation) | Coverage Δ | |
|---|---|---|
| [.../aggregation/function/ModeAggregationFunction.java](https://codecov.io/gh/apache/pinot/pull/7318/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-cGlub3QtY29yZS9zcmMvbWFpbi9qYXZhL29yZy9hcGFjaGUvcGlub3QvY29yZS9xdWVyeS9hZ2dyZWdhdGlvbi9mdW5jdGlvbi9Nb2RlQWdncmVnYXRpb25GdW5jdGlvbi5qYXZh) | `88.40% <88.40%> (ø)` | |
| [...org/apache/pinot/core/common/ObjectSerDeUtils.java](https://codecov.io/gh/apache/pinot/pull/7318/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-cGlub3QtY29yZS9zcmMvbWFpbi9qYXZhL29yZy9hcGFjaGUvcGlub3QvY29yZS9jb21tb24vT2JqZWN0U2VyRGVVdGlscy5qYXZh) | `89.75% <100.00%> (+2.08%)` | :arrow_up: |
| [...gregation/function/AggregationFunctionFactory.java](https://codecov.io/gh/apache/pinot/pull/7318/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-cGlub3QtY29yZS9zcmMvbWFpbi9qYXZhL29yZy9hcGFjaGUvcGlub3QvY29yZS9xdWVyeS9hZ2dyZWdhdGlvbi9mdW5jdGlvbi9BZ2dyZWdhdGlvbkZ1bmN0aW9uRmFjdG9yeS5qYXZh) | `88.60% <100.00%> (+0.14%)` | :arrow_up: |
| [...che/pinot/segment/spi/AggregationFunctionType.java](https://codecov.io/gh/apache/pinot/pull/7318/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-cGlub3Qtc2VnbWVudC1zcGkvc3JjL21haW4vamF2YS9vcmcvYXBhY2hlL3Bpbm90L3NlZ21lbnQvc3BpL0FnZ3JlZ2F0aW9uRnVuY3Rpb25UeXBlLmphdmE=) | `100.00% <100.00%> (ø)` | |
| [...pache/pinot/common/utils/grpc/GrpcQueryClient.java](https://codecov.io/gh/apache/pinot/pull/7318/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-cGlub3QtY29tbW9uL3NyYy9tYWluL2phdmEvb3JnL2FwYWNoZS9waW5vdC9jb21tb24vdXRpbHMvZ3JwYy9HcnBjUXVlcnlDbGllbnQuamF2YQ==) | `0.00% <0.00%> (-100.00%)` | :arrow_down: |
| [...ore/operator/streaming/StreamingResponseUtils.java](https://codecov.io/gh/apache/pinot/pull/7318/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-cGlub3QtY29yZS9zcmMvbWFpbi9qYXZhL29yZy9hcGFjaGUvcGlub3QvY29yZS9vcGVyYXRvci9zdHJlYW1pbmcvU3RyZWFtaW5nUmVzcG9uc2VVdGlscy5qYXZh) | `0.00% <0.00%> (-100.00%)` | :arrow_down: |
| [...ager/realtime/PeerSchemeSplitSegmentCommitter.java](https://codecov.io/gh/apache/pinot/pull/7318/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-cGlub3QtY29yZS9zcmMvbWFpbi9qYXZhL29yZy9hcGFjaGUvcGlub3QvY29yZS9kYXRhL21hbmFnZXIvcmVhbHRpbWUvUGVlclNjaGVtZVNwbGl0U2VnbWVudENvbW1pdHRlci5qYXZh) | `0.00% <0.00%> (-100.00%)` | :arrow_down: |
| [...ator/streaming/StreamingSelectionOnlyOperator.java](https://codecov.io/gh/apache/pinot/pull/7318/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-cGlub3QtY29yZS9zcmMvbWFpbi9qYXZhL29yZy9hcGFjaGUvcGlub3QvY29yZS9vcGVyYXRvci9zdHJlYW1pbmcvU3RyZWFtaW5nU2VsZWN0aW9uT25seU9wZXJhdG9yLmphdmE=) | `0.00% <0.00%> (-92.31%)` | :arrow_down: |
| [...he/pinot/core/plan/StreamingSelectionPlanNode.java](https://codecov.io/gh/apache/pinot/pull/7318/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-cGlub3QtY29yZS9zcmMvbWFpbi9qYXZhL29yZy9hcGFjaGUvcGlub3QvY29yZS9wbGFuL1N0cmVhbWluZ1NlbGVjdGlvblBsYW5Ob2RlLmphdmE=) | `0.00% <0.00%> (-90.00%)` | :arrow_down: |
| [...ller/api/access/BasicAuthAccessControlFactory.java](https://codecov.io/gh/apache/pinot/pull/7318/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-cGlub3QtY29udHJvbGxlci9zcmMvbWFpbi9qYXZhL29yZy9hcGFjaGUvcGlub3QvY29udHJvbGxlci9hcGkvYWNjZXNzL0Jhc2ljQXV0aEFjY2Vzc0NvbnRyb2xGYWN0b3J5LmphdmE=) | `0.00% <0.00%> (-80.00%)` | :arrow_down: |
| ... and [148 more](https://codecov.io/gh/apache/pinot/pull/7318/diff?src=pr&el=tree-more&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation) | |
------
[Continue to review full report at Codecov](https://codecov.io/gh/apache/pinot/pull/7318?src=pr&el=continue&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation).
> **Legend** - [Click here to learn more](https://docs.codecov.io/docs/codecov-delta?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation)
> `Δ = absolute <relative> (impact)`, `ø = not affected`, `? = missing data`
> Powered by [Codecov](https://codecov.io/gh/apache/pinot/pull/7318?src=pr&el=footer&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation). Last update [a539958...60f7b0a](https://codecov.io/gh/apache/pinot/pull/7318?src=pr&el=lastupdated&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation). Read the [comment docs](https://docs.codecov.io/docs/pull-request-comments?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation).
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@pinot.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@pinot.apache.org
For additional commands, e-mail: commits-help@pinot.apache.org
[GitHub] [pinot] codecov-commenter edited a comment on pull request #7318: add mode aggregation function
Posted by GitBox <gi...@apache.org>.
codecov-commenter edited a comment on pull request #7318:
URL: https://github.com/apache/pinot/pull/7318#issuecomment-901092615
# [Codecov](https://codecov.io/gh/apache/pinot/pull/7318?src=pr&el=h1&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation) Report
> Merging [#7318](https://codecov.io/gh/apache/pinot/pull/7318?src=pr&el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation) (57e0c97) into [master](https://codecov.io/gh/apache/pinot/commit/a539958eef8480cf95e39ed4788543e3d094c7bf?el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation) (a539958) will **decrease** coverage by `1.32%`.
> The diff coverage is `66.81%`.
[](https://codecov.io/gh/apache/pinot/pull/7318?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation)
```diff
@@ Coverage Diff @@
## master #7318 +/- ##
============================================
- Coverage 71.47% 70.15% -1.33%
- Complexity 3283 3290 +7
============================================
Files 1504 1504
Lines 73975 74310 +335
Branches 10704 10797 +93
============================================
- Hits 52876 52131 -745
- Misses 17505 18564 +1059
- Partials 3594 3615 +21
```
| Flag | Coverage Δ | |
|---|---|---|
| integration1 | `?` | |
| integration2 | `29.05% <2.00%> (-0.26%)` | :arrow_down: |
| unittests1 | `69.13% <66.81%> (+0.05%)` | :arrow_up: |
| unittests2 | `14.49% <0.00%> (-0.16%)` | :arrow_down: |
Flags with carried forward coverage won't be shown. [Click here](https://docs.codecov.io/docs/carryforward-flags?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#carryforward-flags-in-the-pull-request-comment) to find out more.
| [Impacted Files](https://codecov.io/gh/apache/pinot/pull/7318?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation) | Coverage Δ | |
|---|---|---|
| [.../aggregation/function/ModeAggregationFunction.java](https://codecov.io/gh/apache/pinot/pull/7318/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-cGlub3QtY29yZS9zcmMvbWFpbi9qYXZhL29yZy9hcGFjaGUvcGlub3QvY29yZS9xdWVyeS9hZ2dyZWdhdGlvbi9mdW5jdGlvbi9Nb2RlQWdncmVnYXRpb25GdW5jdGlvbi5qYXZh) | `59.72% <59.72%> (ø)` | |
| [...org/apache/pinot/core/common/ObjectSerDeUtils.java](https://codecov.io/gh/apache/pinot/pull/7318/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-cGlub3QtY29yZS9zcmMvbWFpbi9qYXZhL29yZy9hcGFjaGUvcGlub3QvY29yZS9jb21tb24vT2JqZWN0U2VyRGVVdGlscy5qYXZh) | `89.75% <100.00%> (+2.08%)` | :arrow_up: |
| [...gregation/function/AggregationFunctionFactory.java](https://codecov.io/gh/apache/pinot/pull/7318/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-cGlub3QtY29yZS9zcmMvbWFpbi9qYXZhL29yZy9hcGFjaGUvcGlub3QvY29yZS9xdWVyeS9hZ2dyZWdhdGlvbi9mdW5jdGlvbi9BZ2dyZWdhdGlvbkZ1bmN0aW9uRmFjdG9yeS5qYXZh) | `88.60% <100.00%> (+0.14%)` | :arrow_up: |
| [...che/pinot/segment/spi/AggregationFunctionType.java](https://codecov.io/gh/apache/pinot/pull/7318/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-cGlub3Qtc2VnbWVudC1zcGkvc3JjL21haW4vamF2YS9vcmcvYXBhY2hlL3Bpbm90L3NlZ21lbnQvc3BpL0FnZ3JlZ2F0aW9uRnVuY3Rpb25UeXBlLmphdmE=) | `100.00% <100.00%> (ø)` | |
| [...pinot/minion/exception/TaskCancelledException.java](https://codecov.io/gh/apache/pinot/pull/7318/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-cGlub3QtbWluaW9uL3NyYy9tYWluL2phdmEvb3JnL2FwYWNoZS9waW5vdC9taW5pb24vZXhjZXB0aW9uL1Rhc2tDYW5jZWxsZWRFeGNlcHRpb24uamF2YQ==) | `0.00% <0.00%> (-100.00%)` | :arrow_down: |
| [...ore/startree/executor/StarTreeGroupByExecutor.java](https://codecov.io/gh/apache/pinot/pull/7318/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-cGlub3QtY29yZS9zcmMvbWFpbi9qYXZhL29yZy9hcGFjaGUvcGlub3QvY29yZS9zdGFydHJlZS9leGVjdXRvci9TdGFyVHJlZUdyb3VwQnlFeGVjdXRvci5qYXZh) | `0.00% <0.00%> (-86.67%)` | :arrow_down: |
| [.../transform/function/MapValueTransformFunction.java](https://codecov.io/gh/apache/pinot/pull/7318/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-cGlub3QtY29yZS9zcmMvbWFpbi9qYXZhL29yZy9hcGFjaGUvcGlub3QvY29yZS9vcGVyYXRvci90cmFuc2Zvcm0vZnVuY3Rpb24vTWFwVmFsdWVUcmFuc2Zvcm1GdW5jdGlvbi5qYXZh) | `0.00% <0.00%> (-85.30%)` | :arrow_down: |
| [...plugin/segmentuploader/SegmentUploaderDefault.java](https://codecov.io/gh/apache/pinot/pull/7318/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-cGlub3QtcGx1Z2lucy9waW5vdC1zZWdtZW50LXVwbG9hZGVyL3Bpbm90LXNlZ21lbnQtdXBsb2FkZXItZGVmYXVsdC9zcmMvbWFpbi9qYXZhL29yZy9hcGFjaGUvcGlub3QvcGx1Z2luL3NlZ21lbnR1cGxvYWRlci9TZWdtZW50VXBsb2FkZXJEZWZhdWx0LmphdmE=) | `0.00% <0.00%> (-85.19%)` | :arrow_down: |
| [...ot/common/messages/RoutingTableRebuildMessage.java](https://codecov.io/gh/apache/pinot/pull/7318/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-cGlub3QtY29tbW9uL3NyYy9tYWluL2phdmEvb3JnL2FwYWNoZS9waW5vdC9jb21tb24vbWVzc2FnZXMvUm91dGluZ1RhYmxlUmVidWlsZE1lc3NhZ2UuamF2YQ==) | `0.00% <0.00%> (-81.82%)` | :arrow_down: |
| [...e/pinot/common/minion/MergeRollupTaskMetadata.java](https://codecov.io/gh/apache/pinot/pull/7318/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-cGlub3QtY29tbW9uL3NyYy9tYWluL2phdmEvb3JnL2FwYWNoZS9waW5vdC9jb21tb24vbWluaW9uL01lcmdlUm9sbHVwVGFza01ldGFkYXRhLmphdmE=) | `0.00% <0.00%> (-78.27%)` | :arrow_down: |
| ... and [154 more](https://codecov.io/gh/apache/pinot/pull/7318/diff?src=pr&el=tree-more&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation) | |
------
[Continue to review full report at Codecov](https://codecov.io/gh/apache/pinot/pull/7318?src=pr&el=continue&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation).
> **Legend** - [Click here to learn more](https://docs.codecov.io/docs/codecov-delta?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation)
> `Δ = absolute <relative> (impact)`, `ø = not affected`, `? = missing data`
> Powered by [Codecov](https://codecov.io/gh/apache/pinot/pull/7318?src=pr&el=footer&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation). Last update [a539958...57e0c97](https://codecov.io/gh/apache/pinot/pull/7318?src=pr&el=lastupdated&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation). Read the [comment docs](https://docs.codecov.io/docs/pull-request-comments?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation).
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@pinot.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@pinot.apache.org
For additional commands, e-mail: commits-help@pinot.apache.org
[GitHub] [pinot] codecov-commenter edited a comment on pull request #7318: add mode aggregation function
Posted by GitBox <gi...@apache.org>.
codecov-commenter edited a comment on pull request #7318:
URL: https://github.com/apache/pinot/pull/7318#issuecomment-901092615
# [Codecov](https://codecov.io/gh/apache/pinot/pull/7318?src=pr&el=h1&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation) Report
> Merging [#7318](https://codecov.io/gh/apache/pinot/pull/7318?src=pr&el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation) (57e0c97) into [master](https://codecov.io/gh/apache/pinot/commit/a539958eef8480cf95e39ed4788543e3d094c7bf?el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation) (a539958) will **decrease** coverage by `0.08%`.
> The diff coverage is `66.81%`.
[](https://codecov.io/gh/apache/pinot/pull/7318?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation)
```diff
@@ Coverage Diff @@
## master #7318 +/- ##
============================================
- Coverage 71.47% 71.39% -0.09%
- Complexity 3283 3290 +7
============================================
Files 1504 1504
Lines 73975 74310 +335
Branches 10704 10797 +93
============================================
+ Hits 52876 53051 +175
- Misses 17505 17644 +139
- Partials 3594 3615 +21
```
| Flag | Coverage Δ | |
|---|---|---|
| integration1 | `30.47% <2.00%> (-0.43%)` | :arrow_down: |
| integration2 | `29.05% <2.00%> (-0.26%)` | :arrow_down: |
| unittests1 | `69.13% <66.81%> (+0.05%)` | :arrow_up: |
| unittests2 | `14.49% <0.00%> (-0.16%)` | :arrow_down: |
Flags with carried forward coverage won't be shown. [Click here](https://docs.codecov.io/docs/carryforward-flags?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#carryforward-flags-in-the-pull-request-comment) to find out more.
| [Impacted Files](https://codecov.io/gh/apache/pinot/pull/7318?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation) | Coverage Δ | |
|---|---|---|
| [.../aggregation/function/ModeAggregationFunction.java](https://codecov.io/gh/apache/pinot/pull/7318/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-cGlub3QtY29yZS9zcmMvbWFpbi9qYXZhL29yZy9hcGFjaGUvcGlub3QvY29yZS9xdWVyeS9hZ2dyZWdhdGlvbi9mdW5jdGlvbi9Nb2RlQWdncmVnYXRpb25GdW5jdGlvbi5qYXZh) | `59.72% <59.72%> (ø)` | |
| [...org/apache/pinot/core/common/ObjectSerDeUtils.java](https://codecov.io/gh/apache/pinot/pull/7318/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-cGlub3QtY29yZS9zcmMvbWFpbi9qYXZhL29yZy9hcGFjaGUvcGlub3QvY29yZS9jb21tb24vT2JqZWN0U2VyRGVVdGlscy5qYXZh) | `89.75% <100.00%> (+2.08%)` | :arrow_up: |
| [...gregation/function/AggregationFunctionFactory.java](https://codecov.io/gh/apache/pinot/pull/7318/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-cGlub3QtY29yZS9zcmMvbWFpbi9qYXZhL29yZy9hcGFjaGUvcGlub3QvY29yZS9xdWVyeS9hZ2dyZWdhdGlvbi9mdW5jdGlvbi9BZ2dyZWdhdGlvbkZ1bmN0aW9uRmFjdG9yeS5qYXZh) | `88.60% <100.00%> (+0.14%)` | :arrow_up: |
| [...che/pinot/segment/spi/AggregationFunctionType.java](https://codecov.io/gh/apache/pinot/pull/7318/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-cGlub3Qtc2VnbWVudC1zcGkvc3JjL21haW4vamF2YS9vcmcvYXBhY2hlL3Bpbm90L3NlZ21lbnQvc3BpL0FnZ3JlZ2F0aW9uRnVuY3Rpb25UeXBlLmphdmE=) | `100.00% <100.00%> (ø)` | |
| [...data/manager/realtime/SegmentCommitterFactory.java](https://codecov.io/gh/apache/pinot/pull/7318/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-cGlub3QtY29yZS9zcmMvbWFpbi9qYXZhL29yZy9hcGFjaGUvcGlub3QvY29yZS9kYXRhL21hbmFnZXIvcmVhbHRpbWUvU2VnbWVudENvbW1pdHRlckZhY3RvcnkuamF2YQ==) | `64.70% <0.00%> (-29.42%)` | :arrow_down: |
| [...ller/helix/core/minion/TaskTypeMetricsUpdater.java](https://codecov.io/gh/apache/pinot/pull/7318/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-cGlub3QtY29udHJvbGxlci9zcmMvbWFpbi9qYXZhL29yZy9hcGFjaGUvcGlub3QvY29udHJvbGxlci9oZWxpeC9jb3JlL21pbmlvbi9UYXNrVHlwZU1ldHJpY3NVcGRhdGVyLmphdmE=) | `80.00% <0.00%> (-20.00%)` | :arrow_down: |
| [...er/api/resources/LLCSegmentCompletionHandlers.java](https://codecov.io/gh/apache/pinot/pull/7318/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-cGlub3QtY29udHJvbGxlci9zcmMvbWFpbi9qYXZhL29yZy9hcGFjaGUvcGlub3QvY29udHJvbGxlci9hcGkvcmVzb3VyY2VzL0xMQ1NlZ21lbnRDb21wbGV0aW9uSGFuZGxlcnMuamF2YQ==) | `52.40% <0.00%> (-8.66%)` | :arrow_down: |
| [...altime/ServerSegmentCompletionProtocolHandler.java](https://codecov.io/gh/apache/pinot/pull/7318/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-cGlub3QtY29yZS9zcmMvbWFpbi9qYXZhL29yZy9hcGFjaGUvcGlub3Qvc2VydmVyL3JlYWx0aW1lL1NlcnZlclNlZ21lbnRDb21wbGV0aW9uUHJvdG9jb2xIYW5kbGVyLmphdmE=) | `49.52% <0.00%> (-8.58%)` | :arrow_down: |
| [...nction/DistinctCountBitmapAggregationFunction.java](https://codecov.io/gh/apache/pinot/pull/7318/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-cGlub3QtY29yZS9zcmMvbWFpbi9qYXZhL29yZy9hcGFjaGUvcGlub3QvY29yZS9xdWVyeS9hZ2dyZWdhdGlvbi9mdW5jdGlvbi9EaXN0aW5jdENvdW50Qml0bWFwQWdncmVnYXRpb25GdW5jdGlvbi5qYXZh) | `49.48% <0.00%> (-7.74%)` | :arrow_down: |
| [...inot/core/util/SegmentCompletionProtocolUtils.java](https://codecov.io/gh/apache/pinot/pull/7318/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-cGlub3QtY29yZS9zcmMvbWFpbi9qYXZhL29yZy9hcGFjaGUvcGlub3QvY29yZS91dGlsL1NlZ21lbnRDb21wbGV0aW9uUHJvdG9jb2xVdGlscy5qYXZh) | `53.84% <0.00%> (-7.70%)` | :arrow_down: |
| ... and [88 more](https://codecov.io/gh/apache/pinot/pull/7318/diff?src=pr&el=tree-more&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation) | |
------
[Continue to review full report at Codecov](https://codecov.io/gh/apache/pinot/pull/7318?src=pr&el=continue&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation).
> **Legend** - [Click here to learn more](https://docs.codecov.io/docs/codecov-delta?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation)
> `Δ = absolute <relative> (impact)`, `ø = not affected`, `? = missing data`
> Powered by [Codecov](https://codecov.io/gh/apache/pinot/pull/7318?src=pr&el=footer&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation). Last update [a539958...57e0c97](https://codecov.io/gh/apache/pinot/pull/7318?src=pr&el=lastupdated&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation). Read the [comment docs](https://docs.codecov.io/docs/pull-request-comments?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation).
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@pinot.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@pinot.apache.org
For additional commands, e-mail: commits-help@pinot.apache.org
[GitHub] [pinot] Jackie-Jiang merged pull request #7318: add mode aggregation function
Posted by GitBox <gi...@apache.org>.
Jackie-Jiang merged pull request #7318:
URL: https://github.com/apache/pinot/pull/7318
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@pinot.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@pinot.apache.org
For additional commands, e-mail: commits-help@pinot.apache.org