当前位置: 首页>>代码示例>>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;未经允许,请勿转载。