Search in sources :

Example 1 with IndexRule

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();
}
Also used : IndexSamplingConfig(org.neo4j.kernel.impl.api.index.sampling.IndexSamplingConfig) IndexRule(org.neo4j.kernel.impl.store.record.IndexRule) SchemaRuleUtil.constraintIndexRule(org.neo4j.consistency.checking.SchemaRuleUtil.constraintIndexRule) SchemaStorage(org.neo4j.kernel.impl.store.SchemaStorage) IndexAccessor(org.neo4j.kernel.api.index.IndexAccessor) IndexUpdater(org.neo4j.kernel.api.index.IndexUpdater) ConsistencySummaryStatistics(org.neo4j.consistency.report.ConsistencySummaryStatistics) Test(org.junit.Test)

Example 2 with IndexRule

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;
}
Also used : IndexRule(org.neo4j.kernel.impl.store.record.IndexRule) NewIndexDescriptor(org.neo4j.kernel.api.schema_new.index.NewIndexDescriptor) HashMap(java.util.HashMap)

Example 3 with IndexRule

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());
}
Also used : IndexRule(org.neo4j.kernel.impl.store.record.IndexRule) SchemaWriteOperations(org.neo4j.kernel.api.SchemaWriteOperations) SchemaStorage(org.neo4j.kernel.impl.store.SchemaStorage) ConstraintRule(org.neo4j.kernel.impl.store.record.ConstraintRule) Test(org.junit.Test)

Example 4 with IndexRule

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);
}
Also used : DynamicRecord(org.neo4j.kernel.impl.store.record.DynamicRecord) IndexRule(org.neo4j.kernel.impl.store.record.IndexRule) SchemaRuleUtil.constraintIndexRule(org.neo4j.consistency.checking.SchemaRuleUtil.constraintIndexRule) SchemaIndexProvider(org.neo4j.kernel.api.index.SchemaIndexProvider) NodePropertyDescriptor(org.neo4j.kernel.api.schema.NodePropertyDescriptor) LabelTokenRecord(org.neo4j.kernel.impl.store.record.LabelTokenRecord) PropertyKeyTokenRecord(org.neo4j.kernel.impl.store.record.PropertyKeyTokenRecord) ConsistencyReport(org.neo4j.consistency.report.ConsistencyReport) Test(org.junit.Test)

Example 5 with IndexRule

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);
}
Also used : DynamicRecord(org.neo4j.kernel.impl.store.record.DynamicRecord) IndexRule(org.neo4j.kernel.impl.store.record.IndexRule) SchemaRuleUtil.constraintIndexRule(org.neo4j.consistency.checking.SchemaRuleUtil.constraintIndexRule) SchemaIndexProvider(org.neo4j.kernel.api.index.SchemaIndexProvider) ConstraintRule(org.neo4j.kernel.impl.store.record.ConstraintRule) SchemaRuleUtil.uniquenessConstraintRule(org.neo4j.consistency.checking.SchemaRuleUtil.uniquenessConstraintRule) NodePropertyDescriptor(org.neo4j.kernel.api.schema.NodePropertyDescriptor) LabelTokenRecord(org.neo4j.kernel.impl.store.record.LabelTokenRecord) PropertyKeyTokenRecord(org.neo4j.kernel.impl.store.record.PropertyKeyTokenRecord) ConsistencyReport(org.neo4j.consistency.report.ConsistencyReport) Test(org.junit.Test)

Aggregations

IndexRule (org.neo4j.kernel.impl.store.record.IndexRule)47 Test (org.junit.Test)30 SchemaIndexProvider (org.neo4j.kernel.api.index.SchemaIndexProvider)20 DynamicRecord (org.neo4j.kernel.impl.store.record.DynamicRecord)19 SchemaRuleUtil.constraintIndexRule (org.neo4j.consistency.checking.SchemaRuleUtil.constraintIndexRule)10 NodePropertyDescriptor (org.neo4j.kernel.api.schema.NodePropertyDescriptor)9 LabelTokenRecord (org.neo4j.kernel.impl.store.record.LabelTokenRecord)9 PropertyKeyTokenRecord (org.neo4j.kernel.impl.store.record.PropertyKeyTokenRecord)9 ConsistencyReport (org.neo4j.consistency.report.ConsistencyReport)8 ConstraintRule (org.neo4j.kernel.impl.store.record.ConstraintRule)8 BatchTransactionApplier (org.neo4j.kernel.impl.api.BatchTransactionApplier)7 LabelTokenCommand (org.neo4j.kernel.impl.transaction.command.Command.LabelTokenCommand)7 PropertyKeyTokenCommand (org.neo4j.kernel.impl.transaction.command.Command.PropertyKeyTokenCommand)7 RelationshipTypeTokenCommand (org.neo4j.kernel.impl.transaction.command.Command.RelationshipTypeTokenCommand)7 ArrayList (java.util.ArrayList)6 SchemaStorage (org.neo4j.kernel.impl.store.SchemaStorage)6 NewIndexDescriptor (org.neo4j.kernel.api.schema_new.index.NewIndexDescriptor)4 IndexSamplingConfig (org.neo4j.kernel.impl.api.index.sampling.IndexSamplingConfig)4 SchemaStore (org.neo4j.kernel.impl.store.SchemaStore)4 SchemaRule (org.neo4j.storageengine.api.schema.SchemaRule)4