Package jdbm.helper

Examples of jdbm.helper.TupleBrowser


             * key argument supplied.  We use this key to advance a browser to
             * that tuple and scan down to lesser Tuples until we hit one
             * that is less than the key argument supplied.  Usually this will
             * be the previous tuple if it exists.
             */
            TupleBrowser browser = bt.browse( tuple.getKey() );

            if ( browser.getPrevious( tuple ) )
            {
                this.closeBrowser( browser );
                return true;
            }

View Full Code Here


    @SuppressWarnings("unchecked")
    private boolean btreeHas( BTree tree, V key, boolean isGreaterThan ) throws IOException
    {
        jdbm.helper.Tuple tuple = new jdbm.helper.Tuple();

        TupleBrowser browser = tree.browse( key );

        try
        {
            if ( isGreaterThan )
            {
                return browser.getNext( tuple );
            }
            else
            {
                if ( browser.getPrevious( tuple ) )
                {
                    return true;
                }
                else
                {
                    /*
                     * getPrevious() above fails which means the browser has is
                     * before the first Tuple of the btree.  A call to getNext()
                     * should work every time.
                     */
                    browser.getNext( tuple );

                    /*
                     * Since the browser is positioned now on the Tuple with the
                     * smallest key we just need to check if it equals this key
                     * which is the only chance for returning true.
View Full Code Here

    @SuppressWarnings("unchecked")
    private ArrayTree<V> convertToArrayTree( BTree bTree ) throws IOException
    {
        ArrayTree<V> avlTree = new ArrayTree<V>( valueComparator );
        TupleBrowser browser = bTree.browse();
        jdbm.helper.Tuple tuple = new jdbm.helper.Tuple();

        while ( browser.getNext( tuple ) )
        {
            avlTree.insert( ( V ) tuple.getKey() );
        }

        this.closeBrowser( browser );
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

                    {
                        @Override
                        public <ReceiverThrowableType extends Throwable> void sendTo( Receiver<? super Reader, ReceiverThrowableType> receiver )
                            throws ReceiverThrowableType, IOException
                        {
                            final TupleBrowser browser = index.browse();
                            final Tuple tuple = new Tuple();

                            while( browser.getNext( tuple ) )
                            {
                                String id = new String( (byte[]) tuple.getKey(), "UTF-8" );

                                Long stateIndex = getStateIndex( id );
View Full Code Here

                    {
                        @Override
                        public <ReceiverThrowableType extends Throwable> void sendTo( Receiver<? super String, ReceiverThrowableType> receiver )
                            throws ReceiverThrowableType, IOException
                        {
                            final TupleBrowser browser = index.browse();
                            final Tuple tuple = new Tuple();

                            while( browser.getNext( tuple ) )
                            {
                                String id = new String( (byte[]) tuple.getKey(), "UTF-8" );

                                Long stateIndex = getStateIndex( id );
View Full Code Here

                            // Lock datastore first
                            lock();

                            try
                            {
                                final TupleBrowser browser = index.browse( offset + 1 );

                                Tuple tuple = new Tuple();

                                while( browser.getNext( tuple ) )
                                {
                                    // Get next transaction
                                    UnitOfWorkDomainEventsValue domainEvents = readTransactionEvents( tuple );

                                    receiver.receive( domainEvents );
View Full Code Here

             * key argument supplied.  We use this key to advance a browser to
             * that tuple and scan down to lesser Tuples until we hit one
             * that is less than the key argument supplied.  Usually this will
             * be the previous tuple if it exists.
             */
            TupleBrowser browser = bt.browse( tuple.getKey() );

            if ( browser.getPrevious( tuple ) )
            {
                this.closeBrowser( browser );
                return true;
            }

View Full Code Here

    @SuppressWarnings("unchecked")
    private boolean btreeHas( BTree tree, V key, boolean isGreaterThan ) throws IOException
    {
        jdbm.helper.Tuple tuple = new jdbm.helper.Tuple();

        TupleBrowser browser = tree.browse( key );

        try
        {
            if ( isGreaterThan )
            {
                return browser.getNext( tuple );
            }
            else
            {
                if ( browser.getPrevious( tuple ) )
                {
                    return true;
                }
                else
                {
                    /*
                     * getPrevious() above fails which means the browser has is
                     * before the first Tuple of the btree.  A call to getNext()
                     * should work every time.
                     */
                    browser.getNext( tuple );

                    /*
                     * Since the browser is positioned now on the Tuple with the
                     * smallest key we just need to check if it equals this key
                     * which is the only chance for returning true.
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.