From 7b78476521e0d01af5734ff2f17aeec76bc41f93 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mattias=20Finn=C3=A9?= Date: Fri, 22 Mar 2019 11:21:49 +0100 Subject: [PATCH] Simpler surface of EntityCommandGrouper --- .../impl/api/index/EntityCommandGrouper.java | 138 +++++++++--------- .../api/index/PropertyCommandsExtractor.java | 11 +- .../PropertyPhysicalToLogicalConverter.java | 4 +- .../transaction/command/IndexUpdatesWork.java | 3 +- .../transaction/state/DirectIndexUpdates.java | 3 +- .../impl/transaction/state/IndexUpdates.java | 4 +- .../transaction/state/OnlineIndexUpdates.java | 17 ++- .../api/index/EntityCommandGrouperTest.java | 31 ++-- .../impl/api/index/IndexingServiceTest.java | 2 +- ...ropertyPhysicalToLogicalConverterTest.java | 5 +- .../TransactionRecordStateTest.java | 21 ++- .../state/OnlineIndexUpdatesTest.java | 9 +- 12 files changed, 137 insertions(+), 111 deletions(-) diff --git a/community/kernel/src/main/java/org/neo4j/kernel/impl/api/index/EntityCommandGrouper.java b/community/kernel/src/main/java/org/neo4j/kernel/impl/api/index/EntityCommandGrouper.java index 0c5de1edaf250..c0b41e2cb21b6 100644 --- a/community/kernel/src/main/java/org/neo4j/kernel/impl/api/index/EntityCommandGrouper.java +++ b/community/kernel/src/main/java/org/neo4j/kernel/impl/api/index/EntityCommandGrouper.java @@ -19,23 +19,38 @@ */ package org.neo4j.kernel.impl.api.index; -import org.eclipse.collections.api.LongIterable; -import org.eclipse.collections.impl.list.mutable.primitive.LongArrayList; - import java.util.Arrays; import java.util.Comparator; import org.neo4j.kernel.impl.transaction.command.Command; +import org.neo4j.kernel.impl.transaction.command.Command.NodeCommand; import org.neo4j.kernel.impl.transaction.command.Command.PropertyCommand; +import org.neo4j.kernel.impl.transaction.command.Command.RelationshipCommand; /** * Groups property commands by entity. The commands are provided from a list of transaction commands. * Most entity updates include both the entity command as well as property commands, but sometimes * only property commands for an entity exists in the list and this grouper handles both scenarios. * Commands are appended to an array and then sorted before handed over for being processed. + * Hence one entity group can look like any of these combinations: + * + *

+ * Typical interaction goes like this: + *

    + *
  1. All commands are added with {@link #add(Command)}
  2. + *
  3. Get a cursor to the sorted commands using {@link #sortAndAccessGroups()}
  4. + *
  5. Call {@link #clear()} and use this instance again for another set of commands
  6. + *
*/ public class EntityCommandGrouper { + /** + * Enforces the order described on the class-level javadoc above. + */ private final Comparator COMMAND_COMPARATOR = new Comparator() { @Override @@ -56,20 +71,13 @@ private long entityId( Command command ) private int commandType( Command command ) { - if ( command.getClass() == entityCommandClass ) - { - return 0; - } - return 1; + return command.getClass() == entityCommandClass ? 0 : 1; } }; private final Class entityCommandClass; private Command[] commands; private int writeCursor; - private int readCursor; - private long currentEntity; - private ENTITY currentEntityCommand; public EntityCommandGrouper( Class entityCommandClass, int sizeHint ) { @@ -86,82 +94,80 @@ public void add( Command command ) commands[writeCursor++] = command; } - public void sort() + public Cursor sortAndAccessGroups() { Arrays.sort( commands, 0, writeCursor, COMMAND_COMPARATOR ); + return new Cursor(); } - public boolean nextEntity() + public void clear() { - if ( readCursor >= writeCursor ) - { - return false; - } - - if ( commands[readCursor].getClass() == entityCommandClass ) - { - currentEntityCommand = (ENTITY) commands[readCursor++]; - currentEntity = currentEntityCommand.getKey(); - } - else + if ( writeCursor > 1_000 ) { - PropertyCommand firstPropertyCommand = (PropertyCommand) commands[readCursor]; - currentEntityCommand = null; - currentEntity = firstPropertyCommand.getEntityId(); + // Don't continue to hog large transactions + Arrays.fill( commands, 1_000, writeCursor, null ); } - return true; + writeCursor = 0; } - public long getCurrentEntity() + /** + * Interaction goes like this: + *
    + *
  1. Call {@link #nextEntity()} to go to the next group, if any
  2. + *
  3. A group may or may not have the entity command, as accessed by {@link #currentEntityCommand()}, + * either way the node id is accessible using {@link #currentEntityId()}
  4. + *
  5. Call {@link #nextProperty()} until it returns null, now all the {@link PropertyCommand} in this group have been accessed
  6. + *
+ */ + public class Cursor { - return currentEntity; - } + private int readCursor; + private long currentEntity; + private ENTITY currentEntityCommand; - public ENTITY getCurrentEntityCommand() - { - return currentEntityCommand; - } + public boolean nextEntity() + { + if ( readCursor >= writeCursor ) + { + return false; + } - public PropertyCommand nextProperty() - { - if ( readCursor < writeCursor ) + if ( commands[readCursor].getClass() == entityCommandClass ) + { + currentEntityCommand = (ENTITY) commands[readCursor++]; + currentEntity = currentEntityCommand.getKey(); + } + else + { + PropertyCommand firstPropertyCommand = (PropertyCommand) commands[readCursor]; + currentEntityCommand = null; + currentEntity = firstPropertyCommand.getEntityId(); + } + return true; + } + + public PropertyCommand nextProperty() { - Command command = commands[readCursor]; - if ( command instanceof PropertyCommand && ((PropertyCommand) command).getEntityId() == currentEntity ) + if ( readCursor < writeCursor ) { - readCursor++; - return (PropertyCommand) command; + Command command = commands[readCursor]; + if ( command instanceof PropertyCommand && ((PropertyCommand) command).getEntityId() == currentEntity ) + { + readCursor++; + return (PropertyCommand) command; + } } + return null; } - return null; - } - public void clear() - { - if ( writeCursor > 1_000 ) + public long currentEntityId() { - // Don't continue to hog large transactions - Arrays.fill( commands, 1_000, writeCursor, null ); + return currentEntity; } - writeCursor = 0; - readCursor = 0; - } - public LongIterable entityIds() - { - LongArrayList list = new LongArrayList(); - int cursor = 0; - long currentNode = -1; - while ( cursor < writeCursor ) + public ENTITY currentEntityCommand() { - Command candidate = commands[cursor++]; - long nodeId = candidate.getClass() == entityCommandClass ? candidate.getKey() : ((PropertyCommand) candidate).getEntityId(); - if ( nodeId != currentNode ) - { - currentNode = nodeId; - list.add( currentNode ); - } + return currentEntityCommand; } - return list; } } diff --git a/community/kernel/src/main/java/org/neo4j/kernel/impl/api/index/PropertyCommandsExtractor.java b/community/kernel/src/main/java/org/neo4j/kernel/impl/api/index/PropertyCommandsExtractor.java index b70fd186de39b..6e4849c3e264f 100644 --- a/community/kernel/src/main/java/org/neo4j/kernel/impl/api/index/PropertyCommandsExtractor.java +++ b/community/kernel/src/main/java/org/neo4j/kernel/impl/api/index/PropertyCommandsExtractor.java @@ -36,7 +36,6 @@ public class PropertyCommandsExtractor extends TransactionApplier.Adapter implements BatchTransactionApplier { - // A list of relevant commands, sorted to be Node(N),Property(N),Property(N)...,Node(O),Property(O),Property(O)..., private final EntityCommandGrouper nodeCommands = new EntityCommandGrouper<>( NodeCommand.class, 16 ); private final EntityCommandGrouper relationshipCommands = new EntityCommandGrouper<>( RelationshipCommand.class, 16 ); private boolean hasUpdates; @@ -110,15 +109,13 @@ public boolean containsAnyEntityOrPropertyUpdate() return hasUpdates; } - public EntityCommandGrouper getNodeCommands() + public EntityCommandGrouper.Cursor getNodeCommands() { - nodeCommands.sort(); - return nodeCommands; + return nodeCommands.sortAndAccessGroups(); } - public EntityCommandGrouper getRelationshipCommands() + public EntityCommandGrouper.Cursor getRelationshipCommands() { - relationshipCommands.sort(); - return relationshipCommands; + return relationshipCommands.sortAndAccessGroups(); } } diff --git a/community/kernel/src/main/java/org/neo4j/kernel/impl/api/index/PropertyPhysicalToLogicalConverter.java b/community/kernel/src/main/java/org/neo4j/kernel/impl/api/index/PropertyPhysicalToLogicalConverter.java index a0716d8702b0b..9168314749957 100644 --- a/community/kernel/src/main/java/org/neo4j/kernel/impl/api/index/PropertyPhysicalToLogicalConverter.java +++ b/community/kernel/src/main/java/org/neo4j/kernel/impl/api/index/PropertyPhysicalToLogicalConverter.java @@ -45,7 +45,7 @@ public PropertyPhysicalToLogicalConverter( PropertyStore propertyStore ) /** * Converts physical changes to PropertyRecords for a entity into logical updates */ - public void convertPropertyRecord( EntityCommandGrouper changes, EntityUpdates.Builder properties ) + public void convertPropertyRecord( EntityCommandGrouper.Cursor changes, EntityUpdates.Builder properties ) { mapBlocks( changes ); @@ -115,7 +115,7 @@ else if ( beforeKey > afterKey ) } } - private void mapBlocks( EntityCommandGrouper changes ) + private void mapBlocks( EntityCommandGrouper.Cursor changes ) { beforeBlocksCursor = 0; afterBlocksCursor = 0; diff --git a/community/kernel/src/main/java/org/neo4j/kernel/impl/transaction/command/IndexUpdatesWork.java b/community/kernel/src/main/java/org/neo4j/kernel/impl/transaction/command/IndexUpdatesWork.java index 610311b59b238..2fec33281946a 100644 --- a/community/kernel/src/main/java/org/neo4j/kernel/impl/transaction/command/IndexUpdatesWork.java +++ b/community/kernel/src/main/java/org/neo4j/kernel/impl/transaction/command/IndexUpdatesWork.java @@ -84,7 +84,8 @@ protected Iterator> createNestedIterator( Ind } @Override - public void feed( EntityCommandGrouper nodeCommands, EntityCommandGrouper relationshipCommands ) + public void feed( EntityCommandGrouper.Cursor nodeCommands, + EntityCommandGrouper.Cursor relationshipCommands ) { throw new UnsupportedOperationException(); } diff --git a/community/kernel/src/main/java/org/neo4j/kernel/impl/transaction/state/DirectIndexUpdates.java b/community/kernel/src/main/java/org/neo4j/kernel/impl/transaction/state/DirectIndexUpdates.java index 916de10adac3e..6e0e60d43ecb5 100644 --- a/community/kernel/src/main/java/org/neo4j/kernel/impl/transaction/state/DirectIndexUpdates.java +++ b/community/kernel/src/main/java/org/neo4j/kernel/impl/transaction/state/DirectIndexUpdates.java @@ -45,7 +45,8 @@ public Iterator> iterator() } @Override - public void feed( EntityCommandGrouper nodeCommands, EntityCommandGrouper relationshipCommands ) + public void feed( EntityCommandGrouper.Cursor nodeCommands, + EntityCommandGrouper.Cursor relationshipCommands ) { throw new UnsupportedOperationException(); } diff --git a/community/kernel/src/main/java/org/neo4j/kernel/impl/transaction/state/IndexUpdates.java b/community/kernel/src/main/java/org/neo4j/kernel/impl/transaction/state/IndexUpdates.java index 3559913758b6f..88fd306f22229 100644 --- a/community/kernel/src/main/java/org/neo4j/kernel/impl/transaction/state/IndexUpdates.java +++ b/community/kernel/src/main/java/org/neo4j/kernel/impl/transaction/state/IndexUpdates.java @@ -31,10 +31,10 @@ public interface IndexUpdates extends Iterable nodeCommands, EntityCommandGrouper relationshipCommands ); + void feed( EntityCommandGrouper.Cursor nodeCommands, EntityCommandGrouper.Cursor relationshipCommands ); boolean hasUpdates(); } diff --git a/community/kernel/src/main/java/org/neo4j/kernel/impl/transaction/state/OnlineIndexUpdates.java b/community/kernel/src/main/java/org/neo4j/kernel/impl/transaction/state/OnlineIndexUpdates.java index 6823114791cdc..01cd4d2973fa9 100644 --- a/community/kernel/src/main/java/org/neo4j/kernel/impl/transaction/state/OnlineIndexUpdates.java +++ b/community/kernel/src/main/java/org/neo4j/kernel/impl/transaction/state/OnlineIndexUpdates.java @@ -51,7 +51,7 @@ * properties matching existing and online indexes; in that case the properties for that node needs to be read * from store since the commands in that transaction cannot itself provide enough information. * - * One instance can be {@link IndexUpdates#feed(EntityCommandGrouper,EntityCommandGrouper) fed} data about + * One instance can be {@link IndexUpdates#feed(EntityCommandGrouper.Cursor,EntityCommandGrouper.Cursor) fed} data about * multiple transactions, to be {@link #iterator() accessed} later. */ public class OnlineIndexUpdates implements IndexUpdates @@ -80,15 +80,15 @@ public Iterator> iterator() } @Override - public void feed( EntityCommandGrouper nodeCommands, EntityCommandGrouper relationshipCommands ) + public void feed( EntityCommandGrouper.Cursor nodeCommands, EntityCommandGrouper.Cursor relationshipCommands ) { while ( nodeCommands.nextEntity() ) { - gatherUpdatesFor( nodeCommands.getCurrentEntity(), nodeCommands.getCurrentEntityCommand(), nodeCommands ); + gatherUpdatesFor( nodeCommands.currentEntityId(), nodeCommands.currentEntityCommand(), nodeCommands ); } while ( relationshipCommands.nextEntity() ) { - gatherUpdatesFor( relationshipCommands.getCurrentEntity(), relationshipCommands.getCurrentEntityCommand(), relationshipCommands ); + gatherUpdatesFor( relationshipCommands.currentEntityId(), relationshipCommands.currentEntityCommand(), relationshipCommands ); } } @@ -98,7 +98,7 @@ public boolean hasUpdates() return !updates.isEmpty(); } - private void gatherUpdatesFor( long nodeId, NodeCommand nodeCommand, EntityCommandGrouper propertyCommands ) + private void gatherUpdatesFor( long nodeId, NodeCommand nodeCommand, EntityCommandGrouper.Cursor propertyCommands ) { EntityUpdates.Builder nodePropertyUpdate = gatherUpdatesFromCommandsForNode( nodeId, nodeCommand, propertyCommands ); @@ -112,7 +112,8 @@ private void gatherUpdatesFor( long nodeId, NodeCommand nodeCommand, EntityComma } } - private void gatherUpdatesFor( long relationshipId, RelationshipCommand relationshipCommand, EntityCommandGrouper propertyCommands ) + private void gatherUpdatesFor( long relationshipId, RelationshipCommand relationshipCommand, + EntityCommandGrouper.Cursor propertyCommands ) { EntityUpdates.Builder relationshipPropertyUpdate = gatherUpdatesFromCommandsForRelationship( relationshipId, relationshipCommand, propertyCommands ); @@ -127,7 +128,7 @@ private void gatherUpdatesFor( long relationshipId, RelationshipCommand relation private EntityUpdates.Builder gatherUpdatesFromCommandsForNode( long nodeId, NodeCommand nodeChanges, - EntityCommandGrouper propertyCommandsForNode ) + EntityCommandGrouper.Cursor propertyCommandsForNode ) { long[] nodeLabelsBefore; long[] nodeLabelsAfter; @@ -173,7 +174,7 @@ private static boolean providesCompleteListOfProperties( Command entityCommand ) } private EntityUpdates.Builder gatherUpdatesFromCommandsForRelationship( long relationshipId, RelationshipCommand relationshipCommand, - EntityCommandGrouper propertyCommands ) + EntityCommandGrouper.Cursor propertyCommands ) { long reltypeBefore; long reltypeAfter; diff --git a/community/kernel/src/test/java/org/neo4j/kernel/impl/api/index/EntityCommandGrouperTest.java b/community/kernel/src/test/java/org/neo4j/kernel/impl/api/index/EntityCommandGrouperTest.java index c4996e78e1632..27d6eb593a1ee 100644 --- a/community/kernel/src/test/java/org/neo4j/kernel/impl/api/index/EntityCommandGrouperTest.java +++ b/community/kernel/src/test/java/org/neo4j/kernel/impl/api/index/EntityCommandGrouperTest.java @@ -53,7 +53,8 @@ public void shouldHandleEmptyList() EntityCommandGrouper grouper = new EntityCommandGrouper<>( NodeCommand.class, 8 ); // when - boolean hasNext = grouper.nextEntity(); + EntityCommandGrouper.Cursor cursor = grouper.sortAndAccessGroups(); + boolean hasNext = cursor.nextEntity(); // then assertFalse( hasNext ); @@ -71,10 +72,10 @@ public void shouldSeeSingleGroupOfPropertiesWithNode() grouper.add( property1 ); grouper.add( property2 ); grouper.add( node ); // <-- deliberately out-of-place - grouper.sort(); + EntityCommandGrouper.Cursor cursor = grouper.sortAndAccessGroups(); // when/then - assertGroups( grouper, group( nodeId, node, property1, property2 ) ); + assertGroups( cursor, group( nodeId, node, property1, property2 ) ); } @Test @@ -87,10 +88,10 @@ public void shouldSeeSingleGroupOfPropertiesWithoutNode() Command.PropertyCommand property2 = property( nodeId ); grouper.add( property1 ); grouper.add( property2 ); - grouper.sort(); + EntityCommandGrouper.Cursor cursor = grouper.sortAndAccessGroups(); // when/then - assertGroups( grouper, group( nodeId, null, property1, property2 ) ); + assertGroups( cursor, group( nodeId, null, property1, property2 ) ); } @Test @@ -117,10 +118,10 @@ public void shouldSeeMultipleGroupsSomeOfThemWithNode() grouper.add( property ); } // ^^^ OK so we've generated property commands for random nodes in random order, let's sort them - grouper.sort(); + EntityCommandGrouper.Cursor cursor = grouper.sortAndAccessGroups(); // then - assertGroups( grouper, groups ); + assertGroups( cursor, groups ); } private NodeCommand node( long nodeId ) @@ -128,7 +129,7 @@ private NodeCommand node( long nodeId ) return new NodeCommand( new NodeRecord( nodeId ), new NodeRecord( nodeId ) ); } - private void assertGroups( EntityCommandGrouper grouper, Group... groups ) + private void assertGroups( EntityCommandGrouper.Cursor cursor, Group... groups ) { for ( Group group : groups ) { @@ -136,10 +137,10 @@ private void assertGroups( EntityCommandGrouper grouper, Group... groups ) { continue; } - assertTrue( grouper.nextEntity() ); - group.assertGroup( grouper ); + assertTrue( cursor.nextEntity() ); + group.assertGroup( cursor ); } - assertFalse( grouper.nextEntity() ); + assertFalse( cursor.nextEntity() ); } private Group group( long nodeId, NodeCommand nodeCommand, Command.PropertyCommand... properties ) @@ -172,14 +173,14 @@ void addProperty( Command.PropertyCommand property ) properties.add( property ); } - void assertGroup( EntityCommandGrouper grouper ) + void assertGroup( EntityCommandGrouper.Cursor cursor ) { - assertEquals( nodeId, grouper.getCurrentEntity() ); - assertSame( nodeCommand, grouper.getCurrentEntityCommand() ); + assertEquals( nodeId, cursor.currentEntityId() ); + assertSame( nodeCommand, cursor.currentEntityCommand() ); Set fromGrouper = new HashSet<>(); while ( true ) { - Command.PropertyCommand property = grouper.nextProperty(); + Command.PropertyCommand property = cursor.nextProperty(); if ( property == null ) { break; diff --git a/community/kernel/src/test/java/org/neo4j/kernel/impl/api/index/IndexingServiceTest.java b/community/kernel/src/test/java/org/neo4j/kernel/impl/api/index/IndexingServiceTest.java index 376d356b99c60..071c9a2bdaabc 100644 --- a/community/kernel/src/test/java/org/neo4j/kernel/impl/api/index/IndexingServiceTest.java +++ b/community/kernel/src/test/java/org/neo4j/kernel/impl/api/index/IndexingServiceTest.java @@ -885,7 +885,7 @@ public Iterator> iterator() } @Override - public void feed( EntityCommandGrouper nodeCommands, EntityCommandGrouper relationshipCommands ) + public void feed( EntityCommandGrouper.Cursor nodeCommands, EntityCommandGrouper.Cursor relationshipCommands ) { throw new UnsupportedOperationException(); } diff --git a/community/kernel/src/test/java/org/neo4j/kernel/impl/api/index/PropertyPhysicalToLogicalConverterTest.java b/community/kernel/src/test/java/org/neo4j/kernel/impl/api/index/PropertyPhysicalToLogicalConverterTest.java index 5b42958c82476..c29019b6acb24 100644 --- a/community/kernel/src/test/java/org/neo4j/kernel/impl/api/index/PropertyPhysicalToLogicalConverterTest.java +++ b/community/kernel/src/test/java/org/neo4j/kernel/impl/api/index/PropertyPhysicalToLogicalConverterTest.java @@ -236,8 +236,9 @@ private EntityUpdates convert( long[] labelsBefore, { grouper.add( change ); } - assertTrue( grouper.nextEntity() ); - converter.convertPropertyRecord( grouper, updates ); + EntityCommandGrouper.Cursor cursor = grouper.sortAndAccessGroups(); + assertTrue( cursor.nextEntity() ); + converter.convertPropertyRecord( cursor, updates ); return updates.build(); } diff --git a/community/kernel/src/test/java/org/neo4j/kernel/impl/storageengine/impl/recordstorage/TransactionRecordStateTest.java b/community/kernel/src/test/java/org/neo4j/kernel/impl/storageengine/impl/recordstorage/TransactionRecordStateTest.java index c7d6ff0ab300b..942a1d2f97cf4 100644 --- a/community/kernel/src/test/java/org/neo4j/kernel/impl/storageengine/impl/recordstorage/TransactionRecordStateTest.java +++ b/community/kernel/src/test/java/org/neo4j/kernel/impl/storageengine/impl/recordstorage/TransactionRecordStateTest.java @@ -19,7 +19,9 @@ */ package org.neo4j.kernel.impl.storageengine.impl.recordstorage; +import org.eclipse.collections.api.LongIterable; import org.eclipse.collections.api.set.primitive.MutableLongSet; +import org.eclipse.collections.impl.list.mutable.primitive.LongArrayList; import org.eclipse.collections.impl.set.mutable.primitive.LongHashSet; import org.junit.Rule; import org.junit.Test; @@ -43,6 +45,7 @@ import org.neo4j.kernel.impl.api.BatchTransactionApplier; import org.neo4j.kernel.impl.api.CommandVisitor; import org.neo4j.kernel.impl.api.TransactionToApply; +import org.neo4j.kernel.impl.api.index.EntityCommandGrouper; import org.neo4j.kernel.impl.api.index.EntityUpdates; import org.neo4j.kernel.impl.api.index.IndexingUpdateService; import org.neo4j.kernel.impl.api.index.PropertyCommandsExtractor; @@ -242,12 +245,12 @@ public void shouldCreateEqualEntityPropertyUpdatesOnRecoveryOfCreatedEntities() // -- later recovering that tx, there should be only one update for each type assertTrue( extractor.containsAnyEntityOrPropertyUpdate() ); MutableLongSet recoveredNodeIds = new LongHashSet(); - recoveredNodeIds.addAll( extractor.getNodeCommands().entityIds() ); + recoveredNodeIds.addAll( entityIds( extractor.getNodeCommands() ) ); assertEquals( 1, recoveredNodeIds.size() ); assertEquals( nodeId, recoveredNodeIds.longIterator().next() ); MutableLongSet recoveredRelIds = new LongHashSet(); - recoveredRelIds.addAll( extractor.getRelationshipCommands().entityIds() ); + recoveredRelIds.addAll( entityIds( extractor.getRelationshipCommands() ) ); assertEquals( 1, recoveredRelIds.size() ); assertEquals( relId, recoveredRelIds.longIterator().next() ); } @@ -1414,6 +1417,20 @@ private RelationshipGroupCommand singleRelationshipGroupCommand( Collection t instanceof RelationshipGroupCommand, commands ) ); } + public LongIterable entityIds( EntityCommandGrouper.Cursor cursor ) + { + LongArrayList list = new LongArrayList(); + if ( cursor.nextEntity() ) + { + while ( cursor.nextProperty() != null ) + { + // Just get any potential property commands out of the way + } + list.add( cursor.currentEntityId() ); + } + return list; + } + private class CollectingIndexingUpdateService implements IndexingUpdateService { final List entityUpdatesList = new ArrayList<>(); diff --git a/community/kernel/src/test/java/org/neo4j/kernel/impl/transaction/state/OnlineIndexUpdatesTest.java b/community/kernel/src/test/java/org/neo4j/kernel/impl/transaction/state/OnlineIndexUpdatesTest.java index 10fb4a0c69c6a..d4a1c643a204c 100644 --- a/community/kernel/src/test/java/org/neo4j/kernel/impl/transaction/state/OnlineIndexUpdatesTest.java +++ b/community/kernel/src/test/java/org/neo4j/kernel/impl/transaction/state/OnlineIndexUpdatesTest.java @@ -289,18 +289,19 @@ public void shouldUpdateCorrectIndexes() throws Exception assertThat( onlineIndexUpdates, not( containsInAnyOrder( indexDescriptor3 ) ) ); // This index is only for a different relationship type. } - private EntityCommandGrouper nodeGroup( Command.NodeCommand nodeCommand, Command.PropertyCommand... propertyCommands ) + private EntityCommandGrouper.Cursor nodeGroup( Command.NodeCommand nodeCommand, Command.PropertyCommand... propertyCommands ) { return group( nodeCommand, Command.NodeCommand.class, propertyCommands ); } - private EntityCommandGrouper relationshipGroup( Command.RelationshipCommand relationshipCommand, + private EntityCommandGrouper.Cursor relationshipGroup( Command.RelationshipCommand relationshipCommand, Command.PropertyCommand... propertyCommands ) { return group( relationshipCommand, Command.RelationshipCommand.class, propertyCommands ); } - private EntityCommandGrouper group( ENTITY entityCommand, Class cls, Command.PropertyCommand... propertyCommands ) + private EntityCommandGrouper.Cursor group( ENTITY entityCommand, Class cls, + Command.PropertyCommand... propertyCommands ) { EntityCommandGrouper grouper = new EntityCommandGrouper<>( cls, 8 ); if ( entityCommand != null ) @@ -311,7 +312,7 @@ private EntityCommandGrouper group( ENTITY enti { grouper.add( propertyCommand ); } - return grouper; + return grouper.sortAndAccessGroups(); } private long createRelationshipProperty( RelationshipRecord relRecord, Value propertyValue, int propertyKey )