當前位置: 首頁>>代碼示例>>Java>>正文


Java ConcurrentHashMap.putAll方法代碼示例

本文整理匯總了Java中java.util.concurrent.ConcurrentHashMap.putAll方法的典型用法代碼示例。如果您正苦於以下問題:Java ConcurrentHashMap.putAll方法的具體用法?Java ConcurrentHashMap.putAll怎麽用?Java ConcurrentHashMap.putAll使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在java.util.concurrent.ConcurrentHashMap的用法示例。


在下文中一共展示了ConcurrentHashMap.putAll方法的7個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: getCloneForTransmission

import java.util.concurrent.ConcurrentHashMap; //導入方法依賴的package包/類
/**
 * Retrieve a vector that can be sent to another member. This clones all of the version
 * information to protect against concurrent modification during serialization
 */
public RegionVersionVector<T> getCloneForTransmission() {
  Map<T, RegionVersionHolder<T>> liveHolders;
  liveHolders = new HashMap<T, RegionVersionHolder<T>>(this.memberToVersion);
  ConcurrentHashMap<T, RegionVersionHolder<T>> clonedHolders =
      new ConcurrentHashMap<T, RegionVersionHolder<T>>(liveHolders.size(), LOAD_FACTOR,
          CONCURRENCY_LEVEL);
  for (Map.Entry<T, RegionVersionHolder<T>> entry : liveHolders.entrySet()) {
    clonedHolders.put(entry.getKey(), entry.getValue().clone());
  }
  ConcurrentHashMap<T, Long> gcVersions = new ConcurrentHashMap<T, Long>(
      this.memberToGCVersion.size(), LOAD_FACTOR, CONCURRENCY_LEVEL);
  gcVersions.putAll(this.memberToGCVersion);
  RegionVersionHolder<T> clonedLocalHolder;
  clonedLocalHolder = this.localExceptions.clone();
  // Make sure the holder that we send to the peer does
  // have an accurate RegionVersionHolder for our local version
  return createCopy(this.myId, clonedHolders, this.localVersion.get(), gcVersions,
      this.localGCVersion.get(), false, clonedLocalHolder);
}
 
開發者ID:ampool,項目名稱:monarch,代碼行數:24,代碼來源:RegionVersionVector.java

示例2: load

import java.util.concurrent.ConcurrentHashMap; //導入方法依賴的package包/類
/**
 * 指定されたパッケージ以下のSQLを順次読み込みする<br>
 * 文末の"/"は削除される<br>
 *
 * @param packageName パッケージ名を格納するStringBuilder
 * @param dir 探索対象ディレクトリ
 * @return SQL識別子をキーとしたSQL文のMap
 * @throws IOException ファイルアクセスに失敗した場合
 */
private ConcurrentHashMap<String, String> load(final StringBuilder packageName, final File dir) throws IOException {
	LOG.debug("Loading SQL template.[{}]", packageName);

	ConcurrentHashMap<String, String> sqlMap = new ConcurrentHashMap<>();
	File[] files = dir.listFiles();
	for (File file : files) {
		String fileName = file.getName();
		if (file.isDirectory()) {
			sqlMap.putAll(load(makeNewPackageName(packageName, file), file));
		} else if (fileName.toLowerCase().endsWith(fileExtension)) {
			String sql = trimSlash(read(new BufferedReader(new InputStreamReader(new FileInputStream(file),
					getSqlEncoding()))));
			String sqlName = makeSqlName(packageName, fileName);
			sqlMap.put(sqlName, sql);

			LOG.trace("Loaded SQL template.[{}]", fileName);
			LOG.trace("Add SQL template.[{}],[{}]", sqlName, sql);
		}
	}
	return sqlMap;
}
 
開發者ID:future-architect,項目名稱:uroborosql,代碼行數:31,代碼來源:SqlLoaderImpl.java

示例3: testPutAll

import java.util.concurrent.ConcurrentHashMap; //導入方法依賴的package包/類
/**
 * putAll adds all key-value pairs from the given map
 */
public void testPutAll() {
    ConcurrentHashMap empty = new ConcurrentHashMap();
    ConcurrentHashMap map = map5();
    empty.putAll(map);
    assertEquals(5, empty.size());
    assertTrue(empty.containsKey(one));
    assertTrue(empty.containsKey(two));
    assertTrue(empty.containsKey(three));
    assertTrue(empty.containsKey(four));
    assertTrue(empty.containsKey(five));
}
 
開發者ID:AdoptOpenJDK,項目名稱:openjdk-jdk10,代碼行數:15,代碼來源:ConcurrentHashMapTest.java

示例4: manageCache

import java.util.concurrent.ConcurrentHashMap; //導入方法依賴的package包/類
private <T> T manageCache(ConcurrentHashMap<Integer, WithUseCount<T>> cache, Accessor<T> accessor, int n, FieldSelector fieldSelector, int limit) throws IOException
{
    Integer key = Integer.valueOf(n);
    WithUseCount<T> value = cache.get(key);
    if (value == null)
    {
        T made = accessor.get(n, fieldSelector);
        value = new WithUseCount<T>(made, n);
        cache.put(key, value);

        // resize

        if (limit >= 0)
        {
            if (cache.size() >= limit)
            {
                HashMap<Integer, WithUseCount<T>> keep = new HashMap<Integer, WithUseCount<T>>();
                WithUseCount<T>[] existing = new WithUseCount[0];
                synchronized (cache)
                {
                    existing = cache.values().toArray(existing);
                    cache.clear();
                }
                Arrays.sort(existing);

                for (WithUseCount<T> current : existing)
                {
                    keep.put(Integer.valueOf(current.doc), current);
                    if ((current.count.get() == 0) || (keep.size() > (limit / 4)))
                    {
                        break;
                    }
                }
                keep.put(key, value);
                cache.putAll(keep);
            }
        }
    }
    else
    {
        value.count.getAndIncrement();
    }
    return value.object;
}
 
開發者ID:Alfresco,項目名稱:alfresco-repository,代碼行數:45,代碼來源:ReferenceCountingReadOnlyIndexReaderFactory.java

示例5: generateDeleteSql

import java.util.concurrent.ConcurrentHashMap; //導入方法依賴的package包/類
/**
 *生成刪除sql
 * @param parameter
 * @return SqlParmeter
 */ 
protected SqlParmeter generateDeleteSql(HeaMap parameter) {
	initEntityInfo(this.entityType);
	String entityName = getEntityName();
	Entity entityInfo = entityMap.get(entityName);
	String tableName = entityInfo.getTableName();
	SqlParmeter sqlParmeter = new SqlParmeter();
	if (null == parameter) {
		parameter = new HeaMap();
	}
	if (parameter.size() == 0) {
		throw new RuntimeException("必須傳人參數!");
	}
	List<Object> params = new ArrayList<Object>();
	ConcurrentHashMap<String, Boolean> aliasMap = new ConcurrentHashMap<String, Boolean>();
	StringBuffer whereSql = new StringBuffer();// 包含where後麵的sql語局
	String link = "where";// 第一個默認連接是where
	boolean firstQueryFlag = true;// 是否是第一個需查項
	List<String> groupSqlList = new ArrayList<String>();
	for (Entry<String, ?> entry : parameter.entrySet()) {
		String key = entry.getKey();
		Object value = entry.getValue();
		key = filterKey(key);
		if (key.startsWith(HeaConstant.Instruction.ADDGROUP)) {
			groupSqlList = getOrder(groupSqlList, value);
			continue;
		}
		ColumnCondition columnCondition = new ColumnCondition();
		columnCondition = analyzeKey(columnCondition, key, value);
		if (!columnCondition.getIfQuery()) {
			continue;
		}
		if (!firstQueryFlag) {
			link = columnCondition.getAndOr();
		}
		whereSql.append(HStringUtils.format(" {0} {1}", link, columnCondition.getSqlFragment()));
		if (null != columnCondition.getCookedValue()) {
			params.addAll(columnCondition.getCookedValue());
		}
		firstQueryFlag = false;
	}
	String whereSqlStr = whereSql.toString();
	String groupSql = "";
	if (groupSqlList.size() > 0) {
		groupSql = " group by " + HStringUtils.StrList(groupSqlList, ",");
	}
	String tempStr = HStringUtils.addStr(whereSqlStr, groupSql);
	aliasMap.putAll(HOrmUtil.getAliasFromSql(tempStr));
	// 分析得到joinSql
	String joinSql = "";
	if (!aliasMap.isEmpty()) {
		HHashMap<Integer, String> joinSqlMap = new HHashMap<Integer, String>();
		analyzeAliasMap(aliasMap, joinSqlMap);
		joinSql = getJoinSql(joinSqlMap);
	}
	String tableSqlStr = HStringUtils.format("{0} t {1}", tableName, joinSql);
	Map<String, Object> viewParams = parameter.getViewParams();
	TableSql tableSql = getTableSql(tableSqlStr, viewParams);
	tableSqlStr = tableSql.getTargetTableSql();
	List<Object> tableParams = tableSql.getParams();
	// 0:tableName 1:where
	String sql = HStringUtils.format("delete t from {0}  {1}", tableSqlStr, whereSqlStr);
	sqlParmeter.setSql(sql);
	tableParams.addAll(params);
	sqlParmeter.setParameters(tableParams.toArray());
	return sqlParmeter;
}
 
開發者ID:VonChange,項目名稱:headb,代碼行數:72,代碼來源:HeaSoul.java

示例6: generateUpdateSql

import java.util.concurrent.ConcurrentHashMap; //導入方法依賴的package包/類
/**
 * 生成更新Sql
 * @param entity
 * @param parameter
 * @return
 */
protected SqlParmeter generateUpdateSql(T entity, HeaMap parameter) {
	initEntityInfo(this.entityType);
	String entityName = getEntityName();
	Entity entityInfo = entityMap.get(entityName);
	String tableName = entityInfo.getTableName();
	SqlParmeter sqlParmeter = new SqlParmeter();
	if (null == parameter) {
		parameter = new HeaMap();
	}
	if (parameter.size() == 0) {
		throw new RuntimeException("必須傳人參數!");
	}
	List<Object> params = new ArrayList<Object>();
	ConcurrentHashMap<String, Boolean> aliasMap = new ConcurrentHashMap<String, Boolean>();
	StringBuffer whereSql = new StringBuffer();// 包含where後麵的sql語局
	String link = "where";// 第一個默認連接是where
	boolean firstQueryFlag = true;// 是否是第一個需查項
	List<String> groupSqlList = new ArrayList<String>();
	for (Entry<String, ?> entry : parameter.entrySet()) {
		String key = entry.getKey();
		Object value = entry.getValue();
		key = filterKey(key);
		if (key.startsWith(HeaConstant.Instruction.ADDGROUP)) {
			groupSqlList = getOrder(groupSqlList, value);
			continue;
		}
		ColumnCondition columnCondition = new ColumnCondition();
		columnCondition = analyzeKey(columnCondition, key, value);
		if (!columnCondition.getIfQuery()) {
			continue;
		}
		if (!firstQueryFlag) {
			link = columnCondition.getAndOr();
		}
		whereSql.append(HStringUtils.format(" {0} {1}", link, columnCondition.getSqlFragment()));
		if (null != columnCondition.getCookedValue()) {
			params.addAll(columnCondition.getCookedValue());
		}
		firstQueryFlag = false;
	}
	String whereSqlStr = whereSql.toString();
	String groupSql = "";
	if (groupSqlList.size() > 0) {
		groupSql = " group by " + HStringUtils.StrList(groupSqlList, ",");
	}
	String tempStr = HStringUtils.addStr(whereSqlStr, groupSql);
	aliasMap.putAll(HOrmUtil.getAliasFromSql(tempStr));
	// 分析得到joinSql
	String joinSql = "";
	if (!aliasMap.isEmpty()) {
		HHashMap<Integer, String> joinSqlMap = new HHashMap<Integer, String>();
		analyzeAliasMap(aliasMap, joinSqlMap);
		joinSql = getJoinSql(joinSqlMap);
	}
	String tableSqlStr = HStringUtils.format("{0} t {1}", tableName, joinSql);
	Map<String, Object> viewParams = parameter.getViewParams();
	TableSql tableSql = getTableSql(tableSqlStr, viewParams);
	tableSqlStr = tableSql.getTargetTableSql();
	List<Object> tableParams = tableSql.getParams();
	// 獲得setSql
	SqlFragment setSqlEntity = getUpdateSetSql(entity, entityInfo, parameter.getUpdateNullMap());
	// 0:tableSql 1:setSql 2:where
	String sql = HStringUtils.format("update {0} set {1} {2}", tableSqlStr, setSqlEntity.getSql(), whereSqlStr);
	// String sql = StringUtils.format("delete t from {0}  {1}",
	// tableSqlStr, whereSqlStr);
	sqlParmeter.setSql(sql);
	tableParams.addAll(setSqlEntity.getParams());// set
	tableParams.addAll(params);
	sqlParmeter.setParameters(tableParams.toArray());
	return sqlParmeter;
}
 
開發者ID:VonChange,項目名稱:headb,代碼行數:78,代碼來源:HeaSoul.java

示例7: process

import java.util.concurrent.ConcurrentHashMap; //導入方法依賴的package包/類
@Override
public void process(ConcurrentHashMap<K, V> impl) {
    impl.putAll(map);
}
 
開發者ID:pravega,項目名稱:pravega-samples,代碼行數:5,代碼來源:SharedMap.java


注:本文中的java.util.concurrent.ConcurrentHashMap.putAll方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。