Murtadha Hubail has submitted this change and it was merged. ( 
https://asterix-gerrit.ics.uci.edu/3411 )

Change subject: [NO ISSUE][BAD] Coordinated Change for ResponsePrinter
......................................................................

[NO ISSUE][BAD] Coordinated Change for ResponsePrinter

- user model changes: no
- storage format changes: no
- interface changes: no

Details:
- Coordinated change for ResponsePrinter.

Change-Id: I9255ef88ea03df629ffe3ca2f1d9b08504459f06
---
M asterix-bad/src/main/java/org/apache/asterix/bad/BADJobService.java
M 
asterix-bad/src/main/java/org/apache/asterix/bad/lang/BADQueryTranslatorFactory.java
M 
asterix-bad/src/main/java/org/apache/asterix/bad/lang/BADStatementExecutor.java
M 
asterix-bad/src/main/java/org/apache/asterix/bad/recovery/BADGlobalRecoveryManager.java
4 files changed, 20 insertions(+), 12 deletions(-)

Approvals:
  Jenkins: Verified
  Till Westmann: Looks good to me, approved



diff --git 
a/asterix-bad/src/main/java/org/apache/asterix/bad/BADJobService.java 
b/asterix-bad/src/main/java/org/apache/asterix/bad/BADJobService.java
index a711a9e..cd3883a 100644
--- a/asterix-bad/src/main/java/org/apache/asterix/bad/BADJobService.java
+++ b/asterix-bad/src/main/java/org/apache/asterix/bad/BADJobService.java
@@ -32,13 +32,14 @@

 import org.apache.asterix.active.ActivityState;
 import org.apache.asterix.active.EntityId;
-import org.apache.asterix.api.http.server.ResultUtil;
 import org.apache.asterix.app.active.ActiveNotificationHandler;
 import org.apache.asterix.app.result.ResultReader;
+import org.apache.asterix.app.result.fields.ResultsPrinter;
 import org.apache.asterix.app.translator.QueryTranslator;
 import org.apache.asterix.bad.lang.BADParserFactory;
 import org.apache.asterix.bad.lang.BADStatementExecutor;
 import org.apache.asterix.bad.metadata.DeployedJobSpecEventListener;
+import org.apache.asterix.common.api.IResponsePrinter;
 import org.apache.asterix.common.dataflow.ICcApplicationContext;
 import org.apache.asterix.common.transactions.ITxnIdFactory;
 import org.apache.asterix.lang.common.base.Statement;
@@ -139,9 +140,10 @@

         if (listener.getType() == 
DeployedJobSpecEventListener.PrecompiledType.QUERY) {
             ResultReader resultReader = new ResultReader(resultSet, jobId, new 
ResultSetId(0));
-
-            ResultUtil.printResults(appCtx, resultReader, 
statementExecutor.getSessionOutput(),
-                    new IStatementExecutor.Stats(), null);
+            IResponsePrinter printer = statementExecutor.getResponsePrinter();
+            printer.addResultPrinter(new ResultsPrinter(appCtx, resultReader, 
null, new IStatementExecutor.Stats(),
+                    statementExecutor.getSessionOutput()));
+            printer.printResults();
         }

         LOGGER.log(Level.SEVERE,
diff --git 
a/asterix-bad/src/main/java/org/apache/asterix/bad/lang/BADQueryTranslatorFactory.java
 
b/asterix-bad/src/main/java/org/apache/asterix/bad/lang/BADQueryTranslatorFactory.java
index 8f5d520..ab5a96e 100644
--- 
a/asterix-bad/src/main/java/org/apache/asterix/bad/lang/BADQueryTranslatorFactory.java
+++ 
b/asterix-bad/src/main/java/org/apache/asterix/bad/lang/BADQueryTranslatorFactory.java
@@ -22,6 +22,7 @@

 import org.apache.asterix.app.translator.DefaultStatementExecutorFactory;
 import org.apache.asterix.app.translator.QueryTranslator;
+import org.apache.asterix.common.api.IResponsePrinter;
 import org.apache.asterix.common.context.IStorageComponentProvider;
 import org.apache.asterix.common.dataflow.ICcApplicationContext;
 import org.apache.asterix.compiler.provider.ILangCompilationProvider;
@@ -32,7 +33,8 @@

     @Override
     public QueryTranslator create(ICcApplicationContext appCtx, 
List<Statement> statements, SessionOutput output,
-            ILangCompilationProvider compilationProvider, 
IStorageComponentProvider storageComponentProvider) {
-        return new BADStatementExecutor(appCtx, statements, output, 
compilationProvider, executorService);
+            ILangCompilationProvider compilationProvider, 
IStorageComponentProvider storageComponentProvider,
+            IResponsePrinter printer) {
+        return new BADStatementExecutor(appCtx, statements, output, 
compilationProvider, executorService, printer);
     }
 }
diff --git 
a/asterix-bad/src/main/java/org/apache/asterix/bad/lang/BADStatementExecutor.java
 
b/asterix-bad/src/main/java/org/apache/asterix/bad/lang/BADStatementExecutor.java
index 9cb57e1..e57a2e5 100644
--- 
a/asterix-bad/src/main/java/org/apache/asterix/bad/lang/BADStatementExecutor.java
+++ 
b/asterix-bad/src/main/java/org/apache/asterix/bad/lang/BADStatementExecutor.java
@@ -32,6 +32,7 @@
 import org.apache.asterix.bad.metadata.Channel;
 import org.apache.asterix.bad.metadata.DeployedJobSpecEventListener;
 import org.apache.asterix.bad.metadata.Procedure;
+import org.apache.asterix.common.api.IResponsePrinter;
 import org.apache.asterix.common.dataflow.ICcApplicationContext;
 import org.apache.asterix.common.exceptions.CompilationException;
 import org.apache.asterix.common.functions.FunctionSignature;
@@ -57,8 +58,8 @@
 public class BADStatementExecutor extends QueryTranslator {

     public BADStatementExecutor(ICcApplicationContext appCtx, List<Statement> 
statements, SessionOutput output,
-            ILangCompilationProvider compliationProvider, ExecutorService 
executorService) {
-        super(appCtx, statements, output, compliationProvider, 
executorService);
+            ILangCompilationProvider compliationProvider, ExecutorService 
executorService, IResponsePrinter printer) {
+        super(appCtx, statements, output, compliationProvider, 
executorService, printer);
     }

     //TODO: Most of this file could go away if we had metadata dependencies
diff --git 
a/asterix-bad/src/main/java/org/apache/asterix/bad/recovery/BADGlobalRecoveryManager.java
 
b/asterix-bad/src/main/java/org/apache/asterix/bad/recovery/BADGlobalRecoveryManager.java
index 38dc16d..629fab3 100644
--- 
a/asterix-bad/src/main/java/org/apache/asterix/bad/recovery/BADGlobalRecoveryManager.java
+++ 
b/asterix-bad/src/main/java/org/apache/asterix/bad/recovery/BADGlobalRecoveryManager.java
@@ -30,6 +30,7 @@
 import org.apache.asterix.active.EntityId;
 import org.apache.asterix.active.IActiveEntityEventsListener;
 import org.apache.asterix.app.active.ActiveNotificationHandler;
+import org.apache.asterix.app.result.ResponsePrinter;
 import org.apache.asterix.app.result.ResultReader;
 import org.apache.asterix.app.translator.DefaultStatementExecutorFactory;
 import org.apache.asterix.app.translator.RequestParameters;
@@ -94,10 +95,12 @@
             throws Exception {
         SessionConfig sessionConfig =
                 new SessionConfig(SessionConfig.OutputFormat.ADM, true, true, 
true, SessionConfig.PlanFormat.STRING);
-
-        BADStatementExecutor badStatementExecutor = new 
BADStatementExecutor(appCtx, new ArrayList<>(),
-                new SessionOutput(sessionConfig, null), new 
BADCompilationProvider(), Executors.newSingleThreadExecutor(
-                        new 
HyracksThreadFactory(DefaultStatementExecutorFactory.class.getSimpleName())));
+        final SessionOutput sessionOutput = new SessionOutput(sessionConfig, 
null);
+        BADStatementExecutor badStatementExecutor =
+                new BADStatementExecutor(appCtx, new ArrayList<>(), 
sessionOutput, new BADCompilationProvider(),
+                        Executors.newSingleThreadExecutor(
+                                new 
HyracksThreadFactory(DefaultStatementExecutorFactory.class.getSimpleName())),
+                        new ResponsePrinter(sessionOutput));

         ActiveNotificationHandler activeEventHandler =
                 (ActiveNotificationHandler) 
appCtx.getActiveNotificationHandler();

--
To view, visit https://asterix-gerrit.ics.uci.edu/3411
To unsubscribe, visit https://asterix-gerrit.ics.uci.edu/settings

Gerrit-Project: asterixdb-bad
Gerrit-Branch: master
Gerrit-MessageType: merged
Gerrit-Change-Id: I9255ef88ea03df629ffe3ca2f1d9b08504459f06
Gerrit-Change-Number: 3411
Gerrit-PatchSet: 4
Gerrit-Owner: Murtadha Hubail <mhub...@apache.org>
Gerrit-Reviewer: Jenkins <jenk...@fulliautomatix.ics.uci.edu>
Gerrit-Reviewer: Murtadha Hubail <mhub...@apache.org>
Gerrit-Reviewer: Till Westmann <ti...@apache.org>

Reply via email to