diff --git a/community/kernel/src/main/java/org/neo4j/kernel/api/index/IndexEntryUpdate.java b/community/kernel/src/main/java/org/neo4j/kernel/api/index/IndexEntryUpdate.java index 212c8618daba7..0741b61d80192 100644 --- a/community/kernel/src/main/java/org/neo4j/kernel/api/index/IndexEntryUpdate.java +++ b/community/kernel/src/main/java/org/neo4j/kernel/api/index/IndexEntryUpdate.java @@ -78,19 +78,6 @@ public Object[] values() return values; } - public Object value() - { - if ( values.length == 1 ) - { - return values[0]; - } - else - { - throw new IllegalStateException( - "Expected single value index update but found " + values.length + " values" ); - } - } - @Override public boolean equals( Object o ) { @@ -124,14 +111,14 @@ public String toString() .userDescription( SchemaUtil.noopTokenNameLookup ), Arrays.toString(values) ); } - public static IndexEntryUpdate add( long nodeId, NewIndexDescriptor descriptor, Object value ) + public static IndexEntryUpdate add( long nodeId, NewIndexDescriptor descriptor, Object... values ) { - return new IndexEntryUpdate( nodeId, descriptor, UpdateMode.ADDED, new Object[]{value} ); + return new IndexEntryUpdate( nodeId, descriptor, UpdateMode.ADDED, values ); } - public static IndexEntryUpdate remove( long nodeId, NewIndexDescriptor descriptor, Object value ) + public static IndexEntryUpdate remove( long nodeId, NewIndexDescriptor descriptor, Object... values ) { - return new IndexEntryUpdate( nodeId, descriptor, UpdateMode.REMOVED, new Object[]{value} ); + return new IndexEntryUpdate( nodeId, descriptor, UpdateMode.REMOVED, values ); } public static IndexEntryUpdate change( long nodeId, NewIndexDescriptor descriptor, Object before, Object after ) @@ -139,16 +126,6 @@ public static IndexEntryUpdate change( long nodeId, NewIndexDescriptor descripto return new IndexEntryUpdate( nodeId, descriptor, UpdateMode.CHANGED, new Object[]{before}, new Object[]{after} ); } - public static IndexEntryUpdate add( long nodeId, NewIndexDescriptor descriptor, Object[] values ) - { - return new IndexEntryUpdate( nodeId, descriptor, UpdateMode.ADDED, values ); - } - - public static IndexEntryUpdate remove( long nodeId, NewIndexDescriptor descriptor, Object[] values ) - { - return new IndexEntryUpdate( nodeId, descriptor, UpdateMode.REMOVED, values ); - } - public static IndexEntryUpdate change( long nodeId, NewIndexDescriptor descriptor, Object[] before, Object[] after ) { return new IndexEntryUpdate( nodeId, descriptor, UpdateMode.CHANGED, before, after ); @@ -162,5 +139,4 @@ public Object[] beforeValues() } return before; } - } diff --git a/community/kernel/src/test/java/org/neo4j/kernel/impl/api/index/IndexCRUDIT.java b/community/kernel/src/test/java/org/neo4j/kernel/impl/api/index/IndexCRUDIT.java index 39975c6a67e47..347f31ea48068 100644 --- a/community/kernel/src/test/java/org/neo4j/kernel/impl/api/index/IndexCRUDIT.java +++ b/community/kernel/src/test/java/org/neo4j/kernel/impl/api/index/IndexCRUDIT.java @@ -271,7 +271,7 @@ public void markAsFailed( String failure ) @Override public void includeSample( IndexEntryUpdate update ) { - addValueToSample( update.getEntityId(), update.value() ); + addValueToSample( update.getEntityId(), update.values()[0] ); } @Override diff --git a/community/kernel/src/test/java/org/neo4j/kernel/impl/api/index/IndexPopulationJobTest.java b/community/kernel/src/test/java/org/neo4j/kernel/impl/api/index/IndexPopulationJobTest.java index e63b31547eb38..68e448b56c434 100644 --- a/community/kernel/src/test/java/org/neo4j/kernel/impl/api/index/IndexPopulationJobTest.java +++ b/community/kernel/src/test/java/org/neo4j/kernel/impl/api/index/IndexPopulationJobTest.java @@ -492,7 +492,7 @@ public void add( Collection updates ) { job.update( IndexEntryUpdate.change( nodeToChange, index, previousValue, newValue ) ); } - added.add( Pair.of( update.getEntityId(), update.value() ) ); + added.add( Pair.of( update.getEntityId(), update.values()[0] ) ); } } @@ -508,7 +508,7 @@ public void process( IndexEntryUpdate update ) throws IOException, IndexEntryCon { case ADDED: case CHANGED: - added.add( Pair.of( update.getEntityId(), update.value() ) ); + added.add( Pair.of( update.getEntityId(), update.values()[0] ) ); break; default: throw new IllegalArgumentException( update.updateMode().name() ); @@ -564,7 +564,7 @@ public void add( Collection updates ) { job.update( IndexEntryUpdate.remove( nodeToDelete, index, valueToDelete ) ); } - added.put( update.getEntityId(), update.value() ); + added.put( update.getEntityId(), update.values()[0] ); } } @@ -580,10 +580,10 @@ public void process( IndexEntryUpdate update ) throws IOException, IndexEntryCon { case ADDED: case CHANGED: - added.put( update.getEntityId(), update.value() ); + added.put( update.getEntityId(), update.values()[0] ); break; case REMOVED: - removed.put( update.getEntityId(), update.value() ); // on remove, value is the before value + removed.put( update.getEntityId(), update.values()[0] ); // on remove, value is the before value break; default: throw new IllegalArgumentException( update.updateMode().name() ); diff --git a/community/kernel/src/test/java/org/neo4j/kernel/impl/api/index/inmemory/InMemoryIndex.java b/community/kernel/src/test/java/org/neo4j/kernel/impl/api/index/inmemory/InMemoryIndex.java index babd76dce4955..967dfa285a223 100644 --- a/community/kernel/src/test/java/org/neo4j/kernel/impl/api/index/inmemory/InMemoryIndex.java +++ b/community/kernel/src/test/java/org/neo4j/kernel/impl/api/index/inmemory/InMemoryIndex.java @@ -64,7 +64,7 @@ public boolean visited( long nodeId ) throws RuntimeException this( new HashBasedIndex() ); } - InMemoryIndex( InMemoryIndexImplementation indexData ) + private InMemoryIndex( InMemoryIndexImplementation indexData ) { this.indexData = indexData; } @@ -92,17 +92,6 @@ final IndexAccessor getOnlineAccessor() return new OnlineAccessor(); } - protected final PrimitiveLongIterator indexSeek( Object propertyValue ) - { - return indexData.seek( propertyValue ); - } - - protected boolean add( long nodeId, Object propertyValue, boolean applyIdempotently ) - throws IndexEntryConflictException, IOException - { - return indexData.add( nodeId, propertyValue, applyIdempotently ); - } - protected boolean add( long nodeId, Object[] propertyValues, boolean applyIdempotently ) throws IndexEntryConflictException, IOException { @@ -117,11 +106,6 @@ protected boolean add( long nodeId, Object[] propertyValues, boolean applyIdempo } } - protected void remove( long nodeId, Object propertyValue ) - { - indexData.remove( nodeId, propertyValue ); - } - protected void remove( long nodeId, Object[] propertyValues ) { assert propertyValues.length > 0; diff --git a/community/lucene-index/src/main/java/org/neo4j/kernel/api/impl/schema/populator/LuceneIndexPopulatingUpdater.java b/community/lucene-index/src/main/java/org/neo4j/kernel/api/impl/schema/populator/LuceneIndexPopulatingUpdater.java index c52f335076f1a..6a8ac0ce29607 100644 --- a/community/lucene-index/src/main/java/org/neo4j/kernel/api/impl/schema/populator/LuceneIndexPopulatingUpdater.java +++ b/community/lucene-index/src/main/java/org/neo4j/kernel/api/impl/schema/populator/LuceneIndexPopulatingUpdater.java @@ -28,8 +28,8 @@ import org.neo4j.kernel.api.exceptions.index.IndexEntryConflictException; import org.neo4j.kernel.api.impl.schema.LuceneDocumentStructure; import org.neo4j.kernel.api.impl.schema.writer.LuceneIndexWriter; +import org.neo4j.kernel.api.index.IndexEntryUpdate; import org.neo4j.kernel.api.index.IndexUpdater; -import org.neo4j.kernel.api.index.NodePropertyUpdate; import org.neo4j.kernel.impl.api.index.UpdateMode; /** @@ -47,28 +47,28 @@ public LuceneIndexPopulatingUpdater( LuceneIndexWriter writer ) } @Override - public void process( NodePropertyUpdate update ) throws IOException, IndexEntryConflictException + public void process( IndexEntryUpdate update ) throws IOException, IndexEntryConflictException { - long nodeId = update.getNodeId(); + long nodeId = update.getEntityId(); - switch ( update.getUpdateMode() ) + switch ( update.updateMode() ) { case ADDED: added( update ); writer.updateDocument( LuceneDocumentStructure.newTermForChangeOrRemove( nodeId ), - LuceneDocumentStructure.documentRepresentingProperty( nodeId, update.getValueAfter() ) ); + LuceneDocumentStructure.documentRepresentingProperty( nodeId, update.values()[0] ) ); break; case CHANGED: changed( update ); writer.updateDocument( LuceneDocumentStructure.newTermForChangeOrRemove( nodeId ), - LuceneDocumentStructure.documentRepresentingProperty( nodeId, update.getValueAfter() ) ); + LuceneDocumentStructure.documentRepresentingProperty( nodeId, update.values()[0] ) ); break; case REMOVED: removed( update ); writer.deleteDocuments( LuceneDocumentStructure.newTermForChangeOrRemove( nodeId ) ); break; default: - throw new IllegalStateException( "Unknown update mode " + update.getUpdateMode() ); + throw new IllegalStateException( "Unknown update mode " + update.values()[0] ); } } @@ -79,23 +79,23 @@ public final void remove( PrimitiveLongSet nodeIds ) } /** - * Method is invoked when {@link NodePropertyUpdate} with {@link UpdateMode#ADDED} is processed. + * Method is invoked when {@link IndexEntryUpdate} with {@link UpdateMode#ADDED} is processed. * * @param update the update being processed. */ - protected abstract void added( NodePropertyUpdate update ); + protected abstract void added( IndexEntryUpdate update ); /** - * Method is invoked when {@link NodePropertyUpdate} with {@link UpdateMode#CHANGED} is processed. + * Method is invoked when {@link IndexEntryUpdate} with {@link UpdateMode#CHANGED} is processed. * * @param update the update being processed. */ - protected abstract void changed( NodePropertyUpdate update ); + protected abstract void changed( IndexEntryUpdate update ); /** - * Method is invoked when {@link NodePropertyUpdate} with {@link UpdateMode#REMOVED} is processed. + * Method is invoked when {@link IndexEntryUpdate} with {@link UpdateMode#REMOVED} is processed. * * @param update the update being processed. */ - protected abstract void removed( NodePropertyUpdate update ); + protected abstract void removed( IndexEntryUpdate update ); } diff --git a/community/lucene-index/src/main/java/org/neo4j/kernel/api/impl/schema/populator/LuceneIndexPopulator.java b/community/lucene-index/src/main/java/org/neo4j/kernel/api/impl/schema/populator/LuceneIndexPopulator.java index b42202fbaff86..5b4160fbea61e 100644 --- a/community/lucene-index/src/main/java/org/neo4j/kernel/api/impl/schema/populator/LuceneIndexPopulator.java +++ b/community/lucene-index/src/main/java/org/neo4j/kernel/api/impl/schema/populator/LuceneIndexPopulator.java @@ -29,8 +29,8 @@ import org.neo4j.kernel.api.impl.schema.LuceneDocumentStructure; import org.neo4j.kernel.api.impl.schema.SchemaIndex; import org.neo4j.kernel.api.impl.schema.writer.LuceneIndexWriter; +import org.neo4j.kernel.api.index.IndexEntryUpdate; import org.neo4j.kernel.api.index.IndexPopulator; -import org.neo4j.kernel.api.index.NodePropertyUpdate; /** * An {@link IndexPopulator} used to create, populate and mark as online a Lucene schema index. @@ -60,7 +60,7 @@ public void drop() throws IOException } @Override - public void add( Collection updates ) throws IndexEntryConflictException, IOException + public void add( Collection updates ) throws IndexEntryConflictException, IOException { // Lucene documents stored in a ThreadLocal and reused so we can't create an eager collection of documents here // That is why we create a lazy Iterator and then Iterable @@ -91,8 +91,8 @@ public void markAsFailed( String failure ) throws IOException luceneIndex.markAsFailed( failure ); } - private static Document updateAsDocument( NodePropertyUpdate update ) + private static Document updateAsDocument( IndexEntryUpdate update ) { - return LuceneDocumentStructure.documentRepresentingProperty( update.getNodeId(), update.getValueAfter() ); + return LuceneDocumentStructure.documentRepresentingProperty( update.getEntityId(), update.values()[0] ); } } diff --git a/community/lucene-index/src/main/java/org/neo4j/kernel/api/impl/schema/populator/NonUniqueLuceneIndexPopulatingUpdater.java b/community/lucene-index/src/main/java/org/neo4j/kernel/api/impl/schema/populator/NonUniqueLuceneIndexPopulatingUpdater.java index c108554487c5f..0e2eeb795524e 100644 --- a/community/lucene-index/src/main/java/org/neo4j/kernel/api/impl/schema/populator/NonUniqueLuceneIndexPopulatingUpdater.java +++ b/community/lucene-index/src/main/java/org/neo4j/kernel/api/impl/schema/populator/NonUniqueLuceneIndexPopulatingUpdater.java @@ -21,7 +21,7 @@ import org.neo4j.kernel.api.impl.schema.LuceneDocumentStructure; import org.neo4j.kernel.api.impl.schema.writer.LuceneIndexWriter; -import org.neo4j.kernel.api.index.NodePropertyUpdate; +import org.neo4j.kernel.api.index.IndexEntryUpdate; import org.neo4j.kernel.impl.api.index.sampling.NonUniqueIndexSampler; /** @@ -38,26 +38,26 @@ public NonUniqueLuceneIndexPopulatingUpdater( LuceneIndexWriter writer, NonUniqu } @Override - protected void added( NodePropertyUpdate update ) + protected void added( IndexEntryUpdate update ) { - String encodedValue = LuceneDocumentStructure.encodedStringValue( update.getValueAfter() ); + String encodedValue = LuceneDocumentStructure.encodedStringValue( update.values()[0] ); sampler.include( encodedValue ); } @Override - protected void changed( NodePropertyUpdate update ) + protected void changed( IndexEntryUpdate update ) { - String encodedValueBefore = LuceneDocumentStructure.encodedStringValue( update.getValueBefore() ); + String encodedValueBefore = LuceneDocumentStructure.encodedStringValue( update.beforeValues()[0] ); sampler.exclude( encodedValueBefore ); - String encodedValueAfter = LuceneDocumentStructure.encodedStringValue( update.getValueAfter() ); + String encodedValueAfter = LuceneDocumentStructure.encodedStringValue( update.values()[0] ); sampler.include( encodedValueAfter ); } @Override - protected void removed( NodePropertyUpdate update ) + protected void removed( IndexEntryUpdate update ) { - String removedValue = LuceneDocumentStructure.encodedStringValue( update.getValueBefore() ); + String removedValue = LuceneDocumentStructure.encodedStringValue( update.values()[0] ); sampler.exclude( removedValue ); } diff --git a/community/lucene-index/src/main/java/org/neo4j/kernel/api/impl/schema/populator/NonUniqueLuceneIndexPopulator.java b/community/lucene-index/src/main/java/org/neo4j/kernel/api/impl/schema/populator/NonUniqueLuceneIndexPopulator.java index ee6880a0d0fd0..075f1c16cadde 100644 --- a/community/lucene-index/src/main/java/org/neo4j/kernel/api/impl/schema/populator/NonUniqueLuceneIndexPopulator.java +++ b/community/lucene-index/src/main/java/org/neo4j/kernel/api/impl/schema/populator/NonUniqueLuceneIndexPopulator.java @@ -24,8 +24,8 @@ import org.neo4j.kernel.api.exceptions.index.IndexEntryConflictException; import org.neo4j.kernel.api.impl.schema.LuceneDocumentStructure; import org.neo4j.kernel.api.impl.schema.SchemaIndex; +import org.neo4j.kernel.api.index.IndexEntryUpdate; import org.neo4j.kernel.api.index.IndexUpdater; -import org.neo4j.kernel.api.index.NodePropertyUpdate; import org.neo4j.kernel.api.index.PropertyAccessor; import org.neo4j.kernel.impl.api.index.sampling.DefaultNonUniqueIndexSampler; import org.neo4j.kernel.impl.api.index.sampling.IndexSamplingConfig; @@ -70,12 +70,12 @@ public IndexUpdater newPopulatingUpdater( PropertyAccessor propertyAccessor ) th } @Override - public void includeSample( NodePropertyUpdate update ) + public void includeSample( IndexEntryUpdate update ) { if ( updateSampling ) { checkSampler(); - sampler.include( LuceneDocumentStructure.encodedStringValue( update.getValueAfter() ) ); + sampler.include( LuceneDocumentStructure.encodedStringValue( update.values()[0] ) ); } } diff --git a/community/lucene-index/src/main/java/org/neo4j/kernel/api/impl/schema/populator/UniqueLuceneIndexPopulatingUpdater.java b/community/lucene-index/src/main/java/org/neo4j/kernel/api/impl/schema/populator/UniqueLuceneIndexPopulatingUpdater.java index e254358ec4a42..9d64187e02e74 100644 --- a/community/lucene-index/src/main/java/org/neo4j/kernel/api/impl/schema/populator/UniqueLuceneIndexPopulatingUpdater.java +++ b/community/lucene-index/src/main/java/org/neo4j/kernel/api/impl/schema/populator/UniqueLuceneIndexPopulatingUpdater.java @@ -26,7 +26,7 @@ import org.neo4j.kernel.api.exceptions.index.IndexEntryConflictException; import org.neo4j.kernel.api.impl.schema.SchemaIndex; import org.neo4j.kernel.api.impl.schema.writer.LuceneIndexWriter; -import org.neo4j.kernel.api.index.NodePropertyUpdate; +import org.neo4j.kernel.api.index.IndexEntryUpdate; import org.neo4j.kernel.api.index.PropertyAccessor; import org.neo4j.kernel.impl.api.index.sampling.UniqueIndexSampler; @@ -55,20 +55,20 @@ public UniqueLuceneIndexPopulatingUpdater( LuceneIndexWriter writer, int propert } @Override - protected void added( NodePropertyUpdate update ) + protected void added( IndexEntryUpdate update ) { sampler.increment( 1 ); - updatedPropertyValues.add( update.getValueAfter() ); + updatedPropertyValues.add( update.values()[0] ); } @Override - protected void changed( NodePropertyUpdate update ) + protected void changed( IndexEntryUpdate update ) { - updatedPropertyValues.add( update.getValueAfter() ); + updatedPropertyValues.add( update.values()[0] ); } @Override - protected void removed( NodePropertyUpdate update ) + protected void removed( IndexEntryUpdate update ) { sampler.increment( -1 ); } diff --git a/community/neo4j/src/test/java/schema/MultiIndexPopulationConcurrentUpdatesIT.java b/community/neo4j/src/test/java/schema/MultiIndexPopulationConcurrentUpdatesIT.java index aded8bd52d714..ad42d5fb5e7bf 100644 --- a/community/neo4j/src/test/java/schema/MultiIndexPopulationConcurrentUpdatesIT.java +++ b/community/neo4j/src/test/java/schema/MultiIndexPopulationConcurrentUpdatesIT.java @@ -479,7 +479,7 @@ public long next() case ADDED: node.addLabel( Label.label( labelsIdNameMap.get( descriptor.schema().getLabelId() ) ) ); - node.setProperty( NAME_PROPERTY, indexUpdate.value() ); + node.setProperty( NAME_PROPERTY, indexUpdate.values()[0] ); break; case REMOVED: node.addLabel(