[ 
https://issues.apache.org/jira/browse/STORM-1271?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=15211887#comment-15211887
 ] 

ASF GitHub Bot commented on STORM-1271:
---------------------------------------

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;
                }
            };
    ```


> port backtype.storm.daemon.task to java
> ---------------------------------------
>
>                 Key: STORM-1271
>                 URL: https://issues.apache.org/jira/browse/STORM-1271
>             Project: Apache Storm
>          Issue Type: New Feature
>          Components: storm-core
>            Reporter: Robert Joseph Evans
>            Assignee: Abhishek Agarwal
>              Labels: java-migration, jstorm-merger
>
> helper functions for task data and sending tuples



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)

Reply via email to