当前位置: 首页>>代码示例>>Java>>正文


Java MapMaker类代码示例

本文整理汇总了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);
}
 
开发者ID:luoyaogui,项目名称:otter-G,代码行数:18,代码来源:MemoryStageController.java

示例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();
}
 
开发者ID:luoyaogui,项目名称:otter-G,代码行数:21,代码来源:RpcStageController.java

示例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());
    }
}
 
开发者ID:luoyaogui,项目名称:otter-G,代码行数:28,代码来源:DbLoadMergerTest.java

示例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());
    }
}
 
开发者ID:luoyaogui,项目名称:otter-G,代码行数:28,代码来源:DbLoadMergerTest.java

示例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());
    }
}
 
开发者ID:luoyaogui,项目名称:otter-G,代码行数:29,代码来源:DbLoadMergerTest.java

示例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);
    }
}
 
开发者ID:luoyaogui,项目名称:otter-G,代码行数:27,代码来源:DbLoadMergerTest.java

示例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
    }
}
 
开发者ID:luoyaogui,项目名称:otter-G,代码行数:25,代码来源:DbLoadMergerTest.java

示例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
    }
}
 
开发者ID:luoyaogui,项目名称:otter-G,代码行数:27,代码来源:DbLoadMergerTest.java

示例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);
    }
}
 
开发者ID:luoyaogui,项目名称:otter-G,代码行数:29,代码来源:DbLoadMergerTest.java

示例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);
    }
}
 
开发者ID:luoyaogui,项目名称:otter-G,代码行数:28,代码来源:DbLoadMergerTest.java

示例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);      
  }
}
 
开发者ID:fengchen8086,项目名称:LCIndex-HBase-0.94.16,代码行数:27,代码来源:ExactCounterMetric.java

示例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();
			}
		}
	};
}
 
开发者ID:cplutte,项目名称:bts,代码行数:27,代码来源:EclipsePreferencesProvider.java

示例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);
}
 
开发者ID:sander120786,项目名称:guava-libraries,代码行数:25,代码来源:MapMakerSingleThreadBenchmark.java

示例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);
}
 
开发者ID:t7seven7t,项目名称:ViewIt,代码行数:17,代码来源:SimpleScoreboardElement.java

示例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);
}
 
开发者ID:mast-group,项目名称:codemining-treelm,代码行数:25,代码来源:PatternStatsCalculator.java


注:本文中的com.google.common.collect.MapMaker类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。