Search in sources :

Example 11 with IndexRule

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

the class NeoStoreTransactionApplierTest method shouldApplyUpdateIndexRuleSchemaRuleCommandToTheStore.

@Test
public void shouldApplyUpdateIndexRuleSchemaRuleCommandToTheStore() throws Exception {
    // given
    final BatchTransactionApplier applier = newApplierFacade(newIndexApplier(), newApplier(false));
    final DynamicRecord record = DynamicRecord.dynamicRecord(21, true);
    final Collection<DynamicRecord> recordsAfter = Arrays.asList(record);
    final IndexRule rule = constraintIndexRule(0, 1, 2, new SchemaIndexProvider.Descriptor("K", "X.Y"), 42L);
    final Command.SchemaRuleCommand command = new Command.SchemaRuleCommand(Collections.<DynamicRecord>emptyList(), recordsAfter, rule);
    // when
    boolean result = apply(applier, command::handle, transactionToApply);
    // then
    assertFalse(result);
    verify(schemaStore, times(1)).updateRecord(record);
    verify(indexingService, times(1)).activateIndex(rule.getId());
    verify(cacheAccess, times(1)).addSchemaRule(rule);
}
Also used : DynamicRecord(org.neo4j.kernel.impl.store.record.DynamicRecord) IndexRule(org.neo4j.kernel.impl.store.record.IndexRule) SchemaIndexProvider(org.neo4j.kernel.api.index.SchemaIndexProvider) RelationshipTypeTokenCommand(org.neo4j.kernel.impl.transaction.command.Command.RelationshipTypeTokenCommand) LabelTokenCommand(org.neo4j.kernel.impl.transaction.command.Command.LabelTokenCommand) PropertyKeyTokenCommand(org.neo4j.kernel.impl.transaction.command.Command.PropertyKeyTokenCommand) BatchTransactionApplier(org.neo4j.kernel.impl.api.BatchTransactionApplier) Test(org.junit.Test)

Example 12 with IndexRule

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

the class NeoStoreTransactionApplierTest method shouldApplyCreateIndexRuleSchemaRuleCommandToTheStore.

@Test
public void shouldApplyCreateIndexRuleSchemaRuleCommandToTheStore() throws Exception {
    // given
    final BatchTransactionApplier applier = newApplierFacade(newApplier(false), newIndexApplier());
    final DynamicRecord record = DynamicRecord.dynamicRecord(21, true);
    record.setCreated();
    final Collection<DynamicRecord> recordsAfter = Arrays.asList(record);
    final IndexRule rule = indexRule(0, 1, 2, new SchemaIndexProvider.Descriptor("K", "X.Y"));
    final Command.SchemaRuleCommand command = new Command.SchemaRuleCommand(Collections.<DynamicRecord>emptyList(), recordsAfter, rule);
    // when
    boolean result = apply(applier, command::handle, transactionToApply);
    // then
    assertFalse(result);
    verify(schemaStore, times(1)).updateRecord(record);
    verify(indexingService, times(1)).createIndexes(rule);
    verify(cacheAccess, times(1)).addSchemaRule(rule);
}
Also used : DynamicRecord(org.neo4j.kernel.impl.store.record.DynamicRecord) IndexRule(org.neo4j.kernel.impl.store.record.IndexRule) SchemaIndexProvider(org.neo4j.kernel.api.index.SchemaIndexProvider) RelationshipTypeTokenCommand(org.neo4j.kernel.impl.transaction.command.Command.RelationshipTypeTokenCommand) LabelTokenCommand(org.neo4j.kernel.impl.transaction.command.Command.LabelTokenCommand) PropertyKeyTokenCommand(org.neo4j.kernel.impl.transaction.command.Command.PropertyKeyTokenCommand) BatchTransactionApplier(org.neo4j.kernel.impl.api.BatchTransactionApplier) Test(org.junit.Test)

Example 13 with IndexRule

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

the class TransactionToRecordStateVisitor method visitRemovedIndex.

@Override
public void visitRemovedIndex(NewIndexDescriptor index) {
    IndexRule rule = schemaStorage.indexGetForSchema(index);
    recordState.dropSchemaRule(rule);
}
Also used : IndexRule(org.neo4j.kernel.impl.store.record.IndexRule)

Example 14 with IndexRule

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

the class TransactionToRecordStateVisitor method visitAddedConstraint.

@Override
public void visitAddedConstraint(ConstraintDescriptor constraint) throws CreateConstraintFailureException {
    clearSchemaState = true;
    long constraintId = schemaStorage.newRuleId();
    switch(constraint.type()) {
        case UNIQUE:
            UniquenessConstraintDescriptor uniqueConstraint = (UniquenessConstraintDescriptor) constraint;
            IndexRule indexRule = schemaStorage.indexGetForSchema(uniqueConstraint.ownedIndexDescriptor());
            recordState.createSchemaRule(constraintSemantics.createUniquenessConstraintRule(constraintId, uniqueConstraint, indexRule.getId()));
            recordState.setConstraintIndexOwner(indexRule, constraintId);
            break;
        case EXISTS:
            recordState.createSchemaRule(constraintSemantics.createExistenceConstraint(schemaStorage.newRuleId(), constraint));
            break;
        default:
            throw new IllegalStateException(constraint.type().toString());
    }
}
Also used : IndexRule(org.neo4j.kernel.impl.store.record.IndexRule) UniquenessConstraintDescriptor(org.neo4j.kernel.api.schema_new.constaints.UniquenessConstraintDescriptor)

Example 15 with IndexRule

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

the class TransactionToRecordStateVisitor method visitAddedIndex.

@Override
public void visitAddedIndex(NewIndexDescriptor index) {
    SchemaIndexProvider.Descriptor providerDescriptor = schemaIndexProviderMap.getDefaultProvider().getProviderDescriptor();
    IndexRule rule = IndexRule.indexRule(schemaStorage.newRuleId(), index, providerDescriptor);
    recordState.createSchemaRule(rule);
}
Also used : IndexRule(org.neo4j.kernel.impl.store.record.IndexRule) SchemaIndexProvider(org.neo4j.kernel.api.index.SchemaIndexProvider)

Aggregations

IndexRule (org.neo4j.kernel.impl.store.record.IndexRule)60 Test (org.junit.Test)42 SchemaIndexProvider (org.neo4j.kernel.api.index.SchemaIndexProvider)24 DynamicRecord (org.neo4j.kernel.impl.store.record.DynamicRecord)22 SchemaRuleUtil.constraintIndexRule (org.neo4j.consistency.checking.SchemaRuleUtil.constraintIndexRule)14 NodePropertyDescriptor (org.neo4j.kernel.api.schema.NodePropertyDescriptor)9 ConstraintRule (org.neo4j.kernel.impl.store.record.ConstraintRule)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 NewIndexDescriptor (org.neo4j.kernel.api.schema_new.index.NewIndexDescriptor)8 IndexSamplingConfig (org.neo4j.kernel.impl.api.index.sampling.IndexSamplingConfig)8 IndexAccessor (org.neo4j.kernel.api.index.IndexAccessor)7 BatchTransactionApplier (org.neo4j.kernel.impl.api.BatchTransactionApplier)7 SchemaStorage (org.neo4j.kernel.impl.store.SchemaStorage)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 ConsistencySummaryStatistics (org.neo4j.consistency.report.ConsistencySummaryStatistics)6