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

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

Introduction

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

Prototype

public static <K extends Comparable, V> TreeMap<K, V> newTreeMap() 

Source Link

Document

Creates a mutable, empty TreeMap instance using the natural ordering of its elements.

Usage

From source file:org.kiji.scoring.statistics.RunningLogarithmicBin.java

/**
 * Initialize a new RunningLogarithmicBin of a given size.
 *
 * @param binCount the desired number of bins in this RunningLogarithmicBin.
 *///from   w  w w .  j a va  2  s.  c  om
public RunningLogarithmicBin(final int binCount) {
    mBins = Maps.newTreeMap();
    populateBins(binCount);
}

From source file:com.cloudera.science.ml.parallel.fn.SvmLightFn.java

@Override
public String map(V v) {
    StringBuilder sb = new StringBuilder();
    if (v instanceof NamedVector) {
        sb.append(((NamedVector) v).getName()).append(' ');
    }/*from   w  w w  .  ja  va 2 s .com*/
    Iterator<Vector.Element> iter = v.iterateNonZero();
    if (v.isSequentialAccess()) {
        if (iter.hasNext()) {
            Vector.Element first = iter.next();
            sb.append(first.index()).append(':').append(first.get());
        }
        while (iter.hasNext()) {
            Vector.Element e = iter.next();
            sb.append(' ').append(e.index()).append(':').append(e.get());
        }
    } else {
        SortedMap<Integer, Double> values = Maps.newTreeMap();
        while (iter.hasNext()) {
            Vector.Element e = iter.next();
            values.put(e.index(), e.get());
        }
        boolean first = true;
        for (Map.Entry<Integer, Double> e : values.entrySet()) {
            if (first) {
                first = false;
            } else {
                sb.append(' ');
            }
            sb.append(e.getKey()).append(':').append(e.getValue());
        }
    }
    return sb.toString();
}

From source file:org.kiji.scoring.params.parser.StringMapParser.java

/** {@inheritDoc} */
@Override/*from   w ww  . j av  a 2s .  c  o  m*/
public Map<String, String> parse(ParamSpec param, String value) {
    final TreeMap<String, String> map = Maps.newTreeMap();
    String[] values = value.split(PAIR_SEPARATOR);

    for (String keyValue : values) {
        if (keyValue == null) {
            throw new IllegalParamValueException(param, keyValue);
        }
        final String[] split = keyValue.split(KEY_VALUE_SEPARATOR, 2);
        if (split.length != 2) {
            throw new IllegalParamValueException(param, keyValue);
        }
        map.put(split[0], split[1]);
    }
    return map;
}

From source file:org.eclipse.wb.internal.core.model.property.editor.ExpressionListPropertyEditor.java

@Override
protected int getValueIndex(Object value) {
    for (int i = 0; i < getCount(); i++) {
        Map<String, Object> variables = Maps.newTreeMap();
        variables.put("value", value);
        setVariables(variables, i);/*from w ww.ja  va  2s  .co  m*/
        if ((Boolean) MVEL.executeExpression(m_compiled[i], variables)) {
            return i;
        }
    }
    return -1;
}

From source file:com.metamx.druid.indexer.HadoopDruidIndexerAzkWrapper.java

public void run() throws Exception {
    final DefaultObjectMapper jsonMapper = new DefaultObjectMapper();

    final List<Interval> dataInterval;
    final Map<String, Object> theMap = Maps.newTreeMap();

    for (String propertyName : properties.stringPropertyNames()) {
        if (propertyName.startsWith(PROPERTY_PREFIX)) {
            final String propValue = properties.getProperty(propertyName);
            if (propValue.trim().startsWith("{") || propValue.trim().startsWith("[")) {
                theMap.put(propertyName.substring(PROPERTY_PREFIX.length()),
                        jsonMapper.readValue(propValue, Object.class));
            } else {
                theMap.put(propertyName.substring(PROPERTY_PREFIX.length()), propValue);
            }/*from   w w  w  .  j  av  a  2  s  . co m*/
        }
    }

    log.info("Running with properties:");
    for (Map.Entry<String, Object> entry : theMap.entrySet()) {
        log.info("%30s => %s", entry.getKey(), entry.getValue());
    }

    dataInterval = Lists.transform(Lists.newArrayList(MapUtils.getString(theMap, "timeInterval").split(",")),
            new StringIntervalFunction());

    final HadoopDruidIndexerConfig config = jsonMapper.convertValue(theMap, HadoopDruidIndexerConfig.class);
    config.setIntervals(dataInterval);
    config.setVersion(new DateTime().toString());

    new HadoopDruidIndexerJob(config).run();
}

From source file:org.apache.pulsar.common.policies.data.NonPersistentTopicStats.java

public NonPersistentTopicStats() {
    this.publishers = Lists.newArrayList();
    this.subscriptions = Maps.newHashMap();
    this.replication = Maps.newTreeMap();
}

From source file:org.gageot.excel.core.BeanCellCallbackHandler.java

public BeanCellCallbackHandler(Class<T> aClass) {
    clazz = aClass;//from w  w  w .  ja va 2 s. c om
    beans = Lists.newArrayList();
    cellMapper = new ObjectCellMapper();
    headerMapper = new StringCellMapper();
    propertyNames = Maps.newTreeMap();
    beanSetter = new BeanSetterImpl();
}

From source file:reconcile.util.RuntimeArgs.java

public RuntimeArgs() {
    mArgs = Maps.newTreeMap();
}

From source file:com.jeroensteenbeeke.carrier.receiver.TokenRepository.java

private TokenRepository() {
    String userFileName = System.getProperty("users.file");

    users = new Properties();
    try {/*  ww w .j  a v  a 2 s .c o m*/
        if (userFileName != null) {
            users.loadFromXML(new FileInputStream(userFileName));
        } else {
            log.error("NO USER FILE INDICATED! ALL WEB SERVICE CALLS WILL FAIL!");
            log.error("Please start this server with -Dusers.file=/location/of/user/file");
        }
    } catch (IOException ioe) {
        log.error("Failed to load users from properties");
    }

    tokens = Maps.newTreeMap();
}

From source file:com.newisys.apps.pktviz.model.xform.AdjSeqTimeTransform.java

public void reset(Iterator<PacketInfo> packetIterator) {
    final SortedMap<Long, AnalysisTickInfo> analysisMap = Maps.newTreeMap();
    while (packetIterator.hasNext()) {
        final PacketInfo packet = packetIterator.next();
        final long fromTime = packet.getFromTimeActual();
        final AnalysisTickInfo fromInfo = getAnalysisTickInfo(analysisMap, fromTime);
        final int fromAlloc = mapIncrement(fromInfo.nodeAllocMap, packet.getFromNode(), 1);
        ++fromInfo.fromPackets;/*from  w ww.  jav  a  2s  .c  om*/

        final long toTime = packet.getToTimeActual();
        final AnalysisTickInfo toInfo = getAnalysisTickInfo(analysisMap, toTime);
        mapIncrement(toInfo.nodeAllocMap, packet.getToNode(), fromTime == toTime ? fromAlloc : 1);
        ++toInfo.toPackets;
    }

    tickInfoMap = Maps.newHashMapWithExpectedSize(analysisMap.size());
    int spanCount = 0;
    long seqTime = 0;
    for (final Map.Entry<Long, AnalysisTickInfo> entry : analysisMap.entrySet()) {
        final Long realTime = entry.getKey();
        final AnalysisTickInfo info = entry.getValue();
        tickInfoMap.put(realTime, new FinalTickInfo(seqTime, info.nodeAllocMap.size()));
        spanCount += info.fromPackets - info.toPackets;
        seqTime += mapMax(info.nodeAllocMap, 1) + 1;
    }
}