コード例 #1
0
ファイル: HaCountsIT.java プロジェクト: akollegger/neo4j
 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;
   }
 }
コード例 #2
0
 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;
   }
 }
コード例 #3
0
 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;
 }
コード例 #4
0
 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();
   }
 }