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

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

Introduction

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

Prototype

public static <K, V> HashMap<K, V> newHashMap() 

Source Link

Document

Creates a mutable, empty HashMap instance.

Usage

From source file:com.naver.timetable.dao.ConfigDAO.java

public void insertSeason(String year, String season) {
    Map<String, String> parameterMap = Maps.newHashMap();
    parameterMap.put("year", year);
    parameterMap.put("season", season);
    hufsCubrid.insert("insertSeason", parameterMap);
}

From source file:com.cloudera.oryx.kmeans.computation.normalize.NormalizeSettings.java

public static NormalizeSettings create(Config config) {
    Config normalize = config.getConfig("model.normalize");
    Boolean sparse = normalize.hasPath("sparse") ? normalize.getBoolean("sparse") : null;

    Transform defaultTransform = Transform.forName(normalize.getString("default-transform"));
    Function<Object, Integer> lookup = InboundSettings.create(config).getLookupFunction();
    Map<Integer, Transform> transforms = Maps.newHashMap();
    load(normalize, "z-transform", Transform.Z, lookup, transforms);
    load(normalize, "log-transform", Transform.LOG, lookup, transforms);
    load(normalize, "linear-transform", Transform.LINEAR, lookup, transforms);
    load(normalize, "no-transform", Transform.NONE, lookup, transforms);

    Map<Integer, Double> scale = Maps.newHashMap();
    if (normalize.hasPath("scale")) {
        Config scaleConfig = normalize.getConfig("scale");
        for (Map.Entry<String, ConfigValue> e : scaleConfig.entrySet()) {
            scale.put(lookup.apply(e.getKey()), scaleConfig.getDouble(e.getKey()));
        }/*  w  ww .j a va  2 s. c  om*/
    }

    return new NormalizeSettings(sparse, defaultTransform, transforms, scale);
}

From source file:co.cask.cdap.data2.util.hbase.CoprocessorUtil.java

/**
 * Returns information for all coprocessor configured for the table.
 *
 * @return a Map from coprocessor class name to {@link CoprocessorDescriptor}
 *//*from  w w  w  .ja v a 2  s  .co  m*/
public static Map<String, CoprocessorDescriptor> getCoprocessors(HTableDescriptor tableDescriptor) {
    Map<String, CoprocessorDescriptor> info = Maps.newHashMap();

    // Extract information about existing data janitor coprocessor
    // The following logic is copied from RegionCoprocessorHost in HBase
    for (Map.Entry<ImmutableBytesWritable, ImmutableBytesWritable> entry : tableDescriptor.getValues()
            .entrySet()) {
        String key = Bytes.toString(entry.getKey().get()).trim();
        String spec = Bytes.toString(entry.getValue().get()).trim();

        if (!HConstants.CP_HTD_ATTR_KEY_PATTERN.matcher(key).matches()) {
            continue;
        }

        try {
            Matcher matcher = HConstants.CP_HTD_ATTR_VALUE_PATTERN.matcher(spec);
            if (!matcher.matches()) {
                continue;
            }

            String className = matcher.group(2).trim();
            Path path = matcher.group(1).trim().isEmpty() ? null : new Path(matcher.group(1).trim());
            int priority = matcher.group(3).trim().isEmpty() ? Coprocessor.PRIORITY_USER
                    : Integer.valueOf(matcher.group(3));
            String cfgSpec = null;
            try {
                cfgSpec = matcher.group(4);
            } catch (IndexOutOfBoundsException ex) {
                // ignore
            }

            Map<String, String> properties = Maps.newHashMap();
            if (cfgSpec != null) {
                cfgSpec = cfgSpec.substring(cfgSpec.indexOf('|') + 1);
                // do an explicit deep copy of the passed configuration
                Matcher m = HConstants.CP_HTD_ATTR_VALUE_PARAM_PATTERN.matcher(cfgSpec);
                while (m.find()) {
                    properties.put(m.group(1), m.group(2));
                }
            }
            String pathStr = path == null ? null : path.toUri().getPath();
            info.put(className, new CoprocessorDescriptor(className, pathStr, priority, properties));
        } catch (Exception ex) {
            LOG.warn("Coprocessor attribute '{}' has invalid coprocessor specification '{}'", key, spec, ex);
        }
    }

    return info;
}

From source file:com.facebook.imagepipeline.memory.PoolStats.java

public PoolStats(BasePool<V> pool) {
    mPool = pool;
    mBucketStats = Maps.newHashMap();
}

From source file:classes.Transaction.java

public Transaction(long time, Map<String, String> orderXmlParams, Multimap<String, Data> dbResult) {
    super(time);/*w  ww.  j  av  a  2 s . c om*/
    parameters = Maps.newHashMap();
    if (orderXmlParams != null) {
        parameters.putAll(orderXmlParams);
    }
    parameters.putAll(dbResult.entries().stream().findFirst().get().getValue().getValues());
}

From source file:com.kingen.repository.permission.PermissionDao.java

public void delOrgMenus(String orgId) {
    String hql = " delete from SysOrgMenu where id.orgId=:p1 ";
    Map<String, Object> parameter = Maps.newHashMap();
    parameter.put("p1", orgId);
    executeHql(hql, parameter);//from   ww  w . j  av a  2 s  .c om
}

From source file:z.tool.util.CollectionUtil.java

@SuppressWarnings("unchecked")
public static <K, V extends IKey<K>> Map<K, V> makeIKeyDataAsMap(List<? extends IKey<K>> list) {
    if (ZUtils.isEmpty(list)) {
        return Collections.emptyMap();
    }/* w  w  w. ja v  a2s . c  o m*/

    Map<K, V> map = Maps.newHashMap();
    for (IKey<K> key : list) {
        map.put(key.getKey(), (V) key);
    }

    return map;
}

From source file:oims.reciptManagement.DetailRecipt.java

public DetailRecipt() {
    recipt_ = Maps.newHashMap();
    this.detailReciptName_ = "NA";
    this.serializedRecipt_ = "NA";
}

From source file:org.ros.internal.transport.ConnectionHeader.java

/**
 * Decodes a header that came over the wire into a {@link Map} of fields and
 * values./*  w  w  w . ja v  a2s . c o m*/
 *
 * @param buffer
 *          the incoming {@link ChannelBuffer} containing the header
 * @return a {@link Map} of header fields and values
 */
public static ConnectionHeader decode(ChannelBuffer buffer) {
    Map<String, String> fields = Maps.newHashMap();
    int position = 0;
    int readableBytes = buffer.readableBytes();
    while (position < readableBytes) {
        int fieldSize = buffer.readInt();
        position += 4;
        if (fieldSize == 0) {
            throw new IllegalStateException("Invalid 0 length handshake header field.");
        }
        if (position + fieldSize > readableBytes) {
            throw new IllegalStateException("Invalid line length handshake header field.");
        }
        String field = decodeAsciiString(buffer, fieldSize);
        position += field.length();
        Preconditions.checkState(field.indexOf("=") > 0,
                String.format("Invalid field in handshake header: \"%s\"", field));
        String[] keyAndValue = field.split("=");
        if (keyAndValue.length == 1) {
            fields.put(keyAndValue[0], "");
        } else {
            fields.put(keyAndValue[0], keyAndValue[1]);
        }
    }
    if (log.isDebugEnabled()) {
        log.debug("Decoded header: " + fields);
    }
    ConnectionHeader connectionHeader = new ConnectionHeader();
    connectionHeader.mergeFields(fields);
    return connectionHeader;
}

From source file:io.mesosphere.mesos.util.Functions.java

@NotNull
@SafeVarargs/* w w w.  jav  a2s .  c  om*/
public static <K, V> Map<K, V> unmodifiableHashMap(@NotNull final Tuple2<K, V>... tuples) {
    final Map<K, V> map = Maps.newHashMap();
    for (final Tuple2<K, V> tuple : tuples) {
        map.put(tuple._1, tuple._2);
    }
    return Collections.unmodifiableMap(map);
}