@Override
 public Long indexGetOwningUniquenessConstraintId(StatementState state, IndexDescriptor index)
     throws SchemaRuleNotFoundException {
   return schemaStorage
       .indexRule(index.getLabelId(), index.getPropertyKeyId())
       .getOwningConstraint();
 }
 @Override
 public Iterator<UniquenessConstraint> constraintsGetAll(StatementState state) {
   return schemaStorage.schemaRules(
       UNIQUENESS_CONSTRAINT_TO_RULE,
       SchemaRule.Kind.UNIQUENESS_CONSTRAINT,
       Predicates.<UniquenessConstraintRule>TRUE());
 }
 @Override
 public Iterator<UniquenessConstraint> constraintsGetForLabel(StatementState state, long labelId) {
   return schemaStorage.schemaRules(
       UNIQUENESS_CONSTRAINT_TO_RULE,
       UniquenessConstraintRule.class,
       labelId,
       Predicates.<UniquenessConstraintRule>TRUE());
 }
 private long indexId(IndexDescriptor descriptor) throws IndexNotFoundKernelException {
   try {
     return schemaStorage
         .indexRule(descriptor.getLabelId(), descriptor.getPropertyKeyId())
         .getId();
   } catch (SchemaRuleNotFoundException e) {
     throw new IndexNotFoundKernelException(e.getMessage(), e);
   }
 }
 @Override
 public synchronized void setSchemaStorage(SchemaStorage storage) throws IOException {
   this.storage = storage;
   if (processor.getSchema() == null) {
     ByteBuffer schemaBuffer = storage.loadSchema();
     if (schemaBuffer != null) {
       ignoreNextUpdate = true;
       processor.loadSchema(schemaBuffer);
     }
   }
 }
 @Override
 public Iterator<UniquenessConstraint> constraintsGetForLabelAndPropertyKey(
     StatementState state, long labelId, final long propertyKeyId) {
   return schemaStorage.schemaRules(
       UNIQUENESS_CONSTRAINT_TO_RULE,
       UniquenessConstraintRule.class,
       labelId,
       new Predicate<UniquenessConstraintRule>() {
         @Override
         public boolean accept(UniquenessConstraintRule rule) {
           return rule.containsPropertyKeyId(propertyKeyId);
         }
       });
 }
 @Override
 public synchronized void onSchemaUpdated(Schema schema) {
   if (!ignoreNextUpdate) {
     try {
       byte[] schemaBuffer = schema.toString().getBytes("UTF-8");
       ByteBuffer buffer = ByteBuffer.wrap(schemaBuffer);
       if (storage != null) {
         storage.saveSchema(buffer);
       }
     } catch (UnsupportedEncodingException ex) {
       LOG.error("Failed to save schema: ", ex);
       throw new SchemaRuntimeException("Failed to save schema");
     }
   } else {
     ignoreNextUpdate = false;
   }
 }
 @Override
 public long indexGetCommittedId(StatementState state, IndexDescriptor index)
     throws SchemaRuleNotFoundException {
   return schemaStorage.indexRule(index.getLabelId(), index.getPropertyKeyId()).getId();
 }
 @Override
 public IndexDescriptor indexesGetForLabelAndPropertyKey(
     StatementState state, final long labelId, final long propertyKey)
     throws SchemaRuleNotFoundException {
   return descriptor(schemaStorage.indexRule(labelId, propertyKey));
 }