示例#1
0
 public void addNodeToIndex(String indexName, String key, Object value, long id)
     throws DatabaseBlockedException {
   Index<Node> index = database.getNodeIndex(indexName);
   Transaction tx = database.graph.beginTx();
   try {
     index.add(database.graph.getNodeById(id), key, value);
     tx.success();
   } finally {
     tx.finish();
   }
 }
示例#2
0
  public Collection<Long> getIndexedNodes(String indexName, String key, Object value)
      throws DatabaseBlockedException {

    Index<Node> index = database.getNodeIndex(indexName);
    Transaction tx = database.graph.beginTx();
    try {
      Collection<Long> result = new ArrayList<Long>();
      for (Node node : index.get(key, value)) {
        result.add(node.getId());
      }
      tx.success();
      return result;
    } finally {
      tx.finish();
    }
  }