当前位置: 首页>>代码示例>>Java>>正文


Java U.capacity方法代码示例

本文整理汇总了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;
}
 
开发者ID:apache,项目名称:ignite,代码行数:24,代码来源:BinaryUtils.java

示例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();
    }
}
 
开发者ID:apache,项目名称:ignite,代码行数:40,代码来源:DataStreamerImpl.java

示例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());
}
 
开发者ID:apache,项目名称:ignite,代码行数:20,代码来源:BinaryUtils.java


注:本文中的org.apache.ignite.internal.util.typedef.internal.U.capacity方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。