本文整理匯總了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);
}