类com.google.common.util.concurrent.AtomicDouble源码实例Demo

下面列出了怎么用com.google.common.util.concurrent.AtomicDouble的API类实例代码及写法,或者点击链接到github查看源代码。

源代码1 项目: termsuite-core   文件: Contextualizer.java
public CrossTable computeCrossTable() {
		
		int totalCoOccurrences = 0;
	    Map<Term, AtomicDouble> aPlusB = Maps.newConcurrentMap() ;
	    Map<Term, AtomicDouble> aPlusC = Maps.newConcurrentMap();

        Term term;
        for (Iterator<TermService> it1 = terminology.getTerms().iterator(); 
        		it1.hasNext() ;) {
            term = it1.next().getTerm();
//            this.totalFrequency++;
            if(term.getContext() == null)
            	continue;
        	ContextVector context = term.getContext();
            for (ContextVector.Entry entry : context.getEntries()) {
            	totalCoOccurrences += entry.getNbCooccs();
                getScoreFromMap(aPlusB, term).addAndGet(entry.getNbCooccs());
                getScoreFromMap(aPlusC, entry.getCoTerm()).addAndGet(entry.getNbCooccs());
            }
        }
        
        return new CrossTable(aPlusB, aPlusC, totalCoOccurrences);
    }
 
源代码2 项目: toolbox   文件: MaximumLikelihoodFading.java
/**
 * {@inheritDoc}
 */
@Override
public void runLearning() {

    efBayesianNetwork = new EF_BayesianNetwork(dag);

    dataInstanceCount = new AtomicDouble(0);
    sumSS = efBayesianNetwork.createZeroSufficientStatistics();
    for (DataOnMemory<DataInstance> batch : dataStream.iterableOverBatches(windowsSize)){
        SufficientStatistics batchSS = batch.stream()
                .map(efBayesianNetwork::getSufficientStatistics)
                .reduce(SufficientStatistics::sumVectorNonStateless).get();

        sumSS.multiplyBy(fadingFactor);
        sumSS.sum(batchSS);

        dataInstanceCount.set(dataInstanceCount.get()*fadingFactor + windowsSize);
    }
}
 
源代码3 项目: mantis   文件: ClutchAutoScaler.java
public ClutchController(StageScalingPolicy.ScalingReason metric, StageSchedulingInfo stageSchedulingInfo, ClutchPIDConfig config, AtomicDouble gainFactor, long initialSize, long min, long max) {
    this.metric = metric;
    this.config = config;
    this.gainFactor = gainFactor;
    this.initialSize = initialSize;
    this.stageSchedulingInfo = stageSchedulingInfo;
    this.min = min;
    this.max = max;

    this.integrator = new Integrator(this.initialSize, this.min - 1, this.max + 1);
}
 
源代码4 项目: mzmine3   文件: AreaShareChart.java
public AreaShareChart(@Nonnull ModularFeatureListRow row, AtomicDouble progress) {
  Float sum = row.streamFeatures().map(ModularFeature::getArea).filter(p -> p.getValue() != null)
      .map(Property<Float>::getValue).reduce(0f, Float::sum);

  List<Rectangle> all = new ArrayList<>();
  int i = 0;
  int size = row.getFeatures().size();
  for (Entry<RawDataFile, ModularFeature> entry : row.getFeatures().entrySet()) {
    Property<Float> areaProperty = entry.getValue().get(AreaType.class);
    if (areaProperty.getValue() != null) {
      // color from sample
      Color color = entry.getValue().get(RawColorType.class).getValue();
      if (color == null)
        color = Color.DARKORANGE;

      float ratio = areaProperty.getValue() / sum;
      Rectangle rect = new Rectangle();
      rect.setFill(color);
      // bind width
      rect.widthProperty().bind(this.widthProperty().multiply(ratio));
      rect.setHeight(i % 2 == 0 ? 20 : 25);
      all.add(rect);
      i++;
      if (progress != null)
        progress.addAndGet(1.0 / size);
    }
  }
  HBox box = new HBox(0, all.toArray(Rectangle[]::new));
  box.setPrefWidth(100);
  box.setAlignment(Pos.CENTER_LEFT);

  this.getChildren().add(box);
}
 
源代码5 项目: mzmine3   文件: AreaBarChart.java
public AreaBarChart(@Nonnull ModularFeatureListRow row, AtomicDouble progress) {
  XYChart.Series data = new XYChart.Series();
  int i = 1;
  int size = row.getFeatures().size();
  for (Entry<RawDataFile, ModularFeature> entry : row.getFeatures().entrySet()) {
    Property<Float> areaProperty = entry.getValue().get(AreaType.class);
    data.getData().add(
        new XYChart.Data("" + i, areaProperty.getValue() == null ? 0f : areaProperty.getValue()));
    i++;
    if (progress != null)
      progress.addAndGet(1.0 / size);
  }

  final CategoryAxis xAxis = new CategoryAxis();
  final NumberAxis yAxis = new NumberAxis();
  final BarChart<String, Number> bc = new BarChart<String, Number>(xAxis, yAxis);
  bc.setLegendVisible(false);
  bc.setMinHeight(100);
  bc.setPrefHeight(100);
  bc.setMaxHeight(100);
  bc.setBarGap(3);
  bc.setCategoryGap(3);
  bc.setPrefWidth(150);

  bc.getData().addAll(data);
  this.getChildren().add(bc);
}
 
源代码6 项目: ForgeHax   文件: MainMenuGuiService.java
private void drawHistory() {
  AtomicDouble offset = new AtomicDouble();
  messageHistory
      .stream()
      .limit(100)
      .forEach(
          str -> {
            MC.fontRenderer.drawString(
                str, 5, (this.height - 50 - offset.intValue()), Colors.WHITE.toBuffer());
            offset.addAndGet(10);
          });
}
 
源代码7 项目: PokeMate   文件: Walking.java
public static void walk( final Context context, S2LatLng end) { // PokeStop Walking
    context.getWalking().set(true);
    S2LatLng start = S2LatLng.fromDegrees(context.getLat().get(), context.getLng().get());
    S2LatLng diff = end.sub(start);
    double distance = start.getEarthDistance(end);
    long timeout = 200L;
    double timeRequired = distance / Config.getSpeed();
    final AtomicDouble stepsRequired = new AtomicDouble(timeRequired / (timeout / 1000D));
    double deltaLat = diff.latDegrees() / stepsRequired.get();
    double deltaLng = diff.lngDegrees() / stepsRequired.get();
    logger.debug("starting to walk");
    //Schedule a timer to walk every 200 ms


    new Timer().scheduleAtFixedRate(new TimerTask() {
        @Override
        public void run() {
            context.getApi().setLocation(context.getLat().addAndGet(deltaLat), context.getLng().addAndGet(deltaLng), new Random().nextInt(10));
            stepsRequired.getAndAdd(-1);
            if (stepsRequired.get() <= 0) {
                logger.debug("Setting a new destination");
                context.getWalking().set(false);
                context.addTask(new TagPokestop(context));
                context.addTask(new Navigate(context, new LatLng(context.getLat().get() - VARIANCE, context.getLng().get() - VARIANCE),
                    new LatLng(context.getLat().get() + VARIANCE, context.getLng().get() + VARIANCE)));
                cancel();
            }
        }
    }, 0, timeout);
}
 
源代码8 项目: symja_android_library   文件: Object2Expr.java
private static IExpr convert(Number n) {
	if (n instanceof Integer) {
		return F.ZZ(((Integer) n).longValue());
	}
	if (n instanceof Double) {
		return F.num(((Double) n).doubleValue());
	}
	if (n instanceof Long) {
		return F.ZZ(((Long) n).longValue());
	}
	if (n instanceof BigInteger) {
		return F.integer((BigInteger) n);
	}
	if (n instanceof BigDecimal) {
		return F.num(new Apfloat(((BigDecimal) n).doubleValue()));
	}
	if (n instanceof Float) {
		return F.num(((Float) n).doubleValue());
	}
	if (n instanceof AtomicDouble) {
		return F.num(((AtomicDouble) n).doubleValue());
	}
	if (n instanceof AtomicInteger) {
		return F.ZZ(((AtomicInteger) n).longValue());
	}
	if (n instanceof AtomicLong) {
		return F.ZZ(((AtomicLong) n).longValue());
	}
	return F.num(((Number) n).doubleValue());
}
 
public double getProjectionScore(TerminologyService referenceTerminology) {
	AtomicDouble sum = new AtomicDouble(0);
	AtomicDouble total = new AtomicDouble(0);
	List<Term> top100 = topN(100).collect(toList());
	for(Term docTerm :top100) {
		total.addAndGet(docTerm.getSpecificity());
		int baseRank = getBaseRankInRefTermino(referenceTerminology, docTerm);
		if(baseRank > 0 && baseRank < 500)
			sum.addAndGet(docTerm.getSpecificity());
	}
	return sum.doubleValue() / total.doubleValue();
}
 
源代码10 项目: disthene   文件: SumService.java
private void flush() {
    Collection<Metric> metricsToFlush = new ArrayList<>();

    while(accumulator.size() > 0 && (accumulator.firstKey() < DateTime.now(DateTimeZone.UTC).getMillis() / 1000 - distheneConfiguration.getCarbon().getAggregatorDelay())) {
        ConcurrentMap<MetricKey, AtomicDouble> timestampMap = accumulator.pollFirstEntry().getValue();

        for(Map.Entry<MetricKey, AtomicDouble> entry : timestampMap.entrySet()) {
            metricsToFlush.add(new Metric(entry.getKey(), entry.getValue().get()));
        }
    }

    if (metricsToFlush.size() > 0) {
        doFlush(metricsToFlush, getFlushRateLimiter(metricsToFlush.size()));
    }
}
 
源代码11 项目: genie   文件: UserMetricsTask.java
/**
 * Constructor.
 *
 * @param registry              the metrics registry
 * @param dataServices          The {@link DataServices} instance to use
 * @param userMetricsProperties the properties that configure this task
 */
public UserMetricsTask(
    final MeterRegistry registry,
    final DataServices dataServices,
    final UserMetricsProperties userMetricsProperties
) {
    this.registry = registry;
    this.persistenceService = dataServices.getPersistenceService();
    this.userMetricsProperties = userMetricsProperties;
    this.activeUsersCount = new AtomicDouble(Double.NaN);

    // Register gauge for count of distinct users with active jobs.
    Gauge.builder(USER_ACTIVE_USERS_METRIC_NAME, this::getUsersCount)
        .register(registry);
}
 
源代码12 项目: toolbox   文件: ParallelMLMissingData.java
/**
 * {@inheritDoc}
 */
@Override
public double updateModel(DataStream<DynamicDataInstance> dataStream) {

    Stream<DataOnMemory<DynamicDataInstance>> stream = null;
    if (parallelMode){
        stream = dataStream.parallelStreamOfBatches(windowsSize);
    }else{
        stream = dataStream.streamOfBatches(windowsSize);
    }


    dataInstanceCount = new AtomicDouble(0); //Initial count

    this.sumSS = stream
            .peek(batch -> {
                dataInstanceCount.getAndAdd(batch.getNumberOfDataInstances());
                if (debug) System.out.println("Parallel ML procesando "+(int)dataInstanceCount.get() +" instances");
            })
            .map(batch -> {
                return batch.stream()
                        .map(dataInstance -> computeCountSufficientStatistics(this.efBayesianNetwork, dataInstance))
                        .reduce(DynamicPartialSufficientSatistics::sumNonStateless).get();
            })
            .reduce(DynamicPartialSufficientSatistics::sumNonStateless).get();

    if (laplace) {
        DynamicPartialSufficientSatistics initSS = DynamicPartialSufficientSatistics.createInitPartialSufficientStatistics(efBayesianNetwork);
        sumSS.sum(initSS);
    }

    return Double.NaN;
}
 
源代码13 项目: sarl   文件: CodeTest.java
@Test
public void operator_equals_short_Number() {
	assertFalse(operator_equals(left, new AtomicDouble(right)));
	assertFalse(operator_equals(left2, new AtomicDouble(right)));
	assertTrue(operator_equals(left, new AtomicDouble(left)));
}
 
源代码14 项目: sarl   文件: CodeTest.java
@Test
public void operator_greaterThan_Byte_Number() {
	assertTrue(operator_greaterThan(left, new AtomicDouble(right)));
	assertFalse(operator_greaterThan(left2, new AtomicDouble(right)));
	assertFalse(operator_greaterThan(left, new AtomicDouble(left)));
}
 
源代码15 项目: secor   文件: MicroMeterMetricCollector.java
@Override
public void metric(String label, double value, String topic) {
    Metrics.gauge(label, Collections.singletonList(
        Tag.of("topic", topic)), new AtomicDouble(0)).set(value);
}
 
源代码16 项目: mantis   文件: PIDController.java
public static PIDController of(Double kp, Double ki, Double kd, Double deltaT, AtomicDouble dampener) {
    return new PIDController(kp, ki, kd, deltaT, dampener);
}
 
源代码17 项目: sarl   文件: CodeTest.java
@Test
public void operator_notEquals_Byte_Number() {
	assertTrue(operator_notEquals(left, new AtomicDouble(right)));
	assertTrue(operator_notEquals(left2, new AtomicDouble(right)));
	assertFalse(operator_notEquals(left, new AtomicDouble(left)));
}
 
源代码18 项目: sarl   文件: CodeTest.java
@Test
public void operator_greaterThan_short_Number() {
	assertTrue(operator_greaterThan(left, new AtomicDouble(right)));
	assertFalse(operator_greaterThan(left2, new AtomicDouble(right)));
	assertFalse(operator_greaterThan(left, new AtomicDouble(left)));
}
 
源代码19 项目: sarl   文件: CodeTest.java
@Test
public void operator_greaterEqualsThan_Byte_Number() {
	assertTrue(operator_greaterEqualsThan(left, new AtomicDouble(right)));
	assertFalse(operator_greaterEqualsThan(left2, new AtomicDouble(right)));
	assertTrue(operator_greaterEqualsThan(left, new AtomicDouble(left)));
}
 
源代码20 项目: pepper-metrics   文件: HealthStatsDefault.java
public Map<String, AtomicDouble> getGaugeCollector() {
    return gaugeCollector;
}
 
源代码21 项目: sarl   文件: CodeTest.java
@Test
public void operator_lessEqualsThan_Byte_Number() {
	assertFalse(operator_lessEqualsThan(left, new AtomicDouble(right)));
	assertTrue(operator_lessEqualsThan(left2, new AtomicDouble(right)));
	assertTrue(operator_lessEqualsThan(left, new AtomicDouble(left)));
}
 
源代码22 项目: pepper-metrics   文件: AbstractHealthPrinter.java
protected String buildGaugeLog(String key, Map<String, AtomicDouble> gaugeCollector) {
    return key + " = " + gaugeCollector.get(key);
}
 
源代码23 项目: sarl   文件: CodeTest.java
@Test
public void operator_greaterThan_Byte_Number() {
	assertTrue(operator_greaterThan(left, new AtomicDouble(right)));
	assertFalse(operator_greaterThan(left2, new AtomicDouble(right)));
	assertFalse(operator_greaterThan(left, new AtomicDouble(left)));
}
 
源代码24 项目: sarl   文件: CodeTest.java
@Test
public void operator_equals_Byte_Number() {
	assertFalse(operator_equals(left, new AtomicDouble(right)));
	assertFalse(operator_equals(left2, new AtomicDouble(right)));
	assertTrue(operator_equals(left, new AtomicDouble(left)));
}
 
源代码25 项目: sarl   文件: CodeTest.java
@Test
public void operator_notEquals_short_Number() {
	assertTrue(operator_notEquals(left, new AtomicDouble(right)));
	assertTrue(operator_notEquals(left2, new AtomicDouble(right)));
	assertFalse(operator_notEquals(left, new AtomicDouble(left)));
}
 
源代码26 项目: sarl   文件: CodeTest.java
@Test
public void operator_lessThan_Byte_Number() {
	assertFalse(operator_lessThan(left, new AtomicDouble(right)));
	assertTrue(operator_lessThan(left2, new AtomicDouble(right)));
	assertFalse(operator_lessThan(left, new AtomicDouble(left)));
}
 
源代码27 项目: localization_nifi   文件: DataDogReportingTask.java
protected ConcurrentHashMap<String, AtomicDouble> getMetricsMap() {
    return new ConcurrentHashMap<>();
}
 
@Override
protected ConcurrentHashMap<String, AtomicDouble> getMetricsMap() {
    return metricsMap;
}
 
源代码29 项目: sarl   文件: CodeTest.java
@Test
public void operator_greaterThan_Byte_Number() {
	assertTrue(operator_greaterThan(left, new AtomicDouble(right)));
	assertFalse(operator_greaterThan(left2, new AtomicDouble(right)));
	assertFalse(operator_greaterThan(left, new AtomicDouble(left)));
}
 
源代码30 项目: sarl   文件: CodeTest.java
@Test
public void operator_lessEqualsThan_short_Number() {
	assertFalse(operator_lessEqualsThan(left, new AtomicDouble(right)));
	assertTrue(operator_lessEqualsThan(left2, new AtomicDouble(right)));
	assertTrue(operator_lessEqualsThan(left, new AtomicDouble(left)));
}
 
 同包方法