Skip to content

Commit

Permalink
Merge pull request #8854 from ragadeeshu/3.2-composite-lucene-seek
Browse files Browse the repository at this point in the history
3.2 composite lucene initial support
  • Loading branch information
chrisvest committed Feb 28, 2017
2 parents 7371cb8 + 823ca25 commit 2a8efa4
Show file tree
Hide file tree
Showing 108 changed files with 1,385 additions and 1,072 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@

import org.neo4j.collection.primitive.Primitive;
import org.neo4j.collection.primitive.PrimitiveIntSet;
import org.neo4j.collection.primitive.PrimitiveLongCollections;
import org.neo4j.collection.primitive.PrimitiveLongIterator;
import org.neo4j.collection.primitive.PrimitiveLongPeekingIterator;
import org.neo4j.consistency.checking.ChainCheck;
Expand All @@ -34,6 +35,7 @@
import org.neo4j.consistency.checking.index.IndexAccessors;
import org.neo4j.consistency.report.ConsistencyReport;
import org.neo4j.consistency.store.RecordAccess;
import org.neo4j.kernel.api.exceptions.index.IndexNotApplicableKernelException;
import org.neo4j.kernel.api.schema_new.IndexQuery;
import org.neo4j.kernel.impl.api.LookupFilter;
import org.neo4j.kernel.impl.store.record.IndexRule;
Expand Down Expand Up @@ -122,7 +124,15 @@ private void verifyNodeCorrectlyIndexedUniquely( long nodeId, int propertyKeyId,
CheckerEngine<NodeRecord,ConsistencyReport.NodeConsistencyReport> engine, IndexRule indexRule,
IndexReader reader )
{
PrimitiveLongIterator indexedNodeIds = reader.query( IndexQuery.exact( propertyKeyId, propertyValue ) );
PrimitiveLongIterator indexedNodeIds = null;
try
{
indexedNodeIds = reader.query( IndexQuery.exact( propertyKeyId, propertyValue ) );
}
catch ( IndexNotApplicableKernelException e )
{
indexedNodeIds = PrimitiveLongCollections.emptyIterator();
}

// For verifying node indexed uniquely in offline CC, if one match found in the first stage match,
// then there is no need to filter the result. The result is a exact match.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@
import java.util.Map;

import org.neo4j.kernel.api.index.IndexAccessor;
import org.neo4j.kernel.api.index.IndexConfiguration;
import org.neo4j.kernel.api.index.InternalIndexState;
import org.neo4j.kernel.api.index.SchemaIndexProvider;
import org.neo4j.kernel.api.schema_new.index.IndexBoundary;
Expand Down Expand Up @@ -77,10 +76,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
Original file line number Diff line number Diff line change
Expand Up @@ -66,17 +66,13 @@
import org.neo4j.kernel.api.exceptions.schema.IllegalTokenNameException;
import org.neo4j.kernel.api.exceptions.schema.TooManyLabelsException;
import org.neo4j.kernel.api.index.IndexAccessor;
import org.neo4j.kernel.api.index.IndexConfiguration;
import org.neo4j.kernel.api.index.IndexEntryUpdate;
import org.neo4j.kernel.api.index.IndexPopulator;
import org.neo4j.kernel.api.index.IndexUpdater;
import org.neo4j.kernel.api.index.SchemaIndexProvider;
import org.neo4j.kernel.api.labelscan.LabelScanStore;
import org.neo4j.kernel.api.labelscan.LabelScanWriter;
import org.neo4j.kernel.api.labelscan.NodeLabelUpdate;
import org.neo4j.kernel.api.schema.IndexDescriptor;
import org.neo4j.kernel.api.schema.IndexDescriptorFactory;
import org.neo4j.kernel.api.schema_new.index.IndexBoundary;
import org.neo4j.kernel.configuration.Config;
import org.neo4j.kernel.impl.annotations.Documented;
import org.neo4j.kernel.impl.api.KernelStatement;
Expand Down Expand Up @@ -414,11 +410,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 +524,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 +543,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
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@
import org.neo4j.kernel.api.exceptions.ProcedureException;
import org.neo4j.kernel.api.exceptions.PropertyKeyIdNotFoundKernelException;
import org.neo4j.kernel.api.exceptions.RelationshipTypeIdNotFoundKernelException;
import org.neo4j.kernel.api.exceptions.index.IndexNotApplicableKernelException;
import org.neo4j.kernel.api.exceptions.index.IndexNotFoundKernelException;
import org.neo4j.kernel.api.exceptions.legacyindex.LegacyIndexNotFoundKernelException;
import org.neo4j.kernel.api.exceptions.schema.DuplicateSchemaRuleException;
Expand Down Expand Up @@ -126,7 +127,8 @@ public interface ReadOperations
* @return ids of the matching nodes
* @throws org.neo4j.kernel.api.exceptions.index.IndexNotFoundKernelException if no such index is found.
*/
PrimitiveLongIterator indexQuery( NewIndexDescriptor index, IndexQuery... predicates ) throws IndexNotFoundKernelException;
PrimitiveLongIterator indexQuery( NewIndexDescriptor index, IndexQuery... predicates )
throws IndexNotFoundKernelException, IndexNotApplicableKernelException;

/**
* @return an iterator over all nodes in the database.
Expand Down Expand Up @@ -155,8 +157,8 @@ RelationshipIterator nodeGetRelationships( long nodeId, Direction direction, int
*
* @throws org.neo4j.kernel.api.exceptions.index.IndexNotFoundKernelException if no such index found.
*/
long nodeGetFromUniqueIndexSeek( NewIndexDescriptor index, Object value ) throws IndexNotFoundKernelException,
IndexBrokenKernelException;
long nodeGetFromUniqueIndexSeek( NewIndexDescriptor index, Object value )
throws IndexNotFoundKernelException, IndexBrokenKernelException, IndexNotApplicableKernelException;

long nodesCountIndexed( NewIndexDescriptor index, long nodeId, Object value )
throws IndexNotFoundKernelException, IndexBrokenKernelException;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
package org.neo4j.kernel.api.index;

import org.neo4j.collection.primitive.PrimitiveLongIterator;
import org.neo4j.kernel.api.exceptions.index.IndexNotApplicableKernelException;
import org.neo4j.kernel.api.schema_new.IndexQuery;
import org.neo4j.storageengine.api.schema.IndexReader;
import org.neo4j.storageengine.api.schema.IndexSampler;
Expand All @@ -34,9 +35,9 @@ public DelegatingIndexReader( IndexReader delegate )
}

@Override
public long countIndexedNodes( long nodeId, Object propertyValue )
public long countIndexedNodes( long nodeId, Object... propertyValues )
{
return delegate.countIndexedNodes( nodeId, propertyValue );
return delegate.countIndexedNodes( nodeId, propertyValues );
}

@Override
Expand All @@ -46,7 +47,7 @@ public IndexSampler createSampler()
}

@Override
public PrimitiveLongIterator query( IndexQuery... predicates )
public PrimitiveLongIterator query( IndexQuery... predicates ) throws IndexNotApplicableKernelException
{
return delegate.query( predicates );
}
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ public class IndexEntryUpdate
private Object[] values;
private NewIndexDescriptor descriptor;

private IndexEntryUpdate( long entityId, NewIndexDescriptor descriptor, UpdateMode updateMode, Object[] values )
private IndexEntryUpdate( long entityId, NewIndexDescriptor descriptor, UpdateMode updateMode, Object... values )
{
this.entityId = entityId;
this.descriptor = descriptor;
Expand Down
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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() );
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@
import org.neo4j.kernel.api.exceptions.InvalidTransactionTypeKernelException;
import org.neo4j.kernel.api.exceptions.KernelException;
import org.neo4j.kernel.api.exceptions.index.IndexEntryConflictException;
import org.neo4j.kernel.api.exceptions.index.IndexNotApplicableKernelException;
import org.neo4j.kernel.api.exceptions.index.IndexNotFoundKernelException;
import org.neo4j.kernel.api.exceptions.legacyindex.AutoIndexingKernelException;
import org.neo4j.kernel.api.exceptions.schema.AlreadyConstrainedException;
Expand Down Expand Up @@ -181,7 +182,7 @@ private void validateNoExistingNodeWithLabelAndProperty(
new IndexEntryConflictException( existing, NO_SUCH_NODE, value ) );
}
}
catch ( IndexNotFoundKernelException | IndexBrokenKernelException e )
catch ( IndexNotFoundKernelException | IndexBrokenKernelException | IndexNotApplicableKernelException e )
{
throw new UnableToValidateConstraintException( constraint, e );
}
Expand Down Expand Up @@ -281,7 +282,8 @@ public PrimitiveLongIterator nodesGetForLabel( KernelStatement state, int labelI

@Override
public PrimitiveLongIterator indexQuery( KernelStatement statement, NewIndexDescriptor index,
IndexQuery[] predicates ) throws IndexNotFoundKernelException
IndexQuery[] predicates )
throws IndexNotFoundKernelException, IndexNotApplicableKernelException
{
return entityReadOperations.indexQuery( statement, index, predicates );
}
Expand All @@ -291,7 +293,7 @@ public long nodeGetFromUniqueIndexSeek(
KernelStatement state,
NewIndexDescriptor index,
Object value )
throws IndexNotFoundKernelException, IndexBrokenKernelException
throws IndexNotFoundKernelException, IndexBrokenKernelException, IndexNotApplicableKernelException
{
assertIndexOnline( state, index );

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
import org.neo4j.kernel.api.exceptions.EntityNotFoundException;
import org.neo4j.kernel.api.exceptions.InvalidTransactionTypeKernelException;
import org.neo4j.kernel.api.exceptions.KernelException;
import org.neo4j.kernel.api.exceptions.index.IndexNotApplicableKernelException;
import org.neo4j.kernel.api.exceptions.index.IndexNotFoundKernelException;
import org.neo4j.kernel.api.exceptions.legacyindex.AutoIndexingKernelException;
import org.neo4j.kernel.api.exceptions.schema.ConstraintValidationException;
Expand Down Expand Up @@ -173,15 +174,16 @@ public PrimitiveLongIterator nodesGetForLabel( KernelStatement statement, int la

@Override
public PrimitiveLongIterator indexQuery( KernelStatement statement, NewIndexDescriptor index,
IndexQuery[] predicates ) throws IndexNotFoundKernelException
IndexQuery[] predicates )
throws IndexNotFoundKernelException, IndexNotApplicableKernelException
{
guard.check( statement );
return entityReadDelegate.indexQuery( statement, index, predicates );
}

@Override
public long nodeGetFromUniqueIndexSeek( KernelStatement statement, NewIndexDescriptor index, Object value )
throws IndexNotFoundKernelException, IndexBrokenKernelException
throws IndexNotFoundKernelException, IndexBrokenKernelException, IndexNotApplicableKernelException
{
guard.check( statement );
return entityReadDelegate.nodeGetFromUniqueIndexSeek( statement, index, value );
Expand Down

0 comments on commit 2a8efa4

Please sign in to comment.