Package java.util

Examples of java.util.SortedMap


     */
    public void skipTo(long date) {
        long time = System.currentTimeMillis();

        // get skip map for this journal
        SortedMap skipMap = getSkipMap();
        synchronized (skipMap) {
            SortedMap head = skipMap.headMap(new Long(time));
            if (!head.isEmpty()) {
                eventBundleBuffer.clear();
                lastRevision = (Long) head.get(head.lastKey());
            }
        }

        try {
            while (hasNext()) {
View Full Code Here


                    }
                }

                if (processor.getNumEvents() >= MIN_BUFFER_SIZE) {
                    // remember in skip map
                    SortedMap skipMap = getSkipMap();
                    Long timestamp = new Long(processor.getLastTimestamp());
                    synchronized (skipMap) {
                        if (log.isDebugEnabled()) {
                            DateFormat df = DateFormat.getDateTimeInstance();
                            log.debug("remember record in skip map: {} -> {}",
                                    df.format(new Date(timestamp.longValue())),
                                            lastRevision);
                        }
                        skipMap.put(timestamp, lastRevision);
                    }
                }
            } finally {
                records.close();
            }
View Full Code Here

    /**
     * @return the revision skip map for this journal.
     */
    private SortedMap getSkipMap() {
        synchronized (REVISION_SKIP_MAPS) {
            SortedMap map = (SortedMap) REVISION_SKIP_MAPS.get(journal);
            if (map == null) {
                map = new TreeMap();
                REVISION_SKIP_MAPS.put(journal, map);
            }
            return map;
View Full Code Here

    if (lastComparison != 0) {
      return lastComparison;
    }

    // Sort a and b so we can compare them.
    SortedMap sortedA = new TreeMap(comparator);
    sortedA.putAll(a);
    Iterator<Map.Entry> iterA = sortedA.entrySet().iterator();
    SortedMap sortedB = new TreeMap(comparator);
    sortedB.putAll(b);
    Iterator<Map.Entry> iterB = sortedB.entrySet().iterator();

    // Compare each item.
    while (iterA.hasNext() && iterB.hasNext()) {
      Map.Entry entryA = iterA.next();
      Map.Entry entryB = iterB.next();
View Full Code Here

     * @param theLowEndpoint low endpoint to use
     * @param theHighEndpoint high endpoint to use
     * @return a SortedMap containing the matches or null if no matches
     */
    private SortedMap getBWSubmap(Object theLowEndpoint, Object theHighEndpoint) {
        SortedMap aSubmap = null;
        TreeSet aLocatorSet;

        // anOperator == IndexQuery.BW
        int aComparison = ((Comparable) theLowEndpoint).compareTo(theHighEndpoint);

        if (aComparison == 0) {
            // low endpoint == high endpoint
            // return result set containing just the low endpoint matches, if any
            aLocatorSet = (TreeSet) itsValues.get(theLowEndpoint);
            if (aLocatorSet != null) {
                aSubmap = new TreeMap(MemValueIndexer.ValueComparator.INSTANCE);
                aSubmap.put(theLowEndpoint, aLocatorSet);
            }
        } else {
            if (aComparison < 0) {
                // force computation of next value as STRING if key is String
                // otherwise, next value will be of same type as stored values
                theHighEndpoint = theHighEndpoint instanceof String ? getNextValueOf(theHighEndpoint, STRING) : getNextValueOf(theHighEndpoint);

                if (theHighEndpoint == null) {
                    // return locators in tail map from low endpoint
                    aSubmap = itsValues.tailMap(theLowEndpoint);
                } else {
                    // return locators in sub map inclusive of endpoints
                    aSubmap = itsValues.subMap(theLowEndpoint, theHighEndpoint);
                }
            }
            // else low > high => empty result
        }
        return aSubmap == null || aSubmap.size() == 0 ? null : aSubmap;
    }
View Full Code Here

     *
     * @param theHighEndpoint high endpoint to use
     * @return a SortedMap containing the matches or null if no matches
     */
    private SortedMap getLTSubmap(Object theHighEndpoint) {
        SortedMap aSubmap = itsValues.headMap(theHighEndpoint);
        return aSubmap == null || aSubmap.size() == 0 ? null : aSubmap;
    }
View Full Code Here

     *
     * @param theLowEndpoint high endpoint to use
     * @return a SortedMap containing the matches or null if no matches
     */
    private SortedMap getGEQSubmap(Object theLowEndpoint) {
        SortedMap aSubmap = itsValues.tailMap(theLowEndpoint);
        return aSubmap == null || aSubmap.size() == 0 ? null : aSubmap;
    }
View Full Code Here

          for (int i = 0; i < objectClasses.length; i++) {
            // handle each of the object classes separately since aspects only work on one object class at a time
            String objectClass = objectClasses[i];
            Map /* <String, Map<Integer, Collection<ServiceListener>>> */ objectClassToRankingToListenersMap = (SortedMap) m_sidToObjectClassToRankingToListenersMap.get(sidObject);
            if (objectClassToRankingToListenersMap != null) {
              SortedMap /* Integer, ServiceListener> */ rankingToListenersMap = (SortedMap) objectClassToRankingToListenersMap.get(objectClass);
              if (rankingToListenersMap != null) {
                Iterator iterator = rankingToListenersMap.entrySet().iterator();
                while (iterator.hasNext()) {
                  Entry entry = (Entry) iterator.next();
                  if (ranking <= ((Integer) entry.getKey()).intValue()) {
                    list.addAll((Collection)entry.getValue());
                  }
View Full Code Here

              if (objectClassToRankingToListenersMap == null) {
                objectClassToRankingToListenersMap = new TreeMap();
                m_sidToObjectClassToRankingToListenersMap.put(sidObject, objectClassToRankingToListenersMap);
              }
             
              SortedMap /* Integer, ServiceListener> */ rankingToListenersMap = (SortedMap) objectClassToRankingToListenersMap.get(data.objectClass);
                if (rankingToListenersMap == null) {
                    rankingToListenersMap = new TreeMap();
                    objectClassToRankingToListenersMap.put(data.objectClass, rankingToListenersMap);
                }             
             
              Collection listeners = (Collection) rankingToListenersMap.get(Integer.valueOf(data.ranking));
              if (listeners == null) {
                listeners = new ArrayList();
                rankingToListenersMap.put(Integer.valueOf(data.ranking), listeners);
              }
             
              listeners.add(listener);
                m_listenerToFilterMap.put(listener, filter);
            }
View Full Code Here

          if (data != null) {
            // this index is applicable
            Long sidObject = Long.valueOf(data.serviceId);
                  Map /* <String, Map<Integer, Collection<ServiceListener>>> */ objectClassToRankingToListenersMap = (SortedMap) m_sidToObjectClassToRankingToListenersMap.get(sidObject);
                  if (objectClassToRankingToListenersMap != null) {
                    SortedMap /* Integer, ServiceListener> */ rankingToListenersMap = (SortedMap) objectClassToRankingToListenersMap.get(data.objectClass);
                    if (rankingToListenersMap != null) {
                      Collection listeners = (Collection) rankingToListenersMap.get(Integer.valueOf(data.ranking));
                      if (listeners != null) {
                        listeners.remove(listener);
                      }
                      // cleanup
                      if (listeners.isEmpty()) {
                        rankingToListenersMap.remove(Integer.valueOf(data.ranking));
                      }
                      if (rankingToListenersMap.isEmpty()) {
                        objectClassToRankingToListenersMap.remove(data.objectClass);
                      }
                      if (objectClassToRankingToListenersMap.isEmpty()) {
                        m_sidToObjectClassToRankingToListenersMap.remove(sidObject);
                      }
View Full Code Here

TOP

Related Classes of java.util.SortedMap

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.