Example usage for java.util SortedMap keySet

List of usage examples for java.util SortedMap keySet

Introduction

In this page you can find the example usage for java.util SortedMap keySet.

Prototype

Set<K> keySet();

Source Link

Document

Returns a Set view of the keys contained in this map.

Usage

From source file:org.exoplatform.addons.es.integration.BaseIntegrationTest.java

protected void deleteAllIndexesInES() {
    SortedMap<String, AliasOrIndex> aliasAndIndexLookup = node.client().admin().cluster().prepareState()
            .execute().actionGet().getState().getMetaData().getAliasAndIndexLookup();
    for (String alias : aliasAndIndexLookup.keySet()) {
        node.client().admin().indices().prepareDelete(alias).execute().actionGet();
    }//from ww w  . ja v a2  s. c o  m
    node.client().admin().indices().prepareRefresh().execute().actionGet();
}

From source file:edu.brown.statistics.AbstractStatistics.java

protected String debug(Database catalog_db, Enum<?> elements[]) {
    Map<String, Object> m = new ListOrderedMap<String, Object>();
    try {//from w w w. j  av a 2 s.  c  om
        Class<?> statsClass = this.getClass();
        for (Enum<?> element : elements) {
            Field field = statsClass.getDeclaredField(element.toString().toLowerCase());
            Object value = field.get(this);

            if (field.getClass().isAssignableFrom(SortedMap.class)) {
                SortedMap<?, ?> orig_value = (SortedMap<?, ?>) value;
                Map<String, Object> inner_m = new ListOrderedMap<String, Object>();
                for (Object inner_key : orig_value.keySet()) {
                    Object inner_val = orig_value.get(inner_key);
                    if (inner_val instanceof AbstractStatistics<?>) {
                        inner_val = ((AbstractStatistics<?>) inner_val).debug(catalog_db);
                    }
                    inner_m.put(inner_key.toString(), inner_val);
                } // FOR
                value = StringUtil.formatMaps(inner_m);
            }
            m.put(element.toString(), value);
        } // FOR
    } catch (Exception ex) {
        ex.printStackTrace();
        System.exit(1);
    }
    return (String.format("%s\n%s", this.getCatalogItem(catalog_db),
            StringUtil.prefix(StringUtil.formatMaps(m), DEBUG_SPACER)));
}

From source file:com.kixeye.chassis.support.metrics.aws.MetricsCloudWatchReporter.java

private void addMeters(SortedMap<String, Meter> meters, LinkedList<PutMetricDataRequest> requests,
        Date timestamp) {//  w  w w  . ja va  2 s .  c o m
    logger.debug("Adding Meters...");
    for (String name : meters.keySet()) {
        addMetered(name, meters.get(name), requests, timestamp);
    }
}

From source file:com.kixeye.chassis.support.metrics.aws.MetricsCloudWatchReporter.java

private void addTimers(SortedMap<String, Timer> timers, LinkedList<PutMetricDataRequest> requests,
        Date timestamp) {/*w  ww  . j  a  v a 2s .c om*/
    logger.debug("Adding Timers...");
    for (String name : timers.keySet()) {
        Timer timer = timers.get(name);
        checkAndAddDatum(MetricFilter.Stat.COUNT, name, timer.getCount(), requests, timestamp);
        addMetered(name, timer, requests, timestamp);
    }
}

From source file:com.haulmont.cuba.web.sys.WebJarResourceResolver.java

protected SortedMap<String, String> filterPathIndexByPrefix(SortedMap<String, String> pathIndex,
        String prefix) {//ww  w . ja  v  a 2s.c  o m
    SortedMap<String, String> filteredPathIndex = new TreeMap<>();
    for (String key : pathIndex.keySet()) {
        String value = pathIndex.get(key);
        if (value.startsWith(prefix)) {
            filteredPathIndex.put(key, value);
        }
    }
    return filteredPathIndex;
}

From source file:com.kixeye.chassis.support.metrics.aws.MetricsCloudWatchReporter.java

@SuppressWarnings("rawtypes")
private void addGauges(SortedMap<String, Gauge> gauges, LinkedList<PutMetricDataRequest> requests,
        Date timestamp) {//from w ww.j a v  a 2s .  c om
    logger.debug("Adding Gauges...");
    for (String name : gauges.keySet()) {
        Gauge<?> gauge = gauges.get(name);
        if (!(gauge.getValue() instanceof Number)) {
            logger.warn("Encountered Gauge with non-numeric value. Gauge:{}, Value:{}", name, gauge.getValue());
            continue;
        }
        Double value = ((Number) gauge.getValue()).doubleValue();
        addDatum(filter.getMatchingMetricDescriptor(name, Stat.ALL).getAlias(), value, requests, timestamp);
    }
}

From source file:com.kixeye.chassis.support.metrics.aws.MetricsCloudWatchReporter.java

private void addCounters(SortedMap<String, Counter> counters, LinkedList<PutMetricDataRequest> requests,
        Date timestamp) {//from   w  w w  .ja  v  a2s .  c  om
    logger.debug("Adding Counters...");
    for (String name : counters.keySet()) {
        Counter counter = counters.get(name);
        addDatum(filter.getMatchingMetricDescriptor(name, Stat.ALL).getAlias(), counter.getCount(), requests,
                timestamp);
    }
}

From source file:org.libreplan.web.common.components.finders.OrdersMultipleFiltersFinder.java

private List<FilterPair> fillWithFirstTenFiltersCriterions() {
    SortedMap<CriterionType, List<Criterion>> mapCriterions = getMapCriterions();
    Iterator<CriterionType> iteratorCriterionType = mapCriterions.keySet().iterator();

    while (iteratorCriterionType.hasNext() && getListMatching().size() < 10) {
        CriterionType type = iteratorCriterionType.next();

        for (int i = 0; getListMatching().size() < 10 && i < mapCriterions.get(type).size(); i++) {
            Criterion criterion = mapCriterions.get(type).get(i);
            addCriterion(type, criterion);
        }/*from  w  w w .jav  a2s  .com*/
    }
    return getListMatching();
}

From source file:com.intuit.tank.script.util.ScriptFilterUtil.java

/**
 * /*from w w w.jav  a 2  s  . co m*/
 * @param filter
 * @param steps
 */
public static void applyFilter(ScriptFilter filter, List<ScriptStep> steps) {
    boolean allConditionsMustPass = filter.getAllConditionsMustPass();
    Set<ScriptStep> stepsToDelete = new HashSet<ScriptStep>();
    SortedMap<Integer, ScriptStep> stepsToAdd = new TreeMap<Integer, ScriptStep>();
    for (ScriptStep step : steps) {
        boolean conditionsMet = true;

        for (ScriptFilterCondition condition : filter.getConditions()) {
            conditionsMet = testConditions(condition.getScope(), condition, step, steps);

            if (!conditionsMet && allConditionsMustPass) {
                break;
            }

            else if (conditionsMet && !allConditionsMustPass) {
                break;
            }
        }

        if (conditionsMet) {
            doAction(steps, stepsToAdd, stepsToDelete, filter.getActions(), step);
        }
    }
    int reqCount = 0;
    Iterator<Integer> itr = stepsToAdd.keySet().iterator();
    while (itr.hasNext()) {
        int index = itr.next();
        steps.add(index + reqCount, stepsToAdd.get(index));
        reqCount++;
    }

    for (ScriptStep delete : stepsToDelete) {
        steps.remove(delete);
    }
}

From source file:org.apache.hadoop.hive.accumulo.predicate.PrimitiveComparisonFilter.java

@Override
protected boolean filter(Text currentRow, List<Key> keys, List<Value> values) {
    SortedMap<Key, Value> items;
    boolean allow;
    try { // if key doesn't contain CF, it's an encoded value from a previous iterator.
        while (keys.get(0).getColumnFamily().getBytes().length == 0) {
            items = decodeRow(keys.get(0), values.get(0));
            keys = Lists.newArrayList(items.keySet());
            values = Lists.newArrayList(items.values());
        }//from   ww w. ja  v a2 s .c  o  m
        allow = accept(keys, values);
    } catch (IOException e) {
        throw new RuntimeException(e);
    }
    return allow;
}