예제 #1
0
 private CypherResult doExecuteQuery(String query, boolean canProfile) {
   long time = System.currentTimeMillis();
   Transaction tx = gdb.beginTx();
   javax.transaction.Transaction resumeTx;
   try {
     resumeTx = suspendTx(query);
     ExecutionResult result =
         canProfile ? executionEngine.profile(query) : executionEngine.execute(query);
     final Collection<Map<String, Object>> data = IteratorUtil.asCollection(result);
     time = System.currentTimeMillis() - time;
     resumeTransaction(resumeTx);
     CypherResult cypherResult =
         new CypherResult(
             result.columns(),
             data,
             result.getQueryStatistics(),
             time,
             canProfile ? result.executionPlanDescription() : null,
             prettify(query));
     tx.success();
     return cypherResult;
   } finally {
     tx.close();
   }
 }
예제 #2
0
 private javax.transaction.Transaction suspendTx(String query) {
   if (!executionEngine.isPeriodicCommitQuery(query)) return null;
   try {
     return transactionManager.suspend();
   } catch (SystemException e) {
     throw new RuntimeException("Error suspending Transaction", e);
   }
 }
예제 #3
0
 @Override
 protected ExecutionResult getResult(String query, Map<String, Object> parameters)
     throws ShellException, RemoteException, SystemException {
   GraphDatabaseAPI graphDatabaseAPI = getServer().getDb();
   ServerExecutionEngine engine = getEngine();
   if (engine.isPeriodicCommitQuery(query)) {
     TransactionManager manager =
         graphDatabaseAPI.getDependencyResolver().resolveDependency(TransactionManager.class);
     Transaction tx = manager.suspend();
     try {
       return super.getResult(query, parameters);
     } finally {
       manager.resume(tx);
     }
   } else {
     return super.getResult(query, parameters);
   }
 }
예제 #4
0
파일: Using.java 프로젝트: Analect/neo4j
  @Override
  protected ExtendedExecutionResult getResult(String query, Map<String, Object> parameters)
      throws ShellException, RemoteException {
    GraphDatabaseAPI graphDatabaseAPI = getServer().getDb();
    ServerExecutionEngine engine = getEngine();
    if (engine.isPeriodicCommit(query)) {
      ThreadToStatementContextBridge manager =
          graphDatabaseAPI
              .getDependencyResolver()
              .resolveDependency(ThreadToStatementContextBridge.class);
      TopLevelTransaction tx = manager.getTopLevelTransactionBoundToThisThread(true);
      manager.unbindTransactionFromCurrentThread();

      try {
        return super.getResult(query, parameters);
      } finally {
        manager.bindTransactionToCurrentThread(tx);
      }
    } else {
      return super.getResult(query, parameters);
    }
  }
예제 #5
0
 public String prettify(String query) {
   return executionEngine.prettify(query).replaceAll("\n", "\n ");
 }