Esempio n. 1
0
 private IndexDescriptor createAnIndex(
     HighlyAvailableGraphDatabase db, Label label, String propertyName) throws KernelException {
   try (Transaction tx = db.beginTx()) {
     Statement statement = statement(db);
     int labelId = statement.tokenWriteOperations().labelGetOrCreateForName(label.name());
     int propertyKeyId =
         statement.tokenWriteOperations().propertyKeyGetOrCreateForName(propertyName);
     IndexDescriptor index = statement.schemaWriteOperations().indexCreate(labelId, propertyKeyId);
     tx.success();
     return index;
   }
 }
 private IndexDescriptor createIndex(String labelName, String propertyKeyName)
     throws KernelException {
   try (Transaction tx = db.beginTx()) {
     Statement statement = bridge.instance();
     int labelId = statement.tokenWriteOperations().labelGetOrCreateForName(labelName);
     int propertyKeyId =
         statement.tokenWriteOperations().propertyKeyGetOrCreateForName(propertyKeyName);
     IndexDescriptor index = statement.schemaWriteOperations().indexCreate(labelId, propertyKeyId);
     tx.success();
     return index;
   }
 }
 private long createNode(
     Statement statement, String labelName, String propertyKeyName, Object value)
     throws KernelException {
   int labelId = statement.tokenWriteOperations().labelGetOrCreateForName(labelName);
   int propertyKeyId =
       statement.tokenWriteOperations().propertyKeyGetOrCreateForName(propertyKeyName);
   long nodeId = statement.dataWriteOperations().nodeCreate();
   statement.dataWriteOperations().nodeAddLabel(nodeId, labelId);
   statement
       .dataWriteOperations()
       .nodeSetProperty(nodeId, Property.property(propertyKeyId, value));
   return nodeId;
 }
 private void changeName(long nodeId, String propertyKeyName, Object newValue)
     throws KernelException {
   try (Transaction tx = db.beginTx()) {
     Statement statement = bridge.instance();
     int propertyKeyId =
         statement.tokenWriteOperations().propertyKeyGetOrCreateForName(propertyKeyName);
     statement
         .dataWriteOperations()
         .nodeSetProperty(nodeId, Property.property(propertyKeyId, newValue));
     tx.success();
   }
 }