Skip to content

Commit

Permalink
Removes outdated comment and uses ThreadLocal#withInitial
Browse files Browse the repository at this point in the history
  • Loading branch information
tinwelint committed Oct 10, 2018
1 parent 76290dd commit 83fe858
Showing 1 changed file with 15 additions and 23 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -73,32 +73,24 @@ class ParallelNativeIndexPopulator<KEY extends NativeIndexKey<KEY>,VALUE extends
ParallelNativeIndexPopulator( File baseIndexFile, IndexLayout<KEY,VALUE> layout, NativeIndexPopulatorPartSupplier<KEY,VALUE> partSupplier )
{
this.layout = layout;
this.threadLocalPopulators = new ThreadLocal<ThreadLocalPopulator>()
this.threadLocalPopulators = ThreadLocal.withInitial( () ->
{
/**
* Creates a new part populator. It can be synchronized because it simplifies the implementation
* and virtually all time is spent in PageCache#map method inside populator.create, which is synchronized anyway.
*/
@Override
protected ThreadLocalPopulator initialValue()
if ( closed )
{
if ( closed )
{
throw new IllegalStateException( "Already closed" );
}
if ( merged )
{
throw new IllegalStateException( "Already merged" );
}

File file = new File( baseIndexFile + "-part-" + nextPartId.getAndIncrement() );
NativeIndexPopulator<KEY,VALUE> populator = partSupplier.part( file );
ThreadLocalPopulator tlPopulator = new ThreadLocalPopulator( populator );
partPopulators.add( tlPopulator );
populator.create();
return tlPopulator;
throw new IllegalStateException( "Already closed" );
}
};
if ( merged )
{
throw new IllegalStateException( "Already merged" );
}

File file = new File( baseIndexFile + "-part-" + nextPartId.getAndIncrement() );
NativeIndexPopulator<KEY,VALUE> populator = partSupplier.part( file );
ThreadLocalPopulator tlPopulator = new ThreadLocalPopulator( populator );
partPopulators.add( tlPopulator );
populator.create();
return tlPopulator;
} );
this.completePopulator = partSupplier.part( baseIndexFile );
}

Expand Down

0 comments on commit 83fe858

Please sign in to comment.