Example usage for java.util SortedMap entrySet

List of usage examples for java.util SortedMap entrySet

Introduction

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

Prototype

Set<Map.Entry<K, V>> entrySet();

Source Link

Document

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

Usage

From source file:org.cloudata.core.tabletserver.ColumnCollection.java

License:asdf

/**
 * MEAT, ROOT tablet?  ?.//  w ww. j  a  v  a  2  s  .  co m
 * ? rowkey? ? ??  ?, ? ? ??   ? .
 * @param rowKey
 * @return
 */
public ColumnValue findNearestValue(Row.Key rowKey) {
    mapLock.readLock().lock();
    try {
        SortedMap<Row.Key, SortedMap<Cell.Key, ValueCollection>> tailMap = columnCollectionMap.tailMap(rowKey);

        if (!tailMap.isEmpty()) {
            for (Map.Entry<Row.Key, SortedMap<Cell.Key, ValueCollection>> entry : tailMap.entrySet()) {
                SortedMap<Cell.Key, ValueCollection> columnValues = entry.getValue();
                synchronized (columnValues) {
                    for (ValueCollection eachValueCollection : columnValues.values()) {

                        if (eachValueCollection.get() != null) {
                            return eachValueCollection.get();
                        }
                    }
                }
            }
            return null;
        } else {
            return null;
        }
    } finally {
        mapLock.readLock().unlock();
    }
}

From source file:ml.shifu.shifu.udf.EvalScoreUDF.java

private void appendFirstHiddenOutputScore(Tuple tuple, SortedMap<String, Double> hiddenLayerScores, boolean b) {
    for (Entry<String, Double> entry : hiddenLayerScores.entrySet()) {
        tuple.append(entry.getValue());//from   ww w . ja v  a2s .  c o m
    }
}

From source file:com.opengamma.util.timeseries.fast.integer.object.FastArrayIntObjectTimeSeries.java

@SuppressWarnings("unchecked")
public FastArrayIntObjectTimeSeries(final DateTimeNumericEncoding encoding,
        final SortedMap<Integer, T> initialMap) {
    super(encoding);
    final int size = initialMap.size();
    _times = new int[size];
    _values = (T[]) new Object[size];
    final Iterator<Entry<Integer, T>> iterator = initialMap.entrySet().iterator();
    int i = 0;//from w w w. ja  va2  s . co  m
    while (iterator.hasNext()) {
        final Entry<Integer, T> entry = iterator.next();
        _times[i] = entry.getKey().intValue();
        _values[i] = entry.getValue();
        i++;
    }
}

From source file:com.opengamma.util.timeseries.fast.integer.FastArrayIntDoubleTimeSeries.java

public FastArrayIntDoubleTimeSeries(final DateTimeNumericEncoding encoding,
        final SortedMap<Integer, Double> initialMap) {
    super(encoding);
    final int size = initialMap.size();
    _times = new int[size];
    _values = new double[size];
    final Iterator<Entry<Integer, Double>> iterator = initialMap.entrySet().iterator();
    int i = 0;//from  w  ww  . j a  va  2s.c  o  m
    while (iterator.hasNext()) {
        final Entry<Integer, Double> entry = iterator.next();
        _times[i] = entry.getKey().intValue();
        _values[i] = entry.getValue().doubleValue();
        i++;
    }
}

From source file:com.opengamma.util.timeseries.fast.longint.object.FastArrayLongObjectTimeSeries.java

@SuppressWarnings("unchecked")
public FastArrayLongObjectTimeSeries(final DateTimeNumericEncoding encoding,
        final SortedMap<Long, T> initialMap) {
    super(encoding);
    final int size = initialMap.size();
    _times = new long[size];
    _values = (T[]) new Object[size];
    final Iterator<Entry<Long, T>> iterator = initialMap.entrySet().iterator();
    int i = 0;/*from  ww w.ja  v a 2s .c  om*/
    while (iterator.hasNext()) {
        final Entry<Long, T> entry = iterator.next();
        _times[i] = entry.getKey().longValue();
        _values[i] = entry.getValue();
        i++;
    }
}

From source file:com.opengamma.util.timeseries.fast.longint.FastArrayLongDoubleTimeSeries.java

public FastArrayLongDoubleTimeSeries(final DateTimeNumericEncoding encoding,
        final SortedMap<Long, Double> initialMap) {
    super(encoding);
    final int size = initialMap.size();
    _times = new long[size];
    _values = new double[size];
    final Iterator<Entry<Long, Double>> iterator = initialMap.entrySet().iterator();
    int i = 0;/*w  ww .ja va  2 s  .c o  m*/
    while (iterator.hasNext()) {
        final Entry<Long, Double> entry = iterator.next();
        _times[i] = entry.getKey().longValue();
        _values[i] = entry.getValue().doubleValue();
        i++;
    }
}

From source file:org.cloudata.core.tabletserver.ColumnCollection.java

License:asdf

public void print() {
    mapLock.readLock().lock();//from  w w w.j a v a2  s  .c om
    try {
        for (Map.Entry<Row.Key, SortedMap<Cell.Key, ValueCollection>> entry : columnCollectionMap.entrySet()) {
            Row.Key rowKey = entry.getKey();
            SortedMap<Cell.Key, ValueCollection> columnValues = entry.getValue();

            System.out.println("\tRow.Key:" + rowKey);

            synchronized (columnValues) {
                for (Map.Entry<Cell.Key, ValueCollection> innerEntry : columnValues.entrySet()) {
                    System.out.println("\t\tCell.Key:" + innerEntry.getKey());
                    innerEntry.getValue().print();
                }
            }
        }
    } finally {
        mapLock.readLock().unlock();
    }
}

From source file:com.espertech.esper.filter.FilterParamIndexNotRange.java

public final void matchEvent(EventBean eventBean, Collection<FilterHandle> matches,
        ExprEvaluatorContext exprEvaluatorContext) {
    Object objAttributeValue = this.getGetter().get(eventBean);

    if ((ExecutionPathDebugLog.isDebugEnabled) && (log.isDebugEnabled())) {
        log.debug(".match Finding range matches, attribute=" + this.getPropertyName() + "  attrValue="
                + objAttributeValue);//from   w  w w .j a v a2  s . c  o m
    }

    if (objAttributeValue == null) {
        return;
    }

    double attributeValue = ((Number) objAttributeValue).doubleValue();

    DoubleRange rangeStart = new DoubleRange(attributeValue - largestRangeValueDouble, attributeValue);
    DoubleRange rangeEnd = new DoubleRange(attributeValue, Double.MAX_VALUE);

    SortedMap<DoubleRange, EventEvaluator> subMap = ranges.subMap(rangeStart, rangeEnd);

    // For not including either endpoint
    // A bit awkward to duplicate the loop code, however better than checking the boolean many times over
    // This may be a bit of an early performance optimization - the optimizer after all may do this better
    Set<EventEvaluator> matchingEvals = new HashSet<EventEvaluator>();
    if (this.getFilterOperator() == FilterOperator.NOT_RANGE_OPEN) // include neither endpoint
    {
        for (Map.Entry<DoubleRange, EventEvaluator> entry : subMap.entrySet()) {
            if ((attributeValue > entry.getKey().getMin()) && (attributeValue < entry.getKey().getMax())) {
                matchingEvals.add(entry.getValue());
            }
        }
    } else if (this.getFilterOperator() == FilterOperator.NOT_RANGE_CLOSED) // include all endpoints
    {
        for (Map.Entry<DoubleRange, EventEvaluator> entry : subMap.entrySet()) {
            if ((attributeValue >= entry.getKey().getMin()) && (attributeValue <= entry.getKey().getMax())) {
                matchingEvals.add(entry.getValue());
            }
        }
    } else if (this.getFilterOperator() == FilterOperator.NOT_RANGE_HALF_CLOSED) // include high endpoint not low endpoint
    {
        for (Map.Entry<DoubleRange, EventEvaluator> entry : subMap.entrySet()) {
            if ((attributeValue > entry.getKey().getMin()) && (attributeValue <= entry.getKey().getMax())) {
                matchingEvals.add(entry.getValue());
            }
        }
    } else if (this.getFilterOperator() == FilterOperator.NOT_RANGE_HALF_OPEN) // include low endpoint not high endpoint
    {
        for (Map.Entry<DoubleRange, EventEvaluator> entry : subMap.entrySet()) {
            if ((attributeValue >= entry.getKey().getMin()) && (attributeValue < entry.getKey().getMax())) {
                matchingEvals.add(entry.getValue());
            }
        }
    } else {
        throw new IllegalStateException("Invalid filter operator " + this.getFilterOperator());
    }

    // Now we have all the matching evaluators, invoke all that don't match
    for (EventEvaluator eval : evaluators) {
        if (!matchingEvals.contains(eval)) {
            eval.matchEvent(eventBean, matches, exprEvaluatorContext);
        }
    }
}

From source file:com.espertech.esper.epl.join.table.PropertySortedEventTable.java

private Set<EventBean> normalize(SortedMap<Object, Set<EventBean>> submapOne,
        SortedMap<Object, Set<EventBean>> submapTwo) {
    if (submapOne.size() == 0) {
        return normalize(submapTwo);
    }//from  w w w .jav  a2s.c om
    if (submapTwo.size() == 0) {
        return normalize(submapOne);
    }
    Set<EventBean> result = new LinkedHashSet<EventBean>();
    for (Map.Entry<Object, Set<EventBean>> entry : submapOne.entrySet()) {
        result.addAll(entry.getValue());
    }
    for (Map.Entry<Object, Set<EventBean>> entry : submapTwo.entrySet()) {
        result.addAll(entry.getValue());
    }
    return result;
}

From source file:org.onehippo.cms7.essentials.dashboard.services.ContentBeansService.java

/**
 * Fetch project content types/*from w w  w.  j  a va 2 s  .c  o  m*/
 *
 * @return empty collection if no types are found
 * @throws javax.jcr.RepositoryException
 */
public Set<ContentType> getProjectContentTypes() throws RepositoryException {
    final String namespacePrefix = context.getProjectNamespacePrefix();
    final Set<ContentType> projectContentTypes = new HashSet<>();
    final Session session = context.createSession();
    try {
        final ContentTypeService service = new HippoContentTypeService(session);
        final ContentTypes contentTypes = service.getContentTypes();
        final SortedMap<String, Set<ContentType>> typesByPrefix = contentTypes.getTypesByPrefix();
        for (Map.Entry<String, Set<ContentType>> entry : typesByPrefix.entrySet()) {
            final String key = entry.getKey();
            final Set<ContentType> value = entry.getValue();
            if (key.equals(namespacePrefix)) {
                projectContentTypes.addAll(value);
                return projectContentTypes;
            }
        }
    } finally {
        GlobalUtils.cleanupSession(session);
    }
    return Collections.emptySet();
}