use of org.neo4j.internal.helpers.collection.LongRange in project neo4j by neo4j.
the class RecordStorageConsistencyChecker method check.
public void check() throws ConsistencyCheckIncompleteException {
assert !context.isCancelled();
try {
context.initialize();
// Starting by loading all tokens from store into the TokenHolders, loaded in a safe way of course
safeLoadTokens(neoStores);
// Check schema - constraints and indexes, that sort of thing
// This is done before instantiating the other checker instances because the schema checker will also
// populate maps regarding mandatory properties which the node/relationship checkers uses
SchemaChecker schemaChecker = new SchemaChecker(context);
MutableIntObjectMap<MutableIntSet> mandatoryNodeProperties = new IntObjectHashMap<>();
MutableIntObjectMap<MutableIntSet> mandatoryRelationshipProperties = new IntObjectHashMap<>();
try (var cursorContext = new CursorContext(cacheTracer.createPageCursorTracer(SCHEMA_CONSISTENCY_CHECKER_TAG))) {
schemaChecker.check(mandatoryNodeProperties, mandatoryRelationshipProperties, cursorContext);
}
// Some pieces of check logic are extracted from this main class to reduce the size of this class. Instantiate those here first
NodeChecker nodeChecker = new NodeChecker(context, mandatoryNodeProperties);
IndexChecker indexChecker = new IndexChecker(context, EntityType.NODE);
RelationshipChecker relationshipChecker = new RelationshipChecker(context, mandatoryRelationshipProperties);
RelationshipGroupChecker relationshipGroupChecker = new RelationshipGroupChecker(context);
RelationshipChainChecker relationshipChainChecker = new RelationshipChainChecker(context);
ProgressMonitorFactory.Completer progressCompleter = progress.build();
int numberOfRanges = limiter.numberOfRanges();
for (int i = 1; limiter.hasNext(); i++) {
if (isCancelled()) {
break;
}
LongRange range = limiter.next();
if (numberOfRanges > 1) {
context.debug("=== Checking range %d/%d (%s) ===", i, numberOfRanges, range);
}
context.initializeRange();
// Tell the cache that the pivot node id is the low end of this range. This will make all interactions with the cache
// take that into consideration when working with offset arrays where the index is based on node ids.
cacheAccess.setPivotId(range.from());
// Go into a node-centric mode where the nodes themselves are checked and somewhat cached off-heap.
// Then while we have the nodes loaded in cache do all other checking that has anything to do with nodes
// so that the "other" store can be checked sequentially and the random node lookups will be cheap
context.runIfAllowed(indexChecker, range);
cacheAccess.setCacheSlotSizesAndClear(DEFAULT_SLOT_SIZES);
context.runIfAllowed(nodeChecker, range);
context.runIfAllowed(relationshipGroupChecker, range);
context.runIfAllowed(relationshipChecker, range);
context.runIfAllowed(relationshipChainChecker, range);
}
if (!isCancelled() && context.consistencyFlags.isCheckGraph()) {
// All counts we've observed while doing other checking along the way we compare against the counts store here
checkCounts();
}
progressCompleter.close();
} catch (Exception e) {
cancel("ConsistencyChecker failed unexpectedly");
throw new ConsistencyCheckIncompleteException(e);
}
}
use of org.neo4j.internal.helpers.collection.LongRange in project neo4j by neo4j.
the class NodeBasedMemoryLimiter method fetchNextOrNull.
@Override
protected LongRange fetchNextOrNull() {
if (currentRangeStart >= highNodeId) {
return null;
}
LongRange range = LongRange.range(currentRangeStart, currentRangeEnd);
currentRangeStart = currentRangeEnd;
currentRangeEnd = min(highNodeId, currentRangeEnd + nodesPerRange);
return range;
}
use of org.neo4j.internal.helpers.collection.LongRange in project neo4j by neo4j.
the class NodeBasedMemoryLimiterTest method shouldReturnTheWholeRangeIfItFits.
@Test
void shouldReturnTheWholeRangeIfItFits() {
// given
NodeBasedMemoryLimiter limiter = new NodeBasedMemoryLimiter(100, 100, 250, 1, 40, 1);
assertEquals(1, limiter.numberOfRanges());
// when
LongRange range = limiter.next();
// then
assertRange(range, 0, 40);
assertFalse(limiter.hasNext());
}
Aggregations