java.util.SortedSet.forEach()方法的使用及代码示例

x33g5p2x  于2022-01-29 转载在 其他  
字(9.6k)|赞(0)|评价(0)|浏览(121)

本文整理了Java中java.util.SortedSet.forEach()方法的一些代码示例,展示了SortedSet.forEach()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。SortedSet.forEach()方法的具体详情如下:
包路径:java.util.SortedSet
类名称:SortedSet
方法名:forEach

SortedSet.forEach介绍

暂无

代码示例

代码示例来源:origin: linkedin/cruise-control

private List<Long> toWindows(SortedSet<Long> windowIndexes) {
 List<Long> windows = new ArrayList<>(windowIndexes.size());
 windowIndexes.forEach(i -> windows.add(i * _windowMs));
 return windows;
}

代码示例来源:origin: linkedin/cruise-control

private SortedSet<Long> windowIndexesToWindows(SortedSet<Long> original, long windowMs) {
 SortedSet<Long> result = new TreeSet<>(Collections.reverseOrder());
 original.forEach(idx -> result.add(idx * windowMs));
 return result;
}

代码示例来源:origin: linkedin/cruise-control

/**
 * Untrack the sorted replicas with the given name to release memory.
 *
 * @param sortName the name of the sorted replicas.
 */
public void untrackSortedReplicas(String sortName) {
 _brokers.forEach(b -> b.untrackSortedReplicas(sortName));
}

代码示例来源:origin: KronicDeth/intellij-elixir

private static void buildCallDefinitions(@NotNull ModuleStub parentStub, @NotNull Beam beam, @NotNull Atoms atoms) {
  macroNameAritySortedSet(beam, atoms).forEach(macroNameArity -> buildCallDefinition(parentStub, macroNameArity));
}

代码示例来源:origin: Graylog2/graylog2-server

public Configuration(Set<Pipeline> pipelines) {
  if (pipelines.isEmpty()) {
    initialStage = extent[0] = extent[1] = 0;
    return;
  }
  pipelines.forEach(pipeline -> {
    // skip pipelines without any stages, they don't contribute any rules to run
    final SortedSet<Stage> stages = pipeline.stages();
    if (stages.isEmpty()) {
      return;
    }
    extent[0] = Math.min(extent[0], stages.first().stage());
    extent[1] = Math.max(extent[1], stages.last().stage());
    stages.forEach(stage -> stageMultimap.put(stage.stage(), stage));
  });
  if (extent[0] == Integer.MIN_VALUE) {
    throw new IllegalArgumentException("First stage cannot be at " + Integer.MIN_VALUE);
  }
  // the stage before the first stage.
  initialStage = extent[0] - 1;
}

代码示例来源:origin: linkedin/cruise-control

/**
 * Ask the cluster model to keep track of the replicas sorted with the given priority function and score function.
 *
 * The sort will first use the priority function then the score function. The priority function allows the
 * caller to prioritize a certain type of replicas, e.g immigrant replicas. The selection function determines
 * which replicas to be included in the sorted replicas.
 *
 * It is recommended to use the functions from {@link ReplicaSortFunctionFactory} so the functions can be maintained
 * in a single place.
 *
 * The sorted replica will only be updated in the following cases:
 * 1. A replica is added to or removed from a broker
 * 2. A replica's role has changed from leader to follower, and vice versa.
 *
 * The sorted replicas are named using the given sortName, and can be accessed using
 * {@link Broker#trackedSortedReplicas(String)}. If the sorted replicas are no longer needed,
 * {@link #untrackSortedReplicas(String)} to release memory.
 *
 * @param sortName the name of the sorted replicas.
 * @param selectionFunc the selection function to decide which replicas to include in the sort.
 * @param priorityFunc the priority function to sort the replicas
 * @param scoreFunc the score function to sort the replicas with the same priority.
 * @see SortedReplicas
 */
public void trackSortedReplicas(String sortName,
                Function<Replica, Boolean> selectionFunc,
                Function<Replica, Integer> priorityFunc,
                Function<Replica, Double> scoreFunc) {
 _brokers.forEach(b -> b.trackSortedReplicas(sortName, selectionFunc, priorityFunc, scoreFunc));
}

代码示例来源:origin: oracle/helidon

/**
   * Clears Application registry. This is required for the Metric TCKs as they
   * all run on the same VM and must not interfere with each other.
   */
  static void clearApplicationRegistry() {
    MetricRegistry applicationRegistry = getApplicationRegistry();
    applicationRegistry.getNames().forEach(applicationRegistry::remove);
  }
}

代码示例来源:origin: apache/incubator-druid

public Builder removeSegment(DataSegment dataSegment)
{
 SegmentAndSum segmentAndSum = new SegmentAndSum(dataSegment, 0.0, 0.0);
 if (!segments.remove(segmentAndSum)) {
  return this;
 }
 double t0 = convertStart(dataSegment, interval);
 double t1 = convertEnd(dataSegment, interval);
 double leftValue = FastMath.exp(t0) - FastMath.exp(t1);
 double rightValue = FastMath.exp(-t1) - FastMath.exp(-t0);
 segments.tailSet(segmentAndSum).forEach(v -> v.leftSum -= leftValue);
 segments.headSet(segmentAndSum).forEach(v -> v.rightSum -= rightValue);
 return this;
}

代码示例来源:origin: Graylog2/graylog2-server

@Nonnull
private Pipeline resolvePipeline(Pipeline pipeline, Map<String, Rule> ruleNameMap) {
  log.debug("Resolving pipeline {}", pipeline.name());
  pipeline.stages().forEach(stage -> {
    final List<Rule> resolvedRules = stage.ruleReferences().stream()
        .map(ref -> {
          Rule rule = ruleNameMap.get(ref);
          if (rule == null) {
            rule = Rule.alwaysFalse("Unresolved rule " + ref);
          }
          // make a copy so that the metrics match up (we don't share actual objects between stages)
          // this also makes sure we don't accidentally share state of generated code between threads
          rule = rule.invokableCopy(functionRegistry);
          log.debug("Resolved rule `{}` to {}", ref, rule);
          // include back reference to stage
          rule.registerMetrics(metricRegistry, pipeline.id(), String.valueOf(stage.stage()));
          return rule;
        })
        .collect(Collectors.toList());
    stage.setRules(resolvedRules);
    stage.setPipeline(pipeline);
    stage.registerMetrics(metricRegistry, pipeline.id());
  });
  pipeline.registerMetrics(metricRegistry);
  return pipeline;
}

代码示例来源:origin: Graylog2/graylog2-server

allIndexRanges.forEach(indexRange -> extraIndices.remove(indexRange.indexName()));
final Set<String> affectedIndexSetNames = extraIndices.stream()
    .map(indexSetRegistry::getForIndex)

代码示例来源:origin: apache/hbase

this.oldsources.add(replicationSource);
for (SortedSet<String> walsByGroup : walsByIdRecoveredQueues.get(queueId).values()) {
 walsByGroup.forEach(wal -> src.enqueueLog(new Path(wal)));

代码示例来源:origin: apache/hbase

syncFutures.forEach(f -> f.done(f.getTxid(), error));
if (!(consumeExecutor instanceof EventLoop)) {
 consumeExecutor.shutdown();

代码示例来源:origin: linkedin/cruise-control

clusterModel.brokers().forEach(broker -> numExcludedReplicasByPositionInBroker.put(broker.id(), new HashMap<>()));
for (String excludedTopic : excludedTopics) {
 for (Partition partition : _partitionsByTopic.get(excludedTopic)) {

代码示例来源:origin: apache/incubator-druid

public Builder addSegment(DataSegment dataSegment)
{
 if (!interval.contains(dataSegment.getInterval().getStartMillis())) {
  throw new ISE("Failed to add segment to bucket: interval is not covered by this bucket");
 }
 // all values are pre-computed relatively to bucket start (which is considered as 0)
 double t0 = convertStart(dataSegment, interval);
 double t1 = convertEnd(dataSegment, interval);
 double leftValue = FastMath.exp(t0) - FastMath.exp(t1);
 double rightValue = FastMath.exp(-t1) - FastMath.exp(-t0);
 SegmentAndSum segmentAndSum = new SegmentAndSum(dataSegment, leftValue, rightValue);
 // left/right value should be added to left/right sums for elements greater/lower than current segment
 segments.tailSet(segmentAndSum).forEach(v -> v.leftSum += leftValue);
 segments.headSet(segmentAndSum).forEach(v -> v.rightSum += rightValue);
 // leftSum_i = leftValue_i + \sum leftValue_j = leftValue_i + leftSum_{i-1} , j < i
 SegmentAndSum lower = segments.lower(segmentAndSum);
 if (lower != null) {
  segmentAndSum.leftSum = leftValue + lower.leftSum;
 }
 // rightSum_i = rightValue_i + \sum rightValue_j = rightValue_i + rightSum_{i+1} , j > i
 SegmentAndSum higher = segments.higher(segmentAndSum);
 if (higher != null) {
  segmentAndSum.rightSum = rightValue + higher.rightSum;
 }
 if (!segments.add(segmentAndSum)) {
  throw new ISE("expect new segment");
 }
 return this;
}

代码示例来源:origin: reactor/reactor-core

AtomicReference<FieldLayout> requested = new AtomicReference<>();
layout.fields().forEach(f -> {
  if ("wip".equals(f.name())) wip.set(f);
  else if ("requested".equals(f.name())) requested.set(f);

代码示例来源:origin: linkedin/cruise-control

/**
 * Get broker return the broker stats.
 */
public BrokerStats brokerStats() {
 BrokerStats brokerStats = new BrokerStats();
 brokers().forEach(broker -> {
  double leaderBytesInRate = broker.leadershipLoadForNwResources().expectedUtilizationFor(Resource.NW_IN);
  brokerStats.addSingleBrokerStats(broker.host().name(),
                   broker.id(),
                   broker.state(),
                   broker.replicas().isEmpty() ? 0 : broker.load().expectedUtilizationFor(Resource.DISK),
                   broker.load().expectedUtilizationFor(Resource.CPU),
                   leaderBytesInRate,
                   broker.load().expectedUtilizationFor(Resource.NW_IN) - leaderBytesInRate,
                   broker.load().expectedUtilizationFor(Resource.NW_OUT),
                   potentialLeadershipLoadFor(broker.id()).expectedUtilizationFor(Resource.NW_OUT),
                   broker.replicas().size(), broker.leaderReplicas().size(),
                   _capacityEstimationInfoByBrokerId.get(broker.id()) != null,
                   broker.capacityFor(Resource.DISK));
 });
 return brokerStats;
}

代码示例来源:origin: linkedin/cruise-control

clusterModel.broker(0).leaderReplicas().forEach(r -> leaderPartitionsOnDemotedBroker.add(r.topicPartition()));
Map<TopicPartition, Integer> leaderDistributionBeforeBrokerDemotion = new HashMap<>();
clusterModel.brokers().forEach(b -> {
 b.leaderReplicas().forEach(r -> leaderDistributionBeforeBrokerDemotion.put(r.topicPartition(), b.id()));
});

代码示例来源:origin: spotify/helios

environment.healthChecks().getNames().forEach(
  name -> environment.metrics().register(
    "helios." + name + ".ok", new HealthCheckGauge(environment.healthChecks(), name)));

代码示例来源:origin: spotify/helios

environment.healthChecks().getNames().forEach(
  name -> environment.metrics().register(
    "helios." + name + ".ok", new HealthCheckGauge(environment.healthChecks(), name)));

代码示例来源:origin: torakiki/pdfsam

@EventListener
public void onRemoveSelected(RemoveSelectedEvent event) {
  SortedSet<Integer> indices = new TreeSet<>(Collections.reverseOrder());
  indices.addAll(getSelectionModel().getSelectedIndices());
  LOG.trace("Removing {} items", indices.size());
  indices.forEach(i -> getItems().remove(i.intValue()).invalidate());
  requestFocus();
}

相关文章