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 BatchInserterImpl method createIndexRule.
private void createIndexRule(int labelId, int[] propertyKeyIds) {
IndexRule schemaRule = IndexRule.indexRule(schemaStore.nextId(), NewIndexDescriptorFactory.forLabel(labelId, propertyKeyIds), schemaIndexProviders.getDefaultProvider().getProviderDescriptor());
for (DynamicRecord record : schemaStore.allocateFrom(schemaRule)) {
schemaStore.updateRecord(record);
}
schemaCache.addSchemaRule(schemaRule);
labelsTouched = true;
flushStrategy.forceFlush();
}
use of org.neo4j.kernel.impl.store.record.IndexRule in project neo4j by neo4j.
the class BatchInserterImpl method createUniquenessConstraintRule.
private void createUniquenessConstraintRule(UniquenessConstraint constraint) {
// TODO: Do not create duplicate index
long indexRuleId = schemaStore.nextId();
long constraintRuleId = schemaStore.nextId();
int propertyKeyId = constraint.indexDescriptor().schema().getPropertyId();
IndexRule indexRule = IndexRule.constraintIndexRule(indexRuleId, NewIndexDescriptorFactory.uniqueForLabel(constraint.label(), propertyKeyId), this.schemaIndexProviders.getDefaultProvider().getProviderDescriptor(), constraintRuleId);
ConstraintRule constraintRule = ConstraintRule.constraintRule(constraintRuleId, ConstraintDescriptorFactory.uniqueForLabel(constraint.label(), propertyKeyId), indexRuleId);
for (DynamicRecord record : schemaStore.allocateFrom(constraintRule)) {
schemaStore.updateRecord(record);
}
schemaCache.addSchemaRule(constraintRule);
for (DynamicRecord record : schemaStore.allocateFrom(indexRule)) {
schemaStore.updateRecord(record);
}
schemaCache.addSchemaRule(indexRule);
labelsTouched = true;
flushStrategy.forceFlush();
}
use of org.neo4j.kernel.impl.store.record.IndexRule in project neo4j by neo4j.
the class DumpCountsStoreTest method createSchemaStorage.
private SchemaStorage createSchemaStorage() {
SchemaStorage schemaStorage = mock(SchemaStorage.class);
SchemaIndexProvider.Descriptor providerDescriptor = new SchemaIndexProvider.Descriptor("in-memory", "1.0");
IndexRule rule = IndexRule.indexRule(indexId, descriptor, providerDescriptor);
ArrayList<IndexRule> rules = new ArrayList<>();
rules.add(rule);
when(schemaStorage.indexesGetAll()).thenReturn(rules.iterator());
return schemaStorage;
}
use of org.neo4j.kernel.impl.store.record.IndexRule in project neo4j by neo4j.
the class SchemaCache method addSchemaRule.
public void addSchemaRule(SchemaRule rule) {
if (rule instanceof ConstraintRule) {
ConstraintRule constraintRule = (ConstraintRule) rule;
constraintRuleById.put(constraintRule.getId(), constraintRule);
constraints.add(constraintSemantics.readConstraint(constraintRule));
} else if (rule instanceof IndexRule) {
IndexRule indexRule = (IndexRule) rule;
indexRuleById.put(indexRule.getId(), indexRule);
indexDescriptors.put(indexRule.schema(), indexRule.getIndexDescriptor());
}
}
Aggregations