Java Code Examples for org.apache.commons.lang3.mutable.MutableLong#increment()
The following examples show how to use
org.apache.commons.lang3.mutable.MutableLong#increment() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: SerialReplicationChecker.java From hbase with Apache License 2.0 | 6 votes |
public boolean canPush(Entry entry, Cell firstCellInEdit) throws IOException { String encodedNameAsString = Bytes.toString(entry.getKey().getEncodedRegionName()); long seqId = entry.getKey().getSequenceId(); Long canReplicateUnderSeqId = canPushUnder.getIfPresent(encodedNameAsString); if (canReplicateUnderSeqId != null) { if (seqId < canReplicateUnderSeqId.longValue()) { LOG.trace("{} is before the end barrier {}, pass", entry, canReplicateUnderSeqId); return true; } LOG.debug("{} is beyond the previous end barrier {}, remove from cache", entry, canReplicateUnderSeqId); // we are already beyond the last safe point, remove canPushUnder.invalidate(encodedNameAsString); } // This is for the case where the region is currently opened on us, if the sequence id is // continuous then we are safe to replicate. If there is a breakpoint, then maybe the region // has been moved to another RS and then back, so we need to check the barrier. MutableLong previousPushedSeqId = pushed.getUnchecked(encodedNameAsString); if (seqId == previousPushedSeqId.longValue() + 1) { LOG.trace("The sequence id for {} is continuous, pass", entry); previousPushedSeqId.increment(); return true; } return canPush(entry, CellUtil.cloneRow(firstCellInEdit)); }
Example 2
Source File: TestHFileProcedurePrettyPrinter.java From hbase with Apache License 2.0 | 6 votes |
private List<String> checkOutput(BufferedReader reader, MutableLong putCount, MutableLong deleteCount, MutableLong markDeletedCount) throws IOException { putCount.setValue(0); deleteCount.setValue(0); markDeletedCount.setValue(0); List<String> fileScanned = new ArrayList<>(); for (;;) { String line = reader.readLine(); if (line == null) { return fileScanned; } LOG.info(line); if (line.contains("V: mark deleted")) { markDeletedCount.increment(); } else if (line.contains("/Put/")) { putCount.increment(); } else if (line.contains("/DeleteFamily/")) { deleteCount.increment(); } else if (line.startsWith("Scanning -> ")) { fileScanned.add(line.split(" -> ")[1]); } else { fail("Unrecognized output: " + line); } } }
Example 3
Source File: WriteHeavyIncrementObserver.java From hbase with Apache License 2.0 | 5 votes |
private long getUniqueTimestamp(byte[] row) { int slot = Bytes.hashCode(row) & mask; MutableLong lastTimestamp = lastTimestamps[slot]; long now = System.currentTimeMillis(); synchronized (lastTimestamp) { long pt = lastTimestamp.longValue() >> 10; if (now > pt) { lastTimestamp.setValue(now << 10); } else { lastTimestamp.increment(); } return lastTimestamp.longValue(); } }
Example 4
Source File: WorldStats.java From tectonicus with BSD 3-Clause "New" or "Revised" License | 5 votes |
public void incBlockId(final int blockId, final int data) { IdDataPair key = new IdDataPair(blockId, data); MutableLong count = blockIdCounts.get(key); if (count != null) count.increment(); else blockIdCounts.put(key, new MutableLong(1L)); }
Example 5
Source File: GlobalVisitStats.java From fasten with Apache License 2.0 | 4 votes |
public static Result reaches(final KnowledgeBase kb, final long startSig, final int maxRevs, final ProgressLogger pl) { final LongOpenHashSet result = new LongOpenHashSet(); final Object2ObjectOpenHashMap<String, IntOpenHashSet> product2Revs = new Object2ObjectOpenHashMap<>(); final MutableLong totRevs = new MutableLong(); // Visit queue final LongArrayFIFOQueue queue = new LongArrayFIFOQueue(); queue.enqueue(startSig); result.add(startSig); String p = kb.callGraphs.get(index(startSig)).product; IntOpenHashSet revs = new IntOpenHashSet(); revs.add(index(startSig)); product2Revs.put(p, revs); totRevs.increment(); pl.itemsName = "nodes"; pl.info = new Object() { @Override public String toString() { return "[nodes: " + result.size() + " products: " + product2Revs.size() + " revisions: " + totRevs.getValue() + "]"; } }; pl.start("Visiting reachable nodes..."); while (!queue.isEmpty()) { final long node = queue.dequeueLong(); for (final long s : kb.successors(node)) if (!result.contains(s)) { p = kb.callGraphs.get(index(s)).product; final long gid = gid(s); if (badGIDs.contains(gid)) continue; final String targetNameSpace = kb.new Node(gid, index(s)).toFastenURI().getRawNamespace(); if (targetNameSpace.startsWith("java.") || targetNameSpace.startsWith("javax.") || targetNameSpace.startsWith("jdk.")) { badGIDs.add(gid); continue; } revs = product2Revs.get(p); if (revs == null) product2Revs.put(p, revs = new IntOpenHashSet()); if (revs.contains(index(s)) || revs.size() < maxRevs) { queue.enqueue(s); result.add(s); //System.out.println(kb.new Node(gid(node), index(node)).toFastenURI() + " -> " + kb.new Node(gid(s), index(s)).toFastenURI()); if (revs.add(index(s))) totRevs.increment(); } } pl.lightUpdate(); } pl.done(); return new Result(result, product2Revs.size(), totRevs.getValue().longValue()); }
Example 6
Source File: GlobalVisitStats.java From fasten with Apache License 2.0 | 4 votes |
public static Result coreaches(final KnowledgeBase kb, final long startSig, final int maxRevs, final ProgressLogger pl) { final LongOpenHashSet result = new LongOpenHashSet(); final Object2ObjectOpenHashMap<String, IntOpenHashSet> product2Revs = new Object2ObjectOpenHashMap<>(); final MutableLong totRevs = new MutableLong(); // Visit queue final LongArrayFIFOQueue queue = new LongArrayFIFOQueue(); queue.enqueue(startSig); result.add(startSig); String p = kb.callGraphs.get(index(startSig)).product; IntOpenHashSet revs = new IntOpenHashSet(); revs.add(index(startSig)); product2Revs.put(p, revs); totRevs.increment(); pl.itemsName = "nodes"; pl.info = new Object() { @Override public String toString() { return "[nodes: " + result.size() + " products: " + product2Revs.size() + " revisions: " + totRevs.getValue() + "]"; } }; pl.start("Visiting coreachable nodes..."); while (!queue.isEmpty()) { final long node = queue.dequeueLong(); for (final long s : kb.predecessors(node)) if (!result.contains(s)) { p = kb.callGraphs.get(index(s)).product; final String targetNameSpace = kb.new Node(gid(s), index(s)).toFastenURI().getRawNamespace(); if (targetNameSpace.startsWith("java.") || targetNameSpace.startsWith("javax.") || targetNameSpace.startsWith("jdk.")) continue; revs = product2Revs.get(p); if (revs == null) product2Revs.put(p, revs = new IntOpenHashSet()); if (revs.contains(index(s)) || revs.size() < maxRevs) { queue.enqueue(s); result.add(s); //System.out.println(kb.new Node(gid(node), index(node)).toFastenURI() + " -> " + kb.new Node(gid(s), index(s)).toFastenURI()); if (revs.add(index(s))) totRevs.increment(); } } pl.lightUpdate(); } pl.done(); return new Result(result, product2Revs.size(), totRevs.getValue().longValue()); }
Example 7
Source File: Count.java From attic-apex-malhar with Apache License 2.0 | 4 votes |
@Override public MutableLong accumulate(MutableLong accumulatedValue, Object input) { accumulatedValue.increment(); return accumulatedValue; }