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 2019/08/23 08:10:36 UTC

[GitHub] [incubator-druid] gianm commented on a change in pull request #8380: Suppress index-out-of-bounds warning from LGTM about loop unrolling

gianm commented on a change in pull request #8380: Suppress index-out-of-bounds warning from LGTM about loop unrolling
URL: https://github.com/apache/incubator-druid/pull/8380#discussion_r317019153
 
 

 ##########
 File path: processing/src/main/java/org/apache/druid/query/topn/TopNNumericResultBuilder.java
 ##########
 @@ -150,13 +150,13 @@ public TopNNumericResultBuilder addEntry(
     }
     for (int i = extra; i < metricVals.length; i += LOOP_UNROLL_COUNT) {
       metricValues.put(aggFactoryNames[i + 0], metricVals[i + 0]);
-      metricValues.put(aggFactoryNames[i + 1], metricVals[i + 1]);
-      metricValues.put(aggFactoryNames[i + 2], metricVals[i + 2]);
-      metricValues.put(aggFactoryNames[i + 3], metricVals[i + 3]);
-      metricValues.put(aggFactoryNames[i + 4], metricVals[i + 4]);
-      metricValues.put(aggFactoryNames[i + 5], metricVals[i + 5]);
-      metricValues.put(aggFactoryNames[i + 6], metricVals[i + 6]);
-      metricValues.put(aggFactoryNames[i + 7], metricVals[i + 7]);
+      metricValues.put(aggFactoryNames[i + 1], metricVals[i + 1]); // lgtm[java/index-out-of-bounds]
 
 Review comment:
   IMO would be nice to have a meta-comment here about why these are needed. Something like:
   
   ```
   // LGTM.com flags this, but it's safe because we know "metricVals.length - extra" is a multiple of LOOP_UNROLL_COUNT.
   ```

----------------------------------------------------------------
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