/** * Creates the master entry table using a Berkeley Db for the backing store. * * @param recMan the jdbm record manager * @throws NamingException if there is an error opening the Db file. */ public JdbmMasterTable(RecordManager recMan) throws NamingException { super( DBF, recMan, BIG_INTEGER_COMPARATOR ); adminTbl = new JdbmTable( "admin", recMan, STRING_COMPARATOR ); String seqValue = ( String ) adminTbl.get( SEQPROP_KEY ); if ( null == seqValue ) { adminTbl.put( SEQPROP_KEY, BigInteger.ZERO.toString() ); } }
/** * {@inheritDoc} */ public long count( PartitionTxn partitionTxn ) throws LdapException { return forward.count( partitionTxn ); }
/** * {@inheritDoc} */ public synchronized void drop( PartitionTxn partitionTxn, K attrVal, String id ) throws LdapException { // The pair to be removed must exists if ( forward.has( partitionTxn, attrVal, id ) ) { forward.remove( partitionTxn, attrVal, id ); if ( withReverse ) { reverse.remove( partitionTxn, id, attrVal ); } } }
/** * @see Index#drop(java.math.BigInteger) */ public void drop( BigInteger entryId ) throws NamingException { NamingEnumeration values = reverse.listValues( entryId ); while ( values.hasMore() ) { forward.remove( values.next(), entryId ); } reverse.remove( entryId ); }
replaced = putRaw( key, value, true ); Object values = getRaw( key ); BTree tree = convertToBTree( set ); BTreeRedirect redirect = new BTreeRedirect( tree.getRecid() ); replaced = putRaw( key, redirect, true ); replaced = putRaw( key, set, true ); BTree tree = getBTree( ( BTreeRedirect ) values ); if ( insertDupIntoBTree( tree, value ) )
return remove( key, value ); Object storedValues = getRaw( key ); putRaw( key, set, true ); return firstValue; BTree tree = getBTree( ( BTreeRedirect ) storedValues ); Object first = null; while ( values.hasMore() ) if ( removeDupFromBTree( tree, val ) )
/** * Get's the current id value from this master database's sequence without * affecting the seq. * * @return the current value. * @throws NamingException if the admin table storing sequences cannot be * read. */ public BigInteger getCurrentId() throws NamingException { BigInteger id = null; synchronized ( adminTbl ) { id = new BigInteger( ( String ) adminTbl.get( SEQPROP_KEY ) ); if ( null == id ) { adminTbl.put( SEQPROP_KEY, BigInteger.ZERO.toString() ); id = BigInteger.ZERO; } } return id; }
DupsContainer<V> values = getDupsContainer( ( byte[] ) bt.find( key ) ); BTree<K, V> tree = getBTree( values.getBTreeRedirect() ); return tree.size() != 0 && btreeHas( tree, val, true );
/** * Deletes a entry from the master table at an index specified by id. * * @param id the BigInteger id of the entry to delete * @return the Attributes of the deleted entry * @throws NamingException if there is a write error on the underlying Db */ public Attributes delete( BigInteger id ) throws NamingException { return ( Attributes ) super.remove( id ); }
/** * Initializes the forward and reverse tables used by this Index. * * @param schemaManager The server schemaManager * @throws IOException if we cannot initialize the forward and reverse * tables * @throws NamingException */ private void initTables( SchemaManager schemaManager ) throws IOException { MatchingRule mr = attributeType.getEquality(); if ( mr == null ) { throw new IOException( I18n.err( I18n.ERR_574, attributeType.getName() ) ); } DnSerializerComparator comp = new DnSerializerComparator( mr.getOid() ); UuidComparator.INSTANCE.setSchemaManager( schemaManager ); DnSerializer dnSerializer = new DnSerializer( schemaManager ); forward = new JdbmTable<Dn, String>( schemaManager, attributeType.getOid() + FORWARD_BTREE, recMan, comp, dnSerializer, UuidSerializer.INSTANCE ); reverse = new JdbmTable<String, Dn>( schemaManager, attributeType.getOid() + REVERSE_BTREE, recMan, UuidComparator.INSTANCE, UuidSerializer.INSTANCE, dnSerializer ); } }
public void beforeKey( K key ) throws LdapException, CursorException { checkNotClosed(); try { browser = table.getBTree().browse( key ); clearValue(); } catch ( IOException e ) { throw new CursorException( e ); } }
BTree bt = table.getBTree( values.getBTreeRedirect() ); dupsCursor = new KeyBTreeCursor<V>( bt, table.getValueComparator() );
BTree tree = table.getBTree( values.getBTreeRedirect() ); dupsCursor = new KeyBTreeCursor<V>( tree, table.getValueComparator() ); if ( table.getKeyComparator().compare( containerTuple.getKey(), key ) == 0 )
DupsContainer<V> values = getDupsContainer( ( byte[] ) bt.find( key ) ); BTree tree = convertToBTree( set ); BTreeRedirect redirect = new BTreeRedirect( tree.getRecordId() ); bt.insert( key, ( V ) BTreeRedirectMarshaller.INSTANCE.serialize( redirect ), true ); BTree tree = getBTree( values.getBTreeRedirect() ); replaced = ( V ) tree.insert( value, Strings.EMPTY_BYTES, true );