Beispiel #1
0
  private void createConstraintRule(UniquenessConstraint constraint) {
    // TODO: Do not create duplicate index

    SchemaStore schemaStore = getSchemaStore();

    long indexRuleId = schemaStore.nextId();
    long constraintRuleId = schemaStore.nextId();

    IndexRule indexRule =
        IndexRule.constraintIndexRule(
            indexRuleId,
            constraint.label(),
            constraint.propertyKeyId(),
            this.schemaIndexProviders.getDefaultProvider().getProviderDescriptor(),
            constraintRuleId);
    UniquenessConstraintRule constraintRule =
        UniquenessConstraintRule.uniquenessConstraintRule(
            constraintRuleId, constraint.label(), constraint.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;
    recordAccess.commit();
  }
Beispiel #2
0
 private IndexRule[] getIndexesNeedingPopulation() {
   List<IndexRule> indexesNeedingPopulation = new ArrayList<>();
   for (SchemaRule rule : schemaCache.schemaRules()) {
     if (rule.getKind().isIndex()) {
       IndexRule indexRule = (IndexRule) rule;
       SchemaIndexProvider provider =
           schemaIndexProviders.apply(indexRule.getProviderDescriptor());
       if (provider.getInitialState(indexRule.getId()) != InternalIndexState.FAILED) {
         indexesNeedingPopulation.add(indexRule);
       }
     }
   }
   return indexesNeedingPopulation.toArray(new IndexRule[indexesNeedingPopulation.size()]);
 }
Beispiel #3
0
  private void createIndexRule(Label label, String propertyKey) {
    // TODO: Do not create duplicate index

    SchemaStore schemaStore = getSchemaStore();
    IndexRule schemaRule =
        IndexRule.indexRule(
            schemaStore.nextId(),
            getOrCreateLabelId(label.name()),
            getOrCreatePropertyKeyId(propertyKey),
            this.schemaIndexProviders.getDefaultProvider().getProviderDescriptor());
    for (DynamicRecord record : schemaStore.allocateFrom(schemaRule)) {
      schemaStore.updateRecord(record);
    }
    schemaCache.addSchemaRule(schemaRule);
  }
 private void loadSchemaCache() {
   schemaCache.clear();
   for (SchemaRule schemaRule : loop(neoStore.getSchemaStore().loadAllSchemaRules())) {
     schemaCache.addSchemaRule(schemaRule);
   }
 }