/** * {@inheritDoc} */ public TupleCursor<K, V> browse( ReadTransaction<K, V> transaction, ParentPos<K, V>[] stack, int depth ) throws IOException { stack[depth++] = new ParentPos<K, V>( this, 0 ); Page<K, V> page = children[0].getValue(); return page.browse( transaction, stack, depth ); }
/** * {@inheritDoc} */ public TupleCursor<K, V> browse( K key, ReadTransaction<K, V> transaction, ParentPos<K, V>[] stack, int depth ) throws IOException { int pos = findPos( key ); if ( pos < 0 ) { pos = -pos; } // We first stack the current page stack[depth++] = new ParentPos<K, V>( this, pos ); Page<K, V> page = children[pos].getValue(); return page.browse( key, transaction, stack, depth ); }
/** * {@inheritDoc} */ public TupleCursor<K, V> browseFrom( K key ) throws IOException { // Check that we have a TransactionManager if ( transactionManager == null ) { throw new BTreeCreationException( "We don't have a transactionLManager" ); } ReadTransaction<K, V> transaction = beginReadTransaction(); ParentPos<K, V>[] stack = ( ParentPos<K, V>[] ) Array.newInstance( ParentPos.class, 32 ); try { TupleCursor<K, V> cursor = getRootPage( transaction.getRevision() ).browse( key, transaction, stack, 0 ); return cursor; } catch ( KeyNotFoundException e ) { throw new IOException( e.getMessage() ); } }
/** * {@inheritDoc} */ public TupleCursor<K, V> browseFrom( long revision, K key ) throws IOException, KeyNotFoundException { // Check that we have a TransactionManager if ( transactionManager == null ) { throw new BTreeCreationException( "We don't have a transactionLManager" ); } ReadTransaction<K, V> transaction = beginReadTransaction( revision ); if ( transaction == null ) { return new EmptyTupleCursor<K, V>(); } else { ParentPos<K, V>[] stack = ( ParentPos<K, V>[] ) Array.newInstance( ParentPos.class, 32 ); // And get the cursor TupleCursor<K, V> cursor = getRootPage( transaction.getRevision() ).browse( key, transaction, stack, 0 ); return cursor; } }
/** * {@inheritDoc} */ public TupleCursor<K, V> browse() throws IOException, KeyNotFoundException { // Check that we have a TransactionManager if ( transactionManager == null ) { throw new BTreeCreationException( "We don't have a transactionLManager" ); } ReadTransaction<K, V> transaction = beginReadTransaction(); if ( transaction == null ) { return new EmptyTupleCursor<K, V>(); } else { ParentPos<K, V>[] stack = ( ParentPos<K, V>[] ) Array.newInstance( ParentPos.class, 32 ); TupleCursor<K, V> cursor = getRootPage().browse( transaction, stack, 0 ); // Set the position before the first element cursor.beforeFirst(); return cursor; } }
/** * {@inheritDoc} */ public TupleCursor<K, V> browse( long revision ) throws IOException, KeyNotFoundException { // Check that we have a TransactionManager if ( transactionManager == null ) { throw new BTreeCreationException( "We don't have a transactionLManager" ); } ReadTransaction<K, V> transaction = beginReadTransaction( revision ); if ( transaction == null ) { return new EmptyTupleCursor<K, V>(); } else { ParentPos<K, V>[] stack = ( ParentPos<K, V>[] ) Array.newInstance( ParentPos.class, 32 ); // And get the cursor TupleCursor<K, V> cursor = getRootPage( transaction.getRevision() ).browse( transaction, stack, 0 ); return cursor; } }