/** * {@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 long getRevision() { // 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 -1L; } else { try { return transaction.getRevision(); } finally { transaction.close(); } } }
/** * {@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; } }
/** * {@inheritDoc} */ public KeyCursor<K> browseKeys() throws IOException, KeyNotFoundException { // Check that we have a TransactionManager if ( transactionManager == null ) { throw new BTreeCreationException( "We don't have a Transaction Manager" ); } ReadTransaction transaction = beginReadTransaction(); if ( transaction == null ) { return new KeyCursor<K>(); } else { ParentPos<K, K>[] stack = ( ParentPos<K, K>[] ) Array.newInstance( ParentPos.class, 32 ); KeyCursor<K> cursor = getRootPage().browseKeys( transaction, stack, 0 ); // Set the position before the first element cursor.beforeFirst(); return cursor; } }
/** * {@inheritDoc} */ public long getNbElems() { // 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 -1L; } else { try { return transaction.getBtreeHeader().getNbElems(); } finally { transaction.close(); } } }
ReadTransaction<K, V> transaction = beginReadTransaction();
/** * {@inheritDoc} */ public V get( 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(); if ( transaction == null ) { return null; } else { try { return getRootPage( transaction.getRevision() ).get( key ); } finally { transaction.close(); } } }
/** * {@inheritDoc} */ public boolean contains( long revision, K key, V value ) throws IOException, KeyNotFoundException { // Check that we have a TransactionManager if ( transactionManager == null ) { throw new BTreeCreationException( "We don't have a transactionLManager" ); } // Fetch the root page for this revision ReadTransaction<K, V> transaction = beginReadTransaction( revision ); if ( transaction == null ) { return false; } else { try { return getRootPage( transaction.getRevision() ).contains( key, value ); } finally { transaction.close(); } } }
/** * {@inheritDoc} */ public V get( 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 null; } else { try { return getRootPage( transaction.getRevision() ).get( key ); } finally { transaction.close(); } } }
ReadTransaction<K, V> transaction = beginReadTransaction();
ReadTransaction<K, V> transaction = beginReadTransaction( revision );
/** * {@inheritDoc} */ public ValueCursor<V> getValues( 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(); if ( transaction == null ) { return new EmptyValueCursor<V>( 0L ); } else { try { return getRootPage( transaction.getRevision() ).getValues( key ); } finally { transaction.close(); } } }