Skip to content
Permalink
Browse files
[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
  • Loading branch information
mhubail committed May 27, 2019
1 parent 385dd62 commit bfa9b56781ab70ac4e2b3a65621cab7fdc86ba0f
Showing 4 changed files with 20 additions and 12 deletions.
@@ -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 @@ public static long runDeployedJobSpec(DeployedJobSpecId distributedId, IHyracksC

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,
@@ -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 @@ public class BADQueryTranslatorFactory extends DefaultStatementExecutorFactory {

@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);
}
}
@@ -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
@@ -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 @@ private void deployJobs(ICcApplicationContext appCtx, List<Channel> channels, Li
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();

0 comments on commit bfa9b56

Please sign in to comment.