Ejemplo n.º 1
0
 @Override
 public UniquenessConstraint apply(UniquenessConstraintRule rule) {
   // We can use propertyKeyId straight up here, without reading from the record, since
   // we have
   // verified that it has that propertyKeyId in the predicate. And since we currently
   // only support
   // uniqueness on single properties, there is nothing else to pass in to
   // UniquenessConstraint.
   return new UniquenessConstraint(rule.getLabel(), rule.getPropertyKey());
 }
Ejemplo n.º 2
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();
  }