List of usage examples for com.google.common.collect Maps newHashMapWithExpectedSize
public static <K, V> HashMap<K, V> newHashMapWithExpectedSize(int expectedSize)
From source file:org.apache.phoenix.schema.PMetaDataCache.java
private static Map<PTableKey, PFunction> newFunctionMap(int expectedCapacity) { // Use regular HashMap, as we cannot use a LinkedHashMap that orders by access time // safely across multiple threads (as the underlying collection is not thread safe). // Instead, we track access time and prune it based on the copy we've made. return Maps.newHashMapWithExpectedSize(expectedCapacity); }
From source file:org.gradle.plugins.ide.eclipse.model.WbDependentModule.java
@Override public void appendNode(Node parentNode) { Map<String, Object> attributes = Maps.newHashMapWithExpectedSize(2); attributes.put("deploy-path", deployPath); attributes.put("handle", handle); Node node = parentNode.appendNode("dependent-module", attributes); node.appendNode("dependency-type").setValue("uses"); }
From source file:org.sonar.server.issue.index.IssueDoc.java
public IssueDoc() { super(Maps.newHashMapWithExpectedSize(30)); }
From source file:org.onos.yangtools.yang.data.impl.schema.builder.impl.ImmutableLeafSetNodeBuilder.java
protected ImmutableLeafSetNodeBuilder(final int sizeHint) { if (sizeHint >= 0) { value = Maps.newHashMapWithExpectedSize(sizeHint); } else {//from w w w . ja v a 2 s.co m value = new HashMap<>(DEFAULT_CAPACITY); } }
From source file:org.apache.shindig.gadgets.config.ShindigAuthConfigContributor.java
/** {@inheritDoc} */ public void contribute(Map<String, Object> config, Gadget gadget) { final GadgetContext context = gadget.getContext(); final SecurityToken authToken = context.getToken(); if (authToken != null) { Map<String, String> authConfig = Maps.newHashMapWithExpectedSize(2); String updatedToken = authToken.getUpdatedToken(); if (updatedToken != null) { authConfig.put("authToken", updatedToken); }//w ww . j a v a 2 s . com String trustedJson = authToken.getTrustedJson(); if (trustedJson != null) { authConfig.put("trustedJson", trustedJson); } config.put("shindig.auth", authConfig); } }
From source file:org.gradoop.flink.algorithms.fsm.transactional.common.functions.ToUndirectedAdjacencyList.java
@Override public AdjacencyList<GradoopId, String, IdWithLabel, IdWithLabel> map(GraphTransaction transaction) throws Exception { Set<Vertex> vertices = transaction.getVertices(); Set<Edge> edges = transaction.getEdges(); int vertexCount = vertices.size(); Map<GradoopId, AdjacencyListRow<IdWithLabel, IdWithLabel>> rows = Maps .newHashMapWithExpectedSize(vertexCount); Map<GradoopId, String> labels = Maps.newHashMapWithExpectedSize(vertexCount); // VERTICES/*from w ww . ja v a 2s. c om*/ for (Vertex vertex : vertices) { labels.put(vertex.getId(), vertex.getLabel()); } // EDGES for (Edge edge : edges) { GradoopId sourceId = edge.getSourceId(); GradoopId targetId = edge.getTargetId(); AdjacencyListRow<IdWithLabel, IdWithLabel> sourceRow = rows.computeIfAbsent(sourceId, k -> new AdjacencyListRow<>()); IdWithLabel edgeData = new IdWithLabel(edge.getId(), edge.getLabel()); IdWithLabel targetData = new IdWithLabel(targetId, labels.get(targetId)); sourceRow.getCells().add(new AdjacencyListCell<>(edgeData, targetData)); if (!sourceId.equals(targetId)) { IdWithLabel sourceData = new IdWithLabel(sourceId, labels.get(sourceId)); AdjacencyListRow<IdWithLabel, IdWithLabel> targetRow = rows.computeIfAbsent(targetId, k -> new AdjacencyListRow<>()); targetRow.getCells().add(new AdjacencyListCell<>(edgeData, sourceData)); } } return new AdjacencyList<>(transaction.getGraphHead(), labels, null, rows, Maps.newHashMap()); }
From source file:com.google.devtools.depan.view_doc.layout.jung.JungLayoutRunner.java
@Override public Map<GraphNode, Point2D> getPositions(Collection<GraphNode> nodes) { // Collect the positions from the Jung layout tool. Map<GraphNode, Point2D> result = Maps.newHashMapWithExpectedSize(nodes.size()); for (GraphNode node : nodes) { Point2D position = jungLayout.apply(node); result.put(node, position);//from w w w . j a v a2 s. c om } Point2dUtils.translatePos(region, nodes, result); return result; }
From source file:org.gradoop.flink.algorithms.fsm.transactional.common.functions.ToDirectedAdjacencyList.java
@Override public AdjacencyList<GradoopId, String, IdWithLabel, IdWithLabel> map(GraphTransaction transaction) throws Exception { Set<Vertex> vertices = transaction.getVertices(); Set<Edge> edges = transaction.getEdges(); int vertexCount = vertices.size(); Map<GradoopId, AdjacencyListRow<IdWithLabel, IdWithLabel>> outgoingRows = Maps .newHashMapWithExpectedSize(vertexCount); Map<GradoopId, AdjacencyListRow<IdWithLabel, IdWithLabel>> incomingRows = Maps .newHashMapWithExpectedSize(vertexCount); Map<GradoopId, String> labels = Maps.newHashMapWithExpectedSize(vertexCount); // VERTICES/* w w w. ja va2 s . co m*/ for (Vertex vertex : vertices) { labels.put(vertex.getId(), vertex.getLabel()); } // EDGES for (Edge edge : edges) { GradoopId sourceId = edge.getSourceId(); AdjacencyListRow<IdWithLabel, IdWithLabel> outgoingRow = outgoingRows.computeIfAbsent(sourceId, k -> new AdjacencyListRow<>()); IdWithLabel sourceData = new IdWithLabel(sourceId, labels.get(sourceId)); GradoopId targetId = edge.getTargetId(); AdjacencyListRow<IdWithLabel, IdWithLabel> incomingRow = incomingRows.computeIfAbsent(targetId, k -> new AdjacencyListRow<>()); IdWithLabel targetData = new IdWithLabel(targetId, labels.get(targetId)); IdWithLabel edgeData = new IdWithLabel(edge.getId(), edge.getLabel()); outgoingRow.getCells().add(new AdjacencyListCell<>(edgeData, targetData)); incomingRow.getCells().add(new AdjacencyListCell<>(edgeData, sourceData)); } return new AdjacencyList<>(transaction.getGraphHead(), labels, null, outgoingRows, incomingRows); }
From source file:tachyon.master.file.journal.SetPinnedEntry.java
@Override public Map<String, Object> getParameters() { Map<String, Object> parameters = Maps.newHashMapWithExpectedSize(3); parameters.put("id", mId); parameters.put("pinned", mPinned); parameters.put("operationTimeMs", mOpTimeMs); return parameters; }
From source file:org.attribyte.api.http.RequestBuilderWithParameters.java
/** * Creates a request builder with a parsed URI. * @param uri The URI string to be parsed. * @param caseSensitiveParameters Should case be preserved for URI parameter names? * @throws InvalidURIException if URI is invalid. *///w w w. ja v a 2 s.c o m protected RequestBuilderWithParameters(final String uri, final boolean caseSensitiveParameters) throws InvalidURIException { super(uri); this.caseSensitiveParameters = caseSensitiveParameters; this.parameters = Maps.newHashMapWithExpectedSize(8); }