>From Peeyush Gupta <[email protected]>:

Peeyush Gupta has uploaded this change for review. ( 
https://asterix-gerrit.ics.uci.edu/c/asterixdb/+/20527?usp=email )


Change subject: [ASTERIXDB-3649][*DB] Improve async request API
......................................................................

[ASTERIXDB-3649][*DB] Improve async request API

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

Details:
Add a field to denote if the partitions returned as part of the
status should be read in order.

Change-Id: If32b1020c41e7d70e2af07275b4f6f9beb8ad184
---
M 
asterixdb/asterix-algebra/src/main/java/org/apache/asterix/translator/ResultMetadata.java
M 
asterixdb/asterix-app/src/main/java/org/apache/asterix/api/http/server/QueryStatusApiServlet.java
M 
asterixdb/asterix-app/src/main/java/org/apache/asterix/app/result/JobResultCallback.java
M 
asterixdb/asterix-app/src/main/java/org/apache/asterix/app/result/fields/PartitionInfoPrinter.java
A 
asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/async-deferred-improved/async-json/async-json.4.ddl.sqlpp
A 
asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/async-deferred-improved/async-json/async-json.5.update.sqlpp
A 
asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/async-deferred-improved/async-json/async-json.6.async.sqlpp
A 
asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/async-deferred-improved/async-json/async-json.7.pollget.http
A 
asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/async-deferred-improved/async-json/async-json.8.get.http
M 
asterixdb/asterix-app/src/test/resources/runtimets/results/async-deferred-improved/async-exhausted-result/async-exhausted-result.2.regexjson
M 
asterixdb/asterix-app/src/test/resources/runtimets/results/async-deferred-improved/async-json/async-json.2.regexjson
A 
asterixdb/asterix-app/src/test/resources/runtimets/results/async-deferred-improved/async-json/async-json.6.ignore
A 
asterixdb/asterix-app/src/test/resources/runtimets/results/async-deferred-improved/async-json/async-json.7.regexjson
A 
asterixdb/asterix-app/src/test/resources/runtimets/results/async-deferred-improved/async-json/async-json.8.json
M 
asterixdb/asterix-app/src/test/resources/runtimets/results/async-deferred-improved/async-repeated/async-repeated.2.regexjson
M 
asterixdb/asterix-app/src/test/resources/runtimets/results/async-deferred-improved/async-running/async-running.3.regexjson
M 
asterixdb/asterix-app/src/test/resources/runtimets/results/async-deferred-improved/async/async.2.regexjson
M 
hyracks-fullstack/algebricks/algebricks-core/src/main/java/org/apache/hyracks/algebricks/core/algebra/operators/physical/AbstractStableSortPOperator.java
M 
hyracks-fullstack/algebricks/algebricks-core/src/main/java/org/apache/hyracks/algebricks/core/algebra/operators/physical/StableSortPOperator.java
M 
hyracks-fullstack/hyracks/hyracks-api/src/main/java/org/apache/hyracks/api/result/ResultJobRecord.java
M 
hyracks-fullstack/hyracks/hyracks-control/hyracks-control-cc/src/main/java/org/apache/hyracks/control/cc/result/ResultDirectoryService.java
21 files changed, 190 insertions(+), 8 deletions(-)



  git pull ssh://asterix-gerrit.ics.uci.edu:29418/asterixdb 
refs/changes/27/20527/1

diff --git 
a/asterixdb/asterix-algebra/src/main/java/org/apache/asterix/translator/ResultMetadata.java
 
b/asterixdb/asterix-algebra/src/main/java/org/apache/asterix/translator/ResultMetadata.java
index de6026b..66b2503 100644
--- 
a/asterixdb/asterix-algebra/src/main/java/org/apache/asterix/translator/ResultMetadata.java
+++ 
b/asterixdb/asterix-algebra/src/main/java/org/apache/asterix/translator/ResultMetadata.java
@@ -47,6 +47,7 @@
     private long compileTime;
     private long createTime;
     private long endTime;
+    private boolean resultSetOrdered;

     public ResultMetadata(SessionConfig.OutputFormat format) {
         this.format = format;
@@ -194,6 +195,14 @@
         this.endTime = endTime;
     }

+    public boolean isResultSetOrdered() {
+        return resultSetOrdered;
+    }
+
+    public void setResultSetOrdered(boolean resultSetOrdered) {
+        this.resultSetOrdered = resultSetOrdered;
+    }
+
     @Override
     public String toString() {
         return "ResultMetadata{" + "format=" + format + ", jobDuration=" + 
jobDuration + ", processedObjects="
diff --git 
a/asterixdb/asterix-app/src/main/java/org/apache/asterix/api/http/server/QueryStatusApiServlet.java
 
b/asterixdb/asterix-app/src/main/java/org/apache/asterix/api/http/server/QueryStatusApiServlet.java
index 52597ad..9052f8f 100644
--- 
a/asterixdb/asterix-app/src/main/java/org/apache/asterix/api/http/server/QueryStatusApiServlet.java
+++ 
b/asterixdb/asterix-app/src/main/java/org/apache/asterix/api/http/server/QueryStatusApiServlet.java
@@ -110,10 +110,11 @@
         }
         printer.addResultPrinter(new ResultHandlePrinter(resHandle));
         if (uriMode) {
+            ResultMetadata metadata = (ResultMetadata) 
resultReader.getMetadata();
             printer.addResultPrinter(new ResultCountPrinter(
                     ((ResultMetadata) 
(resultReader.getResultSetReader().getResultMetadata())).getResultCount()));
-            printer.addResultPrinter(
-                    new 
PartitionInfoPrinter(resultReader.getResultSetReader().getResultRecords(), 
resHandle));
+            printer.addResultPrinter(new 
PartitionInfoPrinter(resultReader.getResultSetReader().getResultRecords(),
+                    resHandle, metadata.isResultSetOrdered()));
         }
     }

diff --git 
a/asterixdb/asterix-app/src/main/java/org/apache/asterix/app/result/JobResultCallback.java
 
b/asterixdb/asterix-app/src/main/java/org/apache/asterix/app/result/JobResultCallback.java
index a941100..6e25be4 100644
--- 
a/asterixdb/asterix-app/src/main/java/org/apache/asterix/app/result/JobResultCallback.java
+++ 
b/asterixdb/asterix-app/src/main/java/org/apache/asterix/app/result/JobResultCallback.java
@@ -67,6 +67,7 @@
         final ResultMetadata metadata = (ResultMetadata) 
resultSetMetaData.getMetadata();
         metadata.setJobDuration(resultJobRecord.getJobDuration());
         metadata.setResultCount(resultJobRecord.getResultCount());
+        metadata.setResultSetOrdered(resultJobRecord.isResultSetOrdered());
         aggregateJobStats(jobId, metadata);
     }

diff --git 
a/asterixdb/asterix-app/src/main/java/org/apache/asterix/app/result/fields/PartitionInfoPrinter.java
 
b/asterixdb/asterix-app/src/main/java/org/apache/asterix/app/result/fields/PartitionInfoPrinter.java
index 8e8d7f2..194f33e 100644
--- 
a/asterixdb/asterix-app/src/main/java/org/apache/asterix/app/result/fields/PartitionInfoPrinter.java
+++ 
b/asterixdb/asterix-app/src/main/java/org/apache/asterix/app/result/fields/PartitionInfoPrinter.java
@@ -29,13 +29,16 @@
     public static final String FIELD_NAME = "partitions";
     public static final String HANDLE_FIELD_NAME = "handle";
     public static final String RESULT_COUNT_FIELD_NAME = "resultCount";
+    public static final String RESULTSET_ORDERED_FIELD_NAME = 
"resultSetOrdered";

     private final ResultDirectoryRecord[] resultRecords;
     private final String handlePrefix;
+    private final boolean resultSetOrdered;

-    public PartitionInfoPrinter(ResultDirectoryRecord[] resultRecords, String 
handlePrefix) {
+    public PartitionInfoPrinter(ResultDirectoryRecord[] resultRecords, String 
handlePrefix, boolean resultSetOrdered) {
         this.resultRecords = resultRecords;
         this.handlePrefix = handlePrefix;
+        this.resultSetOrdered = resultSetOrdered;
     }

     @Override
@@ -54,7 +57,9 @@
                 pw.print(",");
             }
         }
-        pw.print("]");
+        pw.print("],");
+        pw.print("\n\t");
+        ResultUtil.printField(pw, RESULTSET_ORDERED_FIELD_NAME, 
resultSetOrdered, false);
     }

     @Override
diff --git 
a/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/async-deferred-improved/async-json/async-json.4.ddl.sqlpp
 
b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/async-deferred-improved/async-json/async-json.4.ddl.sqlpp
new file mode 100644
index 0000000..b0d22c2
--- /dev/null
+++ 
b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/async-deferred-improved/async-json/async-json.4.ddl.sqlpp
@@ -0,0 +1,32 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+drop  dataverse test if exists;
+create  dataverse test;
+
+use test;
+
+create type TestType as
+ closed {
+  id : integer,
+  val : double
+};
+
+create  dataset Test(TestType) primary key id;
+
diff --git 
a/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/async-deferred-improved/async-json/async-json.5.update.sqlpp
 
b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/async-deferred-improved/async-json/async-json.5.update.sqlpp
new file mode 100644
index 0000000..31abd48
--- /dev/null
+++ 
b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/async-deferred-improved/async-json/async-json.5.update.sqlpp
@@ -0,0 +1,28 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+use test;
+
+UPSERT INTO Test { "id": 1, "val": 2.5 };
+
+UPSERT INTO Test { "id": 2, "val": 3.5 };
+
+UPSERT INTO Test { "id": 3, "val": 4.5 };
+
+UPSERT INTO Test { "id": 4, "val": 5.5 };
diff --git 
a/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/async-deferred-improved/async-json/async-json.6.async.sqlpp
 
b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/async-deferred-improved/async-json/async-json.6.async.sqlpp
new file mode 100644
index 0000000..32ad877
--- /dev/null
+++ 
b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/async-deferred-improved/async-json/async-json.6.async.sqlpp
@@ -0,0 +1,23 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+-- handlevariable=status
+
+use test;
+SET `compiler.sort.parallel` "true";
+Select * from Test order by val;
diff --git 
a/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/async-deferred-improved/async-json/async-json.7.pollget.http
 
b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/async-deferred-improved/async-json/async-json.7.pollget.http
new file mode 100644
index 0000000..d10aed9
--- /dev/null
+++ 
b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/async-deferred-improved/async-json/async-json.7.pollget.http
@@ -0,0 +1,23 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+-- polltimeoutsecs=10
+-- handlevariable=result
+
+$status
diff --git 
a/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/async-deferred-improved/async-json/async-json.8.get.http
 
b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/async-deferred-improved/async-json/async-json.8.get.http
new file mode 100644
index 0000000..6496a4b
--- /dev/null
+++ 
b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/async-deferred-improved/async-json/async-json.8.get.http
@@ -0,0 +1,20 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+-- extractresult=true
+$result
diff --git 
a/asterixdb/asterix-app/src/test/resources/runtimets/results/async-deferred-improved/async-exhausted-result/async-exhausted-result.2.regexjson
 
b/asterixdb/asterix-app/src/test/resources/runtimets/results/async-deferred-improved/async-exhausted-result/async-exhausted-result.2.regexjson
index 0ed7a67..fbcb2c6 100644
--- 
a/asterixdb/asterix-app/src/test/resources/runtimets/results/async-deferred-improved/async-exhausted-result/async-exhausted-result.2.regexjson
+++ 
b/asterixdb/asterix-app/src/test/resources/runtimets/results/async-deferred-improved/async-exhausted-result/async-exhausted-result.2.regexjson
@@ -3,6 +3,7 @@
   "handle": "R{.*}",
   "resultCount": 10,
   "partitions": "R{.*}",
+  "resultSetOrdered": false,
   "metrics": "R{.*}",
   "createdAt": "R{.*}"
 }
\ No newline at end of file
diff --git 
a/asterixdb/asterix-app/src/test/resources/runtimets/results/async-deferred-improved/async-json/async-json.2.regexjson
 
b/asterixdb/asterix-app/src/test/resources/runtimets/results/async-deferred-improved/async-json/async-json.2.regexjson
index c6c829b..a967c36 100644
--- 
a/asterixdb/asterix-app/src/test/resources/runtimets/results/async-deferred-improved/async-json/async-json.2.regexjson
+++ 
b/asterixdb/asterix-app/src/test/resources/runtimets/results/async-deferred-improved/async-json/async-json.2.regexjson
@@ -3,6 +3,7 @@
   "handle": "R{.*}",
   "resultCount": 5,
   "partitions": "R{.*}",
+  "resultSetOrdered": false,
   "metrics": "R{.*}",
   "createdAt": "R{.*}"
 }
\ No newline at end of file
diff --git 
a/asterixdb/asterix-app/src/test/resources/runtimets/results/async-deferred-improved/async-json/async-json.6.ignore
 
b/asterixdb/asterix-app/src/test/resources/runtimets/results/async-deferred-improved/async-json/async-json.6.ignore
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ 
b/asterixdb/asterix-app/src/test/resources/runtimets/results/async-deferred-improved/async-json/async-json.6.ignore
diff --git 
a/asterixdb/asterix-app/src/test/resources/runtimets/results/async-deferred-improved/async-json/async-json.7.regexjson
 
b/asterixdb/asterix-app/src/test/resources/runtimets/results/async-deferred-improved/async-json/async-json.7.regexjson
new file mode 100644
index 0000000..3d4a86c
--- /dev/null
+++ 
b/asterixdb/asterix-app/src/test/resources/runtimets/results/async-deferred-improved/async-json/async-json.7.regexjson
@@ -0,0 +1,9 @@
+{
+  "status":"success",
+  "handle": "R{.*}",
+  "resultCount": 4,
+  "partitions": "R{.*}",
+  "resultSetOrdered": true,
+  "metrics": "R{.*}",
+  "createdAt": "R{.*}"
+}
\ No newline at end of file
diff --git 
a/asterixdb/asterix-app/src/test/resources/runtimets/results/async-deferred-improved/async-json/async-json.8.json
 
b/asterixdb/asterix-app/src/test/resources/runtimets/results/async-deferred-improved/async-json/async-json.8.json
new file mode 100644
index 0000000..5ca6c1e
--- /dev/null
+++ 
b/asterixdb/asterix-app/src/test/resources/runtimets/results/async-deferred-improved/async-json/async-json.8.json
@@ -0,0 +1,4 @@
+{ "Test": { "id": 1, "val": 2.5 } }
+{ "Test": { "id": 2, "val": 3.5 } }
+{ "Test": { "id": 3, "val": 4.5 } }
+{ "Test": { "id": 4, "val": 5.5 } }
\ No newline at end of file
diff --git 
a/asterixdb/asterix-app/src/test/resources/runtimets/results/async-deferred-improved/async-repeated/async-repeated.2.regexjson
 
b/asterixdb/asterix-app/src/test/resources/runtimets/results/async-deferred-improved/async-repeated/async-repeated.2.regexjson
index 0ed7a67..fbcb2c6 100644
--- 
a/asterixdb/asterix-app/src/test/resources/runtimets/results/async-deferred-improved/async-repeated/async-repeated.2.regexjson
+++ 
b/asterixdb/asterix-app/src/test/resources/runtimets/results/async-deferred-improved/async-repeated/async-repeated.2.regexjson
@@ -3,6 +3,7 @@
   "handle": "R{.*}",
   "resultCount": 10,
   "partitions": "R{.*}",
+  "resultSetOrdered": false,
   "metrics": "R{.*}",
   "createdAt": "R{.*}"
 }
\ No newline at end of file
diff --git 
a/asterixdb/asterix-app/src/test/resources/runtimets/results/async-deferred-improved/async-running/async-running.3.regexjson
 
b/asterixdb/asterix-app/src/test/resources/runtimets/results/async-deferred-improved/async-running/async-running.3.regexjson
index 9e724fd..bc20bf9 100644
--- 
a/asterixdb/asterix-app/src/test/resources/runtimets/results/async-deferred-improved/async-running/async-running.3.regexjson
+++ 
b/asterixdb/asterix-app/src/test/resources/runtimets/results/async-deferred-improved/async-running/async-running.3.regexjson
@@ -3,6 +3,7 @@
   "handle": "R{.*}",
   "resultCount": 1,
   "partitions": "R{.*}",
+  "resultSetOrdered": false,
   "metrics": "R{.*}",
   "createdAt": "R{.*}"
 }
\ No newline at end of file
diff --git 
a/asterixdb/asterix-app/src/test/resources/runtimets/results/async-deferred-improved/async/async.2.regexjson
 
b/asterixdb/asterix-app/src/test/resources/runtimets/results/async-deferred-improved/async/async.2.regexjson
index 0ed7a67..fbcb2c6 100644
--- 
a/asterixdb/asterix-app/src/test/resources/runtimets/results/async-deferred-improved/async/async.2.regexjson
+++ 
b/asterixdb/asterix-app/src/test/resources/runtimets/results/async-deferred-improved/async/async.2.regexjson
@@ -3,6 +3,7 @@
   "handle": "R{.*}",
   "resultCount": 10,
   "partitions": "R{.*}",
+  "resultSetOrdered": false,
   "metrics": "R{.*}",
   "createdAt": "R{.*}"
 }
\ No newline at end of file
diff --git 
a/hyracks-fullstack/algebricks/algebricks-core/src/main/java/org/apache/hyracks/algebricks/core/algebra/operators/physical/AbstractStableSortPOperator.java
 
b/hyracks-fullstack/algebricks/algebricks-core/src/main/java/org/apache/hyracks/algebricks/core/algebra/operators/physical/AbstractStableSortPOperator.java
index ff45322..340203d 100644
--- 
a/hyracks-fullstack/algebricks/algebricks-core/src/main/java/org/apache/hyracks/algebricks/core/algebra/operators/physical/AbstractStableSortPOperator.java
+++ 
b/hyracks-fullstack/algebricks/algebricks-core/src/main/java/org/apache/hyracks/algebricks/core/algebra/operators/physical/AbstractStableSortPOperator.java
@@ -57,6 +57,7 @@

     OrderColumn[] sortColumns;
     ILocalStructuralProperty orderProp;
+    protected boolean parallelSortUsed = false;

     AbstractStableSortPOperator() {
     }
@@ -71,6 +72,12 @@
         computeLocalProperties(sortOp);
         AbstractLogicalOperator childOp = (AbstractLogicalOperator) 
op.getInputs().get(0).getValue();
         StructuralPropertiesVector childProp = (StructuralPropertiesVector) 
childOp.getDeliveredPhysicalProperties();
+        INodeDomain targetNodeDomain = context.getComputationNodeDomain();
+        String fullParallelAnnotation = getFullParallelAnnotation(sortOp, 
targetNodeDomain, context);
+        if (fullParallelAnnotation != null) {
+            ;
+            parallelSortUsed = true;
+        }
         deliveredProperties = new 
StructuralPropertiesVector(childProp.getPartitioningProperty(),
                 Collections.singletonList(orderProp));
     }
diff --git 
a/hyracks-fullstack/algebricks/algebricks-core/src/main/java/org/apache/hyracks/algebricks/core/algebra/operators/physical/StableSortPOperator.java
 
b/hyracks-fullstack/algebricks/algebricks-core/src/main/java/org/apache/hyracks/algebricks/core/algebra/operators/physical/StableSortPOperator.java
index 93c5c3b..58c1813 100644
--- 
a/hyracks-fullstack/algebricks/algebricks-core/src/main/java/org/apache/hyracks/algebricks/core/algebra/operators/physical/StableSortPOperator.java
+++ 
b/hyracks-fullstack/algebricks/algebricks-core/src/main/java/org/apache/hyracks/algebricks/core/algebra/operators/physical/StableSortPOperator.java
@@ -36,7 +36,8 @@
 import org.apache.hyracks.api.dataflow.value.IBinaryComparatorFactory;
 import org.apache.hyracks.api.dataflow.value.INormalizedKeyComputerFactory;
 import org.apache.hyracks.api.dataflow.value.RecordDescriptor;
-import org.apache.hyracks.api.job.IOperatorDescriptorRegistry;
+import org.apache.hyracks.api.job.JobSpecification;
+import org.apache.hyracks.api.result.ResultJobRecord;
 import org.apache.hyracks.dataflow.std.sort.AbstractSorterOperatorDescriptor;
 import org.apache.hyracks.dataflow.std.sort.ExternalSortOperatorDescriptor;
 import org.apache.hyracks.dataflow.std.sort.TopKSorterOperatorDescriptor;
@@ -71,7 +72,8 @@
     public void contributeRuntimeOperator(IHyracksJobBuilder builder, 
JobGenContext context, ILogicalOperator op,
             IOperatorSchema opSchema, IOperatorSchema[] inputSchemas, 
IOperatorSchema outerPlanSchema)
             throws AlgebricksException {
-        IOperatorDescriptorRegistry spec = builder.getJobSpec();
+        JobSpecification spec = builder.getJobSpec();
+        spec.setProperty(ResultJobRecord.RESULT_SET_ORDERED_PROPERTY_NAME, 
parallelSortUsed);
         RecordDescriptor recDescriptor =
                 
JobGenHelper.mkRecordDescriptor(context.getTypeEnvironment(op), opSchema, 
context);
         int n = sortColumns.length;
@@ -109,6 +111,7 @@
             sortOpDesc = new TopKSorterOperatorDescriptor(spec, 
maxNumberOfFrames, topK, sortFields, nkcf, comps,
                     recDescriptor);
         }
+
         sortOpDesc.setSourceLocation(op.getSourceLocation());
         contributeOpDesc(builder, (AbstractLogicalOperator) op, sortOpDesc);
         ILogicalOperator src = op.getInputs().get(0).getValue();
diff --git 
a/hyracks-fullstack/hyracks/hyracks-api/src/main/java/org/apache/hyracks/api/result/ResultJobRecord.java
 
b/hyracks-fullstack/hyracks/hyracks-api/src/main/java/org/apache/hyracks/api/result/ResultJobRecord.java
index edda92f..6bcedc7 100644
--- 
a/hyracks-fullstack/hyracks/hyracks-api/src/main/java/org/apache/hyracks/api/result/ResultJobRecord.java
+++ 
b/hyracks-fullstack/hyracks/hyracks-api/src/main/java/org/apache/hyracks/api/result/ResultJobRecord.java
@@ -30,6 +30,8 @@

 public class ResultJobRecord implements IResultStateRecord {

+    public static final String RESULT_SET_ORDERED_PROPERTY_NAME = 
"ResultSetOrdered";
+
     public enum State {
         IDLE,
         RUNNING,
@@ -87,11 +89,13 @@
     private ResultSetId rsId;
     private ResultSetMetaData resultSetMetaData;
     private long resultCount;
+    private boolean resultSetOrdered;

-    public ResultJobRecord() {
+    public ResultJobRecord(boolean resultSetOrdered) {
         this.timestamp = System.nanoTime();
         this.status = new Status();
         this.resultCount = 0;
+        this.resultSetOrdered = resultSetOrdered;
     }

     private void updateState(State newStatus) {
@@ -149,6 +153,10 @@
         return status;
     }

+    public boolean isResultSetOrdered() {
+        return resultSetOrdered;
+    }
+
     @Override
     public String toString() {
         StringBuilder sb = new StringBuilder();
diff --git 
a/hyracks-fullstack/hyracks/hyracks-control/hyracks-control-cc/src/main/java/org/apache/hyracks/control/cc/result/ResultDirectoryService.java
 
b/hyracks-fullstack/hyracks/hyracks-control/hyracks-control-cc/src/main/java/org/apache/hyracks/control/cc/result/ResultDirectoryService.java
index 6a1d28f..c7ccc22 100644
--- 
a/hyracks-fullstack/hyracks/hyracks-control/hyracks-control-cc/src/main/java/org/apache/hyracks/control/cc/result/ResultDirectoryService.java
+++ 
b/hyracks-fullstack/hyracks/hyracks-control/hyracks-control-cc/src/main/java/org/apache/hyracks/control/cc/result/ResultDirectoryService.java
@@ -83,7 +83,11 @@
         if (jobResultLocations.get(jobId) != null) {
             throw HyracksDataException.create(ErrorCode.MORE_THAN_ONE_RESULT, 
jobId);
         }
-        jobResultLocations.put(jobId, new JobResultInfo(new ResultJobRecord(), 
null));
+        Boolean partitionsOrdered = (Boolean) 
spec.getProperty(ResultJobRecord.RESULT_SET_ORDERED_PROPERTY_NAME);
+        if (partitionsOrdered == null) {
+            partitionsOrdered = false;
+        }
+        jobResultLocations.put(jobId, new JobResultInfo(new 
ResultJobRecord(partitionsOrdered), null));
     }

     @Override

--
To view, visit https://asterix-gerrit.ics.uci.edu/c/asterixdb/+/20527?usp=email
To unsubscribe, or for help writing mail filters, visit 
https://asterix-gerrit.ics.uci.edu/settings?usp=email

Gerrit-MessageType: newchange
Gerrit-Project: asterixdb
Gerrit-Branch: phoenix
Gerrit-Change-Id: If32b1020c41e7d70e2af07275b4f6f9beb8ad184
Gerrit-Change-Number: 20527
Gerrit-PatchSet: 1
Gerrit-Owner: Peeyush Gupta <[email protected]>

Reply via email to