Github user revans2 commented on a diff in the pull request:

    https://github.com/apache/storm/pull/1249#discussion_r57449306
  
    --- Diff: storm-core/src/jvm/org/apache/storm/utils/ConfigUtils.java ---
    @@ -135,7 +137,28 @@ public static int samplingRate(Map conf) {
             throw new IllegalArgumentException("Illegal 
topology.stats.sample.rate in conf: " + rate);
         }
     
    -    // public static mkStatsSampler // depends on Utils.evenSampler() 
TODO, this is sth we need to do after util
    +    public static Callable<Boolean> evenSampler(final int samplingFreq) {
    +        final int start = 0;
    +        final Random random = new Random();
    +        final MutableInt curr = new MutableInt(-1);
    +        final MutableInt target = new 
MutableInt(random.nextInt(samplingFreq));
    --- End diff --
    
    The entire reason for the MutableInt was so clojure could ack more like 
java.  It is going to be a lot faster to just use int instead.
    
    ```
        public static Callable<Boolean> evenSampler(final int samplingFreq) {
            final Random random = new Random();
            return new Callable<Boolean>() {
                private int curr = -1;
                private int target = random.nextInt(samplingFreq);
    
                @Override
                public Boolean call() throws Exception {
                    curr++;
                    if (curr >= samplingFreq) {
                        curr = 0;
                        target = random.nextInt(samplingFreq);
                    }
                    return curr == target;
                }
            };
    ```


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at [email protected] or file a JIRA ticket
with INFRA.
---

Reply via email to