/** * 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 lastKey() { if(size() == 0) throw new NoSuchElementException(); try{ TupleBrowser<K,V> b = toKey==null?tree.browse(null):tree.browse(toKey); Tuple<K,V> t = new Tuple<K,V>(); b.getPrevious(t); return t.getKey(); }catch(IOException e){ throw new IOError(e); } }
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); } }
Set<Object> getChildrenNames0(Fqn name) throws IOException Tuple t = new Tuple();
@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; }
tuple = new Tuple<K, V>( null, null );
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; } }
tuple = new Tuple<K, V>( null, null );
Tuple t = new Tuple(); List<Object> removeList = new ArrayList<Object>(); synchronized (tree)
@SuppressWarnings("unchecked") private boolean btreeHas( BTree tree, V key, boolean isGreaterThan ) throws IOException jdbm.helper.Tuple tuple = new jdbm.helper.Tuple();
Tuple<K, V> tuple = new Tuple<K, V>( null, null ); TupleBrowser<K, V> browser = rootPage.find( bTreeHeight, key );
Tuple tuple = new Tuple( null, null ); TupleBrowser browser = rootPage.find( _height, key );
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; } }
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; } }
jdbm.helper.Tuple tuple = new jdbm.helper.Tuple(); TupleBrowser<K, V> browser = tree.browse(); browser.getNext( tuple );