Skip to content

Commit

Permalink
Pushed Index Boundary around IndexProvider API
Browse files Browse the repository at this point in the history
  • Loading branch information
fickludd authored and ragadeeshu committed Feb 27, 2017
1 parent cdb7592 commit 791a9e8
Show file tree
Hide file tree
Showing 56 changed files with 385 additions and 591 deletions.
Expand Up @@ -77,10 +77,7 @@ public IndexAccessors( SchemaIndexProvider provider,
for ( IndexRule indexRule : indexRules )
{
long indexId = indexRule.getId();
IndexConfiguration indexConfig = IndexConfiguration.of( indexRule );
accessors.put( indexId, provider.getOnlineAccessor( indexId,
IndexBoundary.map( indexRule.getIndexDescriptor() ),
indexConfig, samplingConfig ) );
accessors.put( indexId, provider.getOnlineAccessor( indexId, indexRule.getIndexDescriptor(), samplingConfig ) );
}
}

Expand Down
Expand Up @@ -414,11 +414,9 @@ public void shouldNotReportIndexInconsistenciesIfIndexIsFailed() throws Exceptio
while ( rules.hasNext() )
{
IndexRule rule = rules.next();
IndexDescriptor descriptor = IndexBoundary.map( rule.getIndexDescriptor() );
IndexConfiguration indexConfig = IndexConfiguration.NON_UNIQUE;
IndexSamplingConfig samplingConfig = new IndexSamplingConfig( Config.empty() );
IndexPopulator populator =
storeAccess.indexes().getPopulator( rule.getId(), descriptor, indexConfig, samplingConfig );
storeAccess.indexes().getPopulator( rule.getId(), rule.getIndexDescriptor(), samplingConfig );
populator.markAsFailed( "Oh noes! I was a shiny index and then I was failed" );
populator.close( false );

Expand Down Expand Up @@ -530,8 +528,7 @@ public void shouldReportNodesThatAreNotIndexed() throws Exception
{
IndexRule indexRule = indexRuleIterator.next();
IndexAccessor accessor = fixture.directStoreAccess().indexes().getOnlineAccessor(
indexRule.getId(), IndexBoundary.map( indexRule.getIndexDescriptor() ),
IndexConfiguration.of( indexRule ), samplingConfig );
indexRule.getId(), indexRule.getIndexDescriptor(), samplingConfig );
IndexUpdater updater = accessor.newUpdater( IndexUpdateMode.ONLINE );
updater.remove( asPrimitiveLongSet( indexedNodes ) );
updater.close();
Expand All @@ -550,19 +547,14 @@ public void shouldReportNodesThatAreNotIndexed() throws Exception
public void shouldReportNodesWithDuplicatePropertyValueInUniqueIndex() throws Exception
{
// given
IndexConfiguration indexConfig = IndexConfiguration.NON_UNIQUE;
IndexSamplingConfig samplingConfig = new IndexSamplingConfig( Config.empty() );
Iterator<IndexRule> indexRuleIterator =
new SchemaStorage( fixture.directStoreAccess().nativeStores().getSchemaStore() ).indexesGetAll();
while ( indexRuleIterator.hasNext() )
{
IndexRule indexRule = indexRuleIterator.next();
IndexAccessor accessor = fixture.directStoreAccess()
.indexes()
.getOnlineAccessor( indexRule.getId(),
IndexBoundary.map( indexRule.getIndexDescriptor() ),
indexConfig,
samplingConfig );
IndexAccessor accessor = fixture.directStoreAccess().indexes()
.getOnlineAccessor( indexRule.getId(), indexRule.getIndexDescriptor(), samplingConfig );
IndexUpdater updater = accessor.newUpdater( IndexUpdateMode.ONLINE );
updater.process( IndexEntryUpdate.add( 42, indexRule.getIndexDescriptor(), "value" ) );
updater.close();
Expand Down
Expand Up @@ -26,7 +26,7 @@
import org.neo4j.helpers.collection.Iterators;
import org.neo4j.io.fs.FileSystemAbstraction;
import org.neo4j.io.pagecache.PageCache;
import org.neo4j.kernel.api.schema.IndexDescriptor;
import org.neo4j.kernel.api.schema_new.index.NewIndexDescriptor;
import org.neo4j.kernel.impl.api.index.IndexingService;
import org.neo4j.kernel.impl.api.index.sampling.IndexSamplingConfig;
import org.neo4j.kernel.impl.api.scan.LabelScanStoreProvider;
Expand All @@ -43,7 +43,7 @@
*
* When an index rule is added, the {@link IndexingService} is notified. It will, in turn, ask
* your {@link SchemaIndexProvider} for a\
* {@link #getPopulator(long, IndexDescriptor, IndexConfiguration, IndexSamplingConfig) batch index writer}.
* {@link #getPopulator(long, NewIndexDescriptor, IndexSamplingConfig) batch index writer}.
*
* A background index job is triggered, and all existing data that applies to the new rule, as well as new data
* from the "outside", will be inserted using the writer. You are guaranteed that usage of this writer,
Expand Down Expand Up @@ -88,7 +88,7 @@
* <h3>Online operation</h3>
*
* Once the index is online, the database will move to using the
* {@link #getOnlineAccessor(long, IndexDescriptor, IndexConfiguration, IndexSamplingConfig) online accessor} to
* {@link #getOnlineAccessor(long, NewIndexDescriptor, IndexSamplingConfig) online accessor} to
* write to the index.
*/
public abstract class SchemaIndexProvider extends LifecycleAdapter implements Comparable<SchemaIndexProvider>
Expand All @@ -100,14 +100,14 @@ public abstract class SchemaIndexProvider extends LifecycleAdapter implements Co
private final IndexPopulator singlePopulator = new IndexPopulator.Adapter();

@Override
public IndexAccessor getOnlineAccessor( long indexId, IndexDescriptor descriptor,
IndexConfiguration config, IndexSamplingConfig samplingConfig )
public IndexAccessor getOnlineAccessor( long indexId, NewIndexDescriptor descriptor,
IndexSamplingConfig samplingConfig )
{
return singleWriter;
}

@Override
public IndexPopulator getPopulator( long indexId, IndexDescriptor descriptor, IndexConfiguration config,
public IndexPopulator getPopulator( long indexId, NewIndexDescriptor descriptor,
IndexSamplingConfig samplingConfig )
{
return singlePopulator;
Expand Down Expand Up @@ -146,14 +146,14 @@ protected SchemaIndexProvider( Descriptor descriptor, int priority )
/**
* Used for initially populating a created index, using batch insertion.
*/
public abstract IndexPopulator getPopulator( long indexId, IndexDescriptor descriptor, IndexConfiguration config,
public abstract IndexPopulator getPopulator( long indexId, NewIndexDescriptor descriptor,
IndexSamplingConfig samplingConfig );

/**
* Used for updating an index once initial population has completed.
*/
public abstract IndexAccessor getOnlineAccessor( long indexId, IndexDescriptor descriptor,
IndexConfiguration config, IndexSamplingConfig samplingConfig ) throws IOException;
public abstract IndexAccessor getOnlineAccessor( long indexId, NewIndexDescriptor descriptor,
IndexSamplingConfig samplingConfig ) throws IOException;

/**
* Returns a failure previously gotten from {@link IndexPopulator#markAsFailed(String)}
Expand Down
Expand Up @@ -45,8 +45,8 @@ public static RelationTypeSchemaDescriptor map( RelationshipPropertyDescriptor d
return SchemaDescriptorFactory.forRelType( descriptor.getRelationshipTypeId(), descriptor.getPropertyKeyId() );
}

public static NodePropertyDescriptor map( LabelSchemaDescriptor descriptor )
public static NodePropertyDescriptor map( LabelSchemaDescriptor schema )
{
return IndexDescriptorFactory.getNodePropertyDescriptor( descriptor.getLabelId(), descriptor.getPropertyIds() );
return IndexDescriptorFactory.getNodePropertyDescriptor( schema.getLabelId(), schema.getPropertyIds() );
}
}
Expand Up @@ -28,13 +28,12 @@
import org.neo4j.kernel.api.exceptions.index.IndexEntryConflictException;
import org.neo4j.kernel.api.exceptions.index.IndexNotFoundKernelException;
import org.neo4j.kernel.api.exceptions.index.IndexPopulationFailedKernelException;
import org.neo4j.kernel.api.exceptions.schema.UniquePropertyValueValidationException;
import org.neo4j.kernel.api.index.IndexConfiguration;
import org.neo4j.kernel.api.schema.IndexDescriptor;
import org.neo4j.kernel.api.exceptions.schema.ConstraintVerificationFailedKernelException;
import org.neo4j.kernel.api.index.IndexUpdater;
import org.neo4j.kernel.api.index.InternalIndexState;
import org.neo4j.kernel.api.index.PropertyAccessor;
import org.neo4j.kernel.api.index.SchemaIndexProvider;
import org.neo4j.kernel.api.schema_new.index.NewIndexDescriptor;
import org.neo4j.storageengine.api.schema.IndexReader;
import org.neo4j.storageengine.api.schema.PopulationProgress;

Expand Down Expand Up @@ -67,7 +66,7 @@ public InternalIndexState getState()
}

@Override
public IndexDescriptor getDescriptor()
public NewIndexDescriptor getDescriptor()
{
return getDelegate().getDescriptor();
}
Expand Down Expand Up @@ -144,12 +143,6 @@ public ResourceIterator<File> snapshotFiles() throws IOException
return getDelegate().snapshotFiles();
}

@Override
public IndexConfiguration config()
{
return getDelegate().config();
}

@Override
public void verifyDeferredConstraints( PropertyAccessor accessor ) throws IndexEntryConflictException, IOException
{
Expand Down
Expand Up @@ -25,6 +25,7 @@
import org.neo4j.kernel.api.schema.IndexDescriptor;
import org.neo4j.kernel.api.index.IndexUpdater;
import org.neo4j.kernel.api.index.SchemaIndexProvider;
import org.neo4j.kernel.api.schema_new.index.NewIndexDescriptor;
import org.neo4j.storageengine.api.schema.IndexReader;
import org.neo4j.storageengine.api.schema.PopulationProgress;
import org.neo4j.kernel.impl.api.index.updater.SwallowingIndexUpdater;
Expand All @@ -33,18 +34,16 @@

public abstract class AbstractSwallowingIndexProxy implements IndexProxy
{
private final IndexDescriptor descriptor;
private final NewIndexDescriptor descriptor;
private final SchemaIndexProvider.Descriptor providerDescriptor;
private final IndexPopulationFailure populationFailure;
private final IndexConfiguration configuration;

public AbstractSwallowingIndexProxy( IndexDescriptor descriptor, SchemaIndexProvider.Descriptor providerDescriptor,
IndexPopulationFailure populationFailure, IndexConfiguration configuration )
public AbstractSwallowingIndexProxy( NewIndexDescriptor descriptor,
SchemaIndexProvider.Descriptor providerDescriptor, IndexPopulationFailure populationFailure )
{
this.descriptor = descriptor;
this.providerDescriptor = providerDescriptor;
this.populationFailure = populationFailure;
this.configuration = configuration;
}

@Override
Expand Down Expand Up @@ -83,7 +82,7 @@ public void flush()
}

@Override
public IndexDescriptor getDescriptor()
public NewIndexDescriptor getDescriptor()
{
return descriptor;
}
Expand All @@ -105,10 +104,4 @@ public IndexReader newReader()
{
throw new UnsupportedOperationException();
}

@Override
public IndexConfiguration config()
{
return configuration;
}
}
Expand Up @@ -40,11 +40,11 @@
import org.neo4j.helpers.Exceptions;
import org.neo4j.kernel.api.exceptions.index.IndexEntryConflictException;
import org.neo4j.kernel.api.exceptions.index.IndexPopulationFailedKernelException;
import org.neo4j.kernel.api.index.IndexConfiguration;
import org.neo4j.kernel.api.index.IndexEntryUpdate;
import org.neo4j.kernel.api.schema.IndexDescriptor;
import org.neo4j.kernel.api.index.IndexPopulator;
import org.neo4j.kernel.api.index.SchemaIndexProvider;
import org.neo4j.kernel.api.schema_new.index.NewIndexDescriptor;
import org.neo4j.logging.LogProvider;
import org.neo4j.storageengine.api.schema.PopulationProgress;
import org.neo4j.unsafe.impl.internal.dragons.FeatureToggles;
Expand Down Expand Up @@ -121,10 +121,10 @@ public StoreScan<IndexPopulationFailedKernelException> indexAllNodes()

@Override
protected IndexPopulation createPopulation( IndexPopulator populator, long indexId,
IndexDescriptor descriptor, IndexConfiguration config, SchemaIndexProvider.Descriptor providerDescriptor,
NewIndexDescriptor descriptor, SchemaIndexProvider.Descriptor providerDescriptor,
FlippableIndexProxy flipper, FailedIndexProxyFactory failedIndexProxyFactory, String indexUserDescription )
{
return new BatchingIndexPopulation( populator, indexId, descriptor, config, providerDescriptor, flipper,
return new BatchingIndexPopulation( populator, indexId, descriptor, providerDescriptor, flipper,
failedIndexProxyFactory, indexUserDescription );
}

Expand Down Expand Up @@ -338,12 +338,11 @@ private int getNumberOfPopulationWorkers()
*/
private class BatchingIndexPopulation extends IndexPopulation
{
BatchingIndexPopulation( IndexPopulator populator, long indexId, IndexDescriptor descriptor,
IndexConfiguration config, SchemaIndexProvider.Descriptor providerDescriptor,
FlippableIndexProxy flipper, FailedIndexProxyFactory failedIndexProxyFactory,
String indexUserDescription )
BatchingIndexPopulation( IndexPopulator populator, long indexId, NewIndexDescriptor descriptor,
SchemaIndexProvider.Descriptor providerDescriptor, FlippableIndexProxy flipper,
FailedIndexProxyFactory failedIndexProxyFactory, String indexUserDescription )
{
super( populator, indexId, descriptor, config, providerDescriptor, flipper, failedIndexProxyFactory,
super( populator, indexId, descriptor, providerDescriptor, flipper, failedIndexProxyFactory,
indexUserDescription );
}

Expand Down
Expand Up @@ -30,6 +30,8 @@
import org.neo4j.kernel.api.index.IndexPopulator;
import org.neo4j.kernel.api.index.InternalIndexState;
import org.neo4j.kernel.api.index.SchemaIndexProvider;
import org.neo4j.kernel.api.schema_new.SchemaBoundary;
import org.neo4j.kernel.api.schema_new.index.NewIndexDescriptor;
import org.neo4j.logging.Log;
import org.neo4j.logging.LogProvider;

Expand All @@ -43,16 +45,15 @@ public class FailedIndexProxy extends AbstractSwallowingIndexProxy
private final IndexCountsRemover indexCountsRemover;
private final Log log;

public FailedIndexProxy(IndexDescriptor descriptor,
IndexConfiguration configuration,
public FailedIndexProxy( NewIndexDescriptor descriptor,
SchemaIndexProvider.Descriptor providerDescriptor,
String indexUserDescription,
IndexPopulator populator,
IndexPopulationFailure populationFailure,
IndexCountsRemover indexCountsRemover,
LogProvider logProvider )
{
super( descriptor, providerDescriptor, populationFailure, configuration );
super( descriptor, providerDescriptor, populationFailure );
this.populator = populator;
this.indexUserDescription = indexUserDescription;
this.indexCountsRemover = indexCountsRemover;
Expand All @@ -79,7 +80,8 @@ public InternalIndexState getState()
@Override
public boolean awaitStoreScanCompleted() throws IndexPopulationFailedKernelException
{
throw getPopulationFailure().asIndexPopulationFailure( getDescriptor().descriptor(), indexUserDescription );
throw getPopulationFailure().asIndexPopulationFailure(
SchemaBoundary.map( getDescriptor().schema() ), indexUserDescription );
}

@Override
Expand All @@ -91,7 +93,8 @@ public void activate()
@Override
public void validate() throws IndexPopulationFailedKernelException
{
throw getPopulationFailure().asIndexPopulationFailure( getDescriptor().descriptor(), indexUserDescription );
throw getPopulationFailure().asIndexPopulationFailure(
SchemaBoundary.map( getDescriptor().schema() ), indexUserDescription );
}

@Override
Expand Down
Expand Up @@ -19,34 +19,30 @@
*/
package org.neo4j.kernel.impl.api.index;

import org.neo4j.kernel.api.index.IndexConfiguration;
import org.neo4j.kernel.api.schema.IndexDescriptor;
import org.neo4j.kernel.api.index.IndexPopulator;
import org.neo4j.kernel.api.index.SchemaIndexProvider;
import org.neo4j.kernel.api.schema_new.index.NewIndexDescriptor;
import org.neo4j.logging.LogProvider;

import static org.neo4j.kernel.impl.api.index.IndexPopulationFailure.failure;

public class FailedPopulatingIndexProxyFactory implements FailedIndexProxyFactory
{
private final IndexDescriptor descriptor;
private final IndexConfiguration configuration;
private final NewIndexDescriptor descriptor;
private final SchemaIndexProvider.Descriptor providerDescriptor;
private final IndexPopulator populator;
private final String indexUserDescription;
private final IndexCountsRemover indexCountsRemover;
private final LogProvider logProvider;

FailedPopulatingIndexProxyFactory( IndexDescriptor descriptor,
IndexConfiguration configuration,
FailedPopulatingIndexProxyFactory( NewIndexDescriptor descriptor,
SchemaIndexProvider.Descriptor providerDescriptor,
IndexPopulator populator,
String indexUserDescription,
IndexCountsRemover indexCountsRemover,
LogProvider logProvider )
{
this.descriptor = descriptor;
this.configuration = configuration;
this.providerDescriptor = providerDescriptor;
this.populator = populator;
this.indexUserDescription = indexUserDescription;
Expand All @@ -59,7 +55,7 @@ public IndexProxy create( Throwable failure )
{
return
new FailedIndexProxy(
descriptor, configuration, providerDescriptor,
descriptor, providerDescriptor,
indexUserDescription, populator, failure( failure ), indexCountsRemover, logProvider );
}
}

0 comments on commit 791a9e8

Please sign in to comment.