List of usage examples for com.google.common.collect Maps newHashMapWithExpectedSize
public static <K, V> HashMap<K, V> newHashMapWithExpectedSize(int expectedSize)
From source file:com.android.tools.perflib.vmtrace.MethodInfo.java
public MethodInfo(long id, String className, String methodName, String signature, String srcPath, int srcLineNumber) { this.id = id; this.className = className; this.methodName = methodName; this.signature = signature; this.srcPath = srcPath; this.srcLineNumber = srcLineNumber; mAllThreadsStats = new MethodStats(); mPerThreadStats = Maps.newHashMapWithExpectedSize(20); }
From source file:org.gradoop.flink.algorithms.fsm.transactional.tle.pojos.Embedding.java
/** * Combines this embedding with another one. * * @param that other embedding/*from www. j av a2 s .c om*/ * * @return combined embedding */ public Embedding combine(Embedding that) { Map<Integer, String> commonVertices = Maps.newHashMap(vertices); commonVertices.putAll(that.getVertices()); Map<Integer, FSMEdge> commonEdges = Maps .newHashMapWithExpectedSize(this.edges.size() + that.getEdges().size()); commonEdges.putAll(this.edges); commonEdges.putAll(that.getEdges()); return new Embedding(commonVertices, commonEdges); }
From source file:de.learnlib.algorithms.dhc.mealy.MealyDHCState.java
MealyDHCState(final LinkedHashSet<Word<I>> splitters, final CompactMealy<I, O> hypothesis, final MutableMapping<Integer, MealyDHC.QueueElement<I, O>> accessSequences) { this.splitters = splitters; this.hypothesis = hypothesis; this.accessSequences = Maps.newHashMapWithExpectedSize(hypothesis.size()); for (final Integer s : hypothesis.getStates()) { final MealyDHC.QueueElement<I, O> elem = accessSequences.get(s); if (elem != null) { this.accessSequences.put(s, elem); }/* w ww.java2 s .com*/ } }
From source file:tachyon.master.rawtable.journal.RawTableEntry.java
@Override public Map<String, Object> getParameters() { Map<String, Object> parameters = Maps.newHashMapWithExpectedSize(3); parameters.put("id", mId); parameters.put("columns", mColumns); parameters.put("metadata", mMetadata); return parameters; }
From source file:shaded.org.openqa.selenium.remote.server.handler.internal.ArgumentConverter.java
public Object apply(Object arg) { if (arg instanceof Map) { @SuppressWarnings("unchecked") Map<String, Object> paramAsMap = (Map<String, Object>) arg; if (paramAsMap.containsKey("ELEMENT")) { shaded.org.openqa.selenium.remote.server.KnownElements.ProxiedElement element = (shaded.org.openqa.selenium.remote.server.KnownElements.ProxiedElement) knownElements .get((String) paramAsMap.get("ELEMENT")); return element.getWrappedElement(); }//from w ww . java2s . c o m Map<String, Object> converted = Maps.newHashMapWithExpectedSize(paramAsMap.size()); for (Map.Entry<String, Object> entry : paramAsMap.entrySet()) { converted.put(entry.getKey(), apply(entry.getValue())); } return converted; } if (arg instanceof List<?>) { return Lists.newArrayList(Iterables.transform((List<?>) arg, this)); } return arg; }
From source file:tachyon.master.file.journal.RenameEntry.java
@Override public Map<String, Object> getParameters() { Map<String, Object> parameters = Maps.newHashMapWithExpectedSize(3); parameters.put("fileId", mFileId); parameters.put("destinationPath", mDstPath); parameters.put("operationTimeMs", mOpTimeMs); return parameters; }
From source file:com.cloudera.oryx.computation.common.DependenciesScheduler.java
/** * @param dependencies dependencies, expressed as {@link DependsOn} objects. * @return a series of groups of objects, wherein the members of each group may only run after the members * of all earlier groups are done./*from ww w .j a v a 2 s. c o m*/ */ List<Collection<T>> schedule(Collection<DependsOn<T>> dependencies) { log.info("Scheduling: {}", dependencies); // This will map steps to a collection of all steps that must come before Map<T, Collection<T>> prerequisites = Maps.newHashMapWithExpectedSize(dependencies.size()); for (DependsOn<T> dependency : dependencies) { T first = dependency.getHappensFirst(); T next = dependency.getHappensNext(); // Just make sure it's noted if (!prerequisites.containsKey(first)) { prerequisites.put(first, Lists.<T>newArrayList()); } if (next != null) { Collection<T> required = prerequisites.get(next); if (required == null) { required = Lists.newArrayList(); prerequisites.put(next, required); } required.add(first); } } return schedule(prerequisites); }
From source file:org.apache.druid.query.groupby.epinephelinae.GroupByBinaryFnV2.java
@Override public Row apply(final Row arg1, final Row arg2) { if (arg1 == null) { return arg2; } else if (arg2 == null) { return arg1; }//from w w w .j a va 2 s . c o m final Map<String, Object> newMap = Maps .newHashMapWithExpectedSize(query.getDimensions().size() + query.getAggregatorSpecs().size()); // Add dimensions for (DimensionSpec dimension : query.getDimensions()) { newMap.put(dimension.getOutputName(), arg1.getRaw(dimension.getOutputName())); } // Add aggregations for (AggregatorFactory aggregatorFactory : query.getAggregatorSpecs()) { newMap.put(aggregatorFactory.getName(), aggregatorFactory .combine(arg1.getRaw(aggregatorFactory.getName()), arg2.getRaw(aggregatorFactory.getName()))); } return new MapBasedRow(adjustTimestamp(arg1), newMap); }
From source file:net.minecrell.quartz.event.QuartzEventFactory.java
@SuppressWarnings({ "unchecked", "ConstantConditions" }) public static <T extends StateEvent> T createStateEvent(Class<T> type, Game game) { Map<String, Object> values = Maps.newHashMapWithExpectedSize(1); values.put("game", game); return (T) factories.getUnchecked(type).apply(values); }
From source file:com.flaptor.indextank.rpc.StoringClient.java
@Override public void enqueueAddDocument(String indexId, String sourceDocId, com.flaptor.indextank.index.Document document, int timestamp, Map<Integer, Float> boosts) { TSocket transport = new TSocket(host, port); TProtocol protocol = new TBinaryProtocol(transport); Storage.Client client = new Storage.Client(protocol); try {/* www. j a v a 2 s .com*/ Map<Integer, Double> doubleBoosts = Maps.newHashMapWithExpectedSize(boosts.size()); for (Entry<Integer, Float> entry : boosts.entrySet()) { doubleBoosts.put(entry.getKey(), entry.getValue().doubleValue()); } transport.open(); client.enqueueAddStore(indexId, sourceDocId, new Document(document.asMap()), timestamp, doubleBoosts); transport.close(); } catch (IndextankException e) { throw new RuntimeException(e); } catch (TTransportException e) { throw new RuntimeException(e); } catch (TException e) { throw new RuntimeException(e); } }