allow more than one result for a request
Change-Id: Ib891b39e25d97ee60d4eb2d032d23bd94ad69b0e
Reviewed-on: https://asterix-gerrit.ics.uci.edu/1278
Sonar-Qube: Jenkins <jenkins@fulliautomatix.ics.uci.edu>
Tested-by: Jenkins <jenkins@fulliautomatix.ics.uci.edu>
Reviewed-by: Yingyi Bu <buyingyi@gmail.com>
diff --git a/asterixdb/asterix-app/src/main/java/org/apache/asterix/api/http/servlet/QueryServiceServlet.java b/asterixdb/asterix-app/src/main/java/org/apache/asterix/api/http/servlet/QueryServiceServlet.java
index 427e177..0f88f48 100644
--- a/asterixdb/asterix-app/src/main/java/org/apache/asterix/api/http/servlet/QueryServiceServlet.java
+++ b/asterixdb/asterix-app/src/main/java/org/apache/asterix/api/http/servlet/QueryServiceServlet.java
@@ -54,6 +54,7 @@
import org.apache.asterix.translator.IStatementExecutorFactory;
import org.apache.asterix.translator.SessionConfig;
import org.apache.commons.io.IOUtils;
+import org.apache.hyracks.algebricks.common.exceptions.AlgebricksException;
import org.apache.hyracks.algebricks.core.algebra.prettyprint.AlgebricksAppendable;
import org.apache.hyracks.api.client.IHyracksClientConnection;
import org.apache.hyracks.api.dataset.IHyracksDataset;
@@ -284,11 +285,19 @@
}
private static SessionConfig createSessionConfig(RequestParameters param, PrintWriter resultWriter) {
- SessionConfig.ResultDecorator resultPrefix = (AlgebricksAppendable app) -> {
- app.append("\t\"");
- app.append(ResultFields.RESULTS.str());
- app.append("\": ");
- return app;
+ SessionConfig.ResultDecorator resultPrefix = new SessionConfig.ResultDecorator() {
+ int resultNo = -1;
+ @Override
+ public AlgebricksAppendable append(AlgebricksAppendable app) throws AlgebricksException {
+ app.append("\t\"");
+ app.append(ResultFields.RESULTS.str());
+ if (resultNo >= 0) {
+ app.append('-').append(String.valueOf(resultNo));
+ }
+ ++resultNo;
+ app.append("\": ");
+ return app;
+ }
};
SessionConfig.ResultDecorator resultPostfix = (AlgebricksAppendable app) -> {