Search in sources :

Example 11 with LabelTokenRecord

use of org.neo4j.kernel.impl.store.record.LabelTokenRecord in project neo4j by neo4j.

the class SchemaRecordCheckTest method shouldReportUnreferencedUniquenessConstraint.

@Test
public void shouldReportUnreferencedUniquenessConstraint() throws Exception {
    // given
    int ruleId = 0;
    DynamicRecord record = inUse(dynamicRecord(ruleId));
    ConstraintRule rule = uniquenessConstraintRule(ruleId, labelId, propertyKeyId, ruleId);
    when(checker().ruleAccess.loadSingleSchemaRule(ruleId)).thenReturn(rule);
    add(inUse(new LabelTokenRecord(labelId)));
    add(inUse(new PropertyKeyTokenRecord(propertyKeyId)));
    // when
    check(record);
    SchemaRecordCheck obligationChecker = checker().forObligationChecking();
    ConsistencyReport.SchemaConsistencyReport report = check(obligationChecker, record);
    // then
    verify(report).missingObligation(SchemaRule.Kind.CONSTRAINT_INDEX_RULE);
}
Also used : DynamicRecord(org.neo4j.kernel.impl.store.record.DynamicRecord) ConstraintRule(org.neo4j.kernel.impl.store.record.ConstraintRule) SchemaRuleUtil.uniquenessConstraintRule(org.neo4j.consistency.checking.SchemaRuleUtil.uniquenessConstraintRule) 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 12 with LabelTokenRecord

use of org.neo4j.kernel.impl.store.record.LabelTokenRecord 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)

Example 13 with LabelTokenRecord

use of org.neo4j.kernel.impl.store.record.LabelTokenRecord in project neo4j by neo4j.

the class TransactionWriter method label.

public void label(int id, String name, int... dynamicIds) {
    LabelTokenRecord before = new LabelTokenRecord(id);
    LabelTokenRecord after = withName(new LabelTokenRecord(id), dynamicIds, name);
    otherCommands.add(new Command.LabelTokenCommand(before, after));
}
Also used : StorageCommand(org.neo4j.storageengine.api.StorageCommand) Command(org.neo4j.kernel.impl.transaction.command.Command) LabelTokenRecord(org.neo4j.kernel.impl.store.record.LabelTokenRecord)

Example 14 with LabelTokenRecord

use of org.neo4j.kernel.impl.store.record.LabelTokenRecord in project neo4j by neo4j.

the class NodeRecordCheckTest method shouldReportLabelNotInUse.

@Test
public void shouldReportLabelNotInUse() throws Exception {
    // given
    NodeRecord node = inUse(new NodeRecord(42, false, NONE, NONE));
    new InlineNodeLabels(node).add(1, null, null);
    LabelTokenRecord labelRecordNotInUse = notInUse(new LabelTokenRecord(1));
    add(labelRecordNotInUse);
    add(node);
    // when
    ConsistencyReport.NodeConsistencyReport report = check(node);
    // then
    verify(report).labelNotInUse(labelRecordNotInUse);
}
Also used : NodeRecord(org.neo4j.kernel.impl.store.record.NodeRecord) InlineNodeLabels(org.neo4j.kernel.impl.store.InlineNodeLabels) LabelTokenRecord(org.neo4j.kernel.impl.store.record.LabelTokenRecord) ConsistencyReport(org.neo4j.consistency.report.ConsistencyReport) Test(org.junit.Test)

Example 15 with LabelTokenRecord

use of org.neo4j.kernel.impl.store.record.LabelTokenRecord in project neo4j by neo4j.

the class NodeRecordCheckTest method shouldReportOutOfOrderLabels.

@Test
public void shouldReportOutOfOrderLabels() throws Exception {
    // given
    final NodeRecord node = inUse(new NodeRecord(42, false, NONE, NONE));
    // We need to do this override so we can put the labels unsorted, since InlineNodeLabels always sorts on insert
    new InlineNodeLabels(node) {

        @Override
        public Collection<DynamicRecord> put(long[] labelIds, NodeStore nodeStore, DynamicRecordAllocator allocator) {
            return putSorted(node, labelIds, nodeStore, allocator);
        }
    }.put(new long[] { 3, 1, 2 }, null, null);
    LabelTokenRecord label1 = inUse(new LabelTokenRecord(1));
    LabelTokenRecord label2 = inUse(new LabelTokenRecord(2));
    LabelTokenRecord label3 = inUse(new LabelTokenRecord(3));
    add(label1);
    add(label2);
    add(label3);
    add(node);
    // when
    ConsistencyReport.NodeConsistencyReport report = check(node);
    // then
    verify(report).labelsOutOfOrder(3, 1);
}
Also used : NodeRecord(org.neo4j.kernel.impl.store.record.NodeRecord) InlineNodeLabels(org.neo4j.kernel.impl.store.InlineNodeLabels) DynamicRecordAllocator(org.neo4j.kernel.impl.store.DynamicRecordAllocator) NodeStore(org.neo4j.kernel.impl.store.NodeStore) Collection(java.util.Collection) LabelTokenRecord(org.neo4j.kernel.impl.store.record.LabelTokenRecord) ConsistencyReport(org.neo4j.consistency.report.ConsistencyReport) Test(org.junit.Test)

Aggregations

LabelTokenRecord (org.neo4j.kernel.impl.store.record.LabelTokenRecord)43 Test (org.junit.Test)26 DynamicRecord (org.neo4j.kernel.impl.store.record.DynamicRecord)23 ConsistencyReport (org.neo4j.consistency.report.ConsistencyReport)20 PropertyKeyTokenRecord (org.neo4j.kernel.impl.store.record.PropertyKeyTokenRecord)14 SchemaRuleUtil.constraintIndexRule (org.neo4j.consistency.checking.SchemaRuleUtil.constraintIndexRule)8 SchemaIndexProvider (org.neo4j.kernel.api.index.SchemaIndexProvider)8 NodePropertyDescriptor (org.neo4j.kernel.api.schema.NodePropertyDescriptor)8 IndexRule (org.neo4j.kernel.impl.store.record.IndexRule)8 IOException (java.io.IOException)7 NodeRecord (org.neo4j.kernel.impl.store.record.NodeRecord)7 SchemaRuleUtil.uniquenessConstraintRule (org.neo4j.consistency.checking.SchemaRuleUtil.uniquenessConstraintRule)5 ConstraintRule (org.neo4j.kernel.impl.store.record.ConstraintRule)5 InlineNodeLabels (org.neo4j.kernel.impl.store.InlineNodeLabels)4 StorageCommand (org.neo4j.storageengine.api.StorageCommand)4 NodeStore (org.neo4j.kernel.impl.store.NodeStore)3 RelationshipTypeTokenRecord (org.neo4j.kernel.impl.store.record.RelationshipTypeTokenRecord)3 Command (org.neo4j.kernel.impl.transaction.command.Command)3 LabelTokenCommand (org.neo4j.kernel.impl.transaction.command.Command.LabelTokenCommand)3 Collection (java.util.Collection)2