Package org.apache.directory.server.xdbm

Examples of org.apache.directory.server.xdbm.IndexEntry


            List<ForwardIndexEntry> recordForwards = new ArrayList<ForwardIndexEntry>();
            IndexCursor<Long, Entry, Long> childList = db.list( id );

            while ( childList.next() )
            {
                IndexEntry old = childList.get();
                ForwardIndexEntry newRec = new ForwardIndexEntry();
                newRec.copy( old );
                recordForwards.add( newRec );
            }

            childList.close();

            Iterator list = recordForwards.iterator();

            while ( list.hasNext() )
            {
                IndexEntry rec = ( IndexEntry ) list.next();

                if ( engine != null && exprNode != null )
                {
                    if ( db.getChildCount( (Long)rec.getId() ) == 0 )
                    {
                        Evaluator evaluator = engine.evaluator( exprNode );
                       
                        if ( evaluator.evaluate( rec ) )
                        {
                            Entry newEntry = db.lookup( (Long)rec.getId() );
                            EntryNode child = new EntryNode( ( Long ) rec.getId(), this, db, newEntry, map, exprNode,
                                engine );
                            children.add( child );
                        }
                        else
                        {
                            continue;
                        }
                    }
                    else
                    {
                        Entry newEntry = db.lookup( (Long)rec.getId() );
                        EntryNode child = new EntryNode( ( Long ) rec.getId(), this, db, newEntry, map, exprNode,
                            engine );
                        children.add( child );
                    }
                }
                else
                {
                    Entry newEntry = db.lookup( ( Long ) rec.getId() );
                    EntryNode child = new EntryNode( ( Long ) rec.getId(), this, db, newEntry, map );
                    children.add( child );
                }
            }
        }
        catch ( Exception e )
View Full Code Here


            List<ForwardIndexEntry> recordForwards = new ArrayList<ForwardIndexEntry>();
            IndexCursor<Long, ServerEntry, Long> childList = db.list( id );

            while ( childList.next() )
            {
                IndexEntry old = childList.get();
                ForwardIndexEntry newRec = new ForwardIndexEntry();
                newRec.copy( old );
                recordForwards.add( newRec );
            }

            childList.close();

            Iterator list = recordForwards.iterator();

            while ( list.hasNext() )
            {
                IndexEntry rec = ( IndexEntry ) list.next();

                if ( engine != null && exprNode != null )
                {
                    if ( db.getChildCount( rec.getId() ) == 0 )
                    {
                        Evaluator evaluator = engine.evaluator( exprNode );
                        if ( evaluator.evaluateId( rec.getId() ) )
                        {
                            ServerEntry newEntry = db.lookup( rec.getId() );
                            EntryNode child = new EntryNode( ( Long ) rec.getId(), this, db, newEntry, map, exprNode,
                                engine );
                            children.add( child );
                        }
                        else
                        {
                            continue;
                        }
                    }
                    else
                    {
                        ServerEntry newEntry = db.lookup( rec.getId() );
                        EntryNode child = new EntryNode( ( Long ) rec.getId(), this, db, newEntry, map, exprNode,
                            engine );
                        children.add( child );
                    }
                }
                else
                {
                    ServerEntry newEntry = db.lookup( ( Long ) rec.getId() );
                    EntryNode child = new EntryNode( ( Long ) rec.getId(), this, db, newEntry, map );
                    children.add( child );
                }
            }
        }
        catch ( Exception e )
View Full Code Here

            recordForward.setId( id );
            list.before( recordForward );

            while ( list.next() )
            {
                IndexEntry rec = list.get();
                String val = rec.getValue().toString();
                String attrId = index.getAttribute().getName();
                EntryAttribute attr = entry.get( attrId );

                if ( attr == null )
                {
                    attr = new DefaultClientAttribute( attrId );
                }

                attr.add( val );
                entry.put( attr );
            }
        }

        // Get all existence mappings for this id creating a special key
        // that looks like so 'existence[attribute]' and the value is set to id
        IndexCursor<String, Object, Long> list = store.getPresenceIndex().reverseCursor();
        ForwardIndexEntry recordForward = new ForwardIndexEntry();
        recordForward.setId( id );
        list.before( recordForward );
        StringBuffer val = new StringBuffer();

        while ( list.next() )
        {
            IndexEntry rec = list.get();
            val.append( "_existence[" );
            val.append( rec.getValue().toString() );
            val.append( "]" );

            String valStr = val.toString();
            EntryAttribute attr = entry.get( valStr );

            if ( attr == null )
            {
                attr = new DefaultClientAttribute( valStr );
            }

            attr.add( rec.getId().toString() );
            entry.put( attr );
            val.setLength( 0 );
        }

        // Get all parent child mappings for this entry as the parent using the
        // key 'child' with many entries following it.
        IndexCursor<Long, Object, Long> children = store.getOneLevelIndex().forwardCursor();
        ForwardIndexEntry longRecordForward = new ForwardIndexEntry();
        recordForward.setId( id );
        children.before( longRecordForward );

        EntryAttribute childAttr = new DefaultClientAttribute( "_child" );
        entry.put( childAttr );

        while ( children.next() )
        {
            IndexEntry rec = children.get();
            childAttr.add( rec.getId().toString() );
        }

        return entry;
    }
View Full Code Here

        DefaultTableModel tableModel = new DefaultTableModel( cols, 0 );
        Object[] row = new Object[2];
        int count = 0;
        while ( cursor.next() && count < limitMax )
        {
            IndexEntry rec = ( IndexEntry ) cursor.get();
            row[0] = rec.getId();
            row[1] = partition.getEntryDn( ( Long ) row[0] );
            tableModel.addRow( row );
            count++;
        }
View Full Code Here

        boolean hasPrevious = cursor.previous();

        if ( hasPrevious )
        {
            IndexEntry entry = cursor.get();

            if ( ( ( ParentIdAndRdn ) entry.getTuple().getKey() ).getParentId().equals( parentId ) )
            {
                prefetched = entry;
                return true;
            }
        }
View Full Code Here

        boolean hasNext = cursor.next();

        if ( hasNext )
        {
            IndexEntry cursorEntry = cursor.get();
            IndexEntry<String, String> entry = new IndexEntry();
            entry.setId( ( String ) cursorEntry.getId() );
            entry.setKey( ( ( ParentIdAndRdn ) cursorEntry.getTuple().getKey() ).getParentId() );

            if ( entry.getKey().equals( parentId ) )
            {
                prefetched = entry;
                return true;
            }
        }
View Full Code Here

        boolean hasPrevious = currentCursor.previous();

        if ( hasPrevious )
        {
            IndexEntry entry = currentCursor.get();

            if ( ( ( ParentIdAndRdn ) entry.getTuple().getKey() ).getParentId().equals( currentParentId ) )
            {
                prefetched = entry;
                return true;
            }
        }
View Full Code Here

            // too memory consuming.
            // The idea is to use a ChildrenCursor each time we have an entry with chidren,
            // and process recursively.
            if ( hasNext )
            {
                IndexEntry cursorEntry = currentCursor.get();
                ParentIdAndRdn parentIdAndRdn = ( ( ParentIdAndRdn ) ( cursorEntry.getKey() ) );

                // Check that we aren't out of the cursor's limit
                if ( !parentIdAndRdn.getParentId().equals( currentParentId ) )
                {
                    // Ok, we went too far. Unstack the cursor and return
                    finished = cursorStack.size() == 0;

                    if ( !finished )
                    {
                        currentCursor.close();
                        currentCursor = ( Cursor<IndexEntry<ParentIdAndRdn, String>> ) cursorStack.pop();
                        currentParentId = ( String ) parentIdStack.pop();
                    }

                    // And continue...
                }
                else
                {
                    // We have a candidate, it will be returned.
                    if ( topLevel )
                    {
                        prefetched = new IndexEntry();
                        prefetched.setId( cursorEntry.getId() );
                        prefetched.setKey( baseId );
                    }
                    else
                    {
                        prefetched = cursorEntry;
                    }

                    // Check if the current entry has children or not.
                    if ( parentIdAndRdn.getNbDescendants() > 0 )
                    {
                        String newParentId = ( String ) cursorEntry.getId();

                        // Yes, then create a new cursor and go down one level
                        Cursor<IndexEntry<ParentIdAndRdn, String>> cursor = db.getRdnIndex().forwardCursor();

                        IndexEntry<ParentIdAndRdn, String> startingPos = new IndexEntry<ParentIdAndRdn, String>();
View Full Code Here

        assertFalse( cursor.previous() );
        assertFalse( cursor.available() );

        try
        {
            cursor.after( new IndexEntry() );
            fail( "should fail with UnsupportedOperationException " );
        }
        catch ( UnsupportedOperationException uoe )
        {
        }

        try
        {
            cursor.before( new IndexEntry() );
            fail( "should fail with UnsupportedOperationException " );
        }
        catch ( UnsupportedOperationException uoe )
        {
        }
View Full Code Here

        DefaultTableModel tableModel = new DefaultTableModel( cols, 0 );
        Object[] row = new Object[2];
        int count = 0;
        while ( cursor.next() && count < limitMax )
        {
            IndexEntry rec = ( IndexEntry ) cursor.get();
            row[0] = rec.getId();
            row[1] = partition.getEntryDn( ( Long ) row[0] );
            tableModel.addRow( row );
            count++;
        }
View Full Code Here

TOP

Related Classes of org.apache.directory.server.xdbm.IndexEntry

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.