use of org.neo4j.internal.recordstorage.RecordRelationshipScanCursor in project neo4j by neo4j.
the class RelationshipGroupChecker method checkToRelationship.
/**
* Check relationship groups to first in chain relationship. Run only on first node-range
*/
private void checkToRelationship(long fromGroupId, long toGroupId, PageCacheTracer pageCacheTracer) {
try (var cursorContext = new CursorContext(pageCacheTracer.createPageCursorTracer(RELATIONSHIP_GROUPS_CHECKER_TAG));
RecordReader<RelationshipGroupRecord> groupReader = new RecordReader<>(neoStores.getRelationshipGroupStore(), true, cursorContext);
RecordReader<RelationshipGroupRecord> comparativeReader = new RecordReader<>(neoStores.getRelationshipGroupStore(), false, cursorContext);
RecordStorageReader reader = new RecordStorageReader(neoStores);
RecordRelationshipScanCursor relationshipCursor = reader.allocateRelationshipScanCursor(cursorContext)) {
for (long id = fromGroupId; id < toGroupId && !context.isCancelled(); id++) {
RelationshipGroupRecord record = groupReader.read(id);
if (!record.inUse()) {
continue;
}
long owningNode = record.getOwningNode();
if (owningNode < 0) {
reporter.forRelationshipGroup(record).illegalOwner();
}
checkValidToken(record, record.getType(), context.tokenHolders.relationshipTypeTokens(), neoStores.getRelationshipTypeTokenStore(), (group, token) -> reporter.forRelationshipGroup(group).illegalRelationshipType(), (group, token) -> reporter.forRelationshipGroup(group).relationshipTypeNotInUse(token), cursorContext);
if (!NULL_REFERENCE.is(record.getNext())) {
RelationshipGroupRecord comparativeRecord = comparativeReader.read(record.getNext());
if (!comparativeRecord.inUse()) {
reporter.forRelationshipGroup(record).nextGroupNotInUse();
} else {
if (record.getType() >= comparativeRecord.getType()) {
reporter.forRelationshipGroup(record).invalidTypeSortOrder();
}
if (owningNode != comparativeRecord.getOwningNode()) {
reporter.forRelationshipGroup(record).nextHasOtherOwner(comparativeRecord);
}
}
}
checkRelationshipGroupRelationshipLink(relationshipCursor, record, record.getFirstOut(), RelationshipGroupLink.OUT, group -> reporter.forRelationshipGroup(group).firstOutgoingRelationshipNotInUse(), group -> reporter.forRelationshipGroup(group).firstOutgoingRelationshipNotFirstInChain(), group -> reporter.forRelationshipGroup(group).firstOutgoingRelationshipOfOtherType(), (group, rel) -> reporter.forRelationshipGroup(group).firstOutgoingRelationshipDoesNotShareNodeWithGroup(rel), cursorContext);
checkRelationshipGroupRelationshipLink(relationshipCursor, record, record.getFirstIn(), RelationshipGroupLink.IN, group -> reporter.forRelationshipGroup(group).firstIncomingRelationshipNotInUse(), group -> reporter.forRelationshipGroup(group).firstIncomingRelationshipNotFirstInChain(), group -> reporter.forRelationshipGroup(group).firstIncomingRelationshipOfOtherType(), (group, rel) -> reporter.forRelationshipGroup(group).firstIncomingRelationshipDoesNotShareNodeWithGroup(rel), cursorContext);
checkRelationshipGroupRelationshipLink(relationshipCursor, record, record.getFirstLoop(), RelationshipGroupLink.LOOP, group -> reporter.forRelationshipGroup(group).firstLoopRelationshipNotInUse(), group -> reporter.forRelationshipGroup(group).firstLoopRelationshipNotFirstInChain(), group -> reporter.forRelationshipGroup(group).firstLoopRelationshipOfOtherType(), (group, rel) -> reporter.forRelationshipGroup(group).firstLoopRelationshipDoesNotShareNodeWithGroup(rel), cursorContext);
}
}
}
Aggregations