@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() ); } return avlTree; }
/** * @see TupleBrowser#getPrevious(Tuple) */ public boolean getPrevious( Tuple tuple ) throws NamingException { boolean isSuccess = false; synchronized ( jdbmTuple ) { try { isSuccess = jdbmBrowser.getPrevious( jdbmTuple ); } catch ( IOException ioe ) { NamingException ne = new NamingException( "Failed on call to jdbm TupleBrowser.getPrevious()" ); ne.setRootCause( ioe ); throw ne; } if ( isSuccess ) { tuple.setKey( jdbmTuple.getKey() ); tuple.setValue( jdbmTuple.getValue() ); } } return isSuccess; } }
@Override public boolean available() { return tuple.getKey() != null; }
/** * Find the value associated with the given key, or the entry immediately * following this key in the ordered BTree. * * @param key Lookup key. * @return Value associated with the key, or a greater entry, or null if no * greater entry was found. */ public synchronized Tuple<K,V> findGreaterOrEqual( K key ) throws IOException { Tuple<K,V> tuple; TupleBrowser<K,V> browser; if ( key == null ) { // there can't be a key greater than or equal to "null" // because null is considered an infinite key. return null; } tuple = new Tuple<K,V>( null, null ); browser = browse( key ); if ( browser.getNext( tuple ) ) { return tuple; } else { return null; } }
/** * @see TupleBrowser#getNext(org.apache.directory.server.core.partition.impl.btree.Tuple) */ public boolean getNext( Tuple tuple ) throws NamingException { boolean isSuccess = false; synchronized ( jdbmTuple ) { try { isSuccess = jdbmBrowser.getNext( jdbmTuple ); } catch ( IOException ioe ) { NamingException ne = new NamingException( "Failed on call to jdbm TupleBrowser.getNext()" ); ne.setRootCause( ioe ); throw ne; } if ( isSuccess ) { tuple.setKey( jdbmTuple.getKey() ); tuple.setValue( jdbmTuple.getValue() ); } } return isSuccess; }
/** * Find the value associated with the given key, or the entry immediately * following this key in the ordered BTree. * * @param key Lookup key. * @return Value associated with the key, or a greater entry, or null if no * greater entry was found. */ public synchronized Tuple<K, V> findGreaterOrEqual( K key ) throws IOException { Tuple<K, V> tuple; TupleBrowser<K, V> browser; if ( key == null ) { // there can't be a key greater than or equal to "null" // because null is considered an infinite key. return null; } tuple = new Tuple<K, V>( null, null ); browser = browse( key ); if ( browser.getNext( tuple ) ) { return tuple; } else { return null; } }
public Object next() { if ( ! success ) { throw new NoSuchElementException(); } Object next = jdbmTuple.getKey(); try { prefetch(); } catch ( IOException e ) { throw new NoSuchElementException( "Failure on btree: " + e.getMessage() ); } return next; }
/** * Find the value associated with the given key, or the entry immediately * following this key in the ordered BTree. * * @param key Lookup key. * @return Value associated with the key, or a greater entry, or null if no * greater entry was found. */ public synchronized Tuple findGreaterOrEqual( Object key ) throws IOException { Tuple tuple; TupleBrowser browser; if ( key == null ) { // there can't be a key greater than or equal to "null" // because null is considered an infinite key. return null; } tuple = new Tuple( null, null ); browser = browse( key ); if ( browser.getNext( tuple ) ) { return tuple; } else { return null; } }