本文整理汇总了Java中com.google.common.util.concurrent.AtomicLongMap类的典型用法代码示例。如果您正苦于以下问题:Java AtomicLongMap类的具体用法?Java AtomicLongMap怎么用?Java AtomicLongMap使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
AtomicLongMap类属于com.google.common.util.concurrent包,在下文中一共展示了AtomicLongMap类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: build
import com.google.common.util.concurrent.AtomicLongMap; //导入依赖的package包/类
public static EurostagFakeNodes build(Network network, EurostagEchExportConfig config) {
Objects.requireNonNull(network);
Objects.requireNonNull(config);
BiMap<String, String> fakeNodesMap = HashBiMap.create(new HashMap<>());
AtomicLongMap<String> countUsesMap = AtomicLongMap.create();
//adds 2 default fake nodes
fakeNodesMap.put(EchUtil.FAKE_NODE_NAME1, EchUtil.FAKE_NODE_NAME1);
countUsesMap.getAndIncrement(EchUtil.FAKE_NODE_NAME1);
fakeNodesMap.put(EchUtil.FAKE_NODE_NAME2, EchUtil.FAKE_NODE_NAME2);
countUsesMap.getAndIncrement(EchUtil.FAKE_NODE_NAME2);
Identifiables.sort(network.getVoltageLevels()).stream().map(VoltageLevel::getId).forEach(vlId ->
fakeNodesMap.put(vlId, newEsgId(fakeNodesMap, vlId)));
return new EurostagFakeNodes(fakeNodesMap, countUsesMap, network);
}
开发者ID:itesla,项目名称:ipst,代码行数:19,代码来源:EurostagFakeNodes.java
示例2: end
import com.google.common.util.concurrent.AtomicLongMap; //导入依赖的package包/类
@Override
public void end() {
for(Map.Entry<String, AtomicLongMap<String>> entry : aggregation.entrySet()) {
String fieldName = entry.getKey();
AtomicLongMap<String> fieldValue = entry.getValue();
for(Map.Entry<String,Long> fieldValueEntry : fieldValue.asMap().entrySet()) {
String value = fieldValueEntry.getKey();
Long count = fieldValueEntry.getValue();
Document document = new Document();
document.setField("value", value);
document.setField("count", count);
document.setField("type", fieldName);
super.document(document);
}
}
super.end();
}
开发者ID:tblsoft,项目名称:solr-cmd-utils,代码行数:20,代码来源:AggregationCountFilter.java
示例3: testIncrement
import com.google.common.util.concurrent.AtomicLongMap; //导入依赖的package包/类
@Test
public void testIncrement() throws Exception {
AtomicLongMap<String> cache = AtomicLongMap.create();
cache.addAndGet("a", 1L);
cache.addAndGet("a", 2L);
cache.addAndGet("b", 5L);
Map<String, Long> remove = AtomicLongMapUtils.remove(cache);
Assert.assertEquals((long) remove.get("a"), 3L);
Assert.assertEquals((long) remove.get("b"), 5L);
cache.addAndGet("a", 1L);
Map<String, Long> remove2 = AtomicLongMapUtils.remove(cache);
Assert.assertEquals((long) remove2.get("a"), 1L);
}
开发者ID:naver,项目名称:pinpoint,代码行数:17,代码来源:AtomicLongMapTest.java
示例4: testConsistentHash_probabilities
import com.google.common.util.concurrent.AtomicLongMap; //导入依赖的package包/类
public void testConsistentHash_probabilities() {
AtomicLongMap<Integer> map = AtomicLongMap.create();
Random r = new Random(9);
for (int i = 0; i < ITERS; i++) {
countRemaps(r.nextLong(), map);
}
for (int shard = 2; shard <= MAX_SHARDS; shard++) {
// Rough: don't exceed 1.2x the expected number of remaps by more than 20
assertTrue(map.get(shard) <= 1.2 * ITERS / shard + 20);
}
}
开发者ID:zugzug90,项目名称:guava-mock,代码行数:12,代码来源:HashingTest.java
示例5: countRemaps
import com.google.common.util.concurrent.AtomicLongMap; //导入依赖的package包/类
private void countRemaps(long h, AtomicLongMap<Integer> map) {
int last = 0;
for (int shards = 2; shards <= MAX_SHARDS; shards++) {
int chosen = Hashing.consistentHash(h, shards);
if (chosen != last) {
map.incrementAndGet(shards);
last = chosen;
}
}
}
开发者ID:zugzug90,项目名称:guava-mock,代码行数:11,代码来源:HashingTest.java
示例6: TermVectorsFilter
import com.google.common.util.concurrent.AtomicLongMap; //导入依赖的package包/类
public TermVectorsFilter(Fields termVectorsByField, Fields topLevelFields, Set<String> selectedFields, @Nullable AggregatedDfs dfs) {
this.fields = termVectorsByField;
this.topLevelFields = topLevelFields;
this.selectedFields = selectedFields;
this.dfs = dfs;
this.scoreTerms = new HashMap<>();
this.sizes = AtomicLongMap.create();
this.similarity = new DefaultSimilarity();
}
开发者ID:baidu,项目名称:Elasticsearch,代码行数:11,代码来源:TermVectorsFilter.java
示例7: PartitionMarkowData
import com.google.common.util.concurrent.AtomicLongMap; //导入依赖的package包/类
PartitionMarkowData(List<Actor> actors) {
this.actors = ActorsSorter.topologicalOrder(actors);
successorsMap = new HashMap<>();
for (Actor actor : actors) {
successorsMap.put(actor, AtomicLongMap.create());
}
firings = AtomicLongMap.create();
lastFiredActor = null;
firstFiredActor = null;
}
开发者ID:turnus,项目名称:turnus,代码行数:11,代码来源:MarkovSimpleScheduler.java
示例8: Pcp
import com.google.common.util.concurrent.AtomicLongMap; //导入依赖的package包/类
Pcp(String partition) {
this.partition = partition;
finishTime = 0;
pcpFirings = AtomicLongMap.create();
sumPcpWeightMap = new HashMap<>();
maxBlockedTokens = new HashMap<>();
maxBlockedMultiplication = new HashMap<>();
blockingInstances = new HashMap<>();
partitionsBlockingMap = new HashMap<>();
}
开发者ID:turnus,项目名称:turnus,代码行数:11,代码来源:CriticalPathCollector.java
示例9: Pcp
import com.google.common.util.concurrent.AtomicLongMap; //导入依赖的package包/类
private Pcp(Action action, double weight, double variance) {
pcpWeight = weight;
pcpVariance = variance;
pcpFirings = AtomicLongMap.create();
pcpFirings.incrementAndGet(action);
sumPcpWeightMap = new HashMap<>();
sumPcpWeightMap.put(action, weight);
sumPcpVarianceMap = new HashMap<>();
sumPcpVarianceMap.put(action, variance);
}
开发者ID:turnus,项目名称:turnus,代码行数:14,代码来源:AlgorithmicPartialCriticalPathAnalysis.java
示例10: VectorClock
import com.google.common.util.concurrent.AtomicLongMap; //导入依赖的package包/类
public VectorClock(Vector<Integer> ids) {
minClock = 0;
vecClock = AtomicLongMap.create();
for (Integer id : ids) {
vecClock.put(id, 0);
}
}
开发者ID:sailing-pmls,项目名称:jbosen,代码行数:8,代码来源:VectorClock.java
示例11: testConsistentHash_probabilities
import com.google.common.util.concurrent.AtomicLongMap; //导入依赖的package包/类
public void testConsistentHash_probabilities() {
AtomicLongMap<Integer> map = AtomicLongMap.create();
Random r = new Random(9);
for (int i = 0; i < ITERS; i++) {
countRemaps(r.nextLong(), map);
}
for (int shard = 2; shard <= MAX_SHARDS; shard++) {
// Rough: don't exceed 1.2x the expected number of remaps by more than 20
assertTrue(map.get(shard) <= 1.2 * ITERS / shard + 20);
}
}
开发者ID:adohe,项目名称:java-jump-consistent-hash,代码行数:12,代码来源:HashingTest.java
示例12: countRemaps
import com.google.common.util.concurrent.AtomicLongMap; //导入依赖的package包/类
private void countRemaps(long h, AtomicLongMap<Integer> map) {
int last = 0;
for (int shards = 2; shards <= MAX_SHARDS; shards++) {
int chosen = Hashing.consistentHash(h, shards);
if (chosen != last) {
map.incrementAndGet(shards);
last = chosen;
}
}
}
开发者ID:adohe,项目名称:java-jump-consistent-hash,代码行数:11,代码来源:HashingTest.java
示例13: remove
import com.google.common.util.concurrent.AtomicLongMap; //导入依赖的package包/类
public static <T> Map<T, Long> remove(AtomicLongMap<T> atomicLongMap) {
final Map<T, Long> view = atomicLongMap.asMap();
// view.size() is not recommended, cache entry is striped and volatile field
final List<T> keySnapshot = keySnapshot(view);
return remove(atomicLongMap, keySnapshot);
}
开发者ID:naver,项目名称:pinpoint,代码行数:9,代码来源:AtomicLongMapUtils.java
示例14: testIntegerMax
import com.google.common.util.concurrent.AtomicLongMap; //导入依赖的package包/类
@Test
public void testIntegerMax() throws Exception {
AtomicLongMap<String> cache = AtomicLongMap.create();
cache.addAndGet("a", 1L);
cache.addAndGet("a", 2L);
cache.addAndGet("b", 5L);
}
开发者ID:naver,项目名称:pinpoint,代码行数:8,代码来源:AtomicLongMapTest.java
示例15: testIntegerMin
import com.google.common.util.concurrent.AtomicLongMap; //导入依赖的package包/类
@Test
public void testIntegerMin() throws Exception {
AtomicLongMap<String> cache = AtomicLongMap.create();
cache.addAndGet("a", 1L);
cache.addAndGet("a", 2L);
cache.addAndGet("b", 5L);
}
开发者ID:naver,项目名称:pinpoint,代码行数:9,代码来源:AtomicLongMapTest.java
示例16: setup
import com.google.common.util.concurrent.AtomicLongMap; //导入依赖的package包/类
@SuppressWarnings("unchecked")
@Before
public void setup() throws Exception {
recursionDepthPerThread = AtomicLongMap.create();
maxRecursionDepthPerThread = AtomicLongMap.create();
totIterations = new AtomicLong(0);
}
开发者ID:udoprog,项目名称:tiny-async-java,代码行数:8,代码来源:RecursionSafeAsyncCallerIT.java
示例17: add
import com.google.common.util.concurrent.AtomicLongMap; //导入依赖的package包/类
public static void add(int position, byte base, Map<Integer, AtomicLongMap> alignmentMap) {
try {
if (!alignmentMap.containsKey(position)) {
alignmentMap.put(position, AtomicLongMap.create());
}
alignmentMap.get(position).incrementAndGet(base);
} catch (IllegalArgumentException e) {
System.out.println(e);
}
}
开发者ID:cbg-ethz,项目名称:ConsensusFixer,代码行数:11,代码来源:SFRComputing.java
示例18: addInsert
import com.google.common.util.concurrent.AtomicLongMap; //导入依赖的package包/类
private static void addInsert(int position, int insertIndex, byte base, Map<Integer, Map<Integer, AtomicLongMap>> insertionMap) {
try {
if (!insertionMap.containsKey(position)) {
insertionMap.put(position, new ConcurrentHashMap<Integer, AtomicLongMap>());
}
add(insertIndex, base, insertionMap.get(position));
} catch (IllegalArgumentException e) {
System.out.println(e);
}
}
开发者ID:cbg-ethz,项目名称:ConsensusFixer,代码行数:11,代码来源:SFRComputing.java
示例19: init
import com.google.common.util.concurrent.AtomicLongMap; //导入依赖的package包/类
@PostConstruct
public void init() {
totalRequests = new AtomicLong(0);
staffRequests = new AtomicLong(0);
buildingRequests = new AtomicLong(0);
sportRequests = new AtomicLong(0);
newsRequests = new AtomicLong(0);
mailboxRequests = new AtomicLong(0);
weatherRequests = new AtomicLong(0);
timetableRequests = new AtomicLong(0);
mensaRequests = AtomicLongMap.create();
errorRequests = new AtomicLong(0);
requestType = AtomicLongMap.create();
executionTimes = EvictingQueue.create(10000);
}
开发者ID:HTWK-App,项目名称:Server-Application,代码行数:16,代码来源:StatisticRepository.java
示例20: ApiServicesRetryStrategy
import com.google.common.util.concurrent.AtomicLongMap; //导入依赖的package包/类
private ApiServicesRetryStrategy() {
this.maxAttemptsOnRateExceededError = ConfigCalculator.MAX_ATTEMPTS_ON_RATE_EXCEEDED_ERROR;
this.maxWaitTimeOnRateExceededError = ConfigCalculator.MAX_WAIT_TIME_ON_RATE_EXCEEDED_ERROR;
this.tokenWaitUntil = new AtomicLong();
this.accountWaitUntil = AtomicLongMap.create();
}
开发者ID:googleads,项目名称:googleads-java-lib,代码行数:8,代码来源:ApiServicesRetryStrategy.java
注:本文中的com.google.common.util.concurrent.AtomicLongMap类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论