private void prefetch() throws IOException { success = browser.getNext( jdbmTuple ); }
private void prefetch() throws IOException { if ( stepForward ) { success = browser.getNext( jdbmTuple ); } else { success = browser.getPrevious( jdbmTuple ); } }
private void prefetch() throws IOException { if ( doAscending ) { success = browser.getNext( jdbmTuple ); } else { success = browser.getPrevious( jdbmTuple ); } }
/** * 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(""); }
/** * 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; } }
/** * 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; } }
/** * 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; } }
Tuple t = new Tuple(); boolean first = true; while (browser.getNext(t))
@Override Set<Object> getChildrenNames0(Fqn name) throws IOException { Fqn name2 = withDepth(name, name.size() + 1); TupleBrowser browser = tree.browse(name2); Tuple t = new Tuple(); Set<Object> set = new HashSet<Object>(); while (browser.getNext(t)) { Fqn fqn = (Fqn) t.getKey(); if (!fqn.isChildOf(name2)) { break; } set.add(fqn.getLastElement()); } if (set.isEmpty()) { return null; } return Collections.unmodifiableSet(set); }
public K firstKey() { if(size() == 0) throw new NoSuchElementException(); try{ TupleBrowser<K,V> b = fromKey==null?tree.browse():tree.browse(fromKey); Tuple<K,V> t = new Tuple<K,V>(); b.getNext(t); return t.getKey(); }catch(IOException e){ throw new IOError(e); } }
@Override public boolean next() throws LdapException, CursorException { try { if ( browser == null ) { browser = btree.browse(); } if ( browser.getNext( tuple ) ) { return true; } } catch ( IOException e ) { throw new CursorException( e ); } catch ( NoSuchElementException e ) { // ignore, this is due to the call wrapped.prev() // instead of doing a check like if(wrapped.hasNext()) } clearValue(); return false; }
@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; }
boolean gotNextOk = browser.getNext( jdbmTuple ); if ( gotNextOk )
private Object firstKey ( BTree tree ) throws NamingException { jdbm.helper.Tuple tuple = new jdbm.helper.Tuple(); boolean success = false; try { success = tree.browse().getNext( tuple ); if ( success ) { return tuple.getKey(); } else { return null; } } catch ( IOException e ) { LdapNamingException lne = new LdapNamingException( "IO failure while acessing btree: " + e.getMessage(), ResultCodeEnum.OTHER ); lne.setRootCause( e ); throw lne; } }
/** * @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; }
/** * {@inheritDoc} */ public boolean next() throws LdapException, CursorException { checkNotClosed(); try { if ( browser == null ) { browser = btree.browse(); } if ( browser.getNext( tuple ) ) { valueAvailable = true; return true; } else { clearValue(); return false; } } catch ( IOException e ) { throw new CursorException( e ); } }
private boolean btreeHas( BTree tree, Object key ) throws NamingException { jdbm.helper.Tuple tuple = new jdbm.helper.Tuple(); try { TupleBrowser browser = tree.browse( key ); boolean success = browser.getNext( tuple ); if ( success ) { if ( comparator.compareValue( key, tuple.getKey() ) == 0 ) { return true; } } return false; } catch ( IOException e ) { LdapNamingException lne = new LdapNamingException( "IO failure while acessing btree: " + e.getMessage(), ResultCodeEnum.OTHER ); lne.setRootCause( e ); throw lne; } }
while ( browser.getNext( jdbmTuple ) )
private Object removeAll( BTree tree ) throws NamingException { Object first = null; jdbm.helper.Tuple jdbmTuple = new jdbm.helper.Tuple(); TupleBrowser browser; try { browser = tree.browse(); while( browser.getNext( jdbmTuple ) ) { tree.remove( jdbmTuple.getKey() ); if ( first == null ) { first = jdbmTuple.getKey(); } } } catch ( IOException e ) { LdapNamingException lne = new LdapNamingException( "Failed to remove all keys in BTree", ResultCodeEnum.OTHER ); lne.setRootCause( e ); throw lne; } return first; } }