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.apache.giraph.comm.SendPartitionMutationsRequest.java

@Override
public void readFields(DataInput input) throws IOException {
    partitionId = input.readInt();// ww  w. j  a v a 2 s. co m
    int vertexIdMutationsSize = input.readInt();
    vertexIdMutations = Maps.newHashMapWithExpectedSize(vertexIdMutationsSize);
    for (int i = 0; i < vertexIdMutationsSize; ++i) {
        I vertexId = BspUtils.<I>createVertexIndex(conf);
        vertexId.readFields(input);
        VertexMutations<I, V, E, M> vertexMutations = new VertexMutations<I, V, E, M>();
        vertexMutations.setConf(conf);
        vertexMutations.readFields(input);
        if (vertexIdMutations.put(vertexId, vertexMutations) != null) {
            throw new IllegalStateException("readFields: Already has vertex id " + vertexId);
        }
    }
}

From source file:org.apache.giraph.comm.SendPartitionMessagesRequest.java

@Override
public void readFields(DataInput input) throws IOException {
    partitionId = input.readInt();//from   w  w w.java 2  s.  c  om
    int vertexIdMessagesSize = input.readInt();
    vertexIdMessages = Maps.newHashMapWithExpectedSize(vertexIdMessagesSize);
    for (int i = 0; i < vertexIdMessagesSize; ++i) {
        I vertexId = BspUtils.<I>createVertexIndex(conf);
        vertexId.readFields(input);
        int messageCount = input.readInt();
        List<M> messageList = Lists.newArrayListWithCapacity(messageCount);
        for (int j = 0; j < messageCount; ++j) {
            M message = BspUtils.<M>createMessageValue(conf);
            message.readFields(input);
            messageList.add(message);
        }
        if (vertexIdMessages.put(vertexId, messageList) != null) {
            throw new IllegalStateException("readFields: Already has vertex id " + vertexId);
        }
    }
}

From source file:abstractions.position.PositionManager.java

private Map<Integer, PositionInterface> initializeData(final Set<PositionInterface> set) {
    final Map<Integer, PositionInterface> data = Maps.newHashMapWithExpectedSize(set.size());
    for (final PositionInterface element : set) {
        data.put(this.hash(element.getRow(), element.getColumn()), element);
    }//www  . ja va 2s  . co  m
    return ImmutableMap.copyOf(data);
}

From source file:com.android.tools.idea.uibuilder.model.AttributesTransaction.java

public AttributesTransaction(@NotNull NlComponent thisComponent) {
    myComponent = thisComponent;//w ww  . j  ava  2s .co m
    myModel = myComponent.getModel();

    List<AttributeSnapshot> attributes = myComponent.getAttributes();
    myOriginalValues = Maps.newHashMapWithExpectedSize(attributes.size());
    attributes.stream().forEach((attribute) -> myOriginalValues
            .put(attributeKey(attribute.namespace, attribute.name), attribute.value));
}

From source file:org.apache.giraph.comm.requests.SendPartitionMutationsRequest.java

@Override
public void readFieldsRequest(DataInput input) throws IOException {
    partitionId = input.readInt();/*from w w w  .  ja va2  s  .c  om*/
    int vertexIdMutationsSize = input.readInt();
    vertexIdMutations = Maps.newHashMapWithExpectedSize(vertexIdMutationsSize);
    for (int i = 0; i < vertexIdMutationsSize; ++i) {
        I vertexId = getConf().createVertexId();
        vertexId.readFields(input);
        VertexMutations<I, V, E, M> vertexMutations = new VertexMutations<I, V, E, M>();
        vertexMutations.setConf(getConf());
        vertexMutations.readFields(input);
        if (vertexIdMutations.put(vertexId, vertexMutations) != null) {
            throw new IllegalStateException("readFields: Already has vertex id " + vertexId);
        }
    }
}

From source file:com.kingen.web.StoreRoomController.java

/**
 * ?grid/*from   w  w  w.  java 2 s. c o m*/
 */
//?jsonstring ?jsonObject
@RequestMapping(value = "/treeData")
public @ResponseBody Object data(Page<StoreRoom> page, HttpServletResponse response) {

    List<StoreRoom> all = service.list();
    List<TreeNode> allConverted = BeanMapper.mapList(all, TreeNode.class);

    //      JsonResultBuilder.success(true).data(TreeConverter.toComplexJsonString(allConverted)).json();
    //      Json json = new Json();
    //      List<Map<String, Object>> children = Lists.newArrayList(TreeConverter.tree(allPermissions)); 
    //      json.setChildren(children);//??
    //      json.setSuccess(true);
    //      writeJson(response,json);

    //      return ExtUtils.toComplexJson(offices);

    Map<String, Object> json = Maps.newHashMapWithExpectedSize(1);
    //?chidlren,return toComplexJsonString(offices);?.jsonString???????
    json.put("children", TreeConverter.toComplexTree(allConverted));
    return json;

}

From source file:org.apache.phoenix.end2end.BaseTenantSpecificTablesIT.java

@BeforeClass
public static void doSetup() throws Exception {
    Map<String, String> props = Maps.newHashMapWithExpectedSize(3);
    // Must update config before starting server
    props.put(QueryServices.STATS_GUIDEPOST_WIDTH_BYTES_ATTRIB, Long.toString(20));
    setUpTestDriver(new ReadOnlyProps(props.entrySet().iterator()));
    PHOENIX_JDBC_TENANT_SPECIFIC_URL = getUrl() + ';' + TENANT_ID_ATTRIB + '=' + TENANT_ID;
    PHOENIX_JDBC_TENANT_SPECIFIC_URL2 = getUrl() + ';' + TENANT_ID_ATTRIB + '=' + TENANT_ID2;
}

From source file:org.agatom.springatom.cmp.wizards.core.StepHelperDelegate.java

private StepHelperDelegate(StepHelper... helpers) throws ConfigurationException {
    this.helperMap = Maps.newHashMapWithExpectedSize(helpers.length);
    for (StepHelper helper : helpers) {
        this.helperMap.put(helper.getStep(), helper);
        if (helper.isFinalStep()) {
            if (StringUtils.hasText(lastStep)) {
                throw new ConfigurationException(String.format(
                        "More than one stepHelper reports being final step helper, one already found is %s and the new one is %s",
                        this.lastStep, helper.getStep()));
            }/*from w ww  .j a v  a2 s. c om*/
            this.lastStep = helper.getStep();
        }
    }
}

From source file:org.agatom.springatom.core.locale.SAMessageSource.java

@Override
public Map<String, String> getAllMessages(final Locale locale) {
    final Properties properties = this.getMergedProperties(locale).getProperties();
    final Map<String, String> map = Maps.newHashMapWithExpectedSize(properties.size());
    for (final Object propKey : properties.keySet()) {
        map.put(propKey.toString(), properties.get(propKey).toString());
    }/*w ww  .  j a v  a  2  s. com*/
    return map;
}

From source file:net.minecrell.quartz.mappings.transformer.DeobfuscationTransformer.java

public DeobfuscationTransformer(Mapper mapper, ClassProvider provider) {
    this.mapper = requireNonNull(mapper, "mapper");
    this.provider = requireNonNull(provider, "provider");

    this.methods = Maps.newHashMapWithExpectedSize(mapper.getMethods().size());
    this.fields = Maps.newHashMapWithExpectedSize(mapper.getFields().size());
}