use of org.neo4j.kernel.impl.index.schema.EntityTokenRangeImpl in project neo4j by neo4j.
the class RelationshipChecker method checkRelationshipVsRelationshipTypeIndex.
private void checkRelationshipVsRelationshipTypeIndex(RelationshipRecord relationshipRecord, Iterator<EntityTokenRange> relationshipTypeRangeIterator, EntityTokenIndexCheckState relationshipTypeIndexState, long relationshipId, int type, long fromRelationshipId, CursorContext cursorContext) {
// Detect relationship-type combinations that exists in the relationship type index, but not in the store
while (relationshipTypeIndexState.needToMoveRangeForwardToReachEntity(relationshipId) && !context.isCancelled()) {
if (relationshipTypeRangeIterator.hasNext()) {
if (relationshipTypeIndexState.currentRange != null) {
for (long relationshipIdMissingFromStore = relationshipTypeIndexState.lastCheckedEntityId + 1; relationshipIdMissingFromStore < relationshipId && relationshipTypeIndexState.currentRange.covers(relationshipIdMissingFromStore); relationshipIdMissingFromStore++) {
if (relationshipTypeIndexState.currentRange.tokens(relationshipIdMissingFromStore).length > 0) {
reporter.forRelationshipTypeScan(new TokenScanDocument(relationshipTypeIndexState.currentRange)).relationshipNotInUse(recordLoader.relationship(relationshipIdMissingFromStore, cursorContext));
}
}
}
relationshipTypeIndexState.currentRange = relationshipTypeRangeIterator.next();
relationshipTypeIndexState.lastCheckedEntityId = Math.max(fromRelationshipId, relationshipTypeIndexState.currentRange.entities()[0]) - 1;
} else {
break;
}
}
if (relationshipTypeIndexState.currentRange != null && relationshipTypeIndexState.currentRange.covers(relationshipId)) {
for (long relationshipIdMissingFromStore = relationshipTypeIndexState.lastCheckedEntityId + 1; relationshipIdMissingFromStore < relationshipId; relationshipIdMissingFromStore++) {
if (relationshipTypeIndexState.currentRange.tokens(relationshipIdMissingFromStore).length > 0) {
reporter.forRelationshipTypeScan(new TokenScanDocument(relationshipTypeIndexState.currentRange)).relationshipNotInUse(recordLoader.relationship(relationshipIdMissingFromStore, cursorContext));
}
}
long[] relationshipTypesInTypeIndex = relationshipTypeIndexState.currentRange.tokens(relationshipId);
validateTypeIds(relationshipRecord, type, relationshipTypesInTypeIndex, relationshipTypeIndexState.currentRange, cursorContext);
relationshipTypeIndexState.lastCheckedEntityId = relationshipId;
} else {
TokenScanDocument document = new TokenScanDocument(new EntityTokenRangeImpl(relationshipId / Long.SIZE, NO_TOKENS, RELATIONSHIP));
reporter.forRelationshipTypeScan(document).relationshipTypeNotInIndex(recordLoader.relationship(relationshipId, cursorContext), type);
}
}
use of org.neo4j.kernel.impl.index.schema.EntityTokenRangeImpl in project neo4j by neo4j.
the class EntityTokenRangeTest method shouldAdaptToStringToEntityTypeRelationship.
@Test
void shouldAdaptToStringToEntityTypeRelationship() {
EntityTokenRange relationshipTypeRange = new EntityTokenRangeImpl(0, new long[0][], RELATIONSHIP);
assertThat(relationshipTypeRange.toString()).contains("RelationshipTypeRange");
}
use of org.neo4j.kernel.impl.index.schema.EntityTokenRangeImpl in project neo4j by neo4j.
the class EntityTokenRangeTest method shouldAdaptToStringToEntityTypeNode.
@Test
void shouldAdaptToStringToEntityTypeNode() {
EntityTokenRange nodeLabelRange = new EntityTokenRangeImpl(0, new long[0][], NODE);
assertThat(nodeLabelRange.toString()).contains("NodeLabelRange");
}
use of org.neo4j.kernel.impl.index.schema.EntityTokenRangeImpl in project neo4j by neo4j.
the class NodeChecker method checkNodeVsLabelIndex.
private void checkNodeVsLabelIndex(NodeRecord nodeRecord, Iterator<EntityTokenRange> nodeLabelRangeIterator, EntityTokenIndexCheckState labelIndexState, long nodeId, long[] labels, long fromNodeId, CursorContext cursorContext) {
// Detect node-label combinations that exist in the label index, but not in the store
while (labelIndexState.needToMoveRangeForwardToReachEntity(nodeId) && !context.isCancelled()) {
if (nodeLabelRangeIterator.hasNext()) {
if (labelIndexState.currentRange != null) {
for (long nodeIdMissingFromStore = labelIndexState.lastCheckedEntityId + 1; nodeIdMissingFromStore < nodeId & labelIndexState.currentRange.covers(nodeIdMissingFromStore); nodeIdMissingFromStore++) {
if (labelIndexState.currentRange.tokens(nodeIdMissingFromStore).length > 0) {
reporter.forNodeLabelScan(new TokenScanDocument(labelIndexState.currentRange)).nodeNotInUse(recordLoader.node(nodeIdMissingFromStore, cursorContext));
}
}
}
labelIndexState.currentRange = nodeLabelRangeIterator.next();
labelIndexState.lastCheckedEntityId = max(fromNodeId, labelIndexState.currentRange.entities()[0]) - 1;
} else {
break;
}
}
if (labelIndexState.currentRange != null && labelIndexState.currentRange.covers(nodeId)) {
for (long nodeIdMissingFromStore = labelIndexState.lastCheckedEntityId + 1; nodeIdMissingFromStore < nodeId; nodeIdMissingFromStore++) {
if (labelIndexState.currentRange.tokens(nodeIdMissingFromStore).length > 0) {
reporter.forNodeLabelScan(new TokenScanDocument(labelIndexState.currentRange)).nodeNotInUse(recordLoader.node(nodeIdMissingFromStore, cursorContext));
}
}
long[] labelsInLabelIndex = labelIndexState.currentRange.tokens(nodeId);
if (labels != null) {
validateLabelIds(nodeRecord, labels, sortAndDeduplicate(labelsInLabelIndex), /* TODO remove when fixed */
labelIndexState.currentRange, cursorContext);
}
labelIndexState.lastCheckedEntityId = nodeId;
} else if (labels != null) {
for (long label : labels) {
reporter.forNodeLabelScan(new TokenScanDocument(new EntityTokenRangeImpl(nodeId / Long.SIZE, EntityTokenRangeImpl.NO_TOKENS, NODE))).nodeLabelNotInIndex(recordLoader.node(nodeId, cursorContext), label);
}
}
}
use of org.neo4j.kernel.impl.index.schema.EntityTokenRangeImpl in project neo4j by neo4j.
the class MessageConsistencyLoggerTest method shouldAdaptLogMessageToEntityTokenRangeTypeNode.
@Test
void shouldAdaptLogMessageToEntityTokenRangeTypeNode() {
// when
logger.error(RecordType.LABEL_SCAN_DOCUMENT, new TokenScanDocument(new EntityTokenRangeImpl(0, new long[0][], NODE)), "Some label index error", new NodeRecord(1));
// then
logMatcher.containsMessages("NodeLabelRange");
}
Aggregations