Skip to content

Commit

Permalink
Make the native schema number index respect the index sampling config…
Browse files Browse the repository at this point in the history
…uration

No test because I could not find any way to observe a change in behaviour from this.
  • Loading branch information
chrisvest committed Nov 14, 2017
1 parent 9bafce1 commit 111fd77
Show file tree
Hide file tree
Showing 4 changed files with 34 additions and 13 deletions.
Expand Up @@ -37,6 +37,7 @@
import org.neo4j.kernel.api.index.SchemaIndexProvider;
import org.neo4j.kernel.api.schema.index.IndexDescriptor;
import org.neo4j.kernel.impl.api.index.IndexUpdateMode;
import org.neo4j.kernel.impl.api.index.sampling.IndexSamplingConfig;
import org.neo4j.storageengine.api.schema.IndexReader;

import static org.neo4j.helpers.collection.Iterators.asResourceIterator;
Expand All @@ -47,13 +48,22 @@ public class NativeSchemaNumberIndexAccessor<KEY extends SchemaNumberKey, VALUE
extends NativeSchemaNumberIndex<KEY,VALUE> implements IndexAccessor
{
private final NativeSchemaNumberIndexUpdater<KEY,VALUE> singleUpdater;
private final IndexSamplingConfig samplingConfig;

NativeSchemaNumberIndexAccessor( PageCache pageCache, FileSystemAbstraction fs, File storeFile,
Layout<KEY,VALUE> layout, RecoveryCleanupWorkCollector recoveryCleanupWorkCollector, SchemaIndexProvider.Monitor monitor,
IndexDescriptor descriptor, long indexId ) throws IOException
NativeSchemaNumberIndexAccessor(
PageCache pageCache,
FileSystemAbstraction fs,
File storeFile,
Layout<KEY,VALUE> layout,
RecoveryCleanupWorkCollector recoveryCleanupWorkCollector,
SchemaIndexProvider.Monitor monitor,
IndexDescriptor descriptor,
long indexId,
IndexSamplingConfig samplingConfig ) throws IOException
{
super( pageCache, fs, storeFile, layout, monitor, descriptor, indexId );
singleUpdater = new NativeSchemaNumberIndexUpdater<>( layout.newKey(), layout.newValue() );
this.samplingConfig = samplingConfig;
instantiateTree( recoveryCleanupWorkCollector, NO_HEADER_WRITER );
}

Expand Down Expand Up @@ -95,7 +105,7 @@ public void close() throws IOException
public IndexReader newReader()
{
assertOpen();
return new NativeSchemaNumberIndexReader<>( tree, layout );
return new NativeSchemaNumberIndexReader<>( tree, layout, samplingConfig );
}

@Override
Expand Down
Expand Up @@ -89,8 +89,8 @@ public IndexPopulator getPopulator( long indexId, IndexDescriptor descriptor, In
}

@Override
public IndexAccessor getOnlineAccessor( long indexId, IndexDescriptor descriptor, IndexSamplingConfig samplingConfig )
throws IOException
public IndexAccessor getOnlineAccessor(
long indexId, IndexDescriptor descriptor, IndexSamplingConfig samplingConfig ) throws IOException
{
File storeFile = nativeIndexFileFromIndexId( indexId );
NumberLayout layout;
Expand All @@ -105,8 +105,9 @@ public IndexAccessor getOnlineAccessor( long indexId, IndexDescriptor descriptor
default:
throw new UnsupportedOperationException( "Can not create index accessor of type " + descriptor.type() );
}
return new NativeSchemaNumberIndexAccessor<>( pageCache, fs, storeFile, layout, recoveryCleanupWorkCollector, monitor, descriptor,
indexId );
return new NativeSchemaNumberIndexAccessor<>(
pageCache, fs, storeFile, layout, recoveryCleanupWorkCollector, monitor, descriptor, indexId,
samplingConfig );
}

@Override
Expand Down
Expand Up @@ -35,7 +35,6 @@
import org.neo4j.kernel.api.schema.IndexQuery;
import org.neo4j.kernel.api.schema.IndexQuery.ExactPredicate;
import org.neo4j.kernel.api.schema.IndexQuery.NumberRangePredicate;
import org.neo4j.kernel.configuration.Config;
import org.neo4j.kernel.impl.api.index.sampling.IndexSamplingConfig;
import org.neo4j.storageengine.api.schema.IndexReader;
import org.neo4j.storageengine.api.schema.IndexSampler;
Expand All @@ -47,12 +46,15 @@ class NativeSchemaNumberIndexReader<KEY extends SchemaNumberKey, VALUE extends S
{
private final GBPTree<KEY,VALUE> tree;
private final Layout<KEY,VALUE> layout;
private final IndexSamplingConfig samplingConfig;
private final Set<RawCursor<Hit<KEY,VALUE>,IOException>> openSeekers;

NativeSchemaNumberIndexReader( GBPTree<KEY,VALUE> tree, Layout<KEY,VALUE> layout )
NativeSchemaNumberIndexReader(
GBPTree<KEY,VALUE> tree, Layout<KEY,VALUE> layout, IndexSamplingConfig samplingConfig )
{
this.tree = tree;
this.layout = layout;
this.samplingConfig = samplingConfig;
this.openSeekers = new HashSet<>();
}

Expand All @@ -72,9 +74,8 @@ public IndexSampler createSampler()
// non-unique sampler which scans the index and counts (potentially duplicates, of which there will
// be none in a unique index).

IndexSamplingConfig indexSamplingConfig = new IndexSamplingConfig( Config.defaults() );
FullScanNonUniqueIndexSampler<KEY,VALUE> sampler =
new FullScanNonUniqueIndexSampler<>( tree, layout, indexSamplingConfig );
new FullScanNonUniqueIndexSampler<>( tree, layout, samplingConfig );
return sampler::result;
}

Expand Down
Expand Up @@ -44,7 +44,9 @@
import org.neo4j.kernel.api.index.IndexUpdater;
import org.neo4j.kernel.api.schema.IndexQuery;
import org.neo4j.kernel.api.schema.index.IndexDescriptor;
import org.neo4j.kernel.configuration.Config;
import org.neo4j.kernel.impl.api.index.IndexUpdateMode;
import org.neo4j.kernel.impl.api.index.sampling.IndexSamplingConfig;
import org.neo4j.storageengine.api.schema.IndexReader;
import org.neo4j.storageengine.api.schema.IndexSample;
import org.neo4j.storageengine.api.schema.IndexSampler;
Expand Down Expand Up @@ -86,7 +88,14 @@ public abstract class NativeSchemaNumberIndexAccessorTest<KEY extends SchemaNumb
@Before
public void setupAccessor() throws IOException
{
accessor = new NativeSchemaNumberIndexAccessor<>( pageCache, fs, indexFile, layout, IMMEDIATE, monitor, indexDescriptor, indexId );
IndexSamplingConfig samplingConfig = new IndexSamplingConfig( Config.defaults() );
createAccessorWithSamplingConfig( samplingConfig );
}

private void createAccessorWithSamplingConfig( IndexSamplingConfig samplingConfig ) throws IOException
{
accessor = new NativeSchemaNumberIndexAccessor<>(
pageCache, fs, indexFile, layout, IMMEDIATE, monitor, indexDescriptor, indexId, samplingConfig );
}

@After
Expand Down

0 comments on commit 111fd77

Please sign in to comment.