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.apache.kylin.common.util.RangeUtil.java

/**
 * for NavigableMap sorted by C, given a range of C, return the sub map whose key falls in the range
 *//*from  w w w . j a v a  2s . c o m*/
public static <C extends Comparable<?>, V> NavigableMap<C, V> filter(NavigableMap<C, V> values,
        Range<C> filterRange) {
    if (filterRange == null || filterRange.isEmpty()) {
        return Maps.newTreeMap();
    } else if (filterRange.equals(Range.all())) {
        return values;
    }

    if (filterRange.hasUpperBound() && !filterRange.hasLowerBound()) {
        return values.headMap(filterRange.upperEndpoint(), upperBoundInclusive(filterRange));
    } else if (filterRange.hasLowerBound() && !filterRange.hasUpperBound()) {
        return values.tailMap(filterRange.lowerEndpoint(), lowerBoundInclusive(filterRange));
    } else {
        return values.subMap(filterRange.lowerEndpoint(), lowerBoundInclusive(filterRange), //
                filterRange.upperEndpoint(), upperBoundInclusive(filterRange));
    }
}

From source file:org.geogit.storage.memory.HeapRefDatabase.java

/**
 * Creates the reference database.
 */
@Override
public void create() {
    if (refs == null) {
        refs = Maps.newTreeMap();
    }
}

From source file:com.yahoo.pulsar.common.policies.data.AuthPolicies.java

public AuthPolicies() {
    namespace_auth = Maps.newTreeMap();
    destination_auth = Maps.newTreeMap();
}

From source file:com.turn.sorcerer.metrics.MetricsMonitor.java

public Map<String, Object> getGraphiteMetrics() {
    Map<String, Object> metrics = Maps.newTreeMap();
    for (Map.Entry<MetricUnit, Long> entry : METRICS.entrySet()) {
        metrics.put(entry.getKey().getGraphiteKey(), entry.getValue());
    }//  w  w w .  j av  a  2  s . c  om
    return metrics;
}

From source file:blockplus.model.polyomino.Polyominos.java

private static SortedMap<Integer, Set<Polyomino>> computeRadiusIndexes(final Set<Integer> radius) {
    final Map<Integer, ImmutableSortedSet.Builder<Polyomino>> tmpMap = Maps.newTreeMap();
    for (final Integer integer : radius)
        tmpMap.put(integer, new ImmutableSortedSet.Builder<Polyomino>(Ordering.natural()));
    for (final Polyomino polyomino : Polyomino.set())
        tmpMap.get(polyomino.radius()).add(polyomino);
    final Builder<Integer, Set<Polyomino>> builder = new ImmutableSortedMap.Builder<Integer, Set<Polyomino>>(
            Ordering.natural());//from ww w  . j av  a  2s . c om
    for (final Entry<Integer, ImmutableSortedSet.Builder<Polyomino>> entry : tmpMap.entrySet())
        builder.put(entry.getKey(), entry.getValue().build());
    return builder.build();
}

From source file:io.druid.data.input.Rows.java

/**
 * @param timeStamp rollup up timestamp to be used to create group key
 * @param inputRow input row//  w ww  .  j av  a 2  s.  c om
 * @return groupKey for the given input row
 */
public static List<Object> toGroupKey(long timeStamp, InputRow inputRow) {
    final Map<String, Set<String>> dims = Maps.newTreeMap();
    for (final String dim : inputRow.getDimensions()) {
        final Set<String> dimValues = ImmutableSortedSet.copyOf(inputRow.getDimension(dim));
        if (dimValues.size() > 0) {
            dims.put(dim, dimValues);
        }
    }
    return ImmutableList.of(timeStamp, dims);
}

From source file:com.cloudera.csd.tools.codahale.CodahaleMetricsServletMetricConventionsGenerator.java

public static CodahaleMetricConventions makeConventions() {
    CodahaleMetricConventions conventions = new CodahaleMetricConventions();

    conventions.gaugeContextSuffix = "::value";

    conventions.counterContextSuffix = "::count";

    conventions.meterContextSuffixes = Maps.newTreeMap();
    conventions.meterContextSuffixes.put(MeterMetricType.COUNT, "::count");
    conventions.meterContextSuffixes.put(MeterMetricType.MEAN_RATE_GAUGE, "::mean");
    conventions.meterContextSuffixes.put(MeterMetricType.ONE_MIN_RATE_GAUGE, "::m1");
    conventions.meterContextSuffixes.put(MeterMetricType.FIVE_MIN_RATE_GAUGE, "::m5");
    conventions.meterContextSuffixes.put(MeterMetricType.FIFTEEN_MIN_RATE_GAUGE, "::m15");

    conventions.timerContextSuffixes = Maps.newTreeMap();
    conventions.timerContextSuffixes.put(TimerMetricType.MIN, "::duration::min");
    conventions.timerContextSuffixes.put(TimerMetricType.MAX, "::duration::max");
    conventions.timerContextSuffixes.put(TimerMetricType.MEAN, "::duration::mean");
    conventions.timerContextSuffixes.put(TimerMetricType.STDDEV, "::duration::std_dev");
    conventions.timerContextSuffixes.put(TimerMetricType.MEDIAN, "::duration::median");
    conventions.timerContextSuffixes.put(TimerMetricType.PERCENTILE_75, "::duration::p75");
    conventions.timerContextSuffixes.put(TimerMetricType.PERCENTILE_99, "::duration::p99");
    conventions.timerContextSuffixes.put(TimerMetricType.PERCENTILE_999, "::duration::p999");
    conventions.timerContextSuffixes.put(TimerMetricType.COUNT, "::rate::count");
    conventions.timerContextSuffixes.put(TimerMetricType.ONE_MIN_RATE, "::rate::m1");
    conventions.timerContextSuffixes.put(TimerMetricType.FIVE_MIN_RATE, "::rate::m5");
    conventions.timerContextSuffixes.put(TimerMetricType.FIFTEEN_MIN_RATE, "::rate::m15");

    conventions.histogramContextSuffixes = Maps.newTreeMap();
    conventions.histogramContextSuffixes.put(HistogramMetricType.COUNT, "::count");
    conventions.histogramContextSuffixes.put(HistogramMetricType.MIN, "::min");
    conventions.histogramContextSuffixes.put(HistogramMetricType.MAX, "::max");
    conventions.histogramContextSuffixes.put(HistogramMetricType.MEAN, "::mean");
    conventions.histogramContextSuffixes.put(HistogramMetricType.STDDEV, "::std_dev");
    conventions.histogramContextSuffixes.put(HistogramMetricType.MEDIAN, "::median");
    conventions.histogramContextSuffixes.put(HistogramMetricType.PERCENTILE_75, "::p75");
    conventions.histogramContextSuffixes.put(HistogramMetricType.PERCENTILE_99, "::p99");
    conventions.histogramContextSuffixes.put(HistogramMetricType.PERCENTILE_999, "::p999");

    return conventions;
}

From source file:nl.knaw.huygens.timbuctoo.graph.Graph.java

public Graph() {
    vertices = Maps.newTreeMap();
}

From source file:org.apache.isis.core.runtime.runner.opts.OptionHandlerSystemProperties.java

private static Map<String, String> asMap(Properties properties) {
    final Map<String, String> map = Maps.newTreeMap();
    for (String key : properties.stringPropertyNames()) {
        final String value = properties.getProperty(key);
        if (key.startsWith("isis.")) {
            map.put(key, value);/* w w  w.  j  a v  a  2 s  .  co m*/
        }
    }
    return map;
}

From source file:org.apache.pulsar.common.stats.Metrics.java

/**
 * Creates a metrics object with the dimensions map immutable
 *
 * @param application/*w  ww.j av a 2s  .co  m*/
 * @param timestamp
 * @param dimensionsMap
 * @return
 */
public static Metrics create(Map<String, String> dimensionMap) {
    // make the dimensions map unmodifiable and immutable;
    Map<String, String> map = Maps.newTreeMap();
    map.putAll(dimensionMap);
    return new Metrics(Collections.unmodifiableMap(map));
}