popAmount = filter.getInitPushStage(numWork);
popAmount = filter.getInitPopStage(numWork);
    Map computeBuffersMap(Schedule schedule)    {        Map deltas = (Map) phase2deltaMap.get(schedule);        if (deltas == null)        {            // new a new deltas            deltas = new HashMap();            Set buffers = new HashSet();            deltas.put(null, buffers);            ASSERT(deltas.get(null) == buffers);            // put the original code here            {                // is this a schedule that contains other schedules?                if (!schedule.isBottomSchedule())                {                    // yes - just run through other schedules!                    int schedNum = 0;                    for (; schedNum < schedule.getNumPhases(); schedNum++)                    {                        Map subDeltas =                            computeBuffersMap(schedule.getSubSched(schedNum));                        combineBufferExecutions(deltas, subDeltas);                    }                }                else                {                    // no - this is a bona-fide work function                    Object workFunc = schedule.getWorkFunc();                    Iterator workStream =                        (Iterator) user2persistent.get(                            schedule.getStream());                    // figure out what object contributed this work function:                    Pair workInfo = pairs.getPair(workFunc, workStream);                    int numWork =                        ((Integer) workFunctions.get(workInfo)).intValue();                    if (workStream.isFilter() != null)                    {                        FilterIter filter = workStream.isFilter();                        int peekAmount, popAmount, pushAmount;                        // check if the function is a work or init function                        // and get appropriate peek/pop/push values                        if (filter.getWorkFunctionPhase(numWork) == workFunc)                        {                            // work function                            peekAmount = filter.getPeekPhase(numWork);                            popAmount = filter.getPopPhase(numWork);                            pushAmount = filter.getPushPhase(numWork);                        }                        else                        {                            // init function                            ASSERT(                                filter.getInitFunctionStage(numWork)                                    == workFunc);                            peekAmount = filter.getInitPeekStage(numWork);                            popAmount = filter.getInitPushStage(numWork);                            pushAmount = filter.getInitPushStage(numWork);                        }                        // update the buffers appropriately                        // update buffer before, only if it's used                        if (peekAmount > 0)                        {                            BufferStatus bufferBefore =                                (BufferStatus) targetBufferBefore.get(                                    workStream);                            /*                            bufferBefore.peekData(peekAmount);                            bufferBefore.popData(popAmount);                            */                            BufferDelta smallDelta = new BufferDelta();                            smallDelta.popData(popAmount);                            buffers.add(bufferBefore);                            deltas.put(bufferBefore, smallDelta);                        }                        // update buffer after only if it's used                        if (pushAmount > 0)                        {                            BufferStatus bufferAfter =                                (BufferStatus) targetBufferAfter.get(                                    workStream);                            /*                            bufferAfter.pushData(pushAmount);                            */                            BufferDelta smallDelta = new BufferDelta();                            smallDelta.pushData(pushAmount);                            buffers.add(bufferAfter);                            deltas.put(bufferAfter, smallDelta);                        }                    }                    else if (workStream.isPipeline() != null)                    {                        ERROR("Pipeline is not allowed to have any work functions!");                    }                    else if (workStream.isSplitJoin() != null)                    {                        SplitJoinIter sj = workStream.isSplitJoin();                        int popAmount, pushAmount;                        // check if the function is a splitter or joiner function                        // and get appropriate pop/push values                        // also update the internal buffers!                        if (sj.getSplitterNumWork() > numWork                            && sj.getSplitterWork(numWork) == workFunc)                        {                            // splitter function                            popAmount = sj.getSplitPop(numWork);                            pushAmount = 0;                            // push data into the internal splitter buffers                            int nChild;                            int pushWeights[] =                                sj.getSplitPushWeights(numWork);                            for (nChild = 0;                                nChild < sj.getNumChildren();                                nChild++)                            {                                Iterator firstChild =                                    getFirstStream(sj.getChild(nChild));                                BufferStatus bufferBefore =                                    (BufferStatus) targetBufferBefore.get(                                        firstChild);                                /*                                        bufferBefore.pushData(pushWeights[nChild]);                                */                                BufferDelta smallDelta = new BufferDelta();                                smallDelta.pushData(pushWeights[nChild]);                                buffers.add(bufferBefore);                                deltas.put(bufferBefore, smallDelta);                            }                        }                        else                        {                            // joiner function                            popAmount = 0;                            pushAmount = sj.getJoinPush(numWork);                            // push data into the internal joiner buffers                            int nChild;                            int popWeights[] = sj.getJoinPopWeights(numWork);                            for (nChild = 0;                                nChild < sj.getNumChildren();                                nChild++)                            {                                Iterator lastChild =                                    getLastStream(sj.getChild(nChild));                                BufferStatus bufferAfter =                                    (BufferStatus) targetBufferAfter.get(                                        lastChild);                                /*                                bufferAfter.popData(popWeights[nChild]);                                */                                BufferDelta smallDelta = new BufferDelta();                                smallDelta.popData(popWeights[nChild]);                                buffers.add(bufferAfter);                                deltas.put(bufferAfter, smallDelta);                            }                        }                        // update buffer before, only if it's used                        if (popAmount > 0)                        {                            BufferStatus bufferBefore =                                (BufferStatus) targetBufferBefore.get(                                    workStream);                            /*                            bufferBefore.popData(popAmount);                            */                            BufferDelta smallDelta = new BufferDelta();                            smallDelta.popData(popAmount);                            buffers.add(bufferBefore);                            deltas.put(bufferBefore, smallDelta);                        }                        // update buffer after only if it's used                        if (pushAmount > 0)                        {                            BufferStatus bufferAfter =                                (BufferStatus) targetBufferAfter.get(                                    workStream);                            /*                            bufferAfter.pushData(pushAmount);                            */                            BufferDelta smallDelta = new BufferDelta();                            smallDelta.pushData(pushAmount);                            buffers.add(bufferAfter);                            deltas.put(bufferAfter, smallDelta);                        }                    }                    else if (workStream.isFeedbackLoop() != null)                    {                        FeedbackLoopIter feedbackLoop =                            workStream.isFeedbackLoop();                        Iterator body = feedbackLoop.getBodyChild();                        Iterator loop = feedbackLoop.getLoopChild();                        int popAmount, pushAmount;                        // check if the function is a splitter or joiner function                        // and get appropriate pop/push values                        // also update the internal buffers!                        if (feedbackLoop.getSplitterWork(numWork)                            == workFunc)                        {                            // splitter function                            popAmount = 0;                            pushAmount =                                feedbackLoop.getSplitPushWeights(numWork)[0];                            // pop data from the internal body-splitter buffer                            {                                BufferStatus bodyBuffer =                                    (BufferStatus) targetBufferAfter.get(                                        getLastStream(body));                                /*                                bodyBuffer.popData(                                    feedbackLoop.getSplitPop(numWork));                                */                                BufferDelta smallDelta = new BufferDelta();                                smallDelta.popData(                                    feedbackLoop.getSplitPop(numWork));                                buffers.add(bodyBuffer);                                deltas.put(bodyBuffer, smallDelta);                            }                            // push data to the internal splitter-loop buffer                            {                                BufferStatus loopBuffer =                                    (BufferStatus) targetBufferBefore.get(                                        getFirstStream(loop));                                /*                                loopBuffer.pushData(                                    feedbackLoop.getSplitPushWeights(                                        numWork)[1]);                                */                                BufferDelta smallDelta = new BufferDelta();                                smallDelta.pushData(                                    feedbackLoop.getSplitPushWeights(                                        numWork)[1]);                                buffers.add(loopBuffer);                                deltas.put(loopBuffer, smallDelta);                            }                        }                        else                        {                            // joiner function                            popAmount =                                feedbackLoop.getJoinPopWeights(numWork)[0];                            pushAmount = 0;                            // push data to the internal joiner-body buffer                            {                                BufferStatus bodyBuffer =                                    (BufferStatus) targetBufferBefore.get(                                        getFirstStream(body));                                /*                                bodyBuffer.pushData(                                    feedbackLoop.getJoinPush(numWork));                                */                                BufferDelta smallDelta = new BufferDelta();                                smallDelta.pushData(                                    feedbackLoop.getJoinPush(numWork));                                buffers.add(bodyBuffer);                                deltas.put(bodyBuffer, smallDelta);                            }                            // pop data from the internal loop-joiner buffer                            {                                BufferStatus loopBuffer =                                    (BufferStatus) targetBufferAfter.get(                                        getLastStream(loop));                                /*                                loopBuffer.popData(                                    feedbackLoop.getJoinPopWeights(                                        numWork)[1]);                                */                                BufferDelta smallDelta = new BufferDelta();                                smallDelta.popData(                                    feedbackLoop.getJoinPopWeights(                                        numWork)[1]);                                buffers.add(loopBuffer);                                deltas.put(loopBuffer, smallDelta);                            }                        }                        // update buffer before, only if it's used                        if (popAmount > 0)                        {                            BufferStatus bufferBefore =                                (BufferStatus) targetBufferBefore.get(                                    workStream);                            /*                            bufferBefore.popData(popAmount);                            */                            BufferDelta smallDelta = new BufferDelta();                            smallDelta.popData(popAmount);                            buffers.add(bufferBefore);                            deltas.put(bufferBefore, smallDelta);                        }                        // update buffer after only if it's used                        if (pushAmount > 0)                        {                            BufferStatus bufferAfter =                                (BufferStatus) targetBufferAfter.get(                                    workStream);                            /*                            bufferAfter.pushData(pushAmount);                            */                            BufferDelta smallDelta = new BufferDelta();                            smallDelta.pushData(pushAmount);                            buffers.add(bufferAfter);                            deltas.put(bufferAfter, smallDelta);                        }                    }                    else                        ERROR("stream variable is not a known stream type!");                    ASSERT(deltas.get(null) != null);                }            }            // add deltas to itself schedule.getNumReps times            if (schedule.getNumReps () > 1)            {                Map newDeltas = new HashMap();                newDeltas.put(null, new HashSet());                ASSERT(newDeltas.get(null) != null);                int numExecs = schedule.getNumReps();                for (; numExecs > 0; numExecs--)                {                    combineBufferExecutions(newDeltas, deltas);                }                ASSERT(deltas.get(null) != null);                ASSERT(newDeltas.get(null) != null);                deltas = newDeltas;            }        }        ASSERT(deltas != null);        return deltas;    }