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:no.kantega.publishing.common.cache.DisplayTemplateCache.java

public static synchronized void reloadCache() throws SystemException {
    log.debug("Loading cache");

    List<DisplayTemplate> dtlist = TemplateConfigurationCache.getInstance().getTemplateConfiguration()
            .getDisplayTemplates();/*  w  w  w. java  2s  .c om*/
    Map<Integer, DisplayTemplate> newdisplaytemplates = Maps.newHashMapWithExpectedSize(dtlist.size());
    lastUpdate = new Date();
    for (DisplayTemplate template : dtlist) {
        newdisplaytemplates.put(template.getId(), template);
    }
    displaytemplates = newdisplaytemplates;
}

From source file:com.datastax.driver.core.DirectedGraph.java

DirectedGraph(List<V> vertices) {
    this.vertices = Maps.newHashMapWithExpectedSize(vertices.size());
    this.adjacencyList = HashMultimap.create();

    for (V vertex : vertices) {
        this.vertices.put(vertex, 0);
    }/*from  ww w .j a  v a2 s . co m*/
}

From source file:com.threerings.tools.gxlate.spreadsheet.Row.java

Row(int num, List<String> headers, List<CellEntry> cells) {
    _num = num;//from  w ww .j  a  v  a 2 s.com
    _values = Maps.newHashMapWithExpectedSize(cells.size());
    for (CellEntry cell : cells) {
        String header = headers.get(cell.getCell().getCol() - 1);
        _values.put(header, cell);
    }

    _stringValues = Maps.transformValues(_values, new Function<CellEntry, String>() {
        @Override
        public String apply(CellEntry entry) {
            return entry != null ? entry.getCell().getValue() : null;
        }
    });
}

From source file:org.eclipse.xtext.xbase.typesystem.internal.FeatureScopeTracker.java

protected FeatureScopeTracker() {
    featureScopeSessions = Maps.newHashMapWithExpectedSize(256);
}

From source file:com.romeikat.datamessie.core.statistics.cache.NumberOfDocumentsPerState.java

public NumberOfDocumentsPerState() {
    numberOfDocumentsPerState = Maps.newHashMapWithExpectedSize(DocumentProcessingState.values().length);
}

From source file:com.google.gitiles.TagSoyData.java

public Map<String, Object> toSoyData(RevTag tag) {
    Map<String, Object> data = Maps.newHashMapWithExpectedSize(4);
    data.put("sha", ObjectId.toString(tag));
    if (tag.getTaggerIdent() != null) {
        data.put("tagger", CommitSoyData.toSoyData(tag.getTaggerIdent(), dateFormatter));
    }/*ww  w.  j  a v  a  2  s. c om*/
    data.put("object", ObjectId.toString(tag.getObject()));
    data.put("message", linkifier.linkify(req, tag.getFullMessage()));
    return data;
}

From source file:org.apache.phoenix.monitoring.BasePhoenixMetricsIT.java

@BeforeClass
public static void doSetup() throws Exception {
    Map<String, String> props = Maps.newHashMapWithExpectedSize(3);
    // Disable system task handling
    props.put(QueryServices.TASK_HANDLING_INITIAL_DELAY_MS_ATTRIB, Long.toString(Long.MAX_VALUE));
    // Phoenix Global client metrics are enabled by default
    // Enable request metric collection at the driver level
    props.put(QueryServices.COLLECT_REQUEST_LEVEL_METRICS, String.valueOf(true));
    // disable renewing leases as this will force spooling to happen.
    props.put(QueryServices.RENEW_LEASE_ENABLED, String.valueOf(false));
    setUpTestDriver(new ReadOnlyProps(props.entrySet().iterator()));
    // need the non-test driver for some tests that check number of hconnections, etc.
    DriverManager.registerDriver(PhoenixDriver.INSTANCE);

}

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

@Override
public Map<String, Object> getParameters() {
    Map<String, Object> parameters = Maps.newHashMapWithExpectedSize(2);
    parameters.put("fileId", mFileId);
    return parameters;
}

From source file:voldemort.server.rebalance.RebalancerState.java

public RebalancerState(List<RebalanceTaskInfo> stealInfoList) {
    stealInfoMap = Maps.newHashMapWithExpectedSize(stealInfoList.size());
    for (RebalanceTaskInfo rebalanceTaskInfo : stealInfoList)
        stealInfoMap.put(rebalanceTaskInfo.getDonorId(), rebalanceTaskInfo);
}

From source file:org.auraframework.throwable.SystemErrorException.java

@Override
public Event getEvent() {
    try {/*from   w w w . j a  v a  2s . co m*/
        Map<String, Object> args = Maps.newHashMapWithExpectedSize(1);
        args.put("message", this.getMessage());
        return Aura.getInstanceService().getInstance("aura:systemError", EventDef.class, args);
    } catch (QuickFixException x) {
        throw new AuraRuntimeException(x);
    }
}