本文整理汇总了Java中org.apache.ignite.internal.util.typedef.internal.U.newLinkedHashMap方法的典型用法代码示例。如果您正苦于以下问题:Java U.newLinkedHashMap方法的具体用法?Java U.newLinkedHashMap怎么用?Java U.newLinkedHashMap使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.apache.ignite.internal.util.typedef.internal.U
的用法示例。
在下文中一共展示了U.newLinkedHashMap方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: readLinkedMap
import org.apache.ignite.internal.util.typedef.internal.U; //导入方法依赖的package包/类
/**
* Read linked map.
*
* @param reader Reader.
* @param readClo Reader closure.
* @return Map.
*/
public static <K, V> Map<K, V> readLinkedMap(BinaryRawReaderEx reader,
@Nullable PlatformReaderBiClosure<K, V> readClo) {
int cnt = reader.readInt();
Map<K, V> map = U.newLinkedHashMap(cnt);
if (readClo == null) {
for (int i = 0; i < cnt; i++)
map.put((K)reader.readObjectDetached(), (V)reader.readObjectDetached());
}
else {
for (int i = 0; i < cnt; i++) {
IgniteBiTuple<K, V> entry = readClo.read(reader);
map.put(entry.getKey(), entry.getValue());
}
}
return map;
}
示例2: newKnownMap
import org.apache.ignite.internal.util.typedef.internal.U; //导入方法依赖的package包/类
/**
* Attempts to create a new map of the same known type. Will return null if map type is not supported.
*
* @param map Map.
* @return New map of the same type or null.
*/
@SuppressWarnings("unchecked")
public static <K, V> Map<K, V> newKnownMap(Object map) {
Class<?> cls = map == null ? null : map.getClass();
if (cls == HashMap.class)
return U.newHashMap(((Map)map).size());
else if (cls == LinkedHashMap.class)
return U.newLinkedHashMap(((Map)map).size());
else if (!wrapTrees() && cls == TreeMap.class)
return new TreeMap<>(((TreeMap<Object, Object>)map).comparator());
else if (cls == ConcurrentHashMap8.class)
return new ConcurrentHashMap8<>(U.capacity(((Map)map).size()));
else if (cls == ConcurrentHashMap.class)
return new ConcurrentHashMap<>(U.capacity(((Map)map).size()));
return null;
}
示例3: unmarshalGridData
import org.apache.ignite.internal.util.typedef.internal.U; //导入方法依赖的package包/类
/**
* @param marsh Marsh.
* @param clsLdr Class loader.
* @param clientNode Client node.
* @param log Logger.
*/
public DiscoveryDataBag unmarshalGridData(
Marshaller marsh,
ClassLoader clsLdr,
boolean clientNode,
IgniteLogger log
) {
DiscoveryDataBag dataBag = new DiscoveryDataBag(joiningNodeId);
if (commonData != null && !commonData.isEmpty()) {
Map<Integer, Serializable> unmarshCommonData = unmarshalData(commonData, marsh, clsLdr, clientNode, log);
dataBag.commonData(unmarshCommonData);
}
if (nodeSpecificData != null && !nodeSpecificData.isEmpty()) {
Map<UUID, Map<Integer, Serializable>> unmarshNodeSpecData = U.newLinkedHashMap(nodeSpecificData.size());
for (Map.Entry<UUID, Map<Integer, byte[]>> nodeBinEntry : nodeSpecificData.entrySet()) {
Map<Integer, byte[]> nodeBinData = nodeBinEntry.getValue();
if (nodeBinData == null || nodeBinData.isEmpty())
continue;
Map<Integer, Serializable> unmarshData = unmarshalData(nodeBinData, marsh, clsLdr, clientNode, log);
unmarshNodeSpecData.put(nodeBinEntry.getKey(), unmarshData);
}
dataBag.nodeSpecificData(unmarshNodeSpecData);
}
return dataBag;
}
示例4: init
import org.apache.ignite.internal.util.typedef.internal.U; //导入方法依赖的package包/类
/** {@inheritDoc} */
@Override public boolean init(int txSize) {
if (txMap == null) {
txMap = U.newLinkedHashMap(txSize > 0 ? txSize : 16);
readView = new IgniteTxMap(txMap, CU.reads());
writeView = new IgniteTxMap(txMap, CU.writes());
return true;
}
return false;
}
示例5: newMap
import org.apache.ignite.internal.util.typedef.internal.U; //导入方法依赖的package包/类
/**
* Attempts to create a new map of the same type as {@code map} has. Otherwise returns new {@code HashMap}
* instance.
*
* @param map Original map.
* @return New map.
*/
public static <K, V> Map<K, V> newMap(Map<K, V> map) {
if (map instanceof LinkedHashMap)
return U.newLinkedHashMap(map.size());
else if (map instanceof TreeMap)
return new TreeMap<>(((TreeMap<Object, Object>)map).comparator());
else if (map instanceof ConcurrentHashMap8)
return new ConcurrentHashMap8<>(U.capacity(map.size()));
else if (map instanceof ConcurrentHashMap)
return new ConcurrentHashMap<>(U.capacity(map.size()));
return U.newHashMap(map.size());
}
示例6: map0
import org.apache.ignite.internal.util.typedef.internal.U; //导入方法依赖的package包/类
/**
* @param keys Keys to map.
*/
private void map0(Map<KeyCacheObject, Boolean> keys) {
Map<KeyCacheObject, Boolean> mappedKeys = null;
// Assign keys to primary nodes.
for (Map.Entry<KeyCacheObject, Boolean> key : keys.entrySet()) {
int part = cctx.affinity().partition(key.getKey());
if (retries == null || !retries.contains(part)) {
if (!map(key.getKey())) {
if (retries == null)
retries = new HashSet<>();
retries.add(part);
if (mappedKeys == null) {
mappedKeys = U.newLinkedHashMap(keys.size());
for (Map.Entry<KeyCacheObject, Boolean> key1 : keys.entrySet()) {
if (key1.getKey() == key.getKey())
break;
mappedKeys.put(key.getKey(), key1.getValue());
}
}
}
else if (mappedKeys != null)
mappedKeys.put(key.getKey(), key.getValue());
}
}
// Add new future.
IgniteInternalFuture<Collection<GridCacheEntryInfo>> fut = getAsync(mappedKeys == null ? keys : mappedKeys);
// Optimization to avoid going through compound future,
// if getAsync() has been completed and no other futures added to this
// compound future.
if (fut.isDone() && !hasFutures()) {
if (fut.error() != null)
onDone(fut.error());
else
onDone(fut.result());
return;
}
add(fut);
}
示例7: readMap
import org.apache.ignite.internal.util.typedef.internal.U; //导入方法依赖的package包/类
/** {@inheritDoc} */
@SuppressWarnings("unchecked")
@Override public <M extends Map<?, ?>> M readMap(MessageCollectionItemType keyType,
MessageCollectionItemType valType, boolean linked, MessageReader reader) {
if (readSize == -1) {
int size = readInt();
if (!lastFinished)
return null;
readSize = size;
}
if (readSize >= 0) {
if (map == null)
map = linked ? U.newLinkedHashMap(readSize) : U.newHashMap(readSize);
for (int i = readItems; i < readSize; i++) {
if (!keyDone) {
Object key = read(keyType, reader);
if (!lastFinished)
return null;
mapCur = key;
keyDone = true;
}
Object val = read(valType, reader);
if (!lastFinished)
return null;
map.put(mapCur, val);
keyDone = false;
readItems++;
}
}
readSize = -1;
readItems = 0;
mapCur = null;
M map0 = (M)map;
map = null;
return map0;
}
示例8: testSize
import org.apache.ignite.internal.util.typedef.internal.U; //导入方法依赖的package包/类
/** {@inheritDoc} */
@Override public void testSize() throws Exception {
IgniteCache<String, Integer> nearCache = jcache();
int size = 10;
Map<String, Integer> map = U.newLinkedHashMap(size);
for (int i = 0; i < size; i++)
map.put("key" + i, i);
nearCache.putAll(map);
affinityNodes(); // Just to ack cache configuration to log..
checkKeySize(map.keySet());
checkSize(map.keySet());
assertEquals(10, nearCache.localSize(CachePeekMode.ALL));
int fullCacheSize = 0;
for (int i = 0; i < gridCount(); i++)
fullCacheSize += jcache(i).localSize();
assertEquals("Invalid cache size", fullCacheSize, nearCache.size());
}
示例9: testSize
import org.apache.ignite.internal.util.typedef.internal.U; //导入方法依赖的package包/类
/** {@inheritDoc} */
@Override public void testSize() throws Exception {
IgniteCache<String, Integer> cache = jcache();
int size = 10;
Map<String, Integer> map = U.newLinkedHashMap(size);
for (int i = 0; i < size; i++)
map.put("key" + i, i);
cache.putAll(map);
affinityNodes(); // Just to ack cache configuration to log..
Set<String> keys = new LinkedHashSet<>(map.keySet());
checkKeySize(keys);
checkSize(keys);
int fullCacheSize = 0;
for (int i = 0; i < gridCount(); i++)
fullCacheSize += jcache(i).localSize();
assertEquals("Invalid cache size", fullCacheSize, cache.size());
}