Package jdbm.helper

Examples of jdbm.helper.TupleBrowser


      }
   }

   private Set<Object> getChildrenNames0(Fqn name) throws IOException
   {
      TupleBrowser browser = tree.browse(name);
      Tuple t = new Tuple();

      if (browser.getNext(t))
      {
         if (!t.getValue().equals(NODE))
         {
            log.trace(" not a node");
            return null;
         }
      }
      else
      {
         log.trace(" no nodes");
         return null;
      }

      Set<Object> set = new HashSet<Object>();

      // Want only /a/b/c/X nodes
      int depth = name.size() + 1;
      while (browser.getNext(t))
      {
         Fqn fqn = (Fqn) t.getKey();
         int size = fqn.size();
         if (size < depth)
         {
View Full Code Here


      Tuple t = new Tuple();
      Map map = new HashMap();

      synchronized (tree)
      {
         TupleBrowser browser = tree.browse(keys);
         while (browser.getNext(t))
         {
            Fqn fqn = (Fqn) t.getKey();
            if (!fqn.isChildOf(keys))
            {
               break;
View Full Code Here

      {
         log.trace("erase " + name + " self=" + self);
      }
      synchronized (tree)
      {
         TupleBrowser browser = tree.browse(name);
         Tuple t = new Tuple();
         if (browser.getNext(t) && self)
         {
            tree.remove(t.getKey());
         }

         while (browser.getNext(t))
         {
            Fqn fqn = (Fqn) t.getKey();
            if (!fqn.isChildOf(name))
            {
               break;
View Full Code Here

   /**
    * Dumps the tree past the key to debug.
    */
   public void dump(Object key) throws IOException
   {
      TupleBrowser browser = tree.browse(key);
      Tuple t = new Tuple();
      log.debug("contents: " + key);
      while (browser.getNext(t))
      {
         log.debug(t.getKey() + "\t" + t.getValue());
      }
      log.debug("");
   }
View Full Code Here

            // lets iterate through all IDs from the

            //Tuple tuple = new Tuple();
            Tuple tuple = getOrderedIndex().findGreaterOrEqual(lastAckedSequenceNumber);

            TupleBrowser iter = getOrderedIndex().browse();
            while (iter.getNext(tuple)) {
                Long sequenceNumber = (Long) tuple.getKey();
                if (sequenceNumber.compareTo(lastAckedSequenceNumber) > 0) {
                    ActiveMQMessage message = null;

                    // TODO we could probably tune this some more since we have tuple.getValue() already
View Full Code Here

    }

    public synchronized void recover(QueueMessageContainer container) throws JMSException {
        try {
            Tuple tuple = new Tuple();
            TupleBrowser iter = getOrderedIndex().browse();
            while (iter.getNext(tuple)) {
                Long key = (Long) tuple.getKey();
                MessageIdentity messageIdentity = null;
                if (key != null) {
                    String messageID = (String) tuple.getValue();
                    if (messageID != null) {
View Full Code Here

    public synchronized void start() throws JMSException {
        try {
            // lets iterate through all IDs from the
            Tuple tuple = new Tuple();
            Long lastSequenceNumber = null;
            TupleBrowser iter = getOrderedIndex().browse();
            while (iter.getNext(tuple)) {
                lastSequenceNumber = (Long) tuple.getKey();
            }
            if (lastSequenceNumber != null) {
                this.lastSequenceNumber = lastSequenceNumber.longValue();
                if (log.isDebugEnabled()) {
View Full Code Here

     */
    protected Object findSequenceNumber(String messageID) throws IOException, AlreadyClosedException {
        log.warn("Having to table scan to find the sequence number for messageID: " + messageID);

        Tuple tuple = new Tuple();
        TupleBrowser iter = getOrderedIndex().browse();
        while (iter.getNext(tuple)) {
            Object value = tuple.getValue();
            if (messageID.equals(value)) {
                return tuple.getKey();
            }
        }
View Full Code Here

            }
   
            // Less than searches occur below and are not as efficient or easy.
            // We need to scan up from the begining if findGreaterOrEqual failed
            // or scan down if findGreaterOrEqual succeed.
            TupleBrowser browser = null;
            if ( null == tuple )
            {
                // findGreaterOrEqual failed so we create a tuple and scan from
                // the lowest values up via getNext comparing each key to key
                tuple = new jdbm.helper.Tuple();
                browser = bt.browse();
   
                // We should at most have to read one key.  If 1st key is not
                // less than or equal to key then all keys are > key
                // since the keys are assorted in ascending order based on the
                // comparator.
                while ( browser.getNext( tuple ) )
                {
                    if ( comparator.compareKey( tuple.getKey(), key )
                        <= 0 )
                    {
                        return true;
                    }

                    return false;
                }
            }
            else
            {
                // findGreaterOrEqual succeeded so use the existing tuple and
                // scan the down from the highest key less than key via
                // getPrevious while comparing each key to key.
                browser = bt.browse( tuple.getKey() );
   
                // The above call positions the browser just before the given
                // key so we need to step forward once then back.  Remember this
                // key represents a key greater than or equal to key.
                if ( comparator.compareKey( tuple.getKey(), key ) <= 0 )
                {
                    return true;
                }
               
                browser.getNext( tuple );
   
                // We should at most have to read one key, but we don't short
                // the search as in the search above first because the chance of
                // unneccessarily looping is nil since values get smaller.
                while ( browser.getPrevious( tuple ) )
                {
                    if ( comparator.compareKey( tuple.getKey(), key )
                        <= 0 )
                    {
                        return true;
View Full Code Here

                 * key.  If it does then we do nothing feeding in the browser
                 * to the NoDupsCursor.  If it does not we call getPrevious and
                 * pass it into the NoDupsCursor constructor.
                 */
                jdbm.helper.Tuple tuple = new jdbm.helper.Tuple();
                TupleBrowser browser = bt.browse( key );
               
                if ( browser.getNext( tuple ) )
                {
                    Object greaterKey = tuple.getKey();
                   
                    if ( 0 != comparator.compareKey( key, greaterKey ) )
                    {
                        // Make sure we don't return greaterKey in cursor
                        browser.getPrevious( tuple );
                    }
                }

                // If greaterKey != key above then it will not be returned.
                list = new NoDupsEnumeration(
View Full Code Here

TOP

Related Classes of jdbm.helper.TupleBrowser

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.