Skip to content

Commit

Permalink
Rename IndexMeta to CapableIndexReference
Browse files Browse the repository at this point in the history
  • Loading branch information
ragadeeshu committed May 21, 2018
1 parent dc1caf0 commit b55cacd
Show file tree
Hide file tree
Showing 18 changed files with 77 additions and 79 deletions.
Expand Up @@ -31,12 +31,12 @@

public abstract class AbstractSwallowingIndexProxy implements IndexProxy
{
private final IndexMeta indexMeta;
private final CapableIndexDescriptor capableIndexDescriptor;
private final IndexPopulationFailure populationFailure;

AbstractSwallowingIndexProxy( IndexMeta indexMeta, IndexPopulationFailure populationFailure )
AbstractSwallowingIndexProxy( CapableIndexDescriptor capableIndexDescriptor, IndexPopulationFailure populationFailure )
{
this.indexMeta = indexMeta;
this.capableIndexDescriptor = capableIndexDescriptor;
this.populationFailure = populationFailure;
}

Expand Down Expand Up @@ -73,7 +73,7 @@ public void force( IOLimiter ioLimiter )
@Override
public IndexCapability getIndexCapability()
{
return indexMeta;
return capableIndexDescriptor;
}

@Override
Expand All @@ -84,19 +84,19 @@ public void refresh()
@Override
public IndexDescriptor getDescriptor()
{
return indexMeta;
return capableIndexDescriptor;
}

@Override
public SchemaDescriptor schema()
{
return indexMeta.schema();
return capableIndexDescriptor.schema();
}

@Override
public IndexProvider.Descriptor getProviderDescriptor()
{
return indexMeta.providerDescriptor();
return capableIndexDescriptor.providerDescriptor();
}

@Override
Expand All @@ -113,6 +113,6 @@ public IndexReader newReader()
@Override
public long getIndexId()
{
return indexMeta.getId();
return capableIndexDescriptor.getId();
}
}
Expand Up @@ -26,11 +26,11 @@
import org.neo4j.kernel.api.schema.index.IndexDescriptor;
import org.neo4j.values.storable.ValueCategory;

public class IndexMeta extends IndexDescriptor implements CapableIndexReference
public class CapableIndexDescriptor extends IndexDescriptor implements CapableIndexReference
{
private final IndexCapability indexCapability;

public IndexMeta( IndexDescriptor indexDescriptor, IndexCapability indexCapability )
public CapableIndexDescriptor( IndexDescriptor indexDescriptor, IndexCapability indexCapability )
{
super( indexDescriptor.getId(), indexDescriptor.providerDescriptor(), indexDescriptor, indexDescriptor.getOwningConstraint() );
this.indexCapability = indexCapability;
Expand Down
Expand Up @@ -39,14 +39,14 @@ public class FailedIndexProxy extends AbstractSwallowingIndexProxy
private final IndexCountsRemover indexCountsRemover;
private final Log log;

FailedIndexProxy( IndexMeta indexMeta,
FailedIndexProxy( CapableIndexDescriptor capableIndexDescriptor,
String indexUserDescription,
IndexPopulator populator,
IndexPopulationFailure populationFailure,
IndexCountsRemover indexCountsRemover,
LogProvider logProvider )
{
super( indexMeta, populationFailure );
super( capableIndexDescriptor, populationFailure );
this.populator = populator;
this.indexUserDescription = indexUserDescription;
this.indexCountsRemover = indexCountsRemover;
Expand Down
Expand Up @@ -26,19 +26,19 @@

public class FailedPopulatingIndexProxyFactory implements FailedIndexProxyFactory
{
private final IndexMeta indexMeta;
private final CapableIndexDescriptor capableIndexDescriptor;
private final IndexPopulator populator;
private final String indexUserDescription;
private final IndexCountsRemover indexCountsRemover;
private final LogProvider logProvider;

FailedPopulatingIndexProxyFactory( IndexMeta indexMeta,
FailedPopulatingIndexProxyFactory( CapableIndexDescriptor capableIndexDescriptor,
IndexPopulator populator,
String indexUserDescription,
IndexCountsRemover indexCountsRemover,
LogProvider logProvider )
{
this.indexMeta = indexMeta;
this.capableIndexDescriptor = capableIndexDescriptor;
this.populator = populator;
this.indexUserDescription = indexUserDescription;
this.indexCountsRemover = indexCountsRemover;
Expand All @@ -48,7 +48,7 @@ public class FailedPopulatingIndexProxyFactory implements FailedIndexProxyFactor
@Override
public IndexProxy create( Throwable failure )
{
return new FailedIndexProxy( indexMeta, indexUserDescription, populator, failure( failure ),
return new FailedIndexProxy( capableIndexDescriptor, indexUserDescription, populator, failure( failure ),
indexCountsRemover, logProvider );
}
}
Expand Up @@ -35,7 +35,7 @@
/**
* A background job for initially populating one or more index over existing data in the database.
* Use provided store view to scan store. Participating {@link IndexPopulator} are added with
* {@link #addPopulator(IndexPopulator, IndexMeta, String, FlippableIndexProxy, FailedIndexProxyFactory)}
* {@link #addPopulator(IndexPopulator, CapableIndexDescriptor, String, FlippableIndexProxy, FailedIndexProxyFactory)}
* before {@link #run() running} this job.
*/
public class IndexPopulationJob implements Runnable
Expand All @@ -59,16 +59,16 @@ public IndexPopulationJob( MultipleIndexPopulator multiPopulator, IndexingServic
* Adds an {@link IndexPopulator} to be populated in this store scan. All participating populators must
* be added before calling {@link #run()}.
* @param populator {@link IndexPopulator} to participate.
* @param indexMeta {@link IndexMeta} meta information about index.
* @param capableIndexDescriptor {@link CapableIndexDescriptor} meta information about index.
* @param indexUserDescription user description of this index.
* @param flipper {@link FlippableIndexProxy} to call after a successful population.
* @param failedIndexProxyFactory {@link FailedIndexProxyFactory} to use after an unsuccessful population.
*/
MultipleIndexPopulator.IndexPopulation addPopulator( IndexPopulator populator, IndexMeta indexMeta, String indexUserDescription,
MultipleIndexPopulator.IndexPopulation addPopulator( IndexPopulator populator, CapableIndexDescriptor capableIndexDescriptor, String indexUserDescription,
FlippableIndexProxy flipper, FailedIndexProxyFactory failedIndexProxyFactory )
{
assert storeScan == null : "Population have already started, too late to add populators at this point";
return this.multiPopulator.addPopulator( populator, indexMeta, flipper, failedIndexProxyFactory,
return this.multiPopulator.addPopulator( populator, capableIndexDescriptor, flipper, failedIndexProxyFactory,
indexUserDescription );
}

Expand Down
Expand Up @@ -63,26 +63,25 @@ IndexProxy createPopulatingIndexProxy( final IndexDescriptor descriptor, final b

final String indexUserDescription = indexUserDescription( descriptor );
IndexPopulator populator = populatorFromProvider( descriptor, samplingConfig );
IndexMeta indexMeta = indexMetaFromProvider( descriptor );
CapableIndexDescriptor capableIndexDescriptor = indexMetaFromProvider( descriptor );

FailedIndexProxyFactory failureDelegateFactory = new FailedPopulatingIndexProxyFactory(
indexMeta,
FailedIndexProxyFactory failureDelegateFactory = new FailedPopulatingIndexProxyFactory( capableIndexDescriptor,
populator,
indexUserDescription,
new IndexCountsRemover( storeView, descriptor.getId() ),
logProvider );

MultipleIndexPopulator.IndexPopulation indexPopulation = populationJob
.addPopulator( populator, indexMeta, indexUserDescription, flipper, failureDelegateFactory );
PopulatingIndexProxy populatingIndex = new PopulatingIndexProxy( indexMeta, populationJob, indexPopulation );
.addPopulator( populator, capableIndexDescriptor, indexUserDescription, flipper, failureDelegateFactory );
PopulatingIndexProxy populatingIndex = new PopulatingIndexProxy( capableIndexDescriptor, populationJob, indexPopulation );

flipper.flipTo( populatingIndex );

// Prepare for flipping to online mode
flipper.setFlipTarget( () ->
{
monitor.populationCompleteOn( descriptor );
OnlineIndexProxy onlineProxy = new OnlineIndexProxy( indexMeta, onlineAccessorFromProvider( descriptor, samplingConfig ),
OnlineIndexProxy onlineProxy = new OnlineIndexProxy( capableIndexDescriptor, onlineAccessorFromProvider( descriptor, samplingConfig ),
storeView,
true );
if ( flipToTentative )
Expand All @@ -97,8 +96,8 @@ IndexProxy createPopulatingIndexProxy( final IndexDescriptor descriptor, final b

IndexProxy createRecoveringIndexProxy( IndexDescriptor descriptor )
{
IndexMeta indexMeta = indexMetaFromProvider( descriptor );
IndexProxy proxy = new RecoveringIndexProxy( indexMeta );
CapableIndexDescriptor capableIndexDescriptor = indexMetaFromProvider( descriptor );
IndexProxy proxy = new RecoveringIndexProxy( capableIndexDescriptor );
return new ContractCheckingIndexProxy( proxy, true );
}

Expand All @@ -107,9 +106,9 @@ IndexProxy createOnlineIndexProxy( IndexDescriptor descriptor )
try
{
IndexAccessor onlineAccessor = onlineAccessorFromProvider( descriptor, samplingConfig );
IndexMeta indexMeta = indexMetaFromProvider( descriptor );
CapableIndexDescriptor capableIndexDescriptor = indexMetaFromProvider( descriptor );
IndexProxy proxy;
proxy = new OnlineIndexProxy( indexMeta, onlineAccessor, storeView, false );
proxy = new OnlineIndexProxy( capableIndexDescriptor, onlineAccessor, storeView, false );
proxy = new ContractCheckingIndexProxy( proxy, true );
return proxy;
}
Expand All @@ -125,11 +124,10 @@ IndexProxy createOnlineIndexProxy( IndexDescriptor descriptor )
IndexProxy createFailedIndexProxy( IndexDescriptor descriptor, IndexPopulationFailure populationFailure )
{
IndexPopulator indexPopulator = populatorFromProvider( descriptor, samplingConfig );
IndexMeta indexMeta = indexMetaFromProvider( descriptor );
CapableIndexDescriptor capableIndexDescriptor = indexMetaFromProvider( descriptor );
String indexUserDescription = indexUserDescription( descriptor );
IndexProxy proxy;
proxy = new FailedIndexProxy(
indexMeta,
proxy = new FailedIndexProxy( capableIndexDescriptor,
indexUserDescription,
indexPopulator,
populationFailure,
Expand Down Expand Up @@ -157,9 +155,9 @@ private IndexAccessor onlineAccessorFromProvider( IndexDescriptor descriptor, In
return indexProvider.getOnlineAccessor( descriptor, samplingConfig );
}

private IndexMeta indexMetaFromProvider( IndexDescriptor indexDescriptor )
private CapableIndexDescriptor indexMetaFromProvider( IndexDescriptor indexDescriptor )
{
IndexCapability indexCapability = providerMap.apply( indexDescriptor.providerDescriptor() ).getCapability();
return new IndexMeta( indexDescriptor, indexCapability );
return new CapableIndexDescriptor( indexDescriptor, indexCapability );
}
}
Expand Up @@ -73,7 +73,7 @@
* Usage of this class should be something like:
* <ol>
* <li>Instantiation.</li>
* <li>One or more calls to {@link #addPopulator(IndexPopulator, IndexMeta, FlippableIndexProxy, FailedIndexProxyFactory, String)}.</li>
* <li>One or more calls to {@link #addPopulator(IndexPopulator, CapableIndexDescriptor, FlippableIndexProxy, FailedIndexProxyFactory, String)}.</li>
* <li>Call to {@link #create()} to create data structures and files to start accepting updates.</li>
* <li>Call to {@link #indexAllNodes()} (blocking call).</li>
* <li>While all nodes are being indexed, calls to {@link #queueUpdate(IndexEntryUpdate)} are accepted.</li>
Expand Down Expand Up @@ -109,18 +109,18 @@ public MultipleIndexPopulator( IndexStoreView storeView, LogProvider logProvider
this.log = logProvider.getLog( IndexPopulationJob.class );
}

IndexPopulation addPopulator( IndexPopulator populator, IndexMeta indexMeta, FlippableIndexProxy flipper, FailedIndexProxyFactory failedIndexProxyFactory,
IndexPopulation addPopulator( IndexPopulator populator, CapableIndexDescriptor capableIndexDescriptor, FlippableIndexProxy flipper, FailedIndexProxyFactory failedIndexProxyFactory,
String indexUserDescription )
{
IndexPopulation population =
createPopulation( populator, indexMeta, flipper, failedIndexProxyFactory, indexUserDescription );
createPopulation( populator, capableIndexDescriptor, flipper, failedIndexProxyFactory, indexUserDescription );
populations.add( population );
return population;
}

private IndexPopulation createPopulation( IndexPopulator populator, IndexMeta indexMeta, FlippableIndexProxy flipper, FailedIndexProxyFactory failedIndexProxyFactory, String indexUserDescription )
private IndexPopulation createPopulation( IndexPopulator populator, CapableIndexDescriptor capableIndexDescriptor, FlippableIndexProxy flipper, FailedIndexProxyFactory failedIndexProxyFactory, String indexUserDescription )
{
return new IndexPopulation( populator, indexMeta, flipper, failedIndexProxyFactory, indexUserDescription );
return new IndexPopulation( populator, capableIndexDescriptor, flipper, failedIndexProxyFactory, indexUserDescription );
}

boolean hasPopulators()
Expand Down Expand Up @@ -476,7 +476,7 @@ public class IndexPopulation implements SchemaDescriptorSupplier
public final IndexPopulator populator;
final FlippableIndexProxy flipper;
private final long indexId;
private final IndexMeta indexMeta;
private final CapableIndexDescriptor capableIndexDescriptor;
private final IndexCountsRemover indexCountsRemover;
private final FailedIndexProxyFactory failedIndexProxyFactory;
private final String indexUserDescription;
Expand All @@ -485,11 +485,11 @@ public class IndexPopulation implements SchemaDescriptorSupplier

List<IndexEntryUpdate<?>> batchedUpdates;

IndexPopulation( IndexPopulator populator, IndexMeta indexMeta, FlippableIndexProxy flipper, FailedIndexProxyFactory failedIndexProxyFactory, String indexUserDescription )
IndexPopulation( IndexPopulator populator, CapableIndexDescriptor capableIndexDescriptor, FlippableIndexProxy flipper, FailedIndexProxyFactory failedIndexProxyFactory, String indexUserDescription )
{
this.populator = populator;
this.indexMeta = indexMeta;
this.indexId = indexMeta.getId();
this.capableIndexDescriptor = capableIndexDescriptor;
this.indexId = capableIndexDescriptor.getId();
this.flipper = flipper;
this.failedIndexProxyFactory = failedIndexProxyFactory;
this.indexUserDescription = indexUserDescription;
Expand All @@ -499,7 +499,7 @@ public class IndexPopulation implements SchemaDescriptorSupplier

private void flipToFailed( IndexPopulationFailure failure )
{
flipper.flipTo( new FailedIndexProxy( indexMeta, indexUserDescription, populator, failure, indexCountsRemover, logProvider ) );
flipper.flipTo( new FailedIndexProxy( capableIndexDescriptor, indexUserDescription, populator, failure, indexCountsRemover, logProvider ) );
}

void create() throws IOException
Expand Down Expand Up @@ -580,7 +580,7 @@ void flip() throws FlipFailedKernelException
@Override
public SchemaDescriptor schema()
{
return indexMeta.schema();
return capableIndexDescriptor.schema();
}

public boolean batch( IndexEntryUpdate<?> update )
Expand Down
Expand Up @@ -41,7 +41,7 @@
public class OnlineIndexProxy implements IndexProxy
{
private final long indexId;
private final IndexMeta indexMeta;
private final CapableIndexDescriptor capableIndexDescriptor;
final IndexAccessor accessor;
private final IndexStoreView storeView;
private final IndexCountsRemover indexCountsRemover;
Expand Down Expand Up @@ -73,11 +73,11 @@ public class OnlineIndexProxy implements IndexProxy
// slightly more costly, but shouldn't make that big of a difference hopefully.
private final boolean forcedIdempotentMode;

OnlineIndexProxy( IndexMeta indexMeta, IndexAccessor accessor, IndexStoreView storeView, boolean forcedIdempotentMode )
OnlineIndexProxy( CapableIndexDescriptor capableIndexDescriptor, IndexAccessor accessor, IndexStoreView storeView, boolean forcedIdempotentMode )
{
assert accessor != null;
this.indexId = indexMeta.getId();
this.indexMeta = indexMeta;
this.indexId = capableIndexDescriptor.getId();
this.capableIndexDescriptor = capableIndexDescriptor;
this.accessor = accessor;
this.storeView = storeView;
this.forcedIdempotentMode = forcedIdempotentMode;
Expand Down Expand Up @@ -134,19 +134,19 @@ public void drop()
@Override
public IndexDescriptor getDescriptor()
{
return indexMeta;
return capableIndexDescriptor;
}

@Override
public SchemaDescriptor schema()
{
return indexMeta.schema();
return capableIndexDescriptor.schema();
}

@Override
public IndexProvider.Descriptor getProviderDescriptor()
{
return indexMeta.providerDescriptor();
return capableIndexDescriptor.providerDescriptor();
}

@Override
Expand All @@ -158,7 +158,7 @@ public InternalIndexState getState()
@Override
public IndexCapability getIndexCapability()
{
return indexMeta;
return capableIndexDescriptor;
}

@Override
Expand Down Expand Up @@ -236,7 +236,7 @@ public ResourceIterator<File> snapshotFiles() throws IOException
@Override
public String toString()
{
return getClass().getSimpleName() + "[accessor:" + accessor + ", descriptor:" + indexMeta + "]";
return getClass().getSimpleName() + "[accessor:" + accessor + ", descriptor:" + capableIndexDescriptor + "]";
}

@Override
Expand Down

0 comments on commit b55cacd

Please sign in to comment.