org.apache.commons.lang.mutable.MutableInt#increment ( )源码实例Demo

下面列出了org.apache.commons.lang.mutable.MutableInt#increment ( ) 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。

源代码1 项目: datawave   文件: FlagMaker.java
/**
 * Determine the number of unprocessed flag files in the flag directory
 * 
 * @param fc
 * @return the flag found for this ingest pool
 */
private int countFlagFileBacklog(final FlagDataTypeConfig fc) {
    final MutableInt fileCounter = new MutableInt(0);
    final FileFilter fileFilter = new WildcardFileFilter("*_" + fc.getIngestPool() + "_" + fc.getDataName() + "_*.flag");
    final FileVisitor<java.nio.file.Path> visitor = new SimpleFileVisitor<java.nio.file.Path>() {
        
        @Override
        public FileVisitResult visitFile(java.nio.file.Path path, BasicFileAttributes attrs) throws IOException {
            if (fileFilter.accept(path.toFile())) {
                fileCounter.increment();
            }
            return super.visitFile(path, attrs);
        }
    };
    try {
        Files.walkFileTree(Paths.get(fmc.getFlagFileDirectory()), visitor);
    } catch (IOException e) {
        // unable to get a flag count....
        log.error("Unable to get flag file count", e);
        return -1;
    }
    return fileCounter.intValue();
}
 
/**
 * Given a Key to consume, update any necessary counters etc.
 *
 * @param key
 */
private void consume(Key key) {
    
    if (log.isTraceEnabled()) {
        log.trace("consume, key: " + key);
    }
    
    // update the visibility set
    MutableInt counter = this.currentVisibilityCounts.get(key.getColumnVisibility());
    if (counter == null) {
        this.currentVisibilityCounts.put(key.getColumnVisibility(), new MutableInt(1));
    } else {
        counter.increment();
    }
    
    // update current count
    this.count += 1;
    
    // set most recent timestamp
    this.maxTimeStamp = (this.maxTimeStamp > key.getTimestamp()) ? maxTimeStamp : key.getTimestamp();
}
 
源代码3 项目: termsuite-core   文件: CasStatCounter.java
@Override
public void process(JCas aJCas) throws AnalysisEngineProcessException {
	this.docIt++;
	Optional<SourceDocumentInformation> sourceDocumentAnnotation = JCasUtils.getSourceDocumentAnnotation(aJCas);
	if(sourceDocumentAnnotation.isPresent())
		this.cumulatedFileSize += sourceDocumentAnnotation.get().getDocumentSize();
	FSIterator<Annotation> it =  aJCas.getAnnotationIndex().iterator();
	Annotation a;
	MutableInt i;
	while(it.hasNext()) {
		a = it.next();
		i = counters.get(a.getType().getShortName());
		if(i == null) 
			counters.put(a.getType().getShortName(), new MutableInt(1));
		else
			i.increment();
	}
	if(periodicStatEnabled && this.docIt % this.docPeriod == 0)
		try {
			traceToFile();
		} catch (IOException e) {
			throw new AnalysisEngineProcessException(e);
		}
}
 
源代码4 项目: incubator-pinot   文件: RequestUtils.java
private static FilterQuery traverseFilterQueryAndPopulateMap(FilterQueryTree tree,
    Map<Integer, FilterQuery> filterQueryMap, MutableInt currentId) {
  int currentNodeId = currentId.intValue();
  currentId.increment();

  final List<Integer> f = new ArrayList<>();
  if (null != tree.getChildren()) {
    for (final FilterQueryTree c : tree.getChildren()) {
      final FilterQuery q = traverseFilterQueryAndPopulateMap(c, filterQueryMap, currentId);
      int childNodeId = q.getId();
      f.add(childNodeId);
      filterQueryMap.put(childNodeId, q);
    }
  }

  FilterQuery query = new FilterQuery();
  query.setColumn(tree.getColumn());
  query.setId(currentNodeId);
  query.setNestedFilterQueryIds(f);
  query.setOperator(tree.getOperator());
  query.setValue(tree.getValue());
  return query;
}
 
源代码5 项目: aion-germany   文件: CronServiceTest.java
@Test
public void testCancelRunnableUsingRunnableReference() throws Exception {
	final MutableInt val = new MutableInt();
	Runnable test = new Runnable() {
		@Override
		public void run() {
			val.increment();
			cronService.cancel(this);
		}
	};
	cronService.schedule(test, "0/2 * * * * ?");
	sleep(5);
	assertEquals(val.intValue(), 1);
}
 
源代码6 项目: aion-germany   文件: CronServiceTest.java
@Test
public void testCancelRunnableUsingJobDetails() throws Exception {
	final MutableInt val = new MutableInt();
	Runnable test = new Runnable() {
		@Override
		public void run() {
			val.increment();
			cronService.cancel(cronService.getRunnables().get(this));
		}
	};
	cronService.schedule(test, "0/2 * * * * ?");
	sleep(5);
	assertEquals(val.intValue(), 1);
}
 
源代码7 项目: aion-germany   文件: CronServiceTest.java
private static Runnable newIncrementingRunnable(final MutableInt ref) {
	return new Runnable() {
		@Override
		public void run() {
			if (ref != null) {
				ref.increment();
			}
		}
	};
}
 
源代码8 项目: lams   文件: TransactionRetryInterceptor.java
private void processException(Exception e, MethodInvocation invocation, MutableInt attempt) {

	StringBuilder message = new StringBuilder("When invoking method ")
		.append(invocation.getMethod().getDeclaringClass().getName()).append("#")
		.append(invocation.getMethod().getName()).append(" caught \"").append(e.getMessage())
		.append("\". Attempt #").append(attempt);

	attempt.increment();
	if (attempt.intValue() <= TransactionRetryInterceptor.MAX_ATTEMPTS) {
	    message.append(". Retrying.");
	} else {
	    message.append(". Giving up.");
	}
	TransactionRetryInterceptor.log.warn(message);
    }
 
源代码9 项目: gatk-protected   文件: AnnotateVcfWithBamDepth.java
@Override
public void apply(final VariantContext vc, final ReadsContext readsContext, final ReferenceContext refContext, final FeatureContext fc) {
    final MutableInt depth = new MutableInt(0);
    for (final GATKRead read : readsContext) {
        if (!read.failsVendorQualityCheck() && !read.isDuplicate() && !read.isUnmapped() && read.getEnd() > read.getStart() && new SimpleInterval(read).contains(vc) ) {
            depth.increment();
        }
    }
    vcfWriter.add(new VariantContextBuilder(vc).attribute(POOLED_BAM_DEPTH_ANNOTATION_NAME, depth.intValue()).make());
}
 
源代码10 项目: attic-apex-malhar   文件: TopNUniqueSort.java
/**
 * Adds object
 * @param e object to be added
 * @return true if offer() succeeds
 */
@SuppressWarnings("unchecked")
public boolean offer(E e)
{
  MutableInt ival = hmap.get(e);
  if (ival != null) { // already exists, so no insertion
    ival.increment();
    return true;
  }
  if (q.size() < qbound) {
    if (ival == null) {
      hmap.put(e, new MutableInt(1));
    }
    return q.offer(e);
  }

  boolean ret = false;
  boolean insert;
  Comparable<? super E> head = (Comparable<? super E>)q.peek();

  if (ascending) { // means head is the lowest value due to inversion
    insert = head.compareTo(e) < 0; // e > head
  } else { // means head is the highest value due to inversion
    insert = head.compareTo(e) > 0; // head is < e
  }

  // object e makes it, someone else gets dropped
  if (insert && q.offer(e)) {
    hmap.put(e, new MutableInt(1));
    ret = true;

    // the dropped object will never make it to back in anymore
    E drop = q.poll();
    hmap.remove(drop);
  }
  return ret;
}
 
源代码11 项目: gatk   文件: AnnotateVcfWithBamDepth.java
@Override
public void apply(final VariantContext vc, final ReadsContext readsContext, final ReferenceContext refContext, final FeatureContext fc) {
    final MutableInt depth = new MutableInt(0);
    for (final GATKRead read : readsContext) {
        if (!read.failsVendorQualityCheck() && !read.isDuplicate() && !read.isUnmapped() && read.getEnd() > read.getStart() && new SimpleInterval(read).contains(vc) ) {
            depth.increment();
        }
    }
    vcfWriter.add(new VariantContextBuilder(vc).attribute(POOLED_BAM_DEPTH_ANNOTATION_NAME, depth.intValue()).make());
}
 
源代码12 项目: tez   文件: DagAwareYarnTaskScheduler.java
private void incrVertexTaskCount(Priority priority, RequestPriorityStats stats, int vertexIndex) {
  Integer vertexIndexInt = vertexIndex;
  MutableInt taskCount = stats.vertexTaskCount.get(vertexIndexInt);
  if (taskCount != null) {
    taskCount.increment();
  } else {
    addVertexToRequestStats(priority, stats, vertexIndexInt);
  }
}