@Benchmark public ObjectObjectMap<String, String> hppc() { int localSize = this.size; float localLoadFactor = this.loadFactor; String[] localElements = this.elements; int defaultInitialCapacity = Containers.DEFAULT_EXPECTED_ELEMENTS; ObjectObjectMap<String, String> hppc = this.isPresized ? new ObjectObjectHashMap<>(localSize, localLoadFactor) : new ObjectObjectHashMap<>(defaultInitialCapacity, localLoadFactor); for (int i = 0; i < localSize; i++) { hppc.put(localElements[i], "dummy"); } return hppc; }
transitions = new ObjectObjectHashMap<>(); transitionList = new ObjectArrayList<>(); if (transitions.containsKey(node)) { return false; transitions.put(node, transition); transitionList.add(transition); if (DependencyAnalyzer.shouldLog) {
/** * Return true if all keys of some other container exist in this container. * Equality comparison is performed with this object's {@link #equals(Object, Object)} * method. * Values are compared using {@link Objects#equals(Object)} method. */ protected boolean equalElements(ObjectObjectHashMap<?, ?> other) { if (other.size() != size()) { return false; } for (ObjectObjectCursor<?, ?> c : other) { KType key = (KType) c.key; if (!containsKey(key) || !java.util.Objects.equals(get(key), c.value)) { return false; } } return true; }
/** * Creates a hash map from two index-aligned arrays of key-value pairs. */ public static <KType, VType> ObjectObjectHashMap<KType, VType> from(KType[] keys, VType[] values) { if (keys.length != values.length) { throw new IllegalArgumentException("Arrays of keys and values must have an identical length."); } ObjectObjectHashMap<KType, VType> map = new ObjectObjectHashMap<>(keys.length); for (int i = 0; i < keys.length; i++) { map.put(keys[i], values[i]); } return map; }
public ClusterStatsIndices(List<ClusterStatsNodeResponse> nodeResponses) { ObjectObjectHashMap<String, ShardStats> countsPerIndex = new ObjectObjectHashMap<>(); ShardStats indexShardStats = countsPerIndex.get(shardStats.getShardRouting().getIndexName()); if (indexShardStats == null) { indexShardStats = new ShardStats(); countsPerIndex.put(shardStats.getShardRouting().getIndexName(), indexShardStats); indexCount = countsPerIndex.size(); for (ObjectObjectCursor<String, ShardStats> indexCountsCursor : countsPerIndex) { shards.addIndexShardCount(indexCountsCursor.value);
/** * @return Returns the value associated with the given key or the default value * for the key type, if the key is not associated with any value. * <p> * <b>Important note:</b> For primitive type values, the value returned for a non-existing * key may not be the default value of the primitive type (it may be any value previously * assigned to that slot). */ public VType get(KType key) { return map.get(key); }
for (int i = 0; i < terms.length; i++) { assert terms[i] != null; TermStatistics existing = termStatistics.get(terms[i]); if (existing != null) { assert terms[i].bytes().equals(existing.term()); termStatistics.put(terms[i], new TermStatistics(existing.term(), existing.docFreq() + stats[i].docFreq(), optionalSum(existing.totalTermFreq(), stats[i].totalTermFreq()))); } else { termStatistics.put(terms[i], stats[i]); assert !lEntry.fieldStatistics().containsKey(null); final Object[] keys = lEntry.fieldStatistics().keys; final Object[] values = lEntry.fieldStatistics().values; CollectionStatistics value = (CollectionStatistics) values[i]; assert key != null; CollectionStatistics existing = fieldStatistics.get(key); if (existing != null) { CollectionStatistics merged = new CollectionStatistics( optionalSum(existing.sumDocFreq(), value.sumDocFreq()) ); fieldStatistics.put(key, merged); } else { fieldStatistics.put(key, value);
/** * A put operation that can be used in the fluent pattern. */ public Builder<KType, VType> fPut(KType key, VType value) { map.put(key, value); return this; }
/** * Returns <code>true</code> if this container has an association to a value for * the given key. */ public boolean containsKey(KType key) { return map.containsKey(key); }
/** * <a href="http://trove4j.sourceforge.net">Trove</a>-inspired API method. An equivalent * of the following code: * <pre> * if (!map.containsKey(key)) map.put(value); * </pre> * * @param key The key of the value to check. * @param value The value to put if <code>key</code> does not exist. * @return <code>true</code> if <code>key</code> did not exist and <code>value</code> * was placed in the map. */ public boolean putIfAbsent(KType key, VType value) { int keyIndex = indexOf(key); if (!indexExists(keyIndex)) { indexInsert(keyIndex, key, value); return true; } else { return false; } }
@Override public void clear() { map.clear(); }
/** * @return Returns the current size (number of assigned keys) in the container. */ public int size() { return map.size(); }
/** * {@inheritDoc} */ @Override public VType getOrDefault(KType key, VType defaultValue) { if (((key) == null)) { return hasEmptyKey ? (VType) values[mask + 1] : defaultValue; } else { final KType[] keys = (KType[]) this.keys; final int mask = this.mask; int slot = hashKey(key) & mask; KType existing; while (!((existing = keys[slot]) == null)) { if (this.equals(existing, key)) { return (VType) values[slot]; } slot = (slot + 1) & mask; } return defaultValue; } }
final int before = size(); if (other.size() >= size() && other instanceof ObjectLookupContainer<?>) { if (hasEmptyKey) { if (!((existing = keys[slot]) == null) && other.contains(existing)) { shiftConflictingKeys(slot); } else { slot++; this.remove((KType) c.value); return before - size();
for (Term term : terms) { assert term.field() != null : "field is null"; if (!fieldStatistics.containsKey(term.field())) { final CollectionStatistics collectionStatistics = context.searcher().collectionStatistics(term.field()); fieldStatistics.put(term.field(), collectionStatistics); if(context.isCancelled()) { throw new TaskCancelledException("cancelled");
@Override protected boolean equalElements(ObjectObjectHashMap<?, ?> other) { if (other.size() != size()) { return false; } Iterator<? extends ObjectObjectCursor<?, ?>> i = other.iterator(); while (i.hasNext()) { ObjectObjectCursor<?, ?> c = i.next(); KType key = (KType) c.key; if (!containsKey(key) || !equals(get(key), c.value)) { // Compare values using the same function as keys. return false; } } return true; } /* */
@Override public boolean equals(Object o) { if (this == o) return true; if (o == null || getClass() != o.getClass()) return false; ImmutableOpenMap that = (ImmutableOpenMap) o; if (!map.equals(that.map)) return false; return true; }
@Override public int indexOf(KType key) { return map.indexOf(key); }
@Override public boolean indexExists(int index) { return map.indexExists(index); }