Search in sources :

Example 11 with RelationshipGroupStore

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();
}
Also used : NodeRecord(org.neo4j.kernel.impl.store.record.NodeRecord) NodeStore(org.neo4j.kernel.impl.store.NodeStore) RelationshipGroupRecord(org.neo4j.kernel.impl.store.record.RelationshipGroupRecord) RelationshipGroupStore(org.neo4j.kernel.impl.store.RelationshipGroupStore) RelationshipStore(org.neo4j.kernel.impl.store.RelationshipStore) RelationshipRecord(org.neo4j.kernel.impl.store.record.RelationshipRecord) Test(org.junit.jupiter.api.Test)

Aggregations

RelationshipGroupStore (org.neo4j.kernel.impl.store.RelationshipGroupStore)11 RelationshipGroupRecord (org.neo4j.kernel.impl.store.record.RelationshipGroupRecord)7 NodeStore (org.neo4j.kernel.impl.store.NodeStore)6 RelationshipStore (org.neo4j.kernel.impl.store.RelationshipStore)5 Test (org.junit.jupiter.api.Test)4 NodeRecord (org.neo4j.kernel.impl.store.record.NodeRecord)4 NeoStores (org.neo4j.kernel.impl.store.NeoStores)3 RelationshipRecord (org.neo4j.kernel.impl.store.record.RelationshipRecord)3 PageCursor (org.neo4j.io.pagecache.PageCursor)2 DynamicArrayStore (org.neo4j.kernel.impl.store.DynamicArrayStore)2 DynamicStringStore (org.neo4j.kernel.impl.store.DynamicStringStore)2 PropertyStore (org.neo4j.kernel.impl.store.PropertyStore)2 LinkedList (java.util.LinkedList)1 MutableLongLongMap (org.eclipse.collections.api.map.primitive.MutableLongLongMap)1 CacheAccess (org.neo4j.consistency.checking.cache.CacheAccess)1 RelationshipGroupDegreesStore (org.neo4j.internal.counts.RelationshipGroupDegreesStore)1 ProgressListener (org.neo4j.internal.helpers.progress.ProgressListener)1 RecordProxy (org.neo4j.internal.recordstorage.RecordAccess.RecordProxy)1 RecordStorageEngine (org.neo4j.internal.recordstorage.RecordStorageEngine)1 RecordStorageReader (org.neo4j.internal.recordstorage.RecordStorageReader)1