use of org.neo4j.kernel.impl.store.RelationshipGroupStore in project neo4j by neo4j.
the class TransactionRecordStateTest method shouldDeleteEmptyGroupsWhenDeletingNodeAndLastRelationship.
@Test
void shouldDeleteEmptyGroupsWhenDeletingNodeAndLastRelationship() throws Exception {
// given
// node --> group A (empty) --> group B (not empty) --> group C (empty)
// |
// v
// relationship
neoStores = createStores();
NodeStore nodeStore = neoStores.getNodeStore();
RelationshipGroupStore groupStore = neoStores.getRelationshipGroupStore();
RelationshipStore relationshipStore = neoStores.getRelationshipStore();
long nodeId = nodeStore.nextId(NULL);
long relationshipId = relationshipStore.nextId(NULL);
long groupA = groupStore.nextId(NULL);
long groupB = groupStore.nextId(NULL);
long groupC = groupStore.nextId(NULL);
groupStore.updateRecord(new RelationshipGroupRecord(groupA).initialize(true, 0, NULL_REFERENCE.longValue(), NULL_REFERENCE.longValue(), NULL_REFERENCE.longValue(), nodeId, groupB), NULL);
groupStore.updateRecord(new RelationshipGroupRecord(groupB).initialize(true, 1, NULL_REFERENCE.longValue(), NULL_REFERENCE.longValue(), relationshipId, nodeId, groupC), NULL);
groupStore.updateRecord(new RelationshipGroupRecord(groupC).initialize(true, 2, NULL_REFERENCE.longValue(), NULL_REFERENCE.longValue(), NULL_REFERENCE.longValue(), nodeId, NULL_REFERENCE.longValue()), NULL);
relationshipStore.updateRecord(new RelationshipRecord(relationshipId).initialize(true, NO_NEXT_PROPERTY.longValue(), nodeId, nodeId, 1, 1, NULL_REFERENCE.longValue(), 1, NULL_REFERENCE.longValue(), true, true), NULL);
nodeStore.updateRecord(new NodeRecord(nodeId).initialize(true, NO_NEXT_PROPERTY.longValue(), true, groupA, Record.NO_LABELS_FIELD.longValue()), NULL);
// when
TransactionRecordState state = newTransactionRecordState();
state.relModify(singleDelete(relationship(relationshipId, 1, nodeId, nodeId)));
state.nodeDelete(nodeId);
apply(state);
// then
assertThat(nodeStore.isInUse(nodeId, NULL)).isFalse();
assertThat(groupStore.isInUse(groupA, NULL)).isFalse();
assertThat(groupStore.isInUse(groupB, NULL)).isFalse();
assertThat(groupStore.isInUse(groupC, NULL)).isFalse();
assertThat(relationshipStore.isInUse(relationshipId, NULL)).isFalse();
}
Aggregations