Example usage for org.apache.commons.lang.mutable MutableLong decrement

List of usage examples for org.apache.commons.lang.mutable MutableLong decrement

Introduction

In this page you can find the example usage for org.apache.commons.lang.mutable MutableLong decrement.

Prototype

public void decrement() 

Source Link

Document

Decrements the value.

Usage

From source file:com.datatorrent.stram.client.RecordingsAgent.java

private void processPartFile(BufferedReader partBr, QueryType queryType, long low, long high, long limit,
        String[] ports, MutableLong numRemainingTuples, MutableLong currentTimestamp,
        MutableLong currentWindowLow, long currentOffset, TuplesInfo info) throws IOException {
    String partLine;/*from w ww.j a va 2 s.com*/
    long tmpOffset = currentOffset;
    // advance until offset is reached
    while ((partLine = partBr.readLine()) != null) {
        int partCursor = 2;
        if (partLine.startsWith("B:")) {
            int partCursor2 = partLine.indexOf(':', partCursor);
            currentTimestamp.setValue(Long.valueOf(partLine.substring(partCursor, partCursor2)));
            partCursor = partCursor2 + 1;
            currentWindowLow.setValue(Long.valueOf(partLine.substring(partCursor)));
            if (limit != numRemainingTuples.longValue()) {
                WindowTuplesInfo wtinfo;
                wtinfo = new WindowTuplesInfo();
                wtinfo.windowId = currentWindowLow.longValue();
                info.tuples.add(wtinfo);
            }
        } else if (partLine.startsWith("T:")) {
            int partCursor2 = partLine.indexOf(':', partCursor);
            currentTimestamp.setValue(Long.valueOf(partLine.substring(partCursor, partCursor2)));
            partCursor = partCursor2 + 1;
            partCursor2 = partLine.indexOf(':', partCursor);
            String port = partLine.substring(partCursor, partCursor2);
            boolean portMatch = (ports == null) || (ports.length == 0) || Arrays.asList(ports).contains(port);
            partCursor = partCursor2 + 1;

            if (portMatch && ((queryType == QueryType.WINDOW && currentWindowLow.longValue() >= low)
                    || (queryType == QueryType.OFFSET && tmpOffset >= low)
                    || (queryType == QueryType.TIME && currentTimestamp.longValue() >= low))) {

                if (numRemainingTuples.longValue() > 0) {
                    if (info.startOffset == -1) {
                        info.startOffset = tmpOffset;
                    }
                    WindowTuplesInfo wtinfo;
                    if (info.tuples.isEmpty()
                            || info.tuples.get(info.tuples.size() - 1).windowId != currentWindowLow
                                    .longValue()) {
                        wtinfo = new WindowTuplesInfo();
                        wtinfo.windowId = currentWindowLow.longValue();
                        info.tuples.add(wtinfo);
                    } else {
                        wtinfo = info.tuples.get(info.tuples.size() - 1);
                    }

                    partCursor2 = partLine.indexOf(':', partCursor);
                    int size = Integer.valueOf(partLine.substring(partCursor, partCursor2));
                    partCursor = partCursor2 + 1;
                    //partCursor2 = partCursor + size;
                    String tupleValue = partLine.substring(partCursor);
                    wtinfo.tuples.add(new TupleInfo(port, tupleValue));
                    numRemainingTuples.decrement();
                } else {
                    break;
                }
            }
            if (portMatch) {
                tmpOffset++;
            }
        }
    }
}