/** * {@inheritDoc} */ public Tuple<K, V> findLeftMost() throws IOException { K key = keys[0].getKey(); boolean isSubTree = ( btree.getType() == PERSISTED_SUB ); if ( isSubTree ) { return new Tuple<K, V>( key, null ); } ValueCursor<V> cursor = values[0].getCursor(); try { cursor.beforeFirst(); if ( cursor.hasNext() ) { return new Tuple<K, V>( key, cursor.next() ); } else { // Null value return new Tuple<K, V>( key, null ); } } finally { cursor.close(); } }
/** * {@inheritDoc} */ public Tuple<K, V> findRightMost() throws EndOfFileExceededException, IOException { K key = keys[nbElems - 1].getKey(); boolean isSubTree = ( btree.getType() == PERSISTED_SUB ); if ( isSubTree ) { return new Tuple<K, V>( key, null ); } ValueCursor<V> cursor = values[nbElems - 1].getCursor(); try { cursor.afterLast(); if ( cursor.hasPrev() ) { return new Tuple<K, V>( key, cursor.prev() ); } else { // Null value return new Tuple<K, V>( key, null ); } } finally { cursor.close(); } }
/** * {@inheritDoc} */ public V get( K key ) throws KeyNotFoundException, IOException { int pos = findPos( key ); if ( pos < 0 ) { ValueHolder<V> valueHolder = values[-( pos + 1 )]; ValueCursor<V> cursor = valueHolder.getCursor(); cursor.beforeFirst(); if ( cursor.hasNext() ) { V value = cursor.next(); return value; } else { return null; } } else { throw KeyNotFoundException.INSTANCE; } }
/** * {@inheritDoc} */ public V get( K key ) throws KeyNotFoundException, IOException { int pos = findPos( key ); if ( pos < 0 ) { InMemoryValueHolder<V> valueHolder = ( InMemoryValueHolder<V> ) values[-( pos + 1 )]; V value = valueHolder.getCursor().next(); return value; } else { throw KeyNotFoundException.INSTANCE; } }
/** * {@inheritDoc} */ public void close( Exception reason ) throws IOException { if ( IS_DEBUG ) { LOG_CURSOR.debug( "Closing KeyTupleArrayCursor {}", this ); } if ( wrapped != null ) { wrapped.close(); } super.close( reason ); }
return dupHolder.hasNext();
if ( parentPos.valueCursor.hasPrev() )
parentPos.valueCursor.afterLast(); parentPos.pos = AFTER_LAST;
parentPos.valueCursor.beforeFirst();
/** * {@inheritDoc} */ public boolean next() throws LdapException, CursorException { checkNotClosed(); try { if ( wrapped.hasNext() ) { returnedTuple.setKey( key ); returnedTuple.setValue( wrapped.next() ); valueAvailable = true; return true; } else { clearValue(); return false; } } catch ( IOException e ) { throw new CursorException( e ); } }
/** * {@inheritDoc} */ public boolean previous() throws LdapException, CursorException { checkNotClosed(); try { if ( wrapped.hasPrev() ) { returnedTuple.setKey( key ); returnedTuple.setValue( wrapped.prev() ); valueAvailable = true; return true; } else { clearValue(); return false; } } catch ( IOException e ) { throw new CursorException( e ); } }
/** * {@inheritDoc} */ public Tuple<K, V> findLeftMost() throws IOException { V val = null; val = values[0].getCursor().next(); return new Tuple<K, V>( getKey( 0 ), val ); }