BaseRecordManager base = new BaseRecordManager( path );
base.disableTransactions();
CacheRecordManager recMan = new CacheRecordManager( base, new MRU( 1000 ) );
JdbmMasterTable<Entry> master = new JdbmMasterTable<Entry>( recMan, schemaManager );
JdbmIndex index = new JdbmIndex();
index.setAttributeId( attributeType.getName() );
index.setCacheSize( JdbmIndex.DEFAULT_INDEX_CACHE_SIZE );
index.setNumDupLimit( JdbmIndex.DEFAULT_DUPLICATE_LIMIT );
if( indexDirectory == null )
{
indexDirectory = partitionDirectory;
}
index.setWkDirPath( indexDirectory );
index.init( schemaManager, attributeType, indexDirectory );
IndexUtils.printContents( index );
JdbmIndex existenceIdx = new JdbmIndex();
existenceIdx.setAttributeId( ApacheSchemaConstants.APACHE_EXISTENCE_AT_OID );
existenceIdx.setCacheSize( JdbmIndex.DEFAULT_INDEX_CACHE_SIZE );
existenceIdx.setNumDupLimit( JdbmIndex.DEFAULT_DUPLICATE_LIMIT );
existenceIdx.setWkDirPath( partitionDirectory );
existenceIdx.init( schemaManager, schemaManager.lookupAttributeTypeRegistry( ApacheSchemaConstants.APACHE_EXISTENCE_AT_OID ), partitionDirectory );
Cursor<Tuple<Long,Entry>> list = master.cursor();
while ( list.next() )
{
Tuple<Long,Entry> tuple = list.get();
Long id = tuple.getKey();
Entry entry = ( DefaultEntry ) tuple.getValue();
EntryAttribute attr = entry.get( attributeType );
if ( attr == null )
{
continue;
}
for ( int ii = 0; ii < attr.size(); ii++ )
{
index.add( attr.get( ii ).get(), id );
}
existenceIdx.add( attributeType.getOid(), id );
}
index.sync();
index.close();
existenceIdx.sync();
existenceIdx.close();
}