Skip to content

Commit

Permalink
Label scan store is no longer a kernel extension
Browse files Browse the repository at this point in the history
As there is only one label scan store implementation
there is no need to keep it around as a kernel extension.

Remove
 - LabelScanStoreProvider
 - NativeLabelScanStoreExtension
 - LabelIndex enum in settings

Instead of being loaded as a kernel extension label scan store
is constructed in RecordStorageEngine.

DynamicIndexStoreView that decorate NeoStoreIndexStoreView
with the possibility to utilize LabelScanStore for some operations
used to do this by extending NeoStoreIndexStoreView. This
created a circular dependency that went like

LabelScanStore -> FullLabelStream -> IndexStoreView -> LabelScanStore

This dependency is broken apart by letting DynamicIndexStoreView
delegate to NeoStoreIndexStoreView instead of extending it.
This makes it possible for NativeLabelScanStore to use
NeoStoreIndexStoreView instead of DynamicIndexStoreView.
  • Loading branch information
burqen committed Jul 24, 2017
1 parent c941044 commit ab9c07e
Show file tree
Hide file tree
Showing 46 changed files with 261 additions and 1,001 deletions.
Expand Up @@ -36,7 +36,6 @@
import org.neo4j.consistency.statistics.VerboseStatistics; import org.neo4j.consistency.statistics.VerboseStatistics;
import org.neo4j.function.Suppliers; import org.neo4j.function.Suppliers;
import org.neo4j.graphdb.factory.GraphDatabaseSettings; import org.neo4j.graphdb.factory.GraphDatabaseSettings;
import org.neo4j.graphdb.factory.GraphDatabaseSettings.LabelIndex;
import org.neo4j.helpers.progress.ProgressMonitorFactory; import org.neo4j.helpers.progress.ProgressMonitorFactory;
import org.neo4j.index.internal.gbptree.RecoveryCleanupWorkCollector; import org.neo4j.index.internal.gbptree.RecoveryCleanupWorkCollector;
import org.neo4j.io.fs.DefaultFileSystemAbstraction; import org.neo4j.io.fs.DefaultFileSystemAbstraction;
Expand All @@ -52,9 +51,9 @@
import org.neo4j.kernel.extension.KernelExtensions; import org.neo4j.kernel.extension.KernelExtensions;
import org.neo4j.kernel.extension.dependency.HighestSelectionStrategy; import org.neo4j.kernel.extension.dependency.HighestSelectionStrategy;
import org.neo4j.kernel.impl.api.index.IndexStoreView; import org.neo4j.kernel.impl.api.index.IndexStoreView;
import org.neo4j.kernel.impl.api.scan.LabelScanStoreProvider; import org.neo4j.kernel.impl.api.scan.FullStoreChangeStream;
import org.neo4j.kernel.impl.index.labelscan.NativeLabelScanStore;
import org.neo4j.kernel.impl.locking.LockService; import org.neo4j.kernel.impl.locking.LockService;
import org.neo4j.kernel.impl.logging.SimpleLogService;
import org.neo4j.kernel.impl.pagecache.ConfiguringPageCacheFactory; import org.neo4j.kernel.impl.pagecache.ConfiguringPageCacheFactory;
import org.neo4j.kernel.impl.spi.KernelContext; import org.neo4j.kernel.impl.spi.KernelContext;
import org.neo4j.kernel.impl.spi.SimpleKernelContext; import org.neo4j.kernel.impl.spi.SimpleKernelContext;
Expand Down Expand Up @@ -194,7 +193,7 @@ public Result runFullConsistencyCheck( final File storeDir, Config config, Progr
final boolean verbose, CheckConsistencyConfig checkConsistencyConfig ) final boolean verbose, CheckConsistencyConfig checkConsistencyConfig )
throws ConsistencyCheckIncompleteException throws ConsistencyCheckIncompleteException
{ {
return runFullConsistencyCheck( storeDir, config, progressFactory, logProvider, fileSystem, pageCache, return runFullConsistencyCheck( storeDir, config, progressFactory, logProvider, fileSystem, pageCache,
verbose, defaultReportDir( config, storeDir ), checkConsistencyConfig ); verbose, defaultReportDir( config, storeDir ), checkConsistencyConfig );
} }


Expand All @@ -215,8 +214,7 @@ public Result runFullConsistencyCheck( final File storeDir, Config config, Progr
{ {
Log log = logProvider.getLog( getClass() ); Log log = logProvider.getLog( getClass() );
config = config.with( stringMap( config = config.with( stringMap(
GraphDatabaseSettings.read_only.name(), TRUE, GraphDatabaseSettings.read_only.name(), TRUE ) );
GraphDatabaseSettings.label_index.name(), LabelIndex.AUTO.name() ) );
StoreFactory factory = new StoreFactory( storeDir, config, StoreFactory factory = new StoreFactory( storeDir, config,
new DefaultIdGeneratorFactory( fileSystem ), pageCache, fileSystem, logProvider ); new DefaultIdGeneratorFactory( fileSystem ), pageCache, fileSystem, logProvider );


Expand All @@ -240,16 +238,18 @@ public Result runFullConsistencyCheck( final File storeDir, Config config, Progr
{ {
IndexStoreView indexStoreView = new NeoStoreIndexStoreView( LockService.NO_LOCK_SERVICE, neoStores ); IndexStoreView indexStoreView = new NeoStoreIndexStoreView( LockService.NO_LOCK_SERVICE, neoStores );
Dependencies dependencies = new Dependencies(); Dependencies dependencies = new Dependencies();
dependencies.satisfyDependencies( config, fileSystem, new SimpleLogService( logProvider, logProvider ),
indexStoreView, pageCache, new Monitors(), RecoveryCleanupWorkCollector.IMMEDIATE );
KernelContext kernelContext = new SimpleKernelContext( storeDir, UNKNOWN, dependencies ); KernelContext kernelContext = new SimpleKernelContext( storeDir, UNKNOWN, dependencies );
KernelExtensions extensions = life.add( new KernelExtensions( KernelExtensions extensions = life.add( new KernelExtensions(
kernelContext, (Iterable) load( KernelExtensionFactory.class ), dependencies, ignore() ) ); kernelContext, (Iterable) load( KernelExtensionFactory.class ), dependencies, ignore() ) );
life.start(); life.start();
LabelScanStore labelScanStore = life.add( extensions.resolveDependency( LabelScanStoreProvider.class ).getLabelScanStore() );
SchemaIndexProvider indexes = life.add( extensions.resolveDependency( SchemaIndexProvider.class, SchemaIndexProvider indexes = life.add( extensions.resolveDependency( SchemaIndexProvider.class,
HighestSelectionStrategy.getInstance() ) ); HighestSelectionStrategy.getInstance() ) );


LabelScanStore labelScanStore =
new NativeLabelScanStore( pageCache, storeDir, FullStoreChangeStream.EMPTY, true, new Monitors(),
RecoveryCleanupWorkCollector.IMMEDIATE );
life.add( labelScanStore );

int numberOfThreads = defaultConsistencyCheckThreadsNumber(); int numberOfThreads = defaultConsistencyCheckThreadsNumber();
Statistics statistics; Statistics statistics;
StoreAccess storeAccess; StoreAccess storeAccess;
Expand Down
Expand Up @@ -50,17 +50,13 @@
import org.neo4j.kernel.api.index.SchemaIndexProvider; import org.neo4j.kernel.api.index.SchemaIndexProvider;
import org.neo4j.kernel.api.labelscan.LabelScanStore; import org.neo4j.kernel.api.labelscan.LabelScanStore;
import org.neo4j.kernel.configuration.Config; import org.neo4j.kernel.configuration.Config;
import org.neo4j.kernel.extension.KernelExtensionFactory;
import org.neo4j.kernel.extension.KernelExtensions;
import org.neo4j.kernel.impl.api.TransactionRepresentationCommitProcess; import org.neo4j.kernel.impl.api.TransactionRepresentationCommitProcess;
import org.neo4j.kernel.impl.api.TransactionToApply; import org.neo4j.kernel.impl.api.TransactionToApply;
import org.neo4j.kernel.impl.api.index.IndexStoreView; import org.neo4j.kernel.impl.api.index.IndexStoreView;
import org.neo4j.kernel.impl.api.scan.LabelScanStoreProvider; import org.neo4j.kernel.impl.api.scan.FullLabelStream;
import org.neo4j.kernel.impl.factory.OperationalMode; import org.neo4j.kernel.impl.factory.OperationalMode;
import org.neo4j.kernel.impl.index.labelscan.NativeLabelScanStore;
import org.neo4j.kernel.impl.locking.LockService; import org.neo4j.kernel.impl.locking.LockService;
import org.neo4j.kernel.impl.logging.SimpleLogService;
import org.neo4j.kernel.impl.spi.KernelContext;
import org.neo4j.kernel.impl.spi.SimpleKernelContext;
import org.neo4j.kernel.impl.storageengine.impl.recordstorage.RecordStorageEngine; import org.neo4j.kernel.impl.storageengine.impl.recordstorage.RecordStorageEngine;
import org.neo4j.kernel.impl.store.NeoStores; import org.neo4j.kernel.impl.store.NeoStores;
import org.neo4j.kernel.impl.store.NodeLabelsField; import org.neo4j.kernel.impl.store.NodeLabelsField;
Expand All @@ -78,9 +74,7 @@
import org.neo4j.kernel.impl.transaction.log.TransactionIdStore; import org.neo4j.kernel.impl.transaction.log.TransactionIdStore;
import org.neo4j.kernel.impl.transaction.state.storeview.NeoStoreIndexStoreView; import org.neo4j.kernel.impl.transaction.state.storeview.NeoStoreIndexStoreView;
import org.neo4j.kernel.impl.transaction.tracing.CommitEvent; import org.neo4j.kernel.impl.transaction.tracing.CommitEvent;
import org.neo4j.kernel.impl.util.Dependencies;
import org.neo4j.kernel.internal.GraphDatabaseAPI; import org.neo4j.kernel.internal.GraphDatabaseAPI;
import org.neo4j.kernel.lifecycle.LifeSupport;
import org.neo4j.kernel.monitoring.Monitors; import org.neo4j.kernel.monitoring.Monitors;
import org.neo4j.logging.FormattedLogProvider; import org.neo4j.logging.FormattedLogProvider;
import org.neo4j.logging.LogProvider; import org.neo4j.logging.LogProvider;
Expand All @@ -95,9 +89,6 @@


import static java.lang.System.currentTimeMillis; import static java.lang.System.currentTimeMillis;
import static org.neo4j.consistency.ConsistencyCheckService.defaultConsistencyCheckThreadsNumber; import static org.neo4j.consistency.ConsistencyCheckService.defaultConsistencyCheckThreadsNumber;
import static org.neo4j.helpers.Service.load;
import static org.neo4j.kernel.extension.UnsatisfiedDependencyStrategies.ignore;
import static org.neo4j.kernel.impl.factory.DatabaseInfo.UNKNOWN;


public abstract class GraphStoreFixture extends ConfigurablePageCacheRule implements TestRule public abstract class GraphStoreFixture extends ConfigurablePageCacheRule implements TestRule
{ {
Expand Down Expand Up @@ -187,29 +178,18 @@ public DirectStoreAccess directStoreAccess()
new NeoStoreIndexStoreView( LockService.NO_LOCK_SERVICE, nativeStores.getRawNeoStores() ); new NeoStoreIndexStoreView( LockService.NO_LOCK_SERVICE, nativeStores.getRawNeoStores() );
RecoveryCleanupWorkCollector recoveryCleanupWorkCollector = RecoveryCleanupWorkCollector.IMMEDIATE; RecoveryCleanupWorkCollector recoveryCleanupWorkCollector = RecoveryCleanupWorkCollector.IMMEDIATE;


Dependencies dependencies = new Dependencies(); LabelScanStore labelScanStore = startLabelScanStore( pageCache, indexStoreView );
dependencies.satisfyDependencies( Config.defaults(), fileSystem,
new SimpleLogService( logProvider, logProvider ), indexStoreView, pageCache, new Monitors(),
recoveryCleanupWorkCollector );
KernelContext kernelContext = new SimpleKernelContext( directory, UNKNOWN, dependencies );
LabelScanStore labelScanStore = startLabelScanStore( config, dependencies, kernelContext );
directStoreAccess = new DirectStoreAccess( nativeStores, labelScanStore, createIndexes( fileSystem, directStoreAccess = new DirectStoreAccess( nativeStores, labelScanStore, createIndexes( fileSystem,
config, operationalMode ) ); config, operationalMode ) );
} }
return directStoreAccess; return directStoreAccess;
} }


private LabelScanStore startLabelScanStore( Config config, Dependencies dependencies, KernelContext kernelContext ) private LabelScanStore startLabelScanStore( PageCache pageCache, IndexStoreView indexStoreView )
{ {
// Load correct LSS from kernel extensions NativeLabelScanStore labelScanStore =
LifeSupport life = new LifeSupport(); new NativeLabelScanStore( pageCache, directory, new FullLabelStream( indexStoreView ), false, new Monitors(),
KernelExtensions extensions = life.add( new KernelExtensions( RecoveryCleanupWorkCollector.IMMEDIATE );
kernelContext, (Iterable) load( KernelExtensionFactory.class ), dependencies, ignore() ) );
life.start();
LabelScanStore labelScanStore = extensions.resolveDependency( LabelScanStoreProvider.class ).getLabelScanStore();
life.shutdown();

// Start the selected LSS
try try
{ {
labelScanStore.init(); labelScanStore.init();
Expand Down
Expand Up @@ -45,7 +45,6 @@
import org.neo4j.kernel.impl.cache.MonitorGc; import org.neo4j.kernel.impl.cache.MonitorGc;
import org.neo4j.logging.Level; import org.neo4j.logging.Level;


import static org.neo4j.helpers.collection.Iterables.enumNames;
import static org.neo4j.kernel.configuration.Settings.ANY; import static org.neo4j.kernel.configuration.Settings.ANY;
import static org.neo4j.kernel.configuration.Settings.BOOLEAN; import static org.neo4j.kernel.configuration.Settings.BOOLEAN;
import static org.neo4j.kernel.configuration.Settings.BYTES; import static org.neo4j.kernel.configuration.Settings.BYTES;
Expand Down Expand Up @@ -544,23 +543,11 @@ public class GraphDatabaseSettings implements LoadableConfig
public static final Setting<Integer> batch_inserter_batch_size = setting( "unsupported.tools.batch_inserter.batch_size", INTEGER, public static final Setting<Integer> batch_inserter_batch_size = setting( "unsupported.tools.batch_inserter.batch_size", INTEGER,
"10000" ); "10000" );


public enum LabelIndex // todo Can we simply remove this setting or do we need to depricate it?
{ @Deprecated
/**
* Native label index. Generally the best option.
*/
NATIVE,

/**
* Selects which ever label index is present in a store, or the default (NATIVE) if no label index present.
*/
AUTO
}

@Description( "Backend to use for label --> nodes index" ) @Description( "Backend to use for label --> nodes index" )
@Internal @Internal
public static final Setting<String> label_index = setting( "dbms.label_index", public static final Setting<String> label_index = setting( "dbms.label_index", STRING, "native" );
options( enumNames( LabelIndex.class ), true ), LabelIndex.NATIVE.name() );


// Security settings // Security settings


Expand Down
Expand Up @@ -68,7 +68,6 @@
import org.neo4j.kernel.impl.api.TransactionHooks; import org.neo4j.kernel.impl.api.TransactionHooks;
import org.neo4j.kernel.impl.api.index.IndexingService; import org.neo4j.kernel.impl.api.index.IndexingService;
import org.neo4j.kernel.impl.api.operations.QueryRegistrationOperations; import org.neo4j.kernel.impl.api.operations.QueryRegistrationOperations;
import org.neo4j.kernel.impl.api.scan.LabelScanStoreProvider;
import org.neo4j.kernel.impl.api.state.ConstraintIndexCreator; import org.neo4j.kernel.impl.api.state.ConstraintIndexCreator;
import org.neo4j.kernel.impl.constraints.ConstraintSemantics; import org.neo4j.kernel.impl.constraints.ConstraintSemantics;
import org.neo4j.kernel.impl.core.LabelTokenHolder; import org.neo4j.kernel.impl.core.LabelTokenHolder;
Expand Down Expand Up @@ -267,7 +266,6 @@ boolean applicable( DiagnosticsPhase phase )
private Dependencies dependencies; private Dependencies dependencies;
private LifeSupport life; private LifeSupport life;
private SchemaIndexProvider schemaIndexProvider; private SchemaIndexProvider schemaIndexProvider;
private LabelScanStoreProvider labelScanStoreProvider;
private File storeDir; private File storeDir;
private boolean readOnly; private boolean readOnly;
private final IdController idController; private final IdController idController;
Expand Down Expand Up @@ -408,8 +406,6 @@ public void start() throws IOException
HighestSelectionStrategy.getInstance() ); HighestSelectionStrategy.getInstance() );
dependencies.satisfyDependency( schemaIndexProvider ); dependencies.satisfyDependency( schemaIndexProvider );


labelScanStoreProvider = dependencyResolver.resolveDependency( LabelScanStoreProvider.class );

IndexConfigStore indexConfigStore = new IndexConfigStore( storeDir, fs ); IndexConfigStore indexConfigStore = new IndexConfigStore( storeDir, fs );
dependencies.satisfyDependency( lockService ); dependencies.satisfyDependency( lockService );
dependencies.satisfyDependency( indexConfigStore ); dependencies.satisfyDependency( indexConfigStore );
Expand Down Expand Up @@ -558,7 +554,6 @@ private void upgradeStore( RecordFormats format )
config, config,
logService, logService,
schemaIndexProvider, schemaIndexProvider,
labelScanStoreProvider,
indexProviders, indexProviders,
pageCache, pageCache,
format ).migrate( storeDir ); format ).migrate( storeDir );
Expand All @@ -574,8 +569,8 @@ private StorageEngine buildStorageEngine(
new RecordStorageEngine( storeDir, config, pageCache, fs, logProvider, propertyKeyTokenHolder, new RecordStorageEngine( storeDir, config, pageCache, fs, logProvider, propertyKeyTokenHolder,
labelTokens, relationshipTypeTokens, schemaState, constraintSemantics, scheduler, labelTokens, relationshipTypeTokens, schemaState, constraintSemantics, scheduler,
tokenNameLookup, lockService, schemaIndexProvider, indexingServiceMonitor, databaseHealth, tokenNameLookup, lockService, schemaIndexProvider, indexingServiceMonitor, databaseHealth,
labelScanStoreProvider, legacyIndexProviderLookup, indexConfigStore, legacyIndexProviderLookup, indexConfigStore,
legacyIndexTransactionOrdering, idGeneratorFactory, idController ); legacyIndexTransactionOrdering, idGeneratorFactory, idController, monitors, recoveryCleanupWorkCollector );


// We pretend that the storage engine abstract hides all details within it. Whereas that's mostly // We pretend that the storage engine abstract hides all details within it. Whereas that's mostly
// true it's not entirely true for the time being. As long as we need this call below, which // true it's not entirely true for the time being. As long as we need this call below, which
Expand Down
Expand Up @@ -29,7 +29,6 @@
import org.neo4j.kernel.api.schema.index.IndexDescriptor; import org.neo4j.kernel.api.schema.index.IndexDescriptor;
import org.neo4j.kernel.impl.api.index.IndexingService; import org.neo4j.kernel.impl.api.index.IndexingService;
import org.neo4j.kernel.impl.api.index.sampling.IndexSamplingConfig; import org.neo4j.kernel.impl.api.index.sampling.IndexSamplingConfig;
import org.neo4j.kernel.impl.api.scan.LabelScanStoreProvider;
import org.neo4j.kernel.impl.storemigration.StoreMigrationParticipant; import org.neo4j.kernel.impl.storemigration.StoreMigrationParticipant;
import org.neo4j.kernel.lifecycle.LifecycleAdapter; import org.neo4j.kernel.lifecycle.LifecycleAdapter;


Expand Down Expand Up @@ -121,7 +120,7 @@ public InternalIndexState getInitialState( long indexId, IndexDescriptor descrip


@Override @Override
public StoreMigrationParticipant storeMigrationParticipant( FileSystemAbstraction fs, public StoreMigrationParticipant storeMigrationParticipant( FileSystemAbstraction fs,
PageCache pageCache, LabelScanStoreProvider labelScanStoreProvider ) PageCache pageCache )
{ {
return StoreMigrationParticipant.NOT_PARTICIPATING; return StoreMigrationParticipant.NOT_PARTICIPATING;
} }
Expand Down Expand Up @@ -220,8 +219,7 @@ public File getSchemaIndexStoreDirectory( File storeDir )
return new File( new File( new File( storeDir, "schema" ), "index" ), getProviderDescriptor().getKey() ); return new File( new File( new File( storeDir, "schema" ), "index" ), getProviderDescriptor().getKey() );
} }


public abstract StoreMigrationParticipant storeMigrationParticipant( FileSystemAbstraction fs, PageCache pageCache, public abstract StoreMigrationParticipant storeMigrationParticipant( FileSystemAbstraction fs, PageCache pageCache );
LabelScanStoreProvider labelScanStoreProvider );


/** /**
* Provides a snapshot of meta files about this index provider, not the indexes themselves. * Provides a snapshot of meta files about this index provider, not the indexes themselves.
Expand Down
Expand Up @@ -22,7 +22,6 @@
import org.apache.commons.lang3.ArrayUtils; import org.apache.commons.lang3.ArrayUtils;


import java.io.IOException; import java.io.IOException;
import java.util.function.Supplier;


import org.neo4j.helpers.collection.Visitor; import org.neo4j.helpers.collection.Visitor;
import org.neo4j.kernel.api.labelscan.LabelScanWriter; import org.neo4j.kernel.api.labelscan.LabelScanWriter;
Expand All @@ -37,22 +36,21 @@
*/ */
public class FullLabelStream implements FullStoreChangeStream, Visitor<NodeLabelUpdate,IOException> public class FullLabelStream implements FullStoreChangeStream, Visitor<NodeLabelUpdate,IOException>
{ {
private final Supplier<IndexStoreView> lazyIndexStoreView; private final IndexStoreView indexStoreView;
private LabelScanWriter writer; private LabelScanWriter writer;
private long count; private long count;


public FullLabelStream( Supplier<IndexStoreView> lazyIndexStoreView ) public FullLabelStream( IndexStoreView indexStoreView )
{ {
this.lazyIndexStoreView = lazyIndexStoreView; this.indexStoreView = indexStoreView;
} }


@Override @Override
public long applyTo( LabelScanWriter writer ) throws IOException public long applyTo( LabelScanWriter writer ) throws IOException
{ {
// Keep the write for using it in visit // Keep the write for using it in visit
this.writer = writer; this.writer = writer;
IndexStoreView view = lazyIndexStoreView.get(); StoreScan<IOException> scan = indexStoreView.visitNodes( ArrayUtils.EMPTY_INT_ARRAY, ALWAYS_TRUE_INT, null, this, true );
StoreScan<IOException> scan = view.visitNodes( ArrayUtils.EMPTY_INT_ARRAY, ALWAYS_TRUE_INT, null, this, true );
scan.run(); scan.run();
return count; return count;
} }
Expand Down

This file was deleted.

0 comments on commit ab9c07e

Please sign in to comment.