You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@druid.apache.org by GitBox <gi...@apache.org> on 2020/04/09 21:26:24 UTC

[GitHub] [druid] jihoonson opened a new pull request #9655: Fix wrong cardinality computation in BufferArrayGrouper

jihoonson opened a new pull request #9655: Fix wrong cardinality computation in BufferArrayGrouper
URL: https://github.com/apache/druid/pull/9655
 
 
   ### Description
   
   The below query fails with an integer overflow because of wrong cardinality computation in `BufferArrayGrouper`.
   
   ```
   > select count(*) from wikitikcer where page in (select k from lookup.lu);
   
   Caused by: java.lang.IllegalArgumentException: Out of range: 2147483648
           at com.google.common.primitives.Ints.checkedCast(Ints.java:91) ~[guava-16.0.1.jar:?]
           at org.apache.druid.query.groupby.epinephelinae.BufferArrayGrouper.<init>(BufferArrayGrouper.java:111) ~[druid-processing-0.19.0-SNAPSHOT.jar:0.19.0-SNAPSHOT]
           at org.apache.druid.query.groupby.epinephelinae.GroupByQueryEngineV2$ArrayAggregateIterator.newGrouper(GroupByQueryEngineV2.java:750) ~[druid-processing-0.19.0-SNAPSHOT.jar:0.19.0-SNAPSHOT]
           at org.apache.druid.query.groupby.epinephelinae.GroupByQueryEngineV2$ArrayAggregateIterator.newGrouper(GroupByQueryEngineV2.java:712) ~[druid-processing-0.19.0-SNAPSHOT.jar:0.19.0-SNAPSHOT]
           at org.apache.druid.query.groupby.epinephelinae.GroupByQueryEngineV2$GroupByEngineIterator.initNewDelegate(GroupByQueryEngineV2.java:411) ~[druid-processing-0.19.0-SNAPSHOT.jar:0.19.0-SNAPSHOT]
           at org.apache.druid.query.groupby.epinephelinae.GroupByQueryEngineV2$GroupByEngineIterator.hasNext(GroupByQueryEngineV2.java:469) ~[druid-processing-0.19.0-SNAPSHOT.jar:0.19.0-SNAPSHOT]
           at org.apache.druid.java.util.common.guava.BaseSequence.accumulate(BaseSequence.java:43) ~[druid-core-0.19.0-SNAPSHOT.jar:0.19.0-SNAPSHOT]
           at org.apache.druid.java.util.common.guava.ConcatSequence.lambda$accumulate$0(ConcatSequence.java:41) ~[druid-core-0.19.0-SNAPSHOT.jar:0.19.0-SNAPSHOT]
           at org.apache.druid.java.util.common.guava.MappingAccumulator.accumulate(MappingAccumulator.java:40) ~[druid-core-0.19.0-SNAPSHOT.jar:0.19.0-SNAPSHOT]
           at org.apache.druid.java.util.common.guava.BaseSequence.accumulate(BaseSequence.java:44) ~[druid-core-0.19.0-SNAPSHOT.jar:0.19.0-SNAPSHOT]
           at org.apache.druid.java.util.common.guava.MappedSequence.accumulate(MappedSequence.java:43) ~[druid-core-0.19.0-SNAPSHOT.jar:0.19.0-SNAPSHOT]
           at org.apache.druid.java.util.common.guava.ConcatSequence.accumulate(ConcatSequence.java:41) ~[druid-core-0.19.0-SNAPSHOT.jar:0.19.0-SNAPSHOT]
           at org.apache.druid.java.util.common.guava.WrappingSequence$1.get(WrappingSequence.java:50) ~[druid-core-0.19.0-SNAPSHOT.jar:0.19.0-SNAPSHOT]
           at org.apache.druid.java.util.common.guava.SequenceWrapper.wrap(SequenceWrapper.java:55) ~[druid-core-0.19.0-SNAPSHOT.jar:0.19.0-SNAPSHOT]
           at org.apache.druid.java.util.common.guava.WrappingSequence.accumulate(WrappingSequence.java:45) ~[druid-core-0.19.0-SNAPSHOT.jar:0.19.0-SNAPSHOT]
           at org.apache.druid.query.groupby.epinephelinae.GroupByMergingQueryRunnerV2$1$1$1.call(GroupByMergingQueryRunnerV2.java:246) ~[druid-processing-0.19.0-SNAPSHOT.jar:0.19.0-SNAPSHOT]
           at org.apache.druid.query.groupby.epinephelinae.GroupByMergingQueryRunnerV2$1$1$1.call(GroupByMergingQueryRunnerV2.java:233) ~[druid-processing-0.19.0-SNAPSHOT.jar:0.19.0-SNAPSHOT]
           at java.util.concurrent.FutureTask.run(FutureTask.java:266) ~[?:1.8.0_242]
   ```
   
   <hr>
   
   This PR has:
   - [x] been self-reviewed.
      - [ ] using the [concurrency checklist](https://github.com/apache/druid/blob/master/dev/code-review/concurrency.md) (Remove this item if the PR doesn't have any relation to concurrency.)
   - [ ] added documentation for new or modified features or behaviors.
   - [ ] added Javadocs for most classes and all non-trivial methods. Linked related entities via Javadoc links.
   - [ ] added or updated version, license, or notice information in [licenses.yaml](https://github.com/apache/druid/blob/master/licenses.yaml)
   - [x] added comments explaining the "why" and the intent of the code wherever would not be obvious for an unfamiliar reader.
   - [x] added unit tests or modified existing tests to cover new code paths.
   - [ ] added integration tests.
   - [ ] been tested in a test Druid cluster.

----------------------------------------------------------------
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.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services

---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@druid.apache.org
For additional commands, e-mail: commits-help@druid.apache.org


[GitHub] [druid] fjy merged pull request #9655: Fix wrong cardinality computation in BufferArrayGrouper

Posted by GitBox <gi...@apache.org>.
fjy merged pull request #9655: Fix wrong cardinality computation in BufferArrayGrouper
URL: https://github.com/apache/druid/pull/9655
 
 
   

----------------------------------------------------------------
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.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services

---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@druid.apache.org
For additional commands, e-mail: commits-help@druid.apache.org


[GitHub] [druid] jon-wei commented on a change in pull request #9655: Fix wrong cardinality computation in BufferArrayGrouper

Posted by GitBox <gi...@apache.org>.
jon-wei commented on a change in pull request #9655: Fix wrong cardinality computation in BufferArrayGrouper
URL: https://github.com/apache/druid/pull/9655#discussion_r406550265
 
 

 ##########
 File path: processing/src/main/java/org/apache/druid/query/groupby/epinephelinae/BufferArrayGrouper.java
 ##########
 @@ -69,12 +69,20 @@
   @Nullable
   private int[] vAggregationRows = null;
 
-  static long requiredBufferCapacity(
-      int cardinality,
-      AggregatorFactory[] aggregatorFactories
-  )
+  /**
+   * Computes required buffer capacity for a grouping key of the given cardinaltiy and aggregatorFactories.
+   * This method assumes that the given cardinality doesn't count nulls.
+   *
+   * Returns -1 if it cardinality + 1 (for null) = Integer.MAX_VALUE. Returns computed required buffer capacity
 
 Review comment:
   I think the comment here should have `> Integer.MAX_VALUE` instead

----------------------------------------------------------------
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.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services

---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@druid.apache.org
For additional commands, e-mail: commits-help@druid.apache.org


[GitHub] [druid] jihoonson commented on a change in pull request #9655: Fix wrong cardinality computation in BufferArrayGrouper

Posted by GitBox <gi...@apache.org>.
jihoonson commented on a change in pull request #9655: Fix wrong cardinality computation in BufferArrayGrouper
URL: https://github.com/apache/druid/pull/9655#discussion_r406555229
 
 

 ##########
 File path: processing/src/main/java/org/apache/druid/query/groupby/epinephelinae/BufferArrayGrouper.java
 ##########
 @@ -69,12 +69,20 @@
   @Nullable
   private int[] vAggregationRows = null;
 
-  static long requiredBufferCapacity(
-      int cardinality,
-      AggregatorFactory[] aggregatorFactories
-  )
+  /**
+   * Computes required buffer capacity for a grouping key of the given cardinaltiy and aggregatorFactories.
+   * This method assumes that the given cardinality doesn't count nulls.
+   *
+   * Returns -1 if it cardinality + 1 (for null) = Integer.MAX_VALUE. Returns computed required buffer capacity
 
 Review comment:
   Oops, thanks!

----------------------------------------------------------------
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.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services

---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@druid.apache.org
For additional commands, e-mail: commits-help@druid.apache.org


[GitHub] [druid] jihoonson commented on issue #9655: Fix wrong cardinality computation in BufferArrayGrouper

Posted by GitBox <gi...@apache.org>.
jihoonson commented on issue #9655: Fix wrong cardinality computation in BufferArrayGrouper
URL: https://github.com/apache/druid/pull/9655#issuecomment-611760688
 
 
   This PR is tagged 0.18.0 since it makes semi joins failed.

----------------------------------------------------------------
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.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services

---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@druid.apache.org
For additional commands, e-mail: commits-help@druid.apache.org