下面列出了org.apache.commons.lang3.mutable.MutableLong#increment ( ) 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。
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));
}
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);
}
}
}
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();
}
}
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));
}
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());
}
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());
}
@Override
public MutableLong accumulate(MutableLong accumulatedValue, Object input)
{
accumulatedValue.increment();
return accumulatedValue;
}