peekIndex[i] = sumOfWeights * (int)Math.floor(localPeek / weights[i])
peekIndex[i] = sumOfWeights * (localPeek / weights[i])
    private static Rate calcRate(SIRSplitJoin sj, RepInfo rep) {        // intuitively, the (peek-pop) will be the maximum of:        //   1. the steady-state (peek-pop) required by any stream        //   2. the initPeek of any stream.        // --> since we have invariant that        // (peek-pop)==(initPeek-initPop), initPop cannot be negative,        // and newInitPop==0, this leaves #2 as the only determinant        // of the new (peek-pop) amount.        // so, find maximum initPeek of any stream.  Find this by        // looking at (peek-pop) and adding initPop if it exists.        // Keep in mind that this maximum is in terms of the input        // buffer, not the localized buffer of a given child.            // to calculate: the index in the combined stream that each        // child stream peeks to        int[] peekIndex = new int[sj.size()];        // get splitter weights        int[] weights = sj.getSplitter().getWeights();        int[] partialSum = new int[sj.size()];        // calculate partial sums of weights        for (int i=1; i<weights.length; i++) {            partialSum[i] = partialSum[i-1] + weights[i-1];        }        // get total weights        int sumOfWeights = sj.getSplitter().getSumOfWeights();        boolean isDup = sj.getSplitter().getType()==SIRSplitType.DUPLICATE;        // calculate <peekindex>        for (int i=0; i<sj.size(); i++) {            SIRFilter filter = (SIRFilter)sj.get(i);            int localPeek = filter.getPeekInt() - filter.getPopInt();            if (filter instanceof SIRTwoStageFilter) {                localPeek += ((SIRTwoStageFilter)filter).getInitPopInt();            }            if (isDup || localPeek==0) {                peekIndex[i] = localPeek;            } else {                peekIndex[i] = sumOfWeights * (int)Math.floor(localPeek / weights[i])                     + partialSum[i] + (localPeek % weights[i]);            }        }        // the (peek-pop)==newInitPeek amount is the maximum of all the peekindex's        int peekMinusPop = 0;        for (int i=0; i<peekIndex.length; i++) {            if (peekIndex[i] > peekMinusPop) {                peekMinusPop = peekIndex[i];            }        }        // scale up peekMinusPop to the next round execution of the splitter        if (!isDup) {            peekMinusPop = sumOfWeights * (int)Math.ceil(((float)peekMinusPop) / ((float)sumOfWeights));        }        // in this design there is no pushing or popping the first time through        int newInitPush = 0;        int newInitPeek = peekMinusPop;        int newInitPop = 0;        // calculate the push/pop/peek ratio        int newPush = rep.joiner * sj.getJoiner().getSumOfWeights();        int newPop;        if (isDup) {            newPop = rep.splitter;        } else {            newPop = rep.splitter * sj.getSplitter().getSumOfWeights();;        }        int newPeek = newPop+peekMinusPop;        return new Rate(newInitPush, newInitPop, newInitPeek, newPush, newPop, newPeek);    }