當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。