use of org.neo4j.storageengine.api.StorageCommand in project neo4j by neo4j.
the class TransactionRecordStateTest method shouldIgnoreRelationshipGroupCommandsForGroupThatIsCreatedAndDeletedInThisTx.
@Test
void shouldIgnoreRelationshipGroupCommandsForGroupThatIsCreatedAndDeletedInThisTx() throws Exception {
/*
* This test verifies that there are no transaction commands generated for a state diff that contains a
* relationship group that is created and deleted in this tx. This case requires special handling because
* relationship groups can be created and then deleted from disjoint code paths. Look at
* TransactionRecordState.extractCommands() for more details.
*
* The test setup looks complicated but all it does is mock properly a NeoStoreTransactionContext to
* return an Iterable<RecordSet> that contains a RelationshipGroup record which has been created in this
* tx and also is set notInUse.
*/
// Given:
// - dense node threshold of 5
// - node with 4 rels of type relationshipB and 1 rel of type relationshipB
neoStores = createStores(Config.defaults(dense_node_threshold, 5));
int relationshipA = 0;
int relationshipB = 1;
TransactionRecordState state = newTransactionRecordState();
state.nodeCreate(0);
state.relModify(singleCreate(0, relationshipA, 0, 0));
state.relModify(singleCreate(1, relationshipA, 0, 0));
state.relModify(singleCreate(2, relationshipA, 0, 0));
state.relModify(singleCreate(3, relationshipA, 0, 0));
state.relModify(singleCreate(4, relationshipB, 0, 0));
apply(state);
// When doing a tx where a relationship of type A for the node is create and rel of type relationshipB is deleted
state = newTransactionRecordState();
// here this node should be converted to dense and the groups should be created
// and the group relationshipB should be delete
state.relModify(new FlatRelationshipModifications(relationships(relationship(5, relationshipA, 0, 0)), relationships(relationship(4, relationshipB, 0, 0))));
// Then
Collection<StorageCommand> commands = new ArrayList<>();
state.extractCommands(commands, INSTANCE);
RelationshipGroupCommand group = singleRelationshipGroupCommand(commands);
assertEquals(relationshipA, group.getAfter().getType());
}
use of org.neo4j.storageengine.api.StorageCommand in project neo4j by neo4j.
the class TransactionRecordStateTest method readFromChannel.
@SuppressWarnings("InfiniteLoopStatement")
private static CommandsToApply readFromChannel(ReadableLogChannel channel) throws IOException {
CommandReader reader = LogCommandSerializationV4_0.INSTANCE;
List<StorageCommand> commands = new ArrayList<>();
try {
while (true) {
commands.add(reader.read(channel));
}
} catch (ReadPastEndException e) {
// reached the end
}
return new GroupOfCommands(commands.toArray(new StorageCommand[0]));
}
Aggregations