本文整理汇总了Java中org.apache.ignite.internal.util.typedef.internal.U.capacity方法的典型用法代码示例。如果您正苦于以下问题:Java U.capacity方法的具体用法?Java U.capacity怎么用?Java U.capacity使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.apache.ignite.internal.util.typedef.internal.U
的用法示例。
在下文中一共展示了U.capacity方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: 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;
}
示例2: addDataInternal
import org.apache.ignite.internal.util.typedef.internal.U; //导入方法依赖的package包/类
/**
* @param entries Entries.
* @return Future.
*/
public IgniteFuture<?> addDataInternal(Collection<? extends DataStreamerEntry> entries) {
enterBusy();
GridFutureAdapter<Object> resFut = new GridFutureAdapter<>();
try {
resFut.listen(rmvActiveFut);
activeFuts.add(resFut);
Collection<KeyCacheObjectWrapper> keys = null;
if (entries.size() > 1) {
keys = new GridConcurrentHashSet<>(entries.size(), U.capacity(entries.size()), 1);
for (DataStreamerEntry entry : entries)
keys.add(new KeyCacheObjectWrapper(entry.getKey()));
}
load0(entries, resFut, keys, 0);
return new IgniteCacheFutureImpl<>(resFut);
}
catch (Throwable e) {
resFut.onDone(e);
if (e instanceof Error || e instanceof IgniteDataStreamerTimeoutException)
throw e;
return new IgniteCacheFutureImpl<>(resFut);
}
finally {
leaveBusy();
}
}
示例3: 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());
}