Example usage for com.google.common.collect Maps newHashMapWithExpectedSize

List of usage examples for com.google.common.collect Maps newHashMapWithExpectedSize

Introduction

In this page you can find the example usage for com.google.common.collect Maps newHashMapWithExpectedSize.

Prototype

public static <K, V> HashMap<K, V> newHashMapWithExpectedSize(int expectedSize) 

Source Link

Document

Creates a HashMap instance, with a high enough "initial capacity" that it should hold expectedSize elements without growth.

Usage

From source file:org.eclipse.hawkbit.ui.distributions.event.DistributionsViewAcceptCriteria.java

private static Map<String, List<String>> createDropConfigurations() {
    final Map<String, List<String>> config = Maps.newHashMapWithExpectedSize(2);

    // Delete drop area droppable components
    config.put(UIComponentIdProvider.DELETE_BUTTON_WRAPPER_ID,
            Arrays.asList(SPUIDefinitions.DISTRIBUTION_TYPE_ID_PREFIXS, UIComponentIdProvider.DIST_TABLE_ID,
                    UIComponentIdProvider.UPLOAD_SOFTWARE_MODULE_TABLE,
                    SPUIDefinitions.SOFTWARE_MODULE_TAG_ID_PREFIXS));

    // Distribution table drop components
    config.put(UIComponentIdProvider.DIST_TABLE_ID,
            Arrays.asList(UIComponentIdProvider.UPLOAD_SOFTWARE_MODULE_TABLE));

    return config;
}

From source file:org.gradoop.flink.algorithms.fsm.functions.ToFSMGraph.java

@Override
public FSMGraph map(GraphTransaction graph) throws Exception {

    Map<GradoopId, Integer> vertexIdMap = Maps.newHashMapWithExpectedSize(graph.getVertices().size());

    Map<Integer, String> fsmVertices = Maps.newHashMapWithExpectedSize(graph.getVertices().size());

    Map<Integer, FSMEdge> fsmEdge = Maps.newHashMapWithExpectedSize(graph.getEdges().size());

    int vertexId = 0;
    for (Vertex vertex : graph.getVertices()) {
        vertexIdMap.put(vertex.getId(), vertexId);
        fsmVertices.put(vertexId, vertex.getLabel());
        vertexId++;//w  w w.  j av  a2 s  .  c  o  m
    }

    int edgeId = 0;
    for (Edge edge : graph.getEdges()) {

        int sourceId = vertexIdMap.get(edge.getSourceId());
        int targetId = vertexIdMap.get(edge.getTargetId());

        fsmEdge.put(edgeId, new FSMEdge(sourceId, edge.getLabel(), targetId));

        edgeId++;
    }

    return new FSMGraph(graph.getGraphHead().getId(), fsmVertices, fsmEdge);
}

From source file:org.sonar.server.test.index.CoveredFileDoc.java

@VisibleForTesting
public CoveredFileDoc() {
    super(Maps.newHashMapWithExpectedSize(2));
}

From source file:com.google.devtools.depan.view_doc.layout.eclipse.ui.widgets.LayoutGeneratorsControl.java

public LayoutGeneratorsControl(Composite parent) {
    super(parent);

    List<LayoutPlanDocument<?>> topLayouts = LayoutResources.getTopLayouts();

    Map<String, LayoutPlanDocument<?>> layoutMap = Maps.newHashMapWithExpectedSize(topLayouts.size());
    for (LayoutPlanDocument<?> layoutDoc : topLayouts) {
        layoutMap.put(layoutDoc.getName(), layoutDoc);
    }// ww w.  j av  a 2  s .  c o  m

    setInput(getBestLayout(topLayouts), layoutMap);
}

From source file:org.ow2.clif.jenkins.jobs.ParameterParser.java

/**
 * suited to parse hash notation of boolean input values
 * @param name for example "examples/synchro.ctp[uninstall]"
 * @return for example ["examples/synchro.ctp", "uninstall"] 
 *//*from   w  w  w.j a v a2 s  .c  o m*/
public Map<String, String> parse(String name) {
    Matcher matcher = re.matcher(name);
    HashMap<String, String> results = Maps.newHashMapWithExpectedSize(1);
    if (matcher.matches()) {
        results.put(matcher.group(1), matcher.group(2));
    }
    return results;
}

From source file:org.gradoop.flink.representation.transactional.RepresentationConverters.java

/**
 * transaction => adjacency list/*from  w  ww .  jav a 2  s .  c  om*/
 *
 * @param transaction (g,V,E)
 *
 * @param edgeDataFactory edge data factory
 * @param vertexDataFactory vertex data factory
 *
 * @param <ED> edge data
 * @param <VD> vertex data
 *
 * @return adjacency list
 */
public static <ED, VD> AdjacencyList<GradoopId, String, ED, VD> getAdjacencyList(GraphTransaction transaction,
        MapFunction<Edge, ED> edgeDataFactory, MapFunction<Vertex, VD> vertexDataFactory) throws Exception {

    Set<Vertex> vertices = transaction.getVertices();
    Set<Edge> edges = transaction.getEdges();

    int vertexCount = vertices.size();

    Map<GradoopId, String> labels = Maps.newHashMapWithExpectedSize(1 + vertexCount + edges.size());

    Map<GradoopId, Properties> properties = Maps.newHashMap();

    Map<GradoopId, AdjacencyListRow<ED, VD>> outgoingRows = Maps.newHashMapWithExpectedSize(vertexCount);

    Map<GradoopId, AdjacencyListRow<ED, VD>> incomingRows = Maps.newHashMapWithExpectedSize(vertexCount);

    Map<GradoopId, Vertex> vertexIndex = Maps.newHashMapWithExpectedSize(vertexCount);

    // VERTICES
    for (Vertex vertex : vertices) {
        addLabelsAndProperties(vertex, labels, properties);
        vertexIndex.put(vertex.getId(), vertex);
    }

    // EDGES

    for (Edge edge : edges) {
        addLabelsAndProperties(edge, labels, properties);

        Vertex source = vertexIndex.get(edge.getSourceId());
        AdjacencyListRow<ED, VD> outgoingRow = outgoingRows.computeIfAbsent(source.getId(),
                k -> new AdjacencyListRow<>());

        VD sourceData = vertexDataFactory.map(source);

        Vertex target = vertexIndex.get(edge.getTargetId());
        AdjacencyListRow<ED, VD> incomingRow = incomingRows.computeIfAbsent(target.getId(),
                k -> new AdjacencyListRow<>());
        VD targetData = vertexDataFactory.map(target);

        ED edgeData = edgeDataFactory.map(edge);

        outgoingRow.getCells().add(new AdjacencyListCell<>(edgeData, targetData));
        incomingRow.getCells().add(new AdjacencyListCell<>(edgeData, sourceData));
    }

    return new AdjacencyList<>(transaction.getGraphHead(), labels, properties, outgoingRows, incomingRows);
}

From source file:dmh.kuebiko.model.filesystem.FileSystemNoteCache.java

/**
 * Instantiate a new file system note cache.
 * @param The initial number of items in the cache.
 *//*from w w  w  .  j a va 2 s.c  o  m*/
public FileSystemNoteCache(int size) {
    data = Maps.newHashMapWithExpectedSize(size);
}

From source file:tachyon.master.lineage.journal.LineageIdGeneratorEntry.java

@Override
public Map<String, Object> getParameters() {
    Map<String, Object> parameters = Maps.newHashMapWithExpectedSize(1);
    parameters.put("sequenceNumber", mSequenceNumber);
    return parameters;
}

From source file:org.apache.kylin.engine.mr.common.CuboidStatsReaderUtil.java

public static Pair<Map<Long, Long>, Map<Long, Double>> readCuboidStatsAndSizeFromCube(Set<Long> cuboidIds,
        CubeInstance cube) throws IOException {
    Preconditions.checkNotNull(cuboidIds, "The cuboid set can not be null");
    Preconditions.checkNotNull(cube, "The cube instance can not be null");

    List<CubeSegment> segmentList = cube.getSegments(SegmentStatusEnum.READY);
    Map<Long, Long> statisticsMerged = Maps.newHashMapWithExpectedSize(cuboidIds.size());
    Map<Long, Double> sizeMerged = Maps.newHashMapWithExpectedSize(cuboidIds.size());
    readCuboidStatsFromSegments(cuboidIds, segmentList, statisticsMerged, sizeMerged);
    return new Pair<>(statisticsMerged, sizeMerged);
}

From source file:com.opengamma.core.AbstractSourceWithExternalBundle.java

public static <V extends UniqueIdentifiable & ExternalBundleIdentifiable> Map<ExternalIdBundle, Collection<V>> getAllSingleThread(
        final SourceWithExternalBundle<V> source, final Collection<ExternalIdBundle> bundles,
        final VersionCorrection versionCorrection) {
    final Map<ExternalIdBundle, Collection<V>> results = Maps.newHashMapWithExpectedSize(bundles.size());
    for (ExternalIdBundle bundle : bundles) {
        final Collection<V> result = source.get(bundle, versionCorrection);
        if ((result != null) && !result.isEmpty()) {
            results.put(bundle, result);
        }//from ww  w. j av  a  2s  .c o  m
    }
    return results;
}