本文整理汇总了Java中com.google.common.collect.MapMaker类的典型用法代码示例。如果您正苦于以下问题:Java MapMaker类的具体用法?Java MapMaker怎么用?Java MapMaker使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
MapMaker类属于com.google.common.collect包,在下文中一共展示了MapMaker类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: MemoryStageController
import com.google.common.collect.MapMaker; //导入依赖的package包/类
public MemoryStageController(Long pipelineId){
super(pipelineId);
replys = new MapMaker().makeComputingMap(new Function<StageType, ReplyProcessQueue>() {
public ReplyProcessQueue apply(StageType input) {
int size = ArbitrateConfigUtils.getParallelism(getPipelineId()) * 10;
if (size < 100) {
size = 100;
}
return new ReplyProcessQueue(size);
}
});
progress = new MapMaker().makeMap();
termins = new LinkedBlockingQueue<TerminEventData>(20);
}
示例2: RpcStageController
import com.google.common.collect.MapMaker; //导入依赖的package包/类
public RpcStageController(Long pipelineId){
super(pipelineId);
replys = new MapMaker().makeComputingMap(new Function<StageType, ReplyProcessQueue>() {
public ReplyProcessQueue apply(StageType input) {
int size = ArbitrateConfigUtils.getParallelism(getPipelineId()) * 10;
if (size < 100) {
size = 100;
}
return new ReplyProcessQueue(size);
}
});
progress = new MapMaker().makeMap();
// 注册一下监听事件变化
processMonitor = ArbitrateFactory.getInstance(pipelineId, ProcessMonitor.class);
processMonitor.addListener(this);
processMonitor.reload();
}
示例3: testMergeWithSameKeyOfIU
import com.google.common.collect.MapMaker; //导入依赖的package包/类
/**
* 测试insert+update
*/
@Test
public void testMergeWithSameKeyOfIU() {
Map<RowKey, EventData> mergeMap = new MapMaker().makeMap();
DbLoadMerger.merge(makeInsertEventData(), mergeMap);
DbLoadMerger.merge(makeUpdateEventData(), mergeMap);
for (Entry<RowKey, EventData> entry : mergeMap.entrySet()) {
RowKey key = entry.getKey();
EventColumn keyColumn = key.getKeys().get(0);
Assert.assertEquals(KEY_VALUE, keyColumn.getColumnValue());
Assert.assertEquals(KEY_NAME, keyColumn.getColumnName());
EventData eventData = entry.getValue();
Assert.assertEquals(SCHEMA_NAME, eventData.getSchemaName());
Assert.assertEquals(TABLE_NAME, eventData.getTableName());
Assert.assertEquals(TABLE_ID, eventData.getTableId());
Assert.assertEquals(EventType.INSERT, eventData.getEventType());
Assert.assertEquals(eventData.getOldKeys().size(), 0); // 不存在oldKeys
List<EventColumn> columns = eventData.getColumns();
Assert.assertEquals(3, columns.size());
}
}
示例4: testMergeWithSameKeyOfIUD
import com.google.common.collect.MapMaker; //导入依赖的package包/类
/**
* 测试insert+update+delete
*/
@Test
public void testMergeWithSameKeyOfIUD() {
Map<RowKey, EventData> mergeMap = new MapMaker().makeMap();
DbLoadMerger.merge(makeInsertEventData(), mergeMap);
DbLoadMerger.merge(makeUpdateEventData(), mergeMap);
DbLoadMerger.merge(makeDeleteEventData(), mergeMap);
for (Entry<RowKey, EventData> entry : mergeMap.entrySet()) {
RowKey key = entry.getKey();
EventColumn keyColumn = key.getKeys().get(0);
Assert.assertEquals(KEY_VALUE, keyColumn.getColumnValue());
Assert.assertEquals(KEY_NAME, keyColumn.getColumnName());
EventData eventData = entry.getValue();
Assert.assertEquals(SCHEMA_NAME, eventData.getSchemaName());
Assert.assertEquals(TABLE_NAME, eventData.getTableName());
Assert.assertEquals(TABLE_ID, eventData.getTableId());
Assert.assertEquals(EventType.DELETE, eventData.getEventType());
Assert.assertEquals(eventData.getOldKeys().size(), 0); // 不存在oldKeys
List<EventColumn> columns = eventData.getColumns();
Assert.assertEquals(0, columns.size());
}
}
示例5: testMergeWithSameKeyOfIUDI
import com.google.common.collect.MapMaker; //导入依赖的package包/类
/**
* 测试insert+update+delete+insert
*/
@Test
public void testMergeWithSameKeyOfIUDI() {
Map<RowKey, EventData> mergeMap = new MapMaker().makeMap();
DbLoadMerger.merge(makeInsertEventData(), mergeMap);
DbLoadMerger.merge(makeUpdateEventData(), mergeMap);
DbLoadMerger.merge(makeDeleteEventData(), mergeMap);
DbLoadMerger.merge(makeInsertEventData(), mergeMap);
for (Entry<RowKey, EventData> entry : mergeMap.entrySet()) {
RowKey key = entry.getKey();
EventColumn keyColumn = key.getKeys().get(0);
Assert.assertEquals(KEY_VALUE, keyColumn.getColumnValue());
Assert.assertEquals(KEY_NAME, keyColumn.getColumnName());
EventData eventData = entry.getValue();
Assert.assertEquals(SCHEMA_NAME, eventData.getSchemaName());
Assert.assertEquals(TABLE_NAME, eventData.getTableName());
Assert.assertEquals(TABLE_ID, eventData.getTableId());
Assert.assertEquals(EventType.INSERT, eventData.getEventType());
Assert.assertEquals(eventData.getOldKeys().size(), 0); // 不存在oldKeys
List<EventColumn> columns = eventData.getColumns();
Assert.assertEquals(2, columns.size());
}
}
示例6: testMergeWithUpdateKeyOfUU
import com.google.common.collect.MapMaker; //导入依赖的package包/类
/**
* 测试在主键发生变化后的merge操作,Update/Update
*/
@Test
public void testMergeWithUpdateKeyOfUU() {
Map<RowKey, EventData> mergeMap = new MapMaker().makeMap();
DbLoadMerger.merge(makeUpdateEventData(KEY_VALUE, KEY_VALUE_NEW1), mergeMap);
DbLoadMerger.merge(makeUpdateEventData(KEY_VALUE_NEW1, KEY_VALUE_NEW2), mergeMap);
for (Entry<RowKey, EventData> entry : mergeMap.entrySet()) {
RowKey key = entry.getKey();
EventColumn keyColumn = key.getKeys().get(0);
Assert.assertEquals(KEY_VALUE_NEW2, keyColumn.getColumnValue());
Assert.assertEquals(KEY_NAME, keyColumn.getColumnName());
EventData eventData = entry.getValue();
Assert.assertEquals(SCHEMA_NAME, eventData.getSchemaName());
Assert.assertEquals(TABLE_NAME, eventData.getTableName());
Assert.assertEquals(TABLE_ID, eventData.getTableId());
Assert.assertEquals(EventType.UPDATE, eventData.getEventType());
List<EventColumn> oldKeys = eventData.getOldKeys();
List<EventColumn> keys = eventData.getKeys();
Assert.assertNotSame(oldKeys, keys);
}
}
示例7: testMergeWithUpdateKeyOfUUD
import com.google.common.collect.MapMaker; //导入依赖的package包/类
/**
* 测试在主键发生变化后的merge操作,Update/Update/delete
*/
@Test
public void testMergeWithUpdateKeyOfUUD() {
Map<RowKey, EventData> mergeMap = new MapMaker().makeMap();
DbLoadMerger.merge(makeUpdateEventData(KEY_VALUE_NEW1, KEY_VALUE_NEW2), mergeMap);
DbLoadMerger.merge(makeUpdateEventData(KEY_VALUE_NEW2, KEY_VALUE), mergeMap);
DbLoadMerger.merge(makeDeleteEventData(), mergeMap);
for (Entry<RowKey, EventData> entry : mergeMap.entrySet()) {
RowKey key = entry.getKey();
EventColumn keyColumn = key.getKeys().get(0);
Assert.assertEquals(KEY_VALUE_NEW1, keyColumn.getColumnValue());
Assert.assertEquals(KEY_NAME, keyColumn.getColumnName());
EventData eventData = entry.getValue();
Assert.assertEquals(SCHEMA_NAME, eventData.getSchemaName());
Assert.assertEquals(TABLE_NAME, eventData.getTableName());
Assert.assertEquals(TABLE_ID, eventData.getTableId());
Assert.assertEquals(EventType.DELETE, eventData.getEventType());
Assert.assertEquals(eventData.getOldKeys().size(), 0); // 不存在oldKeys
}
}
示例8: testMergeWithUpdateKeyOfIUUUU
import com.google.common.collect.MapMaker; //导入依赖的package包/类
/**
* 测试在主键发生变化后的merge操作,Insert/Update/Update/Update/Update
*/
@Test
public void testMergeWithUpdateKeyOfIUUUU() {
Map<RowKey, EventData> mergeMap = new MapMaker().makeMap();
DbLoadMerger.merge(makeInsertEventData(), mergeMap);
DbLoadMerger.merge(makeUpdateEventData(KEY_VALUE, KEY_VALUE_NEW1), mergeMap);
DbLoadMerger.merge(makeUpdateEventData(KEY_VALUE_NEW1, KEY_VALUE_NEW2), mergeMap);
DbLoadMerger.merge(makeUpdateEventData(KEY_VALUE_NEW2, KEY_VALUE_NEW3), mergeMap);
DbLoadMerger.merge(makeUpdateEventData(KEY_VALUE_NEW3, KEY_VALUE_NEW4), mergeMap);
for (Entry<RowKey, EventData> entry : mergeMap.entrySet()) {
RowKey key = entry.getKey();
EventColumn keyColumn = key.getKeys().get(0);
Assert.assertEquals(KEY_VALUE_NEW4, keyColumn.getColumnValue());
Assert.assertEquals(KEY_NAME, keyColumn.getColumnName());
EventData eventData = entry.getValue();
Assert.assertEquals(SCHEMA_NAME, eventData.getSchemaName());
Assert.assertEquals(TABLE_NAME, eventData.getTableName());
Assert.assertEquals(TABLE_ID, eventData.getTableId());
Assert.assertEquals(EventType.INSERT, eventData.getEventType());
Assert.assertEquals(eventData.getOldKeys().size(), 0); // 不存在oldKeys
}
}
示例9: testMergeWithUpdateKeyOfUI
import com.google.common.collect.MapMaker; //导入依赖的package包/类
/**
* 测试在主键发生变化后的merge操作,Update/Update/Insert
*/
@Test
public void testMergeWithUpdateKeyOfUI() {
Map<RowKey, EventData> mergeMap = new MapMaker().makeMap();
DbLoadMerger.merge(makeUpdateEventData(KEY_VALUE_NEW1, KEY_VALUE_NEW2), mergeMap);
DbLoadMerger.merge(makeUpdateEventData(KEY_VALUE_NEW2, KEY_VALUE), mergeMap);
DbLoadMerger.merge(makeInsertEventData(), mergeMap);
for (Entry<RowKey, EventData> entry : mergeMap.entrySet()) {
RowKey key = entry.getKey();
EventColumn keyColumn = key.getKeys().get(0);
Assert.assertEquals(KEY_VALUE, keyColumn.getColumnValue());
Assert.assertEquals(KEY_NAME, keyColumn.getColumnName());
EventData eventData = entry.getValue();
Assert.assertEquals(SCHEMA_NAME, eventData.getSchemaName());
Assert.assertEquals(TABLE_NAME, eventData.getTableName());
Assert.assertEquals(TABLE_ID, eventData.getTableId());
Assert.assertEquals(EventType.INSERT, eventData.getEventType());
List<EventColumn> oldKeys = eventData.getOldKeys();
List<EventColumn> keys = eventData.getKeys();
Assert.assertNotSame(oldKeys, keys);
}
}
示例10: testMergeWithUpdateKeyOfII
import com.google.common.collect.MapMaker; //导入依赖的package包/类
/**
* 测试在主键发生变化后的merge操作,Insert/Insert
*/
@Test
public void testMergeWithUpdateKeyOfII() {
Map<RowKey, EventData> mergeMap = new MapMaker().makeMap();
DbLoadMerger.merge(makeInsertEventData(), mergeMap);
DbLoadMerger.merge(makeInsertEventData(), mergeMap);
for (Entry<RowKey, EventData> entry : mergeMap.entrySet()) {
RowKey key = entry.getKey();
EventColumn keyColumn = key.getKeys().get(0);
Assert.assertEquals(KEY_VALUE, keyColumn.getColumnValue());
Assert.assertEquals(KEY_NAME, keyColumn.getColumnName());
EventData eventData = entry.getValue();
Assert.assertEquals(SCHEMA_NAME, eventData.getSchemaName());
Assert.assertEquals(TABLE_NAME, eventData.getTableName());
Assert.assertEquals(TABLE_ID, eventData.getTableId());
Assert.assertEquals(EventType.INSERT, eventData.getEventType());
List<EventColumn> oldKeys = eventData.getOldKeys();
List<EventColumn> keys = eventData.getKeys();
Assert.assertNotSame(oldKeys, keys);
}
}
示例11: ExactCounterMetric
import com.google.common.collect.MapMaker; //导入依赖的package包/类
/**
* Constructor to create a new counter metric
* @param nam the name to publish this metric under
* @param registry where the metrics object will be registered
* @param description metrics description
* @param topN how many 'keys' to publish metrics on
*/
public ExactCounterMetric(final String nam, final MetricsRegistry registry,
final String description, int topN) {
super(nam, description);
this.counts = new MapMaker().makeComputingMap(
new Function<String, Counter>() {
@Override
public Counter apply(String input) {
return new Counter();
}
});
this.lock = new ReentrantReadWriteLock();
this.topN = topN;
if (registry != null) {
registry.add(nam, this);
}
}
示例12: getPreferenceValues
import com.google.common.collect.MapMaker; //导入依赖的package包/类
public IPreferenceValues getPreferenceValues(Resource context) {
final IProject project = getProject(context);
final IPreferenceStore store = project != null ?
access.getContextPreferenceStore(project) :
access.getPreferenceStore();
@SuppressWarnings("deprecation")
final Map<String, String> computingMap = new MapMaker().makeComputingMap(
new Function<String, String>() {
public String apply(String input) {
return store.getString(input);
}
});
return new IPreferenceValues() {
public String getPreference(PreferenceKey key) {
try {
final String string = computingMap.get(key.getId());
return org.eclipse.jface.preference.IPreferenceStore.STRING_DEFAULT_DEFAULT.equals(string) ? key.getDefaultValue() : string;
} catch (Exception e) {
log.error("Error getting preference for key '"+key.getId()+"'.", e);
return key.getDefaultValue();
}
}
};
}
示例13: setUp
import com.google.common.collect.MapMaker; //导入依赖的package包/类
@BeforeExperiment void setUp() {
// random integers will be generated in this range, then raised to the
// power of (1/concentration) and floor()ed
max = Ints.checkedCast((long) Math.pow(distinctKeys, concentration));
cache = new MapMaker()
.concurrencyLevel(segments)
.maximumSize(maximumSize)
.makeComputingMap(
new Function<Integer, Integer>() {
@Override public Integer apply(Integer from) {
return (int) misses.incrementAndGet();
}
});
// To start, fill up the cache.
// Each miss both increments the counter and causes the map to grow by one,
// so until evictions begin, the size of the map is the greatest return
// value seen so far
while (cache.get(nextRandomKey()) < maximumSize) {}
requests.set(0);
misses.set(0);
}
示例14: SimpleScoreboardElement
import com.google.common.collect.MapMaker; //导入依赖的package包/类
public SimpleScoreboardElement(Plugin plugin, int priority, long updateDelay,
List<FrameSupply> contents) {
this.priority = priority;
this.contents = Lists.newCopyOnWriteArrayList(contents);
this.plugin = plugin;
// forced update delay so that players can be cleaned out // implementation specific
this.updateDelay = updateDelay > 0 ? updateDelay : 20L * 10;
this.isTitle = priority < 0;
MapMaker mapMaker = new MapMaker().weakKeys();
this.playerContentsMap = mapMaker.makeMap();
this.cachedContents = mapMaker.makeMap();
Bukkit.getScheduler()
.runTaskTimerAsynchronously(plugin, this::updateAnimations, 1l, this.updateDelay);
}
示例15: PatternStatsCalculator
import com.google.common.collect.MapMaker; //导入依赖的package包/类
public PatternStatsCalculator(final AbstractJavaTreeExtractor treeFormat,
final Set<TreeNode<Integer>> patterns, final File directory) {
this.treeFormat = treeFormat;
this.patterns = HashMultiset.create(patterns);
int currentIdx = 0;
for (final Multiset.Entry<TreeNode<Integer>> rule : this.patterns
.entrySet()) {
patternDictionary.put(rule.getElement(), currentIdx);
patternSizes.put(currentIdx, rule.getElement().getTreeSize());
currentIdx++;
}
allFiles = FileUtils
.listFiles(directory, JavaTokenizer.javaCodeFileFilter,
DirectoryFileFilter.DIRECTORY);
fileSizes = new MapMaker()
.concurrencyLevel(ParallelThreadPool.NUM_THREADS)
.initialCapacity(allFiles.size()).makeMap();
filePatterns = HashBasedTable.create(allFiles.size(),
patterns.size() / 10);
filePatternsCount = HashBasedTable.create(allFiles.size(),
patterns.size() / 1);
}