本文整理汇总了Java中org.apache.ignite.internal.util.typedef.internal.U.newHashMap方法的典型用法代码示例。如果您正苦于以下问题:Java U.newHashMap方法的具体用法?Java U.newHashMap怎么用?Java U.newHashMap使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.apache.ignite.internal.util.typedef.internal.U
的用法示例。
在下文中一共展示了U.newHashMap方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: narrowForQuery
import org.apache.ignite.internal.util.typedef.internal.U; //导入方法依赖的package包/类
/** */
private Map<ClusterNode, IntArray> narrowForQuery(Map<ClusterNode, IntArray> partsMap, int[] parts) {
if (parts == null)
return partsMap;
Map<ClusterNode, IntArray> cp = U.newHashMap(partsMap.size());
for (Map.Entry<ClusterNode, IntArray> entry : partsMap.entrySet()) {
IntArray filtered = new IntArray(parts.length);
IntArray orig = entry.getValue();
for (int i = 0; i < orig.size(); i++) {
int p = orig.get(i);
if (Arrays.binarySearch(parts, p) >= 0)
filtered.add(p);
}
if (filtered.size() > 0)
cp.put(entry.getKey(), filtered);
}
return cp.isEmpty() ? null : cp;
}
示例2: setSources
import org.apache.ignite.internal.util.typedef.internal.U; //导入方法依赖的package包/类
/** {@inheritDoc} */
@Override public void setSources(Collection<ClusterNode> nodes, int segmentsCnt) {
super.setSources(nodes, segmentsCnt);
streamsMap = U.newHashMap(nodes.size());
RowStream[] streams = new RowStream[nodes.size() * segmentsCnt];
int i = 0;
for (ClusterNode node : nodes) {
RowStream[] segments = new RowStream[segmentsCnt];
for (int s = 0; s < segmentsCnt; s++)
streams[i++] = segments[s] = new RowStream();
if (streamsMap.put(node.id(), segments) != null)
throw new IllegalStateException();
}
it = new MergeStreamIterator(streams);
}
示例3: marshalGridNodeData
import org.apache.ignite.internal.util.typedef.internal.U; //导入方法依赖的package包/类
/**
* @param bag Bag.
* @param nodeId Node id.
* @param marsh Marsh.
* @param log Logger.
*/
public void marshalGridNodeData(DiscoveryDataBag bag, UUID nodeId, Marshaller marsh, IgniteLogger log) {
marshalData(bag.commonData(), commonData, marsh, log);
Map<Integer, Serializable> locNodeSpecificData = bag.localNodeSpecificData();
if (locNodeSpecificData != null) {
Map<Integer, byte[]> marshLocNodeSpecificData = U.newHashMap(locNodeSpecificData.size());
marshalData(locNodeSpecificData, marshLocNodeSpecificData, marsh, log);
filterDuplicatedData(marshLocNodeSpecificData);
if (!marshLocNodeSpecificData.isEmpty())
nodeSpecificData.put(nodeId, marshLocNodeSpecificData);
}
}
示例4: map0
import org.apache.ignite.internal.util.typedef.internal.U; //导入方法依赖的package包/类
/**
* Actual map logic.
*
* @param arg Task execution argument.
* @param subgrid Nodes available for this task execution.
* @return Map of grid jobs assigned to subgrid node.
* @throws IgniteException If mapping could not complete successfully.
*/
protected Map<? extends ComputeJob, ClusterNode> map0(List<ClusterNode> subgrid, VisorTaskArgument<A> arg) {
Collection<UUID> nodeIds = jobNodes(arg);
Map<ComputeJob, ClusterNode> map = U.newHashMap(nodeIds.size());
try {
for (ClusterNode node : subgrid)
if (nodeIds.contains(node.id()))
map.put(job(taskArg), node);
return map;
}
finally {
if (debug)
logMapped(ignite.log(), getClass(), map.values());
}
}
示例5: initPageMemoryDataStructures
import org.apache.ignite.internal.util.typedef.internal.U; //导入方法依赖的package包/类
/**
* @param dbCfg Database config.
* @throws IgniteCheckedException If failed.
*/
protected void initPageMemoryDataStructures(DataStorageConfiguration dbCfg) throws IgniteCheckedException {
freeListMap = U.newHashMap(dataRegionMap.size());
String dfltMemPlcName = dbCfg.getDefaultDataRegionConfiguration().getName();
for (DataRegion memPlc : dataRegionMap.values()) {
DataRegionConfiguration memPlcCfg = memPlc.config();
DataRegionMetricsImpl memMetrics = (DataRegionMetricsImpl) memMetricsMap.get(memPlcCfg.getName());
boolean persistenceEnabled = memPlcCfg.isPersistenceEnabled();
CacheFreeListImpl freeList = new CacheFreeListImpl(0,
cctx.igniteInstanceName(),
memMetrics,
memPlc,
null,
persistenceEnabled ? cctx.wal() : null,
0L,
true);
freeListMap.put(memPlcCfg.getName(), freeList);
}
dfltFreeList = freeListMap.get(dfltMemPlcName);
}
示例6: properties
import org.apache.ignite.internal.util.typedef.internal.U; //导入方法依赖的package包/类
/** {@inheritDoc} */
@SuppressWarnings("unchecked")
@Override public <K, V> Map<K, V> properties() {
if (props == null)
props = U.newHashMap(1);
return (Map<K, V>)props;
}
示例7: parameters
import org.apache.ignite.internal.util.typedef.internal.U; //导入方法依赖的package包/类
/**
* Parses HTTP parameters in an appropriate format and return back map of values to predefined list of names.
*
* @param req Request.
* @return Map of parsed parameters.
*/
@SuppressWarnings({"unchecked"})
private Map<String, Object> parameters(ServletRequest req) {
Map<String, String[]> params = req.getParameterMap();
if (F.isEmpty(params))
return Collections.emptyMap();
Map<String, Object> map = U.newHashMap(params.size());
for (Map.Entry<String, String[]> entry : params.entrySet())
map.put(entry.getKey(), parameter(entry.getValue()));
return map;
}
示例8: copyLocalInfos
import org.apache.ignite.internal.util.typedef.internal.U; //导入方法依赖的package包/类
/**
* @param locInfos Locale infos.
*/
private Map<UUID, LocalRoutineInfo> copyLocalInfos(Map<UUID, LocalRoutineInfo> locInfos) {
Map<UUID, LocalRoutineInfo> res = U.newHashMap(locInfos.size());
for (Map.Entry<UUID, LocalRoutineInfo> e : locInfos.entrySet())
res.put(e.getKey(), e.getValue());
return res;
}
示例9: readStringMap
import org.apache.ignite.internal.util.typedef.internal.U; //导入方法依赖的package包/类
/**
* Reads string-to-string map written by {@link #writeStringMap(DataOutput, Map)}.
*
* @param in Data input.
* @throws IOException If write failed.
* @return Read result.
*/
public static Map<String, String> readStringMap(DataInput in) throws IOException {
int size = in.readInt();
if (size == -1)
return null;
else {
Map<String, String> map = U.newHashMap(size);
for (int i = 0; i < size; i++)
map.put(readUTF(in), readUTF(in));
return map;
}
}
示例10: addAll
import org.apache.ignite.internal.util.typedef.internal.U; //导入方法依赖的package包/类
/** {@inheritDoc} */
@Override public boolean addAll(Collection<? extends T> c) {
onAccess();
boolean add = false;
Map<SetItemKey, Boolean> addKeys = null;
for (T obj : c) {
if (add) {
if (addKeys == null)
addKeys = U.newHashMap(BATCH_SIZE);
addKeys.put(itemKey(obj), true);
if (addKeys.size() == BATCH_SIZE) {
retryPutAll(addKeys);
addKeys.clear();
}
}
else
add = add(obj);
}
if (!F.isEmpty(addKeys))
retryPutAll(addKeys);
return add;
}
示例11: map
import org.apache.ignite.internal.util.typedef.internal.U; //导入方法依赖的package包/类
/**
* {@inheritDoc}
*/
@SuppressWarnings({"unchecked"})
@Override public Map<? extends ComputeJob, ClusterNode> map(List<ClusterNode> subgrid, Object arg) {
if (log.isInfoEnabled()) {
log.info("Mapping [task=" + this + ", subgrid=" + F.viewReadOnly(subgrid, F.node2id()) +
", arg=" + arg + ']');
}
Set<UUID> nodeIds;
boolean sleep;
if (arg instanceof Object[]) {
nodeIds = Collections.singleton((UUID)(((Object[])arg)[0]));
sleep = (Boolean)((Object[])arg)[1];
}
else if (arg instanceof List) {
nodeIds = new HashSet<>((Collection<UUID>)arg);
sleep = false;
}
else {
nodeIds = Collections.singleton((UUID)arg);
sleep = false;
}
Map<TestJob2, ClusterNode> jobs = U.newHashMap(subgrid.size());
for (ClusterNode node : subgrid) {
if (nodeIds.contains(node.id()))
jobs.put(new TestJob2(node.id(), sleep), node);
}
if (!jobs.isEmpty())
return jobs;
throw new IgniteException("Failed to find target node: " + arg);
}
示例12: lose
import org.apache.ignite.internal.util.typedef.internal.U; //导入方法依赖的package包/类
/**
* Loses all entries in input map that are evaluated to {@code true} by all given predicates.
*
* @param m Map to filter.
* @param cp If {@code true} method creates new map not modifying input, otherwise does
* <tt>in-place</tt> modifications.
* @param p Optional set of predicates to use for filtration. If none provided - original map
* will (or its copy) be returned.
* @param <K> Type of the free variable for the predicate and type of map's keys.
* @param <V> Type of the free variable for the predicate and type of map's values.
* @return Filtered map.
*/
@SuppressWarnings({"unchecked"})
@Deprecated
public static <K, V> Map<K, V> lose(Map<K, V> m, boolean cp,
@Nullable IgnitePredicate<? super Map.Entry<K, V>>... p) {
A.notNull(m, "m");
Map<K, V> res;
if (!cp) {
res = m;
if (isEmpty(p))
res.clear();
else if (!isAlwaysFalse(p))
for (Iterator<Map.Entry<K, V>> iter = m.entrySet().iterator(); iter.hasNext();)
if (isAll(iter.next(), p))
iter.remove();
}
else {
res = U.newHashMap(m.size());
if (!isEmpty(p) && !isAlwaysTrue(p))
for (Map.Entry<K, V> e : m.entrySet())
if (!F.isAll(e, p))
res.put(e.getKey(), e.getValue());
}
return res;
}
示例13: writeExternal
import org.apache.ignite.internal.util.typedef.internal.U; //导入方法依赖的package包/类
/** {@inheritDoc} */
@Override public void writeExternal(ObjectOutput out) throws IOException {
out.writeInt(tcpPort);
out.writeInt(0); // Jetty port.
String dfltCacheMode = null;
Map<String, String> cacheMap = null;
if (caches != null) {
cacheMap = U.newHashMap(caches.size());
for (GridClientCacheBean cacheBean : caches) {
if (cacheBean.getName() == null)
dfltCacheMode = cacheBean.getMode().toString();
cacheMap.put(cacheBean.getName(), cacheBean.getMode().toString());
}
}
U.writeString(out, dfltCacheMode);
U.writeMap(out, attrs);
U.writeMap(out, cacheMap);
U.writeCollection(out, tcpAddrs);
U.writeCollection(out, tcpHostNames);
U.writeCollection(out, Collections.emptyList()); // Jetty addresses.
U.writeCollection(out, Collections.emptyList()); // Jetty host names.
U.writeUuid(out, nodeId);
out.writeObject(String.valueOf(consistentId));
out.writeObject(metrics);
out.writeLong(order);
}
示例14: toCountersMap
import org.apache.ignite.internal.util.typedef.internal.U; //导入方法依赖的package包/类
/**
* @param cntrsMap Partial local counters map.
* @return Partition ID to partition counters map.
*/
public static Map<Integer, T2<Long, Long>> toCountersMap(CachePartitionPartialCountersMap cntrsMap) {
if (cntrsMap.size() == 0)
return Collections.emptyMap();
Map<Integer, T2<Long, Long>> res = U.newHashMap(cntrsMap.size());
for (int idx = 0; idx < cntrsMap.size(); idx++)
res.put(cntrsMap.partitionAt(idx),
new T2<>(cntrsMap.initialUpdateCounterAt(idx), cntrsMap.updateCounterAt(idx)));
return res;
}
示例15: createAffinityDiffMessages
import org.apache.ignite.internal.util.typedef.internal.U; //导入方法依赖的package包/类
/**
* @param affDiff Affinity diff.
* @return Affinity diff messages.
*/
public static Map<Integer, CacheGroupAffinityMessage> createAffinityDiffMessages(
Map<Integer, Map<Integer, List<Long>>> affDiff) {
if (F.isEmpty(affDiff))
return null;
Map<Integer, CacheGroupAffinityMessage> map = U.newHashMap(affDiff.size());
for (Map.Entry<Integer, Map<Integer, List<Long>>> e : affDiff.entrySet())
map.put(e.getKey(), new CacheGroupAffinityMessage(null, null, e.getValue()));
return map;
}