com.carrotsearch.hppc.ObjectIntHashMap.addTo()方法的使用及代码示例

x33g5p2x  于2022-01-26 转载在 其他  
字(11.1k)|赞(0)|评价(0)|浏览(80)

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

ObjectIntHashMap.addTo介绍

[英]Adds incrementValue to any existing value for the given key or inserts incrementValue if key did not previously exist.
[中]将incrementValue添加到给定key的任何现有值中,或者如果key以前不存在,则插入incrementValue

代码示例

代码示例来源:origin: org.elasticsearch/elasticsearch

/**
 * Captures the most recent commit point {@link #lastCommit} or the most recent safe commit point {@link #safeCommit}.
 * Index files of the capturing commit point won't be released until the commit reference is closed.
 *
 * @param acquiringSafeCommit captures the most recent safe commit point if true; otherwise captures the most recent commit point.
 */
synchronized IndexCommit acquireIndexCommit(boolean acquiringSafeCommit) {
  assert safeCommit != null : "Safe commit is not initialized yet";
  assert lastCommit != null : "Last commit is not initialized yet";
  final IndexCommit snapshotting = acquiringSafeCommit ? safeCommit : lastCommit;
  snapshottedCommits.addTo(snapshotting, 1); // increase refCount
  return new SnapshotIndexCommit(snapshotting);
}

代码示例来源:origin: org.elasticsearch/elasticsearch

public ObjectIntHashMap<String> nodesPerAttributesCounts(String attributeName) {
  ObjectIntHashMap<String> nodesPerAttributesCounts = nodesPerAttributeNames.get(attributeName);
  if (nodesPerAttributesCounts != null) {
    return nodesPerAttributesCounts;
  }
  nodesPerAttributesCounts = new ObjectIntHashMap<>();
  for (RoutingNode routingNode : this) {
    String attrValue = routingNode.node().getAttributes().get(attributeName);
    nodesPerAttributesCounts.addTo(attrValue, 1);
  }
  nodesPerAttributeNames.put(attributeName, nodesPerAttributesCounts);
  return nodesPerAttributesCounts;
}

代码示例来源:origin: org.elasticsearch/elasticsearch

/**
 * Releases an index commit that acquired by {@link #acquireIndexCommit(boolean)}.
 *
 * @return true if the snapshotting commit can be clean up.
 */
synchronized boolean releaseCommit(final IndexCommit snapshotCommit) {
  final IndexCommit releasingCommit = ((SnapshotIndexCommit) snapshotCommit).delegate;
  assert snapshottedCommits.containsKey(releasingCommit) : "Release non-snapshotted commit;" +
    "snapshotted commits [" + snapshottedCommits + "], releasing commit [" + releasingCommit + "]";
  final int refCount = snapshottedCommits.addTo(releasingCommit, -1); // release refCount
  assert refCount >= 0 : "Number of snapshots can not be negative [" + refCount + "]";
  if (refCount == 0) {
    snapshottedCommits.remove(releasingCommit);
  }
  // The commit can be clean up only if no pending snapshot and it is neither the safe commit nor last commit.
  return refCount == 0 && releasingCommit.equals(safeCommit) == false && releasingCommit.equals(lastCommit) == false;
}

代码示例来源:origin: org.elasticsearch/elasticsearch

shardPerAttribute.addTo(routingNode.node().getAttributes().get(awarenessAttribute), 1);
  shardPerAttribute.addTo(node.node().getAttributes().get(awarenessAttribute), 1);
shardPerAttribute.addTo(node.node().getAttributes().get(awarenessAttribute), 1);

代码示例来源:origin: org.elasticsearch/elasticsearch

long heapUsed = 0;
for (NodeInfo nodeInfo : nodeInfos) {
  versions.addTo(new JvmVersion(nodeInfo.getJvm()), 1);

代码示例来源:origin: org.elasticsearch/elasticsearch

names.addTo(nodeInfo.getOs().getName(), 1);
prettyNames.addTo(nodeInfo.getOs().getPrettyName(), 1);

代码示例来源:origin: org.apache.servicemix.bundles/org.apache.servicemix.bundles.elasticsearch

/**
 * Captures the most recent commit point {@link #lastCommit} or the most recent safe commit point {@link #safeCommit}.
 * Index files of the capturing commit point won't be released until the commit reference is closed.
 *
 * @param acquiringSafeCommit captures the most recent safe commit point if true; otherwise captures the most recent commit point.
 */
synchronized IndexCommit acquireIndexCommit(boolean acquiringSafeCommit) {
  assert safeCommit != null : "Safe commit is not initialized yet";
  assert lastCommit != null : "Last commit is not initialized yet";
  final IndexCommit snapshotting = acquiringSafeCommit ? safeCommit : lastCommit;
  snapshottedCommits.addTo(snapshotting, 1); // increase refCount
  return new SnapshotIndexCommit(snapshotting);
}

代码示例来源:origin: apache/servicemix-bundles

/**
 * Captures the most recent commit point {@link #lastCommit} or the most recent safe commit point {@link #safeCommit}.
 * Index files of the capturing commit point won't be released until the commit reference is closed.
 *
 * @param acquiringSafeCommit captures the most recent safe commit point if true; otherwise captures the most recent commit point.
 */
synchronized IndexCommit acquireIndexCommit(boolean acquiringSafeCommit) {
  assert safeCommit != null : "Safe commit is not initialized yet";
  assert lastCommit != null : "Last commit is not initialized yet";
  final IndexCommit snapshotting = acquiringSafeCommit ? safeCommit : lastCommit;
  snapshottedCommits.addTo(snapshotting, 1); // increase refCount
  return new SnapshotIndexCommit(snapshotting);
}

代码示例来源:origin: com.strapdata.elasticsearch/elasticsearch

public ObjectIntHashMap<String> nodesPerAttributesCounts(String attributeName) {
  ObjectIntHashMap<String> nodesPerAttributesCounts = nodesPerAttributeNames.get(attributeName);
  if (nodesPerAttributesCounts != null) {
    return nodesPerAttributesCounts;
  }
  nodesPerAttributesCounts = new ObjectIntHashMap<>();
  for (RoutingNode routingNode : this) {
    String attrValue = routingNode.node().getAttributes().get(attributeName);
    nodesPerAttributesCounts.addTo(attrValue, 1);
  }
  nodesPerAttributeNames.put(attributeName, nodesPerAttributesCounts);
  return nodesPerAttributesCounts;
}

代码示例来源:origin: org.apache.servicemix.bundles/org.apache.servicemix.bundles.elasticsearch

public ObjectIntHashMap<String> nodesPerAttributesCounts(String attributeName) {
  ObjectIntHashMap<String> nodesPerAttributesCounts = nodesPerAttributeNames.get(attributeName);
  if (nodesPerAttributesCounts != null) {
    return nodesPerAttributesCounts;
  }
  nodesPerAttributesCounts = new ObjectIntHashMap<>();
  for (RoutingNode routingNode : this) {
    String attrValue = routingNode.node().getAttributes().get(attributeName);
    nodesPerAttributesCounts.addTo(attrValue, 1);
  }
  nodesPerAttributeNames.put(attributeName, nodesPerAttributesCounts);
  return nodesPerAttributesCounts;
}

代码示例来源:origin: apache/servicemix-bundles

public ObjectIntHashMap<String> nodesPerAttributesCounts(String attributeName) {
  ObjectIntHashMap<String> nodesPerAttributesCounts = nodesPerAttributeNames.get(attributeName);
  if (nodesPerAttributesCounts != null) {
    return nodesPerAttributesCounts;
  }
  nodesPerAttributesCounts = new ObjectIntHashMap<>();
  for (RoutingNode routingNode : this) {
    String attrValue = routingNode.node().getAttributes().get(attributeName);
    nodesPerAttributesCounts.addTo(attrValue, 1);
  }
  nodesPerAttributeNames.put(attributeName, nodesPerAttributesCounts);
  return nodesPerAttributesCounts;
}

代码示例来源:origin: harbby/presto-connectors

public ObjectIntHashMap<String> nodesPerAttributesCounts(String attributeName) {
  ObjectIntHashMap<String> nodesPerAttributesCounts = nodesPerAttributeNames.get(attributeName);
  if (nodesPerAttributesCounts != null) {
    return nodesPerAttributesCounts;
  }
  nodesPerAttributesCounts = new ObjectIntHashMap<>();
  for (RoutingNode routingNode : this) {
    String attrValue = routingNode.node().attributes().get(attributeName);
    nodesPerAttributesCounts.addTo(attrValue, 1);
  }
  nodesPerAttributeNames.put(attributeName, nodesPerAttributesCounts);
  return nodesPerAttributesCounts;
}

代码示例来源:origin: org.apache.servicemix.bundles/org.apache.servicemix.bundles.elasticsearch

/**
 * Releases an index commit that acquired by {@link #acquireIndexCommit(boolean)}.
 *
 * @return true if the snapshotting commit can be clean up.
 */
synchronized boolean releaseCommit(final IndexCommit snapshotCommit) {
  final IndexCommit releasingCommit = ((SnapshotIndexCommit) snapshotCommit).delegate;
  assert snapshottedCommits.containsKey(releasingCommit) : "Release non-snapshotted commit;" +
    "snapshotted commits [" + snapshottedCommits + "], releasing commit [" + releasingCommit + "]";
  final int refCount = snapshottedCommits.addTo(releasingCommit, -1); // release refCount
  assert refCount >= 0 : "Number of snapshots can not be negative [" + refCount + "]";
  if (refCount == 0) {
    snapshottedCommits.remove(releasingCommit);
  }
  // The commit can be clean up only if no pending snapshot and it is neither the safe commit nor last commit.
  return refCount == 0 && releasingCommit.equals(safeCommit) == false && releasingCommit.equals(lastCommit) == false;
}

代码示例来源:origin: apache/servicemix-bundles

/**
 * Releases an index commit that acquired by {@link #acquireIndexCommit(boolean)}.
 *
 * @return true if the snapshotting commit can be clean up.
 */
synchronized boolean releaseCommit(final IndexCommit snapshotCommit) {
  final IndexCommit releasingCommit = ((SnapshotIndexCommit) snapshotCommit).delegate;
  assert snapshottedCommits.containsKey(releasingCommit) : "Release non-snapshotted commit;" +
    "snapshotted commits [" + snapshottedCommits + "], releasing commit [" + releasingCommit + "]";
  final int refCount = snapshottedCommits.addTo(releasingCommit, -1); // release refCount
  assert refCount >= 0 : "Number of snapshots can not be negative [" + refCount + "]";
  if (refCount == 0) {
    snapshottedCommits.remove(releasingCommit);
  }
  // The commit can be clean up only if no pending snapshot and it is neither the safe commit nor last commit.
  return refCount == 0 && releasingCommit.equals(safeCommit) == false && releasingCommit.equals(lastCommit) == false;
}

代码示例来源:origin: harbby/presto-connectors

@Override
public void readFrom(StreamInput in) throws IOException {
  int size = in.readVInt();
  versions = new ObjectIntHashMap<>(size);
  for (; size > 0; size--) {
    versions.addTo(JvmVersion.readJvmVersion(in), in.readVInt());
  }
  threads = in.readVLong();
  maxUptime = in.readVLong();
  heapUsed = in.readVLong();
  heapMax = in.readVLong();
}

代码示例来源:origin: harbby/presto-connectors

@Override
public void readFrom(StreamInput in) throws IOException {
  availableProcessors = in.readVInt();
  if (in.getVersion().onOrAfter(Version.V_2_1_0)) {
    allocatedProcessors = in.readVInt();
  }
  availableMemory = in.readLong();
  int size = in.readVInt();
  names.clear();
  for (int i = 0; i < size; i++) {
    names.addTo(in.readString(), in.readVInt());
  }
}

代码示例来源:origin: harbby/presto-connectors

public void addNodeInfoStats(NodeInfo nodeInfo, NodeStats nodeStats) {
  versions.addTo(new JvmVersion(nodeInfo.getJvm()), 1);
  org.elasticsearch.monitor.jvm.JvmStats js = nodeStats.getJvm();
  if (js == null) {
    return;
  }
  if (js.getThreads() != null) {
    threads += js.getThreads().getCount();
  }
  maxUptime = Math.max(maxUptime, js.getUptime().millis());
  if (js.getMem() != null) {
    heapUsed += js.getMem().getHeapUsed().bytes();
    heapMax += js.getMem().getHeapMax().bytes();
  }
}

代码示例来源:origin: harbby/presto-connectors

public void addNodeInfoStats(NodeInfo nodeInfo, NodeStats nodeStats) {
  availableProcessors += nodeInfo.getOs().getAvailableProcessors();
  allocatedProcessors += nodeInfo.getOs().getAllocatedProcessors();
  if (nodeInfo.getOs().getName() != null) {
    names.addTo(nodeInfo.getOs().getName(), 1);
  }
  if (nodeStats.getOs() != null && nodeStats.getOs().getMem() != null) {
    availableMemory += nodeStats.getOs().getMem().getFree().bytes();
  }
}

代码示例来源:origin: org.apache.servicemix.bundles/org.apache.servicemix.bundles.elasticsearch

long heapUsed = 0;
for (NodeInfo nodeInfo : nodeInfos) {
  versions.addTo(new JvmVersion(nodeInfo.getJvm()), 1);

代码示例来源:origin: org.apache.servicemix.bundles/org.apache.servicemix.bundles.elasticsearch

names.addTo(nodeInfo.getOs().getName(), 1);

相关文章