use of org.neo4j.kernel.impl.store.NodeStore in project neo4j by neo4j.
the class TransactionRecordStateTest method assertRelationshipGroupsInOrder.
private static void assertRelationshipGroupsInOrder(NeoStores neoStores, long nodeId, int... types) {
NodeStore nodeStore = neoStores.getNodeStore();
NodeRecord node = nodeStore.getRecord(nodeId, nodeStore.newRecord(), NORMAL, NULL);
assertTrue(node.isDense(), "Node should be dense, is " + node);
long groupId = node.getNextRel();
int cursor = 0;
List<RelationshipGroupRecord> seen = new ArrayList<>();
while (groupId != Record.NO_NEXT_RELATIONSHIP.intValue()) {
RecordStore<RelationshipGroupRecord> relationshipGroupStore = neoStores.getRelationshipGroupStore();
RelationshipGroupRecord group = relationshipGroupStore.getRecord(groupId, relationshipGroupStore.newRecord(), NORMAL, NULL);
seen.add(group);
assertEquals(types[cursor++], group.getType(), "Invalid type, seen groups so far " + seen);
groupId = group.getNext();
}
assertEquals(types.length, cursor, "Not enough relationship group records found in chain for " + node);
}
use of org.neo4j.kernel.impl.store.NodeStore 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