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);
}
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);
}
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);
}
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());
}
}
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);
}
Aggregations