use of org.neo4j.kernel.impl.store.record.IndexRule in project neo4j by neo4j.
the class FullCheckIntegrationTest method shouldReportNodesThatAreNotIndexed.
@Test
public void shouldReportNodesThatAreNotIndexed() throws Exception {
// given
IndexSamplingConfig samplingConfig = new IndexSamplingConfig(Config.empty());
Iterator<IndexRule> indexRuleIterator = new SchemaStorage(fixture.directStoreAccess().nativeStores().getSchemaStore()).indexesGetAll();
while (indexRuleIterator.hasNext()) {
IndexRule indexRule = indexRuleIterator.next();
IndexAccessor accessor = fixture.directStoreAccess().indexes().getOnlineAccessor(indexRule.getId(), indexRule.getIndexDescriptor(), samplingConfig);
IndexUpdater updater = accessor.newUpdater(IndexUpdateMode.ONLINE);
updater.remove(asPrimitiveLongSet(indexedNodes));
updater.close();
accessor.close();
}
// when
ConsistencySummaryStatistics stats = check();
// then
on(stats).verify(RecordType.NODE, 1).andThatsAllFolks();
}
use of org.neo4j.kernel.impl.store.record.IndexRule in project neo4j by neo4j.
the class DumpCountsStore method getAllIndexesFrom.
private static Map<Long, NewIndexDescriptor> getAllIndexesFrom(SchemaStorage storage) {
HashMap<Long, NewIndexDescriptor> indexes = new HashMap<>();
Iterator<IndexRule> indexRules = storage.indexesGetAll();
while (indexRules.hasNext()) {
IndexRule rule = indexRules.next();
indexes.put(rule.getId(), rule.getIndexDescriptor());
}
return indexes;
}
use of org.neo4j.kernel.impl.store.record.IndexRule in project neo4j by neo4j.
the class UniquenessConstraintCreationIT method committedConstraintRuleShouldCrossReferenceTheCorrespondingIndexRule.
@Test
public void committedConstraintRuleShouldCrossReferenceTheCorrespondingIndexRule() throws Exception {
// when
SchemaWriteOperations statement = schemaWriteOperationsInNewTransaction();
statement.uniquePropertyConstraintCreate(descriptor);
commit();
// then
SchemaStorage schema = new SchemaStorage(neoStores().getSchemaStore());
IndexRule indexRule = schema.indexGetForSchema(NewIndexDescriptorFactory.uniqueForLabel(typeId, propertyKeyId));
ConstraintRule constraintRule = schema.constraintsGetSingle(ConstraintDescriptorFactory.uniqueForLabel(typeId, propertyKeyId));
assertEquals(constraintRule.getId(), indexRule.getOwningConstraint().longValue());
assertEquals(indexRule.getId(), constraintRule.getOwnedIndex());
}
use of org.neo4j.kernel.impl.store.record.IndexRule in project neo4j by neo4j.
the class SchemaRecordCheckTest method shouldReportTwoConstraintIndexesReferencingSameConstraint.
@Test
public void shouldReportTwoConstraintIndexesReferencingSameConstraint() throws Exception {
// given
int ruleId1 = 0;
int ruleId2 = 1;
DynamicRecord record1 = inUse(dynamicRecord(ruleId1));
DynamicRecord record2 = inUse(dynamicRecord(ruleId2));
SchemaIndexProvider.Descriptor providerDescriptor = new SchemaIndexProvider.Descriptor("in-memory", "1.0");
IndexRule rule1 = constraintIndexRule(ruleId1, labelId, propertyKeyId, providerDescriptor, (long) ruleId1);
IndexRule rule2 = constraintIndexRule(ruleId2, labelId, propertyKeyId, providerDescriptor, (long) ruleId1);
when(checker().ruleAccess.loadSingleSchemaRule(ruleId1)).thenReturn(rule1);
when(checker().ruleAccess.loadSingleSchemaRule(ruleId2)).thenReturn(rule2);
add(inUse(new LabelTokenRecord(labelId)));
add(inUse(new PropertyKeyTokenRecord(propertyKeyId)));
// when
check(record1);
ConsistencyReport.SchemaConsistencyReport report = check(record2);
// then
verify(report).duplicateObligation(record1);
}
use of org.neo4j.kernel.impl.store.record.IndexRule in project neo4j by neo4j.
the class SchemaRecordCheckTest method shouldReportConstraintIndexNotReferencingBack.
@Test
public void shouldReportConstraintIndexNotReferencingBack() throws Exception {
// given
int ruleId1 = 0;
int ruleId2 = 1;
DynamicRecord record1 = inUse(dynamicRecord(ruleId1));
DynamicRecord record2 = inUse(dynamicRecord(ruleId2));
SchemaIndexProvider.Descriptor providerDescriptor = new SchemaIndexProvider.Descriptor("in-memory", "1.0");
IndexRule rule1 = constraintIndexRule(ruleId1, labelId, propertyKeyId, providerDescriptor, (long) ruleId1);
ConstraintRule rule2 = uniquenessConstraintRule(ruleId2, labelId, propertyKeyId, ruleId1);
when(checker().ruleAccess.loadSingleSchemaRule(ruleId1)).thenReturn(rule1);
when(checker().ruleAccess.loadSingleSchemaRule(ruleId2)).thenReturn(rule2);
add(inUse(new LabelTokenRecord(labelId)));
add(inUse(new PropertyKeyTokenRecord(propertyKeyId)));
// when
check(record1);
check(record2);
SchemaRecordCheck obligationChecker = checker().forObligationChecking();
ConsistencyReport.SchemaConsistencyReport report = check(obligationChecker, record1);
check(obligationChecker, record2);
// then
verify(report).constraintIndexRuleNotReferencingBack(record2);
}
Aggregations