You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@asterixdb.apache.org by "Taewoo Kim (Code Review)" <do...@asterixdb.incubator.apache.org> on 2016/02/06 02:52:23 UTC

Change in asterixdb[master]: ASTERIXDB-1157: Implemented Limit Pushdown into Order (Exter...

Taewoo Kim has uploaded a new change for review.

  https://asterix-gerrit.ics.uci.edu/617

Change subject: ASTERIXDB-1157: Implemented Limit Pushdown into Order (ExternalSort)
......................................................................

ASTERIXDB-1157: Implemented Limit Pushdown into Order (ExternalSort)

Change-Id: I19aa4ce402b1834d9f68320acb72d7635a41a837
---
M asterix-algebra/src/main/java/org/apache/asterix/optimizer/base/RuleCollections.java
A asterix-algebra/src/main/java/org/apache/asterix/optimizer/rules/PushLimitIntoOrderByRule.java
M asterix-algebra/src/main/java/org/apache/asterix/optimizer/rules/am/AccessMethodUtils.java
3 files changed, 143 insertions(+), 0 deletions(-)


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

diff --git a/asterix-algebra/src/main/java/org/apache/asterix/optimizer/base/RuleCollections.java b/asterix-algebra/src/main/java/org/apache/asterix/optimizer/base/RuleCollections.java
index 4187059..62cada1 100644
--- a/asterix-algebra/src/main/java/org/apache/asterix/optimizer/base/RuleCollections.java
+++ b/asterix-algebra/src/main/java/org/apache/asterix/optimizer/base/RuleCollections.java
@@ -56,6 +56,7 @@
 import org.apache.asterix.optimizer.rules.PushAggregateIntoGroupbyRule;
 import org.apache.asterix.optimizer.rules.PushFieldAccessRule;
 import org.apache.asterix.optimizer.rules.PushGroupByThroughProduct;
+import org.apache.asterix.optimizer.rules.PushLimitIntoOrderByRule;
 import org.apache.asterix.optimizer.rules.PushProperJoinThroughProduct;
 import org.apache.asterix.optimizer.rules.PushSimilarityFunctionsBelowJoin;
 import org.apache.asterix.optimizer.rules.RemoveRedundantListifyRule;
@@ -310,6 +311,7 @@
         List<IAlgebraicRewriteRule> physicalRewritesTopLevel = new LinkedList<IAlgebraicRewriteRule>();
         physicalRewritesTopLevel.add(new PushNestedOrderByUnderPreSortedGroupByRule());
         physicalRewritesTopLevel.add(new CopyLimitDownRule());
+        physicalRewritesTopLevel.add(new PushLimitIntoOrderByRule());
         physicalRewritesTopLevel.add(new IntroduceProjectsRule());
         physicalRewritesTopLevel.add(new SetAlgebricksPhysicalOperatorsRule());
         physicalRewritesTopLevel.add(new IntroduceRapidFrameFlushProjectAssignRule());
diff --git a/asterix-algebra/src/main/java/org/apache/asterix/optimizer/rules/PushLimitIntoOrderByRule.java b/asterix-algebra/src/main/java/org/apache/asterix/optimizer/rules/PushLimitIntoOrderByRule.java
new file mode 100644
index 0000000..565952d
--- /dev/null
+++ b/asterix-algebra/src/main/java/org/apache/asterix/optimizer/rules/PushLimitIntoOrderByRule.java
@@ -0,0 +1,135 @@
+/*
+ * 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.
+ */
+package org.apache.asterix.optimizer.rules;
+
+import org.apache.asterix.optimizer.rules.am.AccessMethodUtils;
+import org.apache.commons.lang3.mutable.Mutable;
+import org.apache.hyracks.algebricks.common.exceptions.AlgebricksException;
+import org.apache.hyracks.algebricks.core.algebra.base.ILogicalOperator;
+import org.apache.hyracks.algebricks.core.algebra.base.IOptimizationContext;
+import org.apache.hyracks.algebricks.core.algebra.base.LogicalExpressionTag;
+import org.apache.hyracks.algebricks.core.algebra.base.LogicalOperatorTag;
+import org.apache.hyracks.algebricks.core.algebra.base.PhysicalOperatorTag;
+import org.apache.hyracks.algebricks.core.algebra.operators.logical.AbstractLogicalOperator;
+import org.apache.hyracks.algebricks.core.algebra.operators.logical.LimitOperator;
+import org.apache.hyracks.algebricks.core.algebra.operators.logical.OrderOperator;
+import org.apache.hyracks.algebricks.core.algebra.operators.physical.StableSortPOperator;
+import org.apache.hyracks.algebricks.core.algebra.util.OperatorPropertiesUtil;
+import org.apache.hyracks.algebricks.core.rewriter.base.IAlgebraicRewriteRule;
+import org.apache.hyracks.algebricks.core.rewriter.base.PhysicalOptimizationConfig;
+
+/**
+ * If an ORDER operator is followed by LIMIT, then we can push LIMIT into ORDER operator.
+ * Finally, ORDER operator use TopKSorterOperatorDescriptor that can efficiently
+ * sort tuples and fetch top K results.
+ * =================
+ * matching pattern:
+ * limit <- order
+ * =
+ * producing pattern:
+ * limit <- new order (topK applied)
+ */
+public class PushLimitIntoOrderByRule implements IAlgebraicRewriteRule {
+
+    @Override
+    public boolean rewritePost(Mutable<ILogicalOperator> opRef, IOptimizationContext context) {
+        return false;
+    }
+
+    @Override
+    public boolean rewritePre(Mutable<ILogicalOperator> opRef, IOptimizationContext context)
+            throws AlgebricksException {
+        AbstractLogicalOperator op = (AbstractLogicalOperator) opRef.getValue();
+        // The current operator should be LIMIT operator.
+        if (op.getOperatorTag() != LogicalOperatorTag.LIMIT) {
+            return false;
+        }
+
+        Mutable<ILogicalOperator> opRef2 = op.getInputs().get(0);
+        AbstractLogicalOperator op2 = (AbstractLogicalOperator) opRef2.getValue();
+
+        if (context.checkAndAddToAlreadyCompared(op, op2)) {
+            return false;
+        }
+
+        // Should be ORDER operator
+        if (op2.getOperatorTag() != LogicalOperatorTag.ORDER) {
+            return false;
+        } else {
+            // ORDER operator is followed by LIMIT. Thus we can check whether we can apply this rule.
+            boolean res = pushLimitIntoOrder(opRef, opRef2, context);
+            if (res) {
+                OperatorPropertiesUtil.typeOpRec(opRef, context);
+            }
+            return res;
+        }
+    }
+
+    /**
+     * Generate new ORDER operator that uses TopKSort module and replaces the old ORDER operator.
+     */
+    private boolean pushLimitIntoOrder(Mutable<ILogicalOperator> opRef, Mutable<ILogicalOperator> opRef2,
+            IOptimizationContext context) throws AlgebricksException {
+        PhysicalOptimizationConfig physicalOptimizationConfig = context.getPhysicalOptimizationConfig();
+        LimitOperator limitOp = (LimitOperator) opRef.getValue();
+        OrderOperator orderOp = (OrderOperator) opRef2.getValue();
+        long topK = -1;
+
+        // We don't push-down LIMIT into in-memory sort.
+        if (orderOp.getPhysicalOperator().getOperatorTag() != PhysicalOperatorTag.STABLE_SORT) {
+            return false;
+        }
+
+        // Get the LIMIT constant
+        if (limitOp.getMaxObjects().getValue().getExpressionTag() == LogicalExpressionTag.CONSTANT) {
+            // Currently, we support LIMIT with a constant value.
+            topK = AccessMethodUtils.getInt64Constant(limitOp.getMaxObjects());
+            // If topK is huge, there is no reason to use topK sort module
+            // since the original external sort's performance might be better.
+            if (topK > Integer.MAX_VALUE) {
+                return false;
+            }
+        } else {
+            return false;
+        }
+
+        // Get the offset constant if there is one. If one presents, then topK = topK + offset.
+        // This is because we can't apply offset to the external sort.
+        // Final topK will be applied through LIMIT.
+        if (limitOp.getOffset().getValue() != null
+                && limitOp.getOffset().getValue().getExpressionTag() == LogicalExpressionTag.CONSTANT) {
+            topK = topK + ((int) AccessMethodUtils.getInt64Constant(limitOp.getOffset()));
+        }
+
+        // Create the new ORDER operator, set the topK value, and replace the current one.
+        OrderOperator newOrderOp = new OrderOperator(orderOp.getOrderExpressions(), (int) topK);
+        newOrderOp.setPhysicalOperator(
+                new StableSortPOperator(physicalOptimizationConfig.getMaxFramesExternalSort(), newOrderOp.getTopK()));
+        newOrderOp.getInputs().addAll(orderOp.getInputs());
+        newOrderOp.setExecutionMode(orderOp.getExecutionMode());
+        newOrderOp.recomputeSchema();
+        newOrderOp.computeDeliveredPhysicalProperties(context);
+        opRef2.setValue(newOrderOp);
+        context.computeAndSetTypeEnvironmentForOperator(newOrderOp);
+        context.addToDontApplySet(this, limitOp);
+
+        return true;
+    }
+
+}
diff --git a/asterix-algebra/src/main/java/org/apache/asterix/optimizer/rules/am/AccessMethodUtils.java b/asterix-algebra/src/main/java/org/apache/asterix/optimizer/rules/am/AccessMethodUtils.java
index 1ff3df6..9165506 100644
--- a/asterix-algebra/src/main/java/org/apache/asterix/optimizer/rules/am/AccessMethodUtils.java
+++ b/asterix-algebra/src/main/java/org/apache/asterix/optimizer/rules/am/AccessMethodUtils.java
@@ -38,6 +38,7 @@
 import org.apache.asterix.metadata.utils.DatasetUtils;
 import org.apache.asterix.om.base.ABoolean;
 import org.apache.asterix.om.base.AInt32;
+import org.apache.asterix.om.base.AInt64;
 import org.apache.asterix.om.base.AString;
 import org.apache.asterix.om.base.IAObject;
 import org.apache.asterix.om.constants.AsterixConstantValue;
@@ -118,6 +119,11 @@
         return ((AInt32) obj).getIntegerValue();
     }
 
+    public static long getInt64Constant(Mutable<ILogicalExpression> expr) {
+        IAObject obj = ((AsterixConstantValue) ((ConstantExpression) expr.getValue()).getValue()).getObject();
+        return ((AInt64) obj).getLongValue();
+    }
+
     public static boolean getBooleanConstant(Mutable<ILogicalExpression> expr) {
         IAObject obj = ((AsterixConstantValue) ((ConstantExpression) expr.getValue()).getValue()).getObject();
         return ((ABoolean) obj).getBoolean();

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

Gerrit-MessageType: newchange
Gerrit-Change-Id: I19aa4ce402b1834d9f68320acb72d7635a41a837
Gerrit-PatchSet: 1
Gerrit-Project: asterixdb
Gerrit-Branch: master
Gerrit-Owner: Taewoo Kim <wa...@gmail.com>

Change in asterixdb[master]: ASTERIXDB-1157: Pushdown Limit

Posted by "Taewoo Kim (Code Review)" <do...@asterixdb.incubator.apache.org>.
Taewoo Kim has posted comments on this change.

Change subject: ASTERIXDB-1157: Pushdown Limit
......................................................................


Patch Set 5:

@Yingyi: it happens regardless of my rule. When I add "ConstantFoldingRule" after "CopyLimitDownRule", it happens. But, it's not happening after "CopyLimitDownRule". It's happening after "RemoveUnusedAssignRule".

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

Gerrit-MessageType: comment
Gerrit-Change-Id: I19aa4ce402b1834d9f68320acb72d7635a41a837
Gerrit-PatchSet: 5
Gerrit-Project: asterixdb
Gerrit-Branch: master
Gerrit-Owner: Taewoo Kim <wa...@gmail.com>
Gerrit-Reviewer: Jenkins <je...@fulliautomatix.ics.uci.edu>
Gerrit-Reviewer: Jianfeng Jia <ji...@gmail.com>
Gerrit-Reviewer: Taewoo Kim <wa...@gmail.com>
Gerrit-Reviewer: Yingyi Bu <bu...@gmail.com>
Gerrit-Reviewer: Young-Seok Kim <ki...@gmail.com>
Gerrit-HasComments: No

Change in asterixdb[master]: ASTERIXDB-1157: Pushdown Limit

Posted by "Yingyi Bu (Code Review)" <do...@asterixdb.incubator.apache.org>.
Yingyi Bu has posted comments on this change.

Change subject: ASTERIXDB-1157: Pushdown Limit
......................................................................


Patch Set 5:

@Taewoo, I think in general, record functions shouldn't be constant-folded.  Maybe that causes the failures.
What you can test is to just disable your new rule but keep the added application of ConstantFoldRule to see if the failures were caused by your rule or by the folding of those record functions.

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

Gerrit-MessageType: comment
Gerrit-Change-Id: I19aa4ce402b1834d9f68320acb72d7635a41a837
Gerrit-PatchSet: 5
Gerrit-Project: asterixdb
Gerrit-Branch: master
Gerrit-Owner: Taewoo Kim <wa...@gmail.com>
Gerrit-Reviewer: Jenkins <je...@fulliautomatix.ics.uci.edu>
Gerrit-Reviewer: Jianfeng Jia <ji...@gmail.com>
Gerrit-Reviewer: Taewoo Kim <wa...@gmail.com>
Gerrit-Reviewer: Yingyi Bu <bu...@gmail.com>
Gerrit-Reviewer: Young-Seok Kim <ki...@gmail.com>
Gerrit-HasComments: No

Change in asterixdb[master]: ASTERIXDB-1157: Pushdown Limit

Posted by "Jenkins (Code Review)" <do...@asterixdb.incubator.apache.org>.
Jenkins has posted comments on this change.

Change subject: ASTERIXDB-1157: Pushdown Limit
......................................................................


Patch Set 3: Verified-1

Build Unstable 

https://asterix-jenkins.ics.uci.edu/job/asterix-gerrit-topic/669/ : UNSTABLE

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

Gerrit-MessageType: comment
Gerrit-Change-Id: I19aa4ce402b1834d9f68320acb72d7635a41a837
Gerrit-PatchSet: 3
Gerrit-Project: asterixdb
Gerrit-Branch: master
Gerrit-Owner: Taewoo Kim <wa...@gmail.com>
Gerrit-Reviewer: Jenkins <je...@fulliautomatix.ics.uci.edu>
Gerrit-Reviewer: Jianfeng Jia <ji...@gmail.com>
Gerrit-Reviewer: Taewoo Kim <wa...@gmail.com>
Gerrit-Reviewer: Yingyi Bu <bu...@gmail.com>
Gerrit-Reviewer: Young-Seok Kim <ki...@gmail.com>
Gerrit-HasComments: No

Change in asterixdb[master]: ASTERIXDB-1157: Pushdown Limit

Posted by "Yingyi Bu (Code Review)" <do...@asterixdb.incubator.apache.org>.
Yingyi Bu has posted comments on this change.

Change subject: ASTERIXDB-1157: Pushdown Limit
......................................................................


Patch Set 7: Code-Review+1

(2 comments)

Just two minor comments.

https://asterix-gerrit.ics.uci.edu/#/c/617/7/asterix-algebra/src/main/java/org/apache/asterix/optimizer/rules/ConstantFoldingRule.java
File asterix-algebra/src/main/java/org/apache/asterix/optimizer/rules/ConstantFoldingRule.java:

Line 87:     private final ImmutableSet<FunctionIdentifier> funcIDSetThatShouldNotBeApplied = ImmutableSet.of(
static? and rename the variable according to static variable convention?


Line 195:             if (expr.getFunctionIdentifier().equals(AsterixBuiltinFunctions.OPEN_RECORD_CONSTRUCTOR)) {
can you move this also into funcIDSetThatShouldNotBeApplied?


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

Gerrit-MessageType: comment
Gerrit-Change-Id: I19aa4ce402b1834d9f68320acb72d7635a41a837
Gerrit-PatchSet: 7
Gerrit-Project: asterixdb
Gerrit-Branch: master
Gerrit-Owner: Taewoo Kim <wa...@gmail.com>
Gerrit-Reviewer: Jenkins <je...@fulliautomatix.ics.uci.edu>
Gerrit-Reviewer: Jianfeng Jia <ji...@gmail.com>
Gerrit-Reviewer: Taewoo Kim <wa...@gmail.com>
Gerrit-Reviewer: Yingyi Bu <bu...@gmail.com>
Gerrit-Reviewer: Young-Seok Kim <ki...@gmail.com>
Gerrit-HasComments: Yes

Change in asterixdb[master]: ASTERIXDB-1157: Pushdown Limit

Posted by "Yingyi Bu (Code Review)" <do...@asterixdb.incubator.apache.org>.
Yingyi Bu has posted comments on this change.

Change subject: ASTERIXDB-1157: Pushdown Limit
......................................................................


Patch Set 4:

(1 comment)

https://asterix-gerrit.ics.uci.edu/#/c/617/4/asterix-algebra/src/main/java/org/apache/asterix/optimizer/rules/PushLimitIntoOrderByRule.java
File asterix-algebra/src/main/java/org/apache/asterix/optimizer/rules/PushLimitIntoOrderByRule.java:

Line 115:             // a copied non-topmost LIMIT can contain NUMERIC-ADD to add the given limit value + offset value
> Throughout the compilation, this LIMIT remains as "NUMERIC_ADD", it doesn't
It is probably because ConstantFoldingRule is applied before CopyLimitDownRule.

What you can do is to apply ConstantFoldingRule again after you do CopyLimitDownRule, by setting the RuleCollections properly.


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

Gerrit-MessageType: comment
Gerrit-Change-Id: I19aa4ce402b1834d9f68320acb72d7635a41a837
Gerrit-PatchSet: 4
Gerrit-Project: asterixdb
Gerrit-Branch: master
Gerrit-Owner: Taewoo Kim <wa...@gmail.com>
Gerrit-Reviewer: Jenkins <je...@fulliautomatix.ics.uci.edu>
Gerrit-Reviewer: Jianfeng Jia <ji...@gmail.com>
Gerrit-Reviewer: Taewoo Kim <wa...@gmail.com>
Gerrit-Reviewer: Yingyi Bu <bu...@gmail.com>
Gerrit-Reviewer: Young-Seok Kim <ki...@gmail.com>
Gerrit-HasComments: Yes

Change in asterixdb[master]: ASTERIXDB-1157: Pushdown Limit

Posted by "Yingyi Bu (Code Review)" <do...@asterixdb.incubator.apache.org>.
Yingyi Bu has posted comments on this change.

Change subject: ASTERIXDB-1157: Pushdown Limit
......................................................................


Patch Set 8: Code-Review+2

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

Gerrit-MessageType: comment
Gerrit-Change-Id: I19aa4ce402b1834d9f68320acb72d7635a41a837
Gerrit-PatchSet: 8
Gerrit-Project: asterixdb
Gerrit-Branch: master
Gerrit-Owner: Taewoo Kim <wa...@gmail.com>
Gerrit-Reviewer: Jenkins <je...@fulliautomatix.ics.uci.edu>
Gerrit-Reviewer: Jianfeng Jia <ji...@gmail.com>
Gerrit-Reviewer: Taewoo Kim <wa...@gmail.com>
Gerrit-Reviewer: Yingyi Bu <bu...@gmail.com>
Gerrit-Reviewer: Young-Seok Kim <ki...@gmail.com>
Gerrit-HasComments: No

Change in asterixdb[master]: ASTERIXDB-1157: Pushdown Limit

Posted by "Jenkins (Code Review)" <do...@asterixdb.incubator.apache.org>.
Jenkins has posted comments on this change.

Change subject: ASTERIXDB-1157: Pushdown Limit
......................................................................


Patch Set 5:

Build Started https://asterix-jenkins.ics.uci.edu/job/asterix-gerrit-topic/672/

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

Gerrit-MessageType: comment
Gerrit-Change-Id: I19aa4ce402b1834d9f68320acb72d7635a41a837
Gerrit-PatchSet: 5
Gerrit-Project: asterixdb
Gerrit-Branch: master
Gerrit-Owner: Taewoo Kim <wa...@gmail.com>
Gerrit-Reviewer: Jenkins <je...@fulliautomatix.ics.uci.edu>
Gerrit-Reviewer: Jianfeng Jia <ji...@gmail.com>
Gerrit-Reviewer: Taewoo Kim <wa...@gmail.com>
Gerrit-Reviewer: Yingyi Bu <bu...@gmail.com>
Gerrit-Reviewer: Young-Seok Kim <ki...@gmail.com>
Gerrit-HasComments: No

Change in asterixdb[master]: ASTERIXDB-1157: Implemented Limit Pushdown into Order (Exter...

Posted by "Jenkins (Code Review)" <do...@asterixdb.incubator.apache.org>.
Jenkins has posted comments on this change.

Change subject: ASTERIXDB-1157: Implemented Limit Pushdown into Order (ExternalSort)
......................................................................


Patch Set 1: -Verified

Build Started https://asterix-jenkins.ics.uci.edu/job/asterix-gerrit-topic/641/

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

Gerrit-MessageType: comment
Gerrit-Change-Id: I19aa4ce402b1834d9f68320acb72d7635a41a837
Gerrit-PatchSet: 1
Gerrit-Project: asterixdb
Gerrit-Branch: master
Gerrit-Owner: Taewoo Kim <wa...@gmail.com>
Gerrit-Reviewer: Jenkins <je...@fulliautomatix.ics.uci.edu>
Gerrit-HasComments: No

Change in asterixdb[master]: ASTERIXDB-1157: Pushdown Limit

Posted by "Jenkins (Code Review)" <do...@asterixdb.incubator.apache.org>.
Jenkins has posted comments on this change.

Change subject: ASTERIXDB-1157: Pushdown Limit
......................................................................


Patch Set 7:

Build Started https://asterix-jenkins.ics.uci.edu/job/asterix-gerrit-topic/683/

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

Gerrit-MessageType: comment
Gerrit-Change-Id: I19aa4ce402b1834d9f68320acb72d7635a41a837
Gerrit-PatchSet: 7
Gerrit-Project: asterixdb
Gerrit-Branch: master
Gerrit-Owner: Taewoo Kim <wa...@gmail.com>
Gerrit-Reviewer: Jenkins <je...@fulliautomatix.ics.uci.edu>
Gerrit-Reviewer: Jianfeng Jia <ji...@gmail.com>
Gerrit-Reviewer: Taewoo Kim <wa...@gmail.com>
Gerrit-Reviewer: Yingyi Bu <bu...@gmail.com>
Gerrit-Reviewer: Young-Seok Kim <ki...@gmail.com>
Gerrit-HasComments: No

Change in asterixdb[master]: ASTERIXDB-1157: Implemented Limit Pushdown into Order (Exter...

Posted by "Jenkins (Code Review)" <do...@asterixdb.incubator.apache.org>.
Jenkins has posted comments on this change.

Change subject: ASTERIXDB-1157: Implemented Limit Pushdown into Order (ExternalSort)
......................................................................


Patch Set 2:

Build Started https://asterix-jenkins.ics.uci.edu/job/asterix-gerrit-topic/656/

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

Gerrit-MessageType: comment
Gerrit-Change-Id: I19aa4ce402b1834d9f68320acb72d7635a41a837
Gerrit-PatchSet: 2
Gerrit-Project: asterixdb
Gerrit-Branch: master
Gerrit-Owner: Taewoo Kim <wa...@gmail.com>
Gerrit-Reviewer: Jenkins <je...@fulliautomatix.ics.uci.edu>
Gerrit-Reviewer: Jianfeng Jia <ji...@gmail.com>
Gerrit-Reviewer: Yingyi Bu <bu...@gmail.com>
Gerrit-Reviewer: Young-Seok Kim <ki...@gmail.com>
Gerrit-HasComments: No

Change in asterixdb[master]: ASTERIXDB-1157: Pushdown Limit

Posted by "Jenkins (Code Review)" <do...@asterixdb.incubator.apache.org>.
Jenkins has posted comments on this change.

Change subject: ASTERIXDB-1157: Pushdown Limit
......................................................................


Patch Set 7: Verified+1

Build Successful 

https://asterix-jenkins.ics.uci.edu/job/asterix-gerrit-topic/683/ : SUCCESS

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

Gerrit-MessageType: comment
Gerrit-Change-Id: I19aa4ce402b1834d9f68320acb72d7635a41a837
Gerrit-PatchSet: 7
Gerrit-Project: asterixdb
Gerrit-Branch: master
Gerrit-Owner: Taewoo Kim <wa...@gmail.com>
Gerrit-Reviewer: Jenkins <je...@fulliautomatix.ics.uci.edu>
Gerrit-Reviewer: Jianfeng Jia <ji...@gmail.com>
Gerrit-Reviewer: Taewoo Kim <wa...@gmail.com>
Gerrit-Reviewer: Yingyi Bu <bu...@gmail.com>
Gerrit-Reviewer: Young-Seok Kim <ki...@gmail.com>
Gerrit-HasComments: No

Change in asterixdb[master]: ASTERIXDB-1157: Pushdown Limit

Posted by "Taewoo Kim (Code Review)" <do...@asterixdb.incubator.apache.org>.
Taewoo Kim has posted comments on this change.

Change subject: ASTERIXDB-1157: Pushdown Limit
......................................................................


Patch Set 4:

(1 comment)

https://asterix-gerrit.ics.uci.edu/#/c/617/4/asterix-algebra/src/main/java/org/apache/asterix/optimizer/rules/PushLimitIntoOrderByRule.java
File asterix-algebra/src/main/java/org/apache/asterix/optimizer/rules/PushLimitIntoOrderByRule.java:

Line 115:             // a copied non-topmost LIMIT can contain NUMERIC-ADD to add the given limit value + offset value
> It is probably because ConstantFoldingRule is applied before CopyLimitDownR
OK. Let me try it.


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

Gerrit-MessageType: comment
Gerrit-Change-Id: I19aa4ce402b1834d9f68320acb72d7635a41a837
Gerrit-PatchSet: 4
Gerrit-Project: asterixdb
Gerrit-Branch: master
Gerrit-Owner: Taewoo Kim <wa...@gmail.com>
Gerrit-Reviewer: Jenkins <je...@fulliautomatix.ics.uci.edu>
Gerrit-Reviewer: Jianfeng Jia <ji...@gmail.com>
Gerrit-Reviewer: Taewoo Kim <wa...@gmail.com>
Gerrit-Reviewer: Yingyi Bu <bu...@gmail.com>
Gerrit-Reviewer: Young-Seok Kim <ki...@gmail.com>
Gerrit-HasComments: Yes

Change in asterixdb[master]: ASTERIXDB-1157: Pushdown Limit

Posted by "Taewoo Kim (Code Review)" <do...@asterixdb.incubator.apache.org>.
Hello Yingyi Bu, Jenkins,

I'd like you to reexamine a change.  Please visit

    https://asterix-gerrit.ics.uci.edu/617

to look at the new patch set (#8).

Change subject: ASTERIXDB-1157: Pushdown Limit
......................................................................

ASTERIXDB-1157: Pushdown Limit

- Limit Pushdown into an Order (ExternalSort) operator.
- ConstantFoldingRule is not applied on the record-related operations.

Change-Id: I19aa4ce402b1834d9f68320acb72d7635a41a837
---
M asterix-algebra/src/main/java/org/apache/asterix/optimizer/base/RuleCollections.java
M asterix-algebra/src/main/java/org/apache/asterix/optimizer/rules/ConstantFoldingRule.java
A asterix-algebra/src/main/java/org/apache/asterix/optimizer/rules/PushLimitIntoOrderByRule.java
M asterix-algebra/src/main/java/org/apache/asterix/optimizer/rules/am/AccessMethodUtils.java
A asterix-app/data/spatial/spatialData2.json
A asterix-app/src/test/resources/optimizerts/queries/orderby_limit_01.aql
A asterix-app/src/test/resources/optimizerts/queries/orderby_limit_offset_01.aql
A asterix-app/src/test/resources/optimizerts/queries/orderby_limit_primary_index_01.aql
A asterix-app/src/test/resources/optimizerts/results/btree-index/btree-primary-limit-orderby-01.plan
A asterix-app/src/test/resources/optimizerts/results/btree-index/btree-primary-limit-orderby-02.plan
M asterix-app/src/test/resources/optimizerts/results/inlined_q18_large_volume_customer.plan
A asterix-app/src/test/resources/optimizerts/results/orderby_limit_01.plan
A asterix-app/src/test/resources/optimizerts/results/orderby_limit_offset_01.plan
A asterix-app/src/test/resources/optimizerts/results/orderby_limit_primary_index_01.plan
M asterix-app/src/test/resources/optimizerts/results/q03_shipping_priority.plan
M asterix-app/src/test/resources/optimizerts/results/q2.plan
M asterix-app/src/test/resources/optimizerts/results/sort-cust.plan
A asterix-app/src/test/resources/runtimets/queries/index-selection/btree-index-limit-orderby-01/btree-index-limit-orderby-01.1.ddl.aql
A asterix-app/src/test/resources/runtimets/queries/index-selection/btree-index-limit-orderby-01/btree-index-limit-orderby-01.2.update.aql
A asterix-app/src/test/resources/runtimets/queries/index-selection/btree-index-limit-orderby-01/btree-index-limit-orderby-01.3.query.aql
A asterix-app/src/test/resources/runtimets/queries/index-selection/btree-index-limit-orderby-02/btree-index-limit-orderby-02.1.ddl.aql
A asterix-app/src/test/resources/runtimets/queries/index-selection/btree-index-limit-orderby-02/btree-index-limit-orderby-02.2.update.aql
A asterix-app/src/test/resources/runtimets/queries/index-selection/btree-index-limit-orderby-02/btree-index-limit-orderby-02.3.query.aql
A asterix-app/src/test/resources/runtimets/queries/orderby_limit/orderby_limit_01/orderby_limit_01.1.ddl.aql
A asterix-app/src/test/resources/runtimets/queries/orderby_limit/orderby_limit_01/orderby_limit_01.2.update.aql
A asterix-app/src/test/resources/runtimets/queries/orderby_limit/orderby_limit_01/orderby_limit_01.3.query.aql
A asterix-app/src/test/resources/runtimets/queries/orderby_limit/orderby_limit_offset_01/orderby_limit_offset_01.1.ddl.aql
A asterix-app/src/test/resources/runtimets/queries/orderby_limit/orderby_limit_offset_01/orderby_limit_offset_01.2.update.aql
A asterix-app/src/test/resources/runtimets/queries/orderby_limit/orderby_limit_offset_01/orderby_limit_offset_01.3.query.aql
A asterix-app/src/test/resources/runtimets/queries/orderby_limit/orderby_limit_primary_index_01/orderby_limit_primary_index_01.1.ddl.aql
A asterix-app/src/test/resources/runtimets/queries/orderby_limit/orderby_limit_primary_index_01/orderby_limit_primary_index_01.2.update.aql
A asterix-app/src/test/resources/runtimets/queries/orderby_limit/orderby_limit_primary_index_01/orderby_limit_primary_index_01.3.query.aql
A asterix-app/src/test/resources/runtimets/results/index-selection/btree-index-limit-orderby-01/btree-index-limit-orderby-01.1.adm
A asterix-app/src/test/resources/runtimets/results/index-selection/btree-index-limit-orderby-02/btree-index-limit-orderby-02.1.adm
A asterix-app/src/test/resources/runtimets/results/orderby_limit/orderby_limit_01/orderby_limit_01.1.adm
A asterix-app/src/test/resources/runtimets/results/orderby_limit/orderby_limit_offset_01/orderby_limit_offset_01.1.adm
A asterix-app/src/test/resources/runtimets/results/orderby_limit/orderby_limit_primary_index_01/orderby_limit_primary_index_01.1.adm
M asterix-app/src/test/resources/runtimets/testsuite.xml
38 files changed, 1,102 insertions(+), 7 deletions(-)


  git pull ssh://asterix-gerrit.ics.uci.edu:29418/asterixdb refs/changes/17/617/8
-- 
To view, visit https://asterix-gerrit.ics.uci.edu/617
To unsubscribe, visit https://asterix-gerrit.ics.uci.edu/settings

Gerrit-MessageType: newpatchset
Gerrit-Change-Id: I19aa4ce402b1834d9f68320acb72d7635a41a837
Gerrit-PatchSet: 8
Gerrit-Project: asterixdb
Gerrit-Branch: master
Gerrit-Owner: Taewoo Kim <wa...@gmail.com>
Gerrit-Reviewer: Jenkins <je...@fulliautomatix.ics.uci.edu>
Gerrit-Reviewer: Jianfeng Jia <ji...@gmail.com>
Gerrit-Reviewer: Taewoo Kim <wa...@gmail.com>
Gerrit-Reviewer: Yingyi Bu <bu...@gmail.com>
Gerrit-Reviewer: Young-Seok Kim <ki...@gmail.com>

Change in asterixdb[master]: ASTERIXDB-1157: Implemented Limit Pushdown into Order (Exter...

Posted by "Yingyi Bu (Code Review)" <do...@asterixdb.incubator.apache.org>.
Yingyi Bu has posted comments on this change.

Change subject: ASTERIXDB-1157: Implemented Limit Pushdown into Order (ExternalSort)
......................................................................


Patch Set 1:

Taewoo,

    Can you add some optimizer tests as well as runtime tests for this change? 
    Thanks!

Best,
Yingyi

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

Gerrit-MessageType: comment
Gerrit-Change-Id: I19aa4ce402b1834d9f68320acb72d7635a41a837
Gerrit-PatchSet: 1
Gerrit-Project: asterixdb
Gerrit-Branch: master
Gerrit-Owner: Taewoo Kim <wa...@gmail.com>
Gerrit-Reviewer: Jenkins <je...@fulliautomatix.ics.uci.edu>
Gerrit-Reviewer: Jianfeng Jia <ji...@gmail.com>
Gerrit-Reviewer: Yingyi Bu <bu...@gmail.com>
Gerrit-Reviewer: Young-Seok Kim <ki...@gmail.com>
Gerrit-HasComments: No

Change in asterixdb[master]: ASTERIXDB-1157: Pushdown Limit

Posted by "Yingyi Bu (Code Review)" <do...@asterixdb.incubator.apache.org>.
Yingyi Bu has posted comments on this change.

Change subject: ASTERIXDB-1157: Pushdown Limit
......................................................................


Patch Set 6:

(1 comment)

https://asterix-gerrit.ics.uci.edu/#/c/617/6/asterix-algebra/src/main/java/org/apache/asterix/optimizer/rules/ConstantFoldingRule.java
File asterix-algebra/src/main/java/org/apache/asterix/optimizer/rules/ConstantFoldingRule.java:

Line 178:                     || expr.getFunctionIdentifier().equals(AsterixBuiltinFunctions.RECORD_MERGE)) {
Can you use an immutable set (ImmutableSet.of(...)) to store all function identifiers that shouldn't be constant-folded?

It should include:

1. All record functions:

record-merge

record-add-fields

record-remove-fields

get-record-fields

get-record-field-value

field-access-nested

field-access-by-index

field-access-by-name


2. All collection functions:

ordered-list-constructor

unordered-list-constructor

get-item


3. All cast functions for complex types:

cast-record

cast-list


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

Gerrit-MessageType: comment
Gerrit-Change-Id: I19aa4ce402b1834d9f68320acb72d7635a41a837
Gerrit-PatchSet: 6
Gerrit-Project: asterixdb
Gerrit-Branch: master
Gerrit-Owner: Taewoo Kim <wa...@gmail.com>
Gerrit-Reviewer: Jenkins <je...@fulliautomatix.ics.uci.edu>
Gerrit-Reviewer: Jianfeng Jia <ji...@gmail.com>
Gerrit-Reviewer: Taewoo Kim <wa...@gmail.com>
Gerrit-Reviewer: Yingyi Bu <bu...@gmail.com>
Gerrit-Reviewer: Young-Seok Kim <ki...@gmail.com>
Gerrit-HasComments: Yes

Change in asterixdb[master]: ASTERIXDB-1157: Pushdown Limit

Posted by "Taewoo Kim (Code Review)" <do...@asterixdb.incubator.apache.org>.
Taewoo Kim has posted comments on this change.

Change subject: ASTERIXDB-1157: Pushdown Limit
......................................................................


Patch Set 7:

@Yingyi: I reflected your comments except the functions where it is already included in that rule.

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

Gerrit-MessageType: comment
Gerrit-Change-Id: I19aa4ce402b1834d9f68320acb72d7635a41a837
Gerrit-PatchSet: 7
Gerrit-Project: asterixdb
Gerrit-Branch: master
Gerrit-Owner: Taewoo Kim <wa...@gmail.com>
Gerrit-Reviewer: Jenkins <je...@fulliautomatix.ics.uci.edu>
Gerrit-Reviewer: Jianfeng Jia <ji...@gmail.com>
Gerrit-Reviewer: Taewoo Kim <wa...@gmail.com>
Gerrit-Reviewer: Yingyi Bu <bu...@gmail.com>
Gerrit-Reviewer: Young-Seok Kim <ki...@gmail.com>
Gerrit-HasComments: No

Change in asterixdb[master]: ASTERIXDB-1157: Pushdown Limit

Posted by "Taewoo Kim (Code Review)" <do...@asterixdb.incubator.apache.org>.
Hello Jenkins,

I'd like you to reexamine a change.  Please visit

    https://asterix-gerrit.ics.uci.edu/617

to look at the new patch set (#6).

Change subject: ASTERIXDB-1157: Pushdown Limit
......................................................................

ASTERIXDB-1157: Pushdown Limit

- Limit Pushdown into an Order (ExternalSort) operator.

Change-Id: I19aa4ce402b1834d9f68320acb72d7635a41a837
---
M asterix-algebra/src/main/java/org/apache/asterix/optimizer/base/RuleCollections.java
M asterix-algebra/src/main/java/org/apache/asterix/optimizer/rules/ConstantFoldingRule.java
A asterix-algebra/src/main/java/org/apache/asterix/optimizer/rules/PushLimitIntoOrderByRule.java
M asterix-algebra/src/main/java/org/apache/asterix/optimizer/rules/am/AccessMethodUtils.java
A asterix-app/data/spatial/spatialData2.json
A asterix-app/src/test/resources/optimizerts/queries/orderby_limit_01.aql
A asterix-app/src/test/resources/optimizerts/queries/orderby_limit_offset_01.aql
A asterix-app/src/test/resources/optimizerts/queries/orderby_limit_primary_index_01.aql
A asterix-app/src/test/resources/optimizerts/results/btree-index/btree-primary-limit-orderby-01.plan
A asterix-app/src/test/resources/optimizerts/results/btree-index/btree-primary-limit-orderby-02.plan
M asterix-app/src/test/resources/optimizerts/results/inlined_q18_large_volume_customer.plan
A asterix-app/src/test/resources/optimizerts/results/orderby_limit_01.plan
A asterix-app/src/test/resources/optimizerts/results/orderby_limit_offset_01.plan
A asterix-app/src/test/resources/optimizerts/results/orderby_limit_primary_index_01.plan
M asterix-app/src/test/resources/optimizerts/results/q03_shipping_priority.plan
M asterix-app/src/test/resources/optimizerts/results/q2.plan
M asterix-app/src/test/resources/optimizerts/results/sort-cust.plan
A asterix-app/src/test/resources/runtimets/queries/index-selection/btree-index-limit-orderby-01/btree-index-limit-orderby-01.1.ddl.aql
A asterix-app/src/test/resources/runtimets/queries/index-selection/btree-index-limit-orderby-01/btree-index-limit-orderby-01.2.update.aql
A asterix-app/src/test/resources/runtimets/queries/index-selection/btree-index-limit-orderby-01/btree-index-limit-orderby-01.3.query.aql
A asterix-app/src/test/resources/runtimets/queries/index-selection/btree-index-limit-orderby-02/btree-index-limit-orderby-02.1.ddl.aql
A asterix-app/src/test/resources/runtimets/queries/index-selection/btree-index-limit-orderby-02/btree-index-limit-orderby-02.2.update.aql
A asterix-app/src/test/resources/runtimets/queries/index-selection/btree-index-limit-orderby-02/btree-index-limit-orderby-02.3.query.aql
A asterix-app/src/test/resources/runtimets/queries/orderby_limit/orderby_limit_01/orderby_limit_01.1.ddl.aql
A asterix-app/src/test/resources/runtimets/queries/orderby_limit/orderby_limit_01/orderby_limit_01.2.update.aql
A asterix-app/src/test/resources/runtimets/queries/orderby_limit/orderby_limit_01/orderby_limit_01.3.query.aql
A asterix-app/src/test/resources/runtimets/queries/orderby_limit/orderby_limit_offset_01/orderby_limit_offset_01.1.ddl.aql
A asterix-app/src/test/resources/runtimets/queries/orderby_limit/orderby_limit_offset_01/orderby_limit_offset_01.2.update.aql
A asterix-app/src/test/resources/runtimets/queries/orderby_limit/orderby_limit_offset_01/orderby_limit_offset_01.3.query.aql
A asterix-app/src/test/resources/runtimets/queries/orderby_limit/orderby_limit_primary_index_01/orderby_limit_primary_index_01.1.ddl.aql
A asterix-app/src/test/resources/runtimets/queries/orderby_limit/orderby_limit_primary_index_01/orderby_limit_primary_index_01.2.update.aql
A asterix-app/src/test/resources/runtimets/queries/orderby_limit/orderby_limit_primary_index_01/orderby_limit_primary_index_01.3.query.aql
A asterix-app/src/test/resources/runtimets/results/index-selection/btree-index-limit-orderby-01/btree-index-limit-orderby-01.1.adm
A asterix-app/src/test/resources/runtimets/results/index-selection/btree-index-limit-orderby-02/btree-index-limit-orderby-02.1.adm
A asterix-app/src/test/resources/runtimets/results/orderby_limit/orderby_limit_01/orderby_limit_01.1.adm
A asterix-app/src/test/resources/runtimets/results/orderby_limit/orderby_limit_offset_01/orderby_limit_offset_01.1.adm
A asterix-app/src/test/resources/runtimets/results/orderby_limit/orderby_limit_primary_index_01/orderby_limit_primary_index_01.1.adm
M asterix-app/src/test/resources/runtimets/testsuite.xml
38 files changed, 1,090 insertions(+), 4 deletions(-)


  git pull ssh://asterix-gerrit.ics.uci.edu:29418/asterixdb refs/changes/17/617/6
-- 
To view, visit https://asterix-gerrit.ics.uci.edu/617
To unsubscribe, visit https://asterix-gerrit.ics.uci.edu/settings

Gerrit-MessageType: newpatchset
Gerrit-Change-Id: I19aa4ce402b1834d9f68320acb72d7635a41a837
Gerrit-PatchSet: 6
Gerrit-Project: asterixdb
Gerrit-Branch: master
Gerrit-Owner: Taewoo Kim <wa...@gmail.com>
Gerrit-Reviewer: Jenkins <je...@fulliautomatix.ics.uci.edu>
Gerrit-Reviewer: Jianfeng Jia <ji...@gmail.com>
Gerrit-Reviewer: Taewoo Kim <wa...@gmail.com>
Gerrit-Reviewer: Yingyi Bu <bu...@gmail.com>
Gerrit-Reviewer: Young-Seok Kim <ki...@gmail.com>

Change in asterixdb[master]: ASTERIXDB-1157: Pushdown Limit

Posted by "Jenkins (Code Review)" <do...@asterixdb.incubator.apache.org>.
Jenkins has posted comments on this change.

Change subject: ASTERIXDB-1157: Pushdown Limit
......................................................................


Patch Set 6: Verified+1

Build Successful 

https://asterix-jenkins.ics.uci.edu/job/asterix-gerrit-topic/680/ : SUCCESS

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

Gerrit-MessageType: comment
Gerrit-Change-Id: I19aa4ce402b1834d9f68320acb72d7635a41a837
Gerrit-PatchSet: 6
Gerrit-Project: asterixdb
Gerrit-Branch: master
Gerrit-Owner: Taewoo Kim <wa...@gmail.com>
Gerrit-Reviewer: Jenkins <je...@fulliautomatix.ics.uci.edu>
Gerrit-Reviewer: Jianfeng Jia <ji...@gmail.com>
Gerrit-Reviewer: Taewoo Kim <wa...@gmail.com>
Gerrit-Reviewer: Yingyi Bu <bu...@gmail.com>
Gerrit-Reviewer: Young-Seok Kim <ki...@gmail.com>
Gerrit-HasComments: No

Change in asterixdb[master]: ASTERIXDB-1157: Pushdown Limit

Posted by "Yingyi Bu (Code Review)" <do...@asterixdb.incubator.apache.org>.
Yingyi Bu has posted comments on this change.

Change subject: ASTERIXDB-1157: Pushdown Limit
......................................................................


Patch Set 4:

(1 comment)

https://asterix-gerrit.ics.uci.edu/#/c/617/4/asterix-algebra/src/main/java/org/apache/asterix/optimizer/rules/PushLimitIntoOrderByRule.java
File asterix-algebra/src/main/java/org/apache/asterix/optimizer/rules/PushLimitIntoOrderByRule.java:

Line 115:             // a copied non-topmost LIMIT can contain NUMERIC-ADD to add the given limit value + offset value
Should we let ConstantFoldingRule deal with that else-if block?
It doesn't seem to right to perform a hard-coded constant folding here...


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

Gerrit-MessageType: comment
Gerrit-Change-Id: I19aa4ce402b1834d9f68320acb72d7635a41a837
Gerrit-PatchSet: 4
Gerrit-Project: asterixdb
Gerrit-Branch: master
Gerrit-Owner: Taewoo Kim <wa...@gmail.com>
Gerrit-Reviewer: Jenkins <je...@fulliautomatix.ics.uci.edu>
Gerrit-Reviewer: Jianfeng Jia <ji...@gmail.com>
Gerrit-Reviewer: Taewoo Kim <wa...@gmail.com>
Gerrit-Reviewer: Yingyi Bu <bu...@gmail.com>
Gerrit-Reviewer: Young-Seok Kim <ki...@gmail.com>
Gerrit-HasComments: Yes

Change in asterixdb[master]: ASTERIXDB-1157: Implemented Limit Pushdown into Order (Exter...

Posted by "Taewoo Kim (Code Review)" <do...@asterixdb.incubator.apache.org>.
Hello Jenkins,

I'd like you to reexamine a change.  Please visit

    https://asterix-gerrit.ics.uci.edu/617

to look at the new patch set (#2).

Change subject: ASTERIXDB-1157: Implemented Limit Pushdown into Order (ExternalSort)
......................................................................

ASTERIXDB-1157: Implemented Limit Pushdown into Order (ExternalSort)

Change-Id: I19aa4ce402b1834d9f68320acb72d7635a41a837
---
M asterix-algebra/src/main/java/org/apache/asterix/optimizer/base/RuleCollections.java
A asterix-algebra/src/main/java/org/apache/asterix/optimizer/rules/PushLimitIntoOrderByRule.java
M asterix-algebra/src/main/java/org/apache/asterix/optimizer/rules/am/AccessMethodUtils.java
A asterix-app/data/spatial/spatialData2.json
A asterix-app/src/test/resources/optimizerts/queries/btree-index/btree-primary-limit-orderby-01.aql
A asterix-app/src/test/resources/optimizerts/queries/btree-index/btree-primary-limit-orderby-02.aql
A asterix-app/src/test/resources/optimizerts/results/btree-index/btree-primary-limit-orderby-01.plan
A asterix-app/src/test/resources/optimizerts/results/btree-index/btree-primary-limit-orderby-02.plan
A asterix-app/src/test/resources/runtimets/queries/index-selection/btree-index-limit-orderby-01/btree-index-limit-orderby-01.1.ddl.aql
A asterix-app/src/test/resources/runtimets/queries/index-selection/btree-index-limit-orderby-01/btree-index-limit-orderby-01.2.update.aql
A asterix-app/src/test/resources/runtimets/queries/index-selection/btree-index-limit-orderby-01/btree-index-limit-orderby-01.3.query.aql
A asterix-app/src/test/resources/runtimets/queries/index-selection/btree-index-limit-orderby-02/btree-index-limit-orderby-02.1.ddl.aql
A asterix-app/src/test/resources/runtimets/queries/index-selection/btree-index-limit-orderby-02/btree-index-limit-orderby-02.2.update.aql
A asterix-app/src/test/resources/runtimets/queries/index-selection/btree-index-limit-orderby-02/btree-index-limit-orderby-02.3.query.aql
A asterix-app/src/test/resources/runtimets/results/index-selection/btree-index-limit-orderby-01/btree-index-limit-orderby-01.1.adm
A asterix-app/src/test/resources/runtimets/results/index-selection/btree-index-limit-orderby-02/btree-index-limit-orderby-02.1.adm
M asterix-app/src/test/resources/runtimets/testsuite.xml
17 files changed, 602 insertions(+), 0 deletions(-)


  git pull ssh://asterix-gerrit.ics.uci.edu:29418/asterixdb refs/changes/17/617/2
-- 
To view, visit https://asterix-gerrit.ics.uci.edu/617
To unsubscribe, visit https://asterix-gerrit.ics.uci.edu/settings

Gerrit-MessageType: newpatchset
Gerrit-Change-Id: I19aa4ce402b1834d9f68320acb72d7635a41a837
Gerrit-PatchSet: 2
Gerrit-Project: asterixdb
Gerrit-Branch: master
Gerrit-Owner: Taewoo Kim <wa...@gmail.com>
Gerrit-Reviewer: Jenkins <je...@fulliautomatix.ics.uci.edu>
Gerrit-Reviewer: Jianfeng Jia <ji...@gmail.com>
Gerrit-Reviewer: Yingyi Bu <bu...@gmail.com>
Gerrit-Reviewer: Young-Seok Kim <ki...@gmail.com>

Change in asterixdb[master]: ASTERIXDB-1157: Pushdown Limit

Posted by "Jenkins (Code Review)" <do...@asterixdb.incubator.apache.org>.
Jenkins has posted comments on this change.

Change subject: ASTERIXDB-1157: Pushdown Limit
......................................................................


Patch Set 4:

Build Started https://asterix-jenkins.ics.uci.edu/job/asterix-gerrit-topic/671/

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

Gerrit-MessageType: comment
Gerrit-Change-Id: I19aa4ce402b1834d9f68320acb72d7635a41a837
Gerrit-PatchSet: 4
Gerrit-Project: asterixdb
Gerrit-Branch: master
Gerrit-Owner: Taewoo Kim <wa...@gmail.com>
Gerrit-Reviewer: Jenkins <je...@fulliautomatix.ics.uci.edu>
Gerrit-Reviewer: Jianfeng Jia <ji...@gmail.com>
Gerrit-Reviewer: Taewoo Kim <wa...@gmail.com>
Gerrit-Reviewer: Yingyi Bu <bu...@gmail.com>
Gerrit-Reviewer: Young-Seok Kim <ki...@gmail.com>
Gerrit-HasComments: No

Change in asterixdb[master]: ASTERIXDB-1157: Pushdown Limit

Posted by "Taewoo Kim (Code Review)" <do...@asterixdb.incubator.apache.org>.
Hello Jenkins,

I'd like you to reexamine a change.  Please visit

    https://asterix-gerrit.ics.uci.edu/617

to look at the new patch set (#4).

Change subject: ASTERIXDB-1157: Pushdown Limit
......................................................................

ASTERIXDB-1157: Pushdown Limit

- Limit Pushdown into an Order (ExternalSort) operator.

Change-Id: I19aa4ce402b1834d9f68320acb72d7635a41a837
---
M asterix-algebra/src/main/java/org/apache/asterix/optimizer/base/RuleCollections.java
A asterix-algebra/src/main/java/org/apache/asterix/optimizer/rules/PushLimitIntoOrderByRule.java
M asterix-algebra/src/main/java/org/apache/asterix/optimizer/rules/am/AccessMethodUtils.java
A asterix-app/data/spatial/spatialData2.json
A asterix-app/src/test/resources/optimizerts/queries/orderby_limit_01.aql
A asterix-app/src/test/resources/optimizerts/queries/orderby_limit_offset_01.aql
A asterix-app/src/test/resources/optimizerts/queries/orderby_limit_primary_index_01.aql
A asterix-app/src/test/resources/optimizerts/results/btree-index/btree-primary-limit-orderby-01.plan
A asterix-app/src/test/resources/optimizerts/results/btree-index/btree-primary-limit-orderby-02.plan
M asterix-app/src/test/resources/optimizerts/results/inlined_q18_large_volume_customer.plan
A asterix-app/src/test/resources/optimizerts/results/orderby_limit_01.plan
A asterix-app/src/test/resources/optimizerts/results/orderby_limit_offset_01.plan
A asterix-app/src/test/resources/optimizerts/results/orderby_limit_primary_index_01.plan
M asterix-app/src/test/resources/optimizerts/results/q03_shipping_priority.plan
M asterix-app/src/test/resources/optimizerts/results/q2.plan
M asterix-app/src/test/resources/optimizerts/results/sort-cust.plan
A asterix-app/src/test/resources/runtimets/queries/index-selection/btree-index-limit-orderby-01/btree-index-limit-orderby-01.1.ddl.aql
A asterix-app/src/test/resources/runtimets/queries/index-selection/btree-index-limit-orderby-01/btree-index-limit-orderby-01.2.update.aql
A asterix-app/src/test/resources/runtimets/queries/index-selection/btree-index-limit-orderby-01/btree-index-limit-orderby-01.3.query.aql
A asterix-app/src/test/resources/runtimets/queries/index-selection/btree-index-limit-orderby-02/btree-index-limit-orderby-02.1.ddl.aql
A asterix-app/src/test/resources/runtimets/queries/index-selection/btree-index-limit-orderby-02/btree-index-limit-orderby-02.2.update.aql
A asterix-app/src/test/resources/runtimets/queries/index-selection/btree-index-limit-orderby-02/btree-index-limit-orderby-02.3.query.aql
A asterix-app/src/test/resources/runtimets/queries/orderby_limit/orderby_limit_01/orderby_limit_01.1.ddl.aql
A asterix-app/src/test/resources/runtimets/queries/orderby_limit/orderby_limit_01/orderby_limit_01.2.update.aql
A asterix-app/src/test/resources/runtimets/queries/orderby_limit/orderby_limit_01/orderby_limit_01.3.query.aql
A asterix-app/src/test/resources/runtimets/queries/orderby_limit/orderby_limit_offset_01/orderby_limit_offset_01.1.ddl.aql
A asterix-app/src/test/resources/runtimets/queries/orderby_limit/orderby_limit_offset_01/orderby_limit_offset_01.2.update.aql
A asterix-app/src/test/resources/runtimets/queries/orderby_limit/orderby_limit_offset_01/orderby_limit_offset_01.3.query.aql
A asterix-app/src/test/resources/runtimets/queries/orderby_limit/orderby_limit_primary_index_01/orderby_limit_primary_index_01.1.ddl.aql
A asterix-app/src/test/resources/runtimets/queries/orderby_limit/orderby_limit_primary_index_01/orderby_limit_primary_index_01.2.update.aql
A asterix-app/src/test/resources/runtimets/queries/orderby_limit/orderby_limit_primary_index_01/orderby_limit_primary_index_01.3.query.aql
A asterix-app/src/test/resources/runtimets/results/index-selection/btree-index-limit-orderby-01/btree-index-limit-orderby-01.1.adm
A asterix-app/src/test/resources/runtimets/results/index-selection/btree-index-limit-orderby-02/btree-index-limit-orderby-02.1.adm
A asterix-app/src/test/resources/runtimets/results/orderby_limit/orderby_limit_01/orderby_limit_01.1.adm
A asterix-app/src/test/resources/runtimets/results/orderby_limit/orderby_limit_offset_01/orderby_limit_offset_01.1.adm
A asterix-app/src/test/resources/runtimets/results/orderby_limit/orderby_limit_primary_index_01/orderby_limit_primary_index_01.1.adm
M asterix-app/src/test/resources/runtimets/testsuite.xml
37 files changed, 1,111 insertions(+), 4 deletions(-)


  git pull ssh://asterix-gerrit.ics.uci.edu:29418/asterixdb refs/changes/17/617/4
-- 
To view, visit https://asterix-gerrit.ics.uci.edu/617
To unsubscribe, visit https://asterix-gerrit.ics.uci.edu/settings

Gerrit-MessageType: newpatchset
Gerrit-Change-Id: I19aa4ce402b1834d9f68320acb72d7635a41a837
Gerrit-PatchSet: 4
Gerrit-Project: asterixdb
Gerrit-Branch: master
Gerrit-Owner: Taewoo Kim <wa...@gmail.com>
Gerrit-Reviewer: Jenkins <je...@fulliautomatix.ics.uci.edu>
Gerrit-Reviewer: Jianfeng Jia <ji...@gmail.com>
Gerrit-Reviewer: Taewoo Kim <wa...@gmail.com>
Gerrit-Reviewer: Yingyi Bu <bu...@gmail.com>
Gerrit-Reviewer: Young-Seok Kim <ki...@gmail.com>

Change in asterixdb[master]: ASTERIXDB-1157: Implemented Limit Pushdown into Order (Exter...

Posted by "Jenkins (Code Review)" <do...@asterixdb.incubator.apache.org>.
Jenkins has posted comments on this change.

Change subject: ASTERIXDB-1157: Implemented Limit Pushdown into Order (ExternalSort)
......................................................................


Patch Set 1: Verified+1

Build Successful 

https://asterix-jenkins.ics.uci.edu/job/asterix-gerrit-topic/641/ : SUCCESS

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

Gerrit-MessageType: comment
Gerrit-Change-Id: I19aa4ce402b1834d9f68320acb72d7635a41a837
Gerrit-PatchSet: 1
Gerrit-Project: asterixdb
Gerrit-Branch: master
Gerrit-Owner: Taewoo Kim <wa...@gmail.com>
Gerrit-Reviewer: Jenkins <je...@fulliautomatix.ics.uci.edu>
Gerrit-Reviewer: Jianfeng Jia <ji...@gmail.com>
Gerrit-Reviewer: Yingyi Bu <bu...@gmail.com>
Gerrit-Reviewer: Young-Seok Kim <ki...@gmail.com>
Gerrit-HasComments: No

Change in asterixdb[master]: ASTERIXDB-1157: Pushdown Limit

Posted by "Jenkins (Code Review)" <do...@asterixdb.incubator.apache.org>.
Jenkins has posted comments on this change.

Change subject: ASTERIXDB-1157: Pushdown Limit
......................................................................


Patch Set 6:

Build Started https://asterix-jenkins.ics.uci.edu/job/asterix-gerrit-topic/680/

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

Gerrit-MessageType: comment
Gerrit-Change-Id: I19aa4ce402b1834d9f68320acb72d7635a41a837
Gerrit-PatchSet: 6
Gerrit-Project: asterixdb
Gerrit-Branch: master
Gerrit-Owner: Taewoo Kim <wa...@gmail.com>
Gerrit-Reviewer: Jenkins <je...@fulliautomatix.ics.uci.edu>
Gerrit-Reviewer: Jianfeng Jia <ji...@gmail.com>
Gerrit-Reviewer: Taewoo Kim <wa...@gmail.com>
Gerrit-Reviewer: Yingyi Bu <bu...@gmail.com>
Gerrit-Reviewer: Young-Seok Kim <ki...@gmail.com>
Gerrit-HasComments: No

Change in asterixdb[master]: ASTERIXDB-1157: Pushdown Limit

Posted by "Taewoo Kim (Code Review)" <do...@asterixdb.incubator.apache.org>.
Hello Jenkins,

I'd like you to reexamine a change.  Please visit

    https://asterix-gerrit.ics.uci.edu/617

to look at the new patch set (#7).

Change subject: ASTERIXDB-1157: Pushdown Limit
......................................................................

ASTERIXDB-1157: Pushdown Limit

- Limit Pushdown into an Order (ExternalSort) operator.
- ConstantFoldingRule is not applied on the record-related operations.

Change-Id: I19aa4ce402b1834d9f68320acb72d7635a41a837
---
M asterix-algebra/src/main/java/org/apache/asterix/optimizer/base/RuleCollections.java
M asterix-algebra/src/main/java/org/apache/asterix/optimizer/rules/ConstantFoldingRule.java
A asterix-algebra/src/main/java/org/apache/asterix/optimizer/rules/PushLimitIntoOrderByRule.java
M asterix-algebra/src/main/java/org/apache/asterix/optimizer/rules/am/AccessMethodUtils.java
A asterix-app/data/spatial/spatialData2.json
A asterix-app/src/test/resources/optimizerts/queries/orderby_limit_01.aql
A asterix-app/src/test/resources/optimizerts/queries/orderby_limit_offset_01.aql
A asterix-app/src/test/resources/optimizerts/queries/orderby_limit_primary_index_01.aql
A asterix-app/src/test/resources/optimizerts/results/btree-index/btree-primary-limit-orderby-01.plan
A asterix-app/src/test/resources/optimizerts/results/btree-index/btree-primary-limit-orderby-02.plan
M asterix-app/src/test/resources/optimizerts/results/inlined_q18_large_volume_customer.plan
A asterix-app/src/test/resources/optimizerts/results/orderby_limit_01.plan
A asterix-app/src/test/resources/optimizerts/results/orderby_limit_offset_01.plan
A asterix-app/src/test/resources/optimizerts/results/orderby_limit_primary_index_01.plan
M asterix-app/src/test/resources/optimizerts/results/q03_shipping_priority.plan
M asterix-app/src/test/resources/optimizerts/results/q2.plan
M asterix-app/src/test/resources/optimizerts/results/sort-cust.plan
A asterix-app/src/test/resources/runtimets/queries/index-selection/btree-index-limit-orderby-01/btree-index-limit-orderby-01.1.ddl.aql
A asterix-app/src/test/resources/runtimets/queries/index-selection/btree-index-limit-orderby-01/btree-index-limit-orderby-01.2.update.aql
A asterix-app/src/test/resources/runtimets/queries/index-selection/btree-index-limit-orderby-01/btree-index-limit-orderby-01.3.query.aql
A asterix-app/src/test/resources/runtimets/queries/index-selection/btree-index-limit-orderby-02/btree-index-limit-orderby-02.1.ddl.aql
A asterix-app/src/test/resources/runtimets/queries/index-selection/btree-index-limit-orderby-02/btree-index-limit-orderby-02.2.update.aql
A asterix-app/src/test/resources/runtimets/queries/index-selection/btree-index-limit-orderby-02/btree-index-limit-orderby-02.3.query.aql
A asterix-app/src/test/resources/runtimets/queries/orderby_limit/orderby_limit_01/orderby_limit_01.1.ddl.aql
A asterix-app/src/test/resources/runtimets/queries/orderby_limit/orderby_limit_01/orderby_limit_01.2.update.aql
A asterix-app/src/test/resources/runtimets/queries/orderby_limit/orderby_limit_01/orderby_limit_01.3.query.aql
A asterix-app/src/test/resources/runtimets/queries/orderby_limit/orderby_limit_offset_01/orderby_limit_offset_01.1.ddl.aql
A asterix-app/src/test/resources/runtimets/queries/orderby_limit/orderby_limit_offset_01/orderby_limit_offset_01.2.update.aql
A asterix-app/src/test/resources/runtimets/queries/orderby_limit/orderby_limit_offset_01/orderby_limit_offset_01.3.query.aql
A asterix-app/src/test/resources/runtimets/queries/orderby_limit/orderby_limit_primary_index_01/orderby_limit_primary_index_01.1.ddl.aql
A asterix-app/src/test/resources/runtimets/queries/orderby_limit/orderby_limit_primary_index_01/orderby_limit_primary_index_01.2.update.aql
A asterix-app/src/test/resources/runtimets/queries/orderby_limit/orderby_limit_primary_index_01/orderby_limit_primary_index_01.3.query.aql
A asterix-app/src/test/resources/runtimets/results/index-selection/btree-index-limit-orderby-01/btree-index-limit-orderby-01.1.adm
A asterix-app/src/test/resources/runtimets/results/index-selection/btree-index-limit-orderby-02/btree-index-limit-orderby-02.1.adm
A asterix-app/src/test/resources/runtimets/results/orderby_limit/orderby_limit_01/orderby_limit_01.1.adm
A asterix-app/src/test/resources/runtimets/results/orderby_limit/orderby_limit_offset_01/orderby_limit_offset_01.1.adm
A asterix-app/src/test/resources/runtimets/results/orderby_limit/orderby_limit_primary_index_01/orderby_limit_primary_index_01.1.adm
M asterix-app/src/test/resources/runtimets/testsuite.xml
38 files changed, 1,104 insertions(+), 6 deletions(-)


  git pull ssh://asterix-gerrit.ics.uci.edu:29418/asterixdb refs/changes/17/617/7
-- 
To view, visit https://asterix-gerrit.ics.uci.edu/617
To unsubscribe, visit https://asterix-gerrit.ics.uci.edu/settings

Gerrit-MessageType: newpatchset
Gerrit-Change-Id: I19aa4ce402b1834d9f68320acb72d7635a41a837
Gerrit-PatchSet: 7
Gerrit-Project: asterixdb
Gerrit-Branch: master
Gerrit-Owner: Taewoo Kim <wa...@gmail.com>
Gerrit-Reviewer: Jenkins <je...@fulliautomatix.ics.uci.edu>
Gerrit-Reviewer: Jianfeng Jia <ji...@gmail.com>
Gerrit-Reviewer: Taewoo Kim <wa...@gmail.com>
Gerrit-Reviewer: Yingyi Bu <bu...@gmail.com>
Gerrit-Reviewer: Young-Seok Kim <ki...@gmail.com>

Change in asterixdb[master]: ASTERIXDB-1157: Pushdown Limit

Posted by "Yingyi Bu (Code Review)" <do...@asterixdb.incubator.apache.org>.
Yingyi Bu has posted comments on this change.

Change subject: ASTERIXDB-1157: Pushdown Limit
......................................................................


Patch Set 6:

Yes, can you make sure all record functions are disabled for constant folding here:
https://github.com/apache/incubator-asterixdb/blob/master/asterix-algebra/src/main/java/org/apache/asterix/optimizer/rules/ConstantFoldingRule.java#L192

Then, also mention that in your commit message.

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

Gerrit-MessageType: comment
Gerrit-Change-Id: I19aa4ce402b1834d9f68320acb72d7635a41a837
Gerrit-PatchSet: 6
Gerrit-Project: asterixdb
Gerrit-Branch: master
Gerrit-Owner: Taewoo Kim <wa...@gmail.com>
Gerrit-Reviewer: Jenkins <je...@fulliautomatix.ics.uci.edu>
Gerrit-Reviewer: Jianfeng Jia <ji...@gmail.com>
Gerrit-Reviewer: Taewoo Kim <wa...@gmail.com>
Gerrit-Reviewer: Yingyi Bu <bu...@gmail.com>
Gerrit-Reviewer: Young-Seok Kim <ki...@gmail.com>
Gerrit-HasComments: No

Change in asterixdb[master]: ASTERIXDB-1157: Implemented Limit Pushdown into Order (Exter...

Posted by "Taewoo Kim (Code Review)" <do...@asterixdb.incubator.apache.org>.
Taewoo Kim has posted comments on this change.

Change subject: ASTERIXDB-1157: Implemented Limit Pushdown into Order (ExternalSort)
......................................................................


Patch Set 2:

@Yingyi: added two runtime tests and two optimizer tests.

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

Gerrit-MessageType: comment
Gerrit-Change-Id: I19aa4ce402b1834d9f68320acb72d7635a41a837
Gerrit-PatchSet: 2
Gerrit-Project: asterixdb
Gerrit-Branch: master
Gerrit-Owner: Taewoo Kim <wa...@gmail.com>
Gerrit-Reviewer: Jenkins <je...@fulliautomatix.ics.uci.edu>
Gerrit-Reviewer: Jianfeng Jia <ji...@gmail.com>
Gerrit-Reviewer: Taewoo Kim <wa...@gmail.com>
Gerrit-Reviewer: Yingyi Bu <bu...@gmail.com>
Gerrit-Reviewer: Young-Seok Kim <ki...@gmail.com>
Gerrit-HasComments: No

Change in asterixdb[master]: ASTERIXDB-1157: Pushdown Limit

Posted by "Taewoo Kim (Code Review)" <do...@asterixdb.incubator.apache.org>.
Taewoo Kim has submitted this change and it was merged.

Change subject: ASTERIXDB-1157: Pushdown Limit
......................................................................


ASTERIXDB-1157: Pushdown Limit

- Limit Pushdown into an Order (ExternalSort) operator.
- ConstantFoldingRule is not applied on the record-related operations.

Change-Id: I19aa4ce402b1834d9f68320acb72d7635a41a837
Reviewed-on: https://asterix-gerrit.ics.uci.edu/617
Reviewed-by: Yingyi Bu <bu...@gmail.com>
Tested-by: Jenkins <je...@fulliautomatix.ics.uci.edu>
---
M asterix-algebra/src/main/java/org/apache/asterix/optimizer/base/RuleCollections.java
M asterix-algebra/src/main/java/org/apache/asterix/optimizer/rules/ConstantFoldingRule.java
A asterix-algebra/src/main/java/org/apache/asterix/optimizer/rules/PushLimitIntoOrderByRule.java
M asterix-algebra/src/main/java/org/apache/asterix/optimizer/rules/am/AccessMethodUtils.java
A asterix-app/data/spatial/spatialData2.json
A asterix-app/src/test/resources/optimizerts/queries/orderby_limit_01.aql
A asterix-app/src/test/resources/optimizerts/queries/orderby_limit_offset_01.aql
A asterix-app/src/test/resources/optimizerts/queries/orderby_limit_primary_index_01.aql
A asterix-app/src/test/resources/optimizerts/results/btree-index/btree-primary-limit-orderby-01.plan
A asterix-app/src/test/resources/optimizerts/results/btree-index/btree-primary-limit-orderby-02.plan
M asterix-app/src/test/resources/optimizerts/results/inlined_q18_large_volume_customer.plan
A asterix-app/src/test/resources/optimizerts/results/orderby_limit_01.plan
A asterix-app/src/test/resources/optimizerts/results/orderby_limit_offset_01.plan
A asterix-app/src/test/resources/optimizerts/results/orderby_limit_primary_index_01.plan
M asterix-app/src/test/resources/optimizerts/results/q03_shipping_priority.plan
M asterix-app/src/test/resources/optimizerts/results/q2.plan
M asterix-app/src/test/resources/optimizerts/results/sort-cust.plan
A asterix-app/src/test/resources/runtimets/queries/index-selection/btree-index-limit-orderby-01/btree-index-limit-orderby-01.1.ddl.aql
A asterix-app/src/test/resources/runtimets/queries/index-selection/btree-index-limit-orderby-01/btree-index-limit-orderby-01.2.update.aql
A asterix-app/src/test/resources/runtimets/queries/index-selection/btree-index-limit-orderby-01/btree-index-limit-orderby-01.3.query.aql
A asterix-app/src/test/resources/runtimets/queries/index-selection/btree-index-limit-orderby-02/btree-index-limit-orderby-02.1.ddl.aql
A asterix-app/src/test/resources/runtimets/queries/index-selection/btree-index-limit-orderby-02/btree-index-limit-orderby-02.2.update.aql
A asterix-app/src/test/resources/runtimets/queries/index-selection/btree-index-limit-orderby-02/btree-index-limit-orderby-02.3.query.aql
A asterix-app/src/test/resources/runtimets/queries/orderby_limit/orderby_limit_01/orderby_limit_01.1.ddl.aql
A asterix-app/src/test/resources/runtimets/queries/orderby_limit/orderby_limit_01/orderby_limit_01.2.update.aql
A asterix-app/src/test/resources/runtimets/queries/orderby_limit/orderby_limit_01/orderby_limit_01.3.query.aql
A asterix-app/src/test/resources/runtimets/queries/orderby_limit/orderby_limit_offset_01/orderby_limit_offset_01.1.ddl.aql
A asterix-app/src/test/resources/runtimets/queries/orderby_limit/orderby_limit_offset_01/orderby_limit_offset_01.2.update.aql
A asterix-app/src/test/resources/runtimets/queries/orderby_limit/orderby_limit_offset_01/orderby_limit_offset_01.3.query.aql
A asterix-app/src/test/resources/runtimets/queries/orderby_limit/orderby_limit_primary_index_01/orderby_limit_primary_index_01.1.ddl.aql
A asterix-app/src/test/resources/runtimets/queries/orderby_limit/orderby_limit_primary_index_01/orderby_limit_primary_index_01.2.update.aql
A asterix-app/src/test/resources/runtimets/queries/orderby_limit/orderby_limit_primary_index_01/orderby_limit_primary_index_01.3.query.aql
A asterix-app/src/test/resources/runtimets/results/index-selection/btree-index-limit-orderby-01/btree-index-limit-orderby-01.1.adm
A asterix-app/src/test/resources/runtimets/results/index-selection/btree-index-limit-orderby-02/btree-index-limit-orderby-02.1.adm
A asterix-app/src/test/resources/runtimets/results/orderby_limit/orderby_limit_01/orderby_limit_01.1.adm
A asterix-app/src/test/resources/runtimets/results/orderby_limit/orderby_limit_offset_01/orderby_limit_offset_01.1.adm
A asterix-app/src/test/resources/runtimets/results/orderby_limit/orderby_limit_primary_index_01/orderby_limit_primary_index_01.1.adm
M asterix-app/src/test/resources/runtimets/testsuite.xml
38 files changed, 1,102 insertions(+), 7 deletions(-)

Approvals:
  Yingyi Bu: Looks good to me, approved
  Jenkins: Verified



diff --git a/asterix-algebra/src/main/java/org/apache/asterix/optimizer/base/RuleCollections.java b/asterix-algebra/src/main/java/org/apache/asterix/optimizer/base/RuleCollections.java
index 4187059..ae0b2f6 100644
--- a/asterix-algebra/src/main/java/org/apache/asterix/optimizer/base/RuleCollections.java
+++ b/asterix-algebra/src/main/java/org/apache/asterix/optimizer/base/RuleCollections.java
@@ -56,6 +56,7 @@
 import org.apache.asterix.optimizer.rules.PushAggregateIntoGroupbyRule;
 import org.apache.asterix.optimizer.rules.PushFieldAccessRule;
 import org.apache.asterix.optimizer.rules.PushGroupByThroughProduct;
+import org.apache.asterix.optimizer.rules.PushLimitIntoOrderByRule;
 import org.apache.asterix.optimizer.rules.PushProperJoinThroughProduct;
 import org.apache.asterix.optimizer.rules.PushSimilarityFunctionsBelowJoin;
 import org.apache.asterix.optimizer.rules.RemoveRedundantListifyRule;
@@ -310,6 +311,10 @@
         List<IAlgebraicRewriteRule> physicalRewritesTopLevel = new LinkedList<IAlgebraicRewriteRule>();
         physicalRewritesTopLevel.add(new PushNestedOrderByUnderPreSortedGroupByRule());
         physicalRewritesTopLevel.add(new CopyLimitDownRule());
+        // CopyLimitDownRule may generates non-topmost limits with numeric_adds functions.
+        // We are going to apply a constant folding rule again for this case.
+        physicalRewritesTopLevel.add(new ConstantFoldingRule());
+        physicalRewritesTopLevel.add(new PushLimitIntoOrderByRule());
         physicalRewritesTopLevel.add(new IntroduceProjectsRule());
         physicalRewritesTopLevel.add(new SetAlgebricksPhysicalOperatorsRule());
         physicalRewritesTopLevel.add(new IntroduceRapidFrameFlushProjectAssignRule());
diff --git a/asterix-algebra/src/main/java/org/apache/asterix/optimizer/rules/ConstantFoldingRule.java b/asterix-algebra/src/main/java/org/apache/asterix/optimizer/rules/ConstantFoldingRule.java
index effb973..ebe01a7 100644
--- a/asterix-algebra/src/main/java/org/apache/asterix/optimizer/rules/ConstantFoldingRule.java
+++ b/asterix-algebra/src/main/java/org/apache/asterix/optimizer/rules/ConstantFoldingRule.java
@@ -62,6 +62,7 @@
 import org.apache.hyracks.algebricks.core.algebra.expressions.StatefulFunctionCallExpression;
 import org.apache.hyracks.algebricks.core.algebra.expressions.UnnestingFunctionCallExpression;
 import org.apache.hyracks.algebricks.core.algebra.expressions.VariableReferenceExpression;
+import org.apache.hyracks.algebricks.core.algebra.functions.FunctionIdentifier;
 import org.apache.hyracks.algebricks.core.algebra.operators.logical.IOperatorSchema;
 import org.apache.hyracks.algebricks.core.algebra.visitors.ILogicalExpressionReferenceTransform;
 import org.apache.hyracks.algebricks.core.algebra.visitors.ILogicalExpressionVisitor;
@@ -75,9 +76,21 @@
 import org.apache.hyracks.data.std.primitive.VoidPointable;
 import org.apache.hyracks.dataflow.common.comm.util.ByteBufferInputStream;
 
+import com.google.common.collect.ImmutableSet;
+
 public class ConstantFoldingRule implements IAlgebraicRewriteRule {
 
     private final ConstantFoldingVisitor cfv = new ConstantFoldingVisitor();
+
+    // Function Identifier sets that the ConstantFolding rule should skip to apply.
+    // Most of them are record-related functions.
+    private static final ImmutableSet<FunctionIdentifier> FUNC_ID_SET_THAT_SHOULD_NOT_BE_APPLIED = ImmutableSet.of(
+            AsterixBuiltinFunctions.RECORD_MERGE, AsterixBuiltinFunctions.ADD_FIELDS,
+            AsterixBuiltinFunctions.REMOVE_FIELDS, AsterixBuiltinFunctions.GET_RECORD_FIELDS,
+            AsterixBuiltinFunctions.GET_RECORD_FIELD_VALUE, AsterixBuiltinFunctions.FIELD_ACCESS_NESTED,
+            AsterixBuiltinFunctions.GET_ITEM, AsterixBuiltinFunctions.OPEN_RECORD_CONSTRUCTOR,
+            AsterixBuiltinFunctions.FIELD_ACCESS_BY_INDEX, AsterixBuiltinFunctions.CAST_RECORD,
+            AsterixBuiltinFunctions.CAST_LIST);
 
     /** Throws exceptions in substituiteProducedVariable, setVarType, and one getVarType method. */
     private static final IVariableTypeEnvironment _emptyTypeEnv = new IVariableTypeEnvironment() {
@@ -133,6 +146,7 @@
         if (context.checkIfInDontApplySet(this, op)) {
             return false;
         }
+
         return op.acceptExpressionTransform(cfv);
     }
 
@@ -172,11 +186,12 @@
             if (!checkArgs(expr) || !expr.isFunctional()) {
                 return new Pair<Boolean, ILogicalExpression>(changed, expr);
             }
-            //Current ARecord SerDe assumes a closed record, so we do not constant fold open record constructors
-            if (expr.getFunctionIdentifier().equals(AsterixBuiltinFunctions.OPEN_RECORD_CONSTRUCTOR)
-                    || expr.getFunctionIdentifier().equals(AsterixBuiltinFunctions.CAST_RECORD)) {
+
+            // Skip Constant Folding for the record-related functions.
+            if (FUNC_ID_SET_THAT_SHOULD_NOT_BE_APPLIED.contains(expr.getFunctionIdentifier())) {
                 return new Pair<Boolean, ILogicalExpression>(false, null);
             }
+
             //Current List SerDe assumes a strongly typed list, so we do not constant fold the list constructors if they are not strongly typed
             if (expr.getFunctionIdentifier().equals(AsterixBuiltinFunctions.UNORDERED_LIST_CONSTRUCTOR)
                     || expr.getFunctionIdentifier().equals(AsterixBuiltinFunctions.ORDERED_LIST_CONSTRUCTOR)) {
@@ -199,6 +214,7 @@
                     return new Pair<Boolean, ILogicalExpression>(changed, expr);
                 }
             }
+
             IScalarEvaluatorFactory fact = _jobGenCtx.getExpressionRuntimeProvider().createEvaluatorFactory(expr,
                     _emptyTypeEnv, _emptySchemas, _jobGenCtx);
             IScalarEvaluator eval = fact.createScalarEvaluator(null);
diff --git a/asterix-algebra/src/main/java/org/apache/asterix/optimizer/rules/PushLimitIntoOrderByRule.java b/asterix-algebra/src/main/java/org/apache/asterix/optimizer/rules/PushLimitIntoOrderByRule.java
new file mode 100644
index 0000000..b573ae4
--- /dev/null
+++ b/asterix-algebra/src/main/java/org/apache/asterix/optimizer/rules/PushLimitIntoOrderByRule.java
@@ -0,0 +1,140 @@
+/*
+ * 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.
+ */
+package org.apache.asterix.optimizer.rules;
+
+import org.apache.asterix.optimizer.rules.am.AccessMethodUtils;
+import org.apache.commons.lang3.mutable.Mutable;
+import org.apache.hyracks.algebricks.common.exceptions.AlgebricksException;
+import org.apache.hyracks.algebricks.core.algebra.base.ILogicalOperator;
+import org.apache.hyracks.algebricks.core.algebra.base.IOptimizationContext;
+import org.apache.hyracks.algebricks.core.algebra.base.LogicalExpressionTag;
+import org.apache.hyracks.algebricks.core.algebra.base.LogicalOperatorTag;
+import org.apache.hyracks.algebricks.core.algebra.base.PhysicalOperatorTag;
+import org.apache.hyracks.algebricks.core.algebra.operators.logical.AbstractLogicalOperator;
+import org.apache.hyracks.algebricks.core.algebra.operators.logical.LimitOperator;
+import org.apache.hyracks.algebricks.core.algebra.operators.logical.OrderOperator;
+import org.apache.hyracks.algebricks.core.algebra.operators.physical.StableSortPOperator;
+import org.apache.hyracks.algebricks.core.algebra.util.OperatorPropertiesUtil;
+import org.apache.hyracks.algebricks.core.rewriter.base.IAlgebraicRewriteRule;
+import org.apache.hyracks.algebricks.core.rewriter.base.PhysicalOptimizationConfig;
+
+/**
+ * If an ORDER operator is followed by LIMIT, then we can push LIMIT into ORDER operator.
+ * Finally, ORDER operator use TopKSorterOperatorDescriptor that can efficiently
+ * sort tuples and fetch top K results.
+ * =================
+ * matching pattern:
+ * limit <- order
+ * =
+ * producing pattern:
+ * limit <- new order (topK applied)
+ */
+public class PushLimitIntoOrderByRule implements IAlgebraicRewriteRule {
+
+    @Override
+    public boolean rewritePost(Mutable<ILogicalOperator> opRef, IOptimizationContext context) {
+        return false;
+    }
+
+    @Override
+    public boolean rewritePre(Mutable<ILogicalOperator> opRef, IOptimizationContext context)
+            throws AlgebricksException {
+        AbstractLogicalOperator op = (AbstractLogicalOperator) opRef.getValue();
+        // The current operator should be LIMIT operator.
+        if (op.getOperatorTag() != LogicalOperatorTag.LIMIT) {
+            return false;
+        }
+
+        Mutable<ILogicalOperator> opRef2 = op.getInputs().get(0);
+        AbstractLogicalOperator op2 = (AbstractLogicalOperator) opRef2.getValue();
+
+        if (context.checkAndAddToAlreadyCompared(op, op2)) {
+            return false;
+        }
+
+        // Should be ORDER operator
+        if (op2.getOperatorTag() != LogicalOperatorTag.ORDER) {
+            return false;
+        } else {
+            // ORDER operator is followed by LIMIT. Thus we can check whether we can apply this rule.
+            boolean res = pushLimitIntoOrder(opRef, opRef2, context);
+            if (res) {
+                OperatorPropertiesUtil.typeOpRec(opRef, context);
+            }
+            return res;
+        }
+    }
+
+    /**
+     * Generate new ORDER operator that uses TopKSort module and replaces the old ORDER operator.
+     */
+    private boolean pushLimitIntoOrder(Mutable<ILogicalOperator> opRef, Mutable<ILogicalOperator> opRef2,
+            IOptimizationContext context) throws AlgebricksException {
+        PhysicalOptimizationConfig physicalOptimizationConfig = context.getPhysicalOptimizationConfig();
+        LimitOperator limitOp = (LimitOperator) opRef.getValue();
+        OrderOperator orderOp = (OrderOperator) opRef2.getValue();
+        long topK = -1;
+
+        // We don't push-down LIMIT into in-memory sort.
+        if (orderOp.getPhysicalOperator().getOperatorTag() != PhysicalOperatorTag.STABLE_SORT) {
+            return false;
+        }
+
+        boolean needToCheckOffsetValue = true;
+
+        // Get the LIMIT constant
+        if (limitOp.getMaxObjects().getValue().getExpressionTag() == LogicalExpressionTag.CONSTANT) {
+            // Currently, we support LIMIT with a constant value.
+            topK = AccessMethodUtils.getInt64Constant(limitOp.getMaxObjects());
+            // If topK is huge, there is no reason to use topK sort module
+            // since the original external sort's performance might be better.
+            if (topK > Integer.MAX_VALUE) {
+                return false;
+            }
+        } else {
+            return false;
+        }
+
+        // Get the offset constant if there is one. If one presents, then topK = topK + offset.
+        // This is because we can't apply offset to the external sort.
+        // Final topK will be applied through LIMIT.
+        if (limitOp.getOffset().getValue() != null) {
+            if (limitOp.getOffset().getValue().getExpressionTag() == LogicalExpressionTag.CONSTANT) {
+                topK = topK + ((int) AccessMethodUtils.getInt64Constant(limitOp.getOffset()));
+            } else {
+                return false;
+            }
+        }
+
+        // Create the new ORDER operator, set the topK value, and replace the current one.
+        OrderOperator newOrderOp = new OrderOperator(orderOp.getOrderExpressions(), (int) topK);
+        newOrderOp.setPhysicalOperator(
+                new StableSortPOperator(physicalOptimizationConfig.getMaxFramesExternalSort(), newOrderOp.getTopK()));
+        newOrderOp.getInputs().addAll(orderOp.getInputs());
+        newOrderOp.setExecutionMode(orderOp.getExecutionMode());
+        newOrderOp.recomputeSchema();
+        newOrderOp.computeDeliveredPhysicalProperties(context);
+        opRef2.setValue(newOrderOp);
+        context.computeAndSetTypeEnvironmentForOperator(newOrderOp);
+        context.addToDontApplySet(this, limitOp);
+
+        return true;
+    }
+
+}
diff --git a/asterix-algebra/src/main/java/org/apache/asterix/optimizer/rules/am/AccessMethodUtils.java b/asterix-algebra/src/main/java/org/apache/asterix/optimizer/rules/am/AccessMethodUtils.java
index 1ff3df6..9165506 100644
--- a/asterix-algebra/src/main/java/org/apache/asterix/optimizer/rules/am/AccessMethodUtils.java
+++ b/asterix-algebra/src/main/java/org/apache/asterix/optimizer/rules/am/AccessMethodUtils.java
@@ -38,6 +38,7 @@
 import org.apache.asterix.metadata.utils.DatasetUtils;
 import org.apache.asterix.om.base.ABoolean;
 import org.apache.asterix.om.base.AInt32;
+import org.apache.asterix.om.base.AInt64;
 import org.apache.asterix.om.base.AString;
 import org.apache.asterix.om.base.IAObject;
 import org.apache.asterix.om.constants.AsterixConstantValue;
@@ -118,6 +119,11 @@
         return ((AInt32) obj).getIntegerValue();
     }
 
+    public static long getInt64Constant(Mutable<ILogicalExpression> expr) {
+        IAObject obj = ((AsterixConstantValue) ((ConstantExpression) expr.getValue()).getValue()).getObject();
+        return ((AInt64) obj).getLongValue();
+    }
+
     public static boolean getBooleanConstant(Mutable<ILogicalExpression> expr) {
         IAObject obj = ((AsterixConstantValue) ((ConstantExpression) expr.getValue()).getValue()).getObject();
         return ((ABoolean) obj).getBoolean();
diff --git a/asterix-app/data/spatial/spatialData2.json b/asterix-app/data/spatial/spatialData2.json
new file mode 100644
index 0000000..7f676f2
--- /dev/null
+++ b/asterix-app/data/spatial/spatialData2.json
@@ -0,0 +1,60 @@
+{"id": 1, "docid": 1, "val1": 7, "title": "Object SQL - A Language for the Design and Implementation of Object Databases", "kwds": "sign ahead", "line1": line("4.0,7.0 9.0,7.0"), "line2": line("5.0,8.0 5.0,1.0"), "poly1": polygon("1.0,1.0 1.0,4.0 3.0,4.0 3.0,1.0"), "poly2": polygon("5.0,1.0 5.0,4.0 7.0,4.0 7.0,1.0"), "rec": rectangle("0.0,0.0 4.2,7.0"), "circle" : circle("1.0,1.0 10.0"), "point": point("4.1,7.0")}
+{"id": 2, "docid": 2, "val1": 1, "title": "OQL[C++]  Extending C++ with an Object Query Capability", "kwds": "factory hosedan", "line1": line("-4.0,2.0 2.0,2.0"), "line2": line("4.0,7.0 2.0,17.0"), "poly1": polygon("1.0,1.0 1.0,4.0 3.0,4.0 3.0,1.0"), "poly2": polygon("5.0,1.0 5.0,4.0 7.0,4.0 7.0,1.0"), "rec": rectangle("0.0,0.0 4.0,4.0"), "circle" : circle("2.0,3.0 2.0"), "point": point("40.2152,-75.0449")}
+{"id": 3, "docid": 3, "val1": 10, "title": "Transaction Management in Multidatabase Systems", "kwds": "enterprisecamp torcamp", "line1": line("3.0,0.0 0.0,4.0"), "line2": line("4.0,7.0 2.0,17.0"), "poly1": polygon("1.0,1.0 1.0,4.0 3.0,4.0 3.0,1.0"), "poly2": polygon("1.0,1.0 1.0,4.0 3.0,4.0 3.0,1.0"), "rec": rectangle("0.0,0.0 4.0,4.0"), "circle" : circle("5.5,1.0 10.0"), "point": point("43.5083,-79.3007")}
+{"id": 4, "docid": 4, "val1": 5, "title": "Multimedia Information Systems  Issues and Approaches", "kwds": "enterprisecamp torcamp", "line1": line("4.0,7.0 2.0,17.0"), "line2": line("4.0,7.0 2.0,17.0"), "poly1": polygon("1.0,1.0 1.0,4.0 3.0,4.0 3.0,1.0 2.0,1.0 1.0,0.0"), "poly2": polygon("2.0,1.0 2.0,2.0 3.0,2.0 3.0,1.0"), "rec": rectangle("0.0,0.0 4.0,4.0"), "circle" : circle("77.0,4.0 30.0"), "point": point("43.5083,-79.3007")}
+{"id": 5, "docid": 5, "val1": 4, "title": "Active Database Systems", "kwds": "enterprisecamp torcamp", "line1": line("4.0,7.0 2.0,17.0"), "line2": line("4.0,7.0 2.0,17.0"), "poly1": polygon("100.0,100.0 100.0,400.0 300.0,400.0 300.0,100.0"), "poly2": polygon("5.0,1.0 5.0,4.0 7.0,4.0 7.0,1.0"), "rec": rectangle("0.0,0.0 4.0,4.0"), "circle" : circle("88.0,1.0 10.0"), "point": point("43.5083,-79.3007")}
+{"id": 6, "docid": 6, "val1": 17, "title": "Where Object-Oriented DBMSs Should Do Better  A Critique Based on Early Experiences", "kwds": "enterprisecamp torcamp", "line1": line("0.0,5.0 1.0,7.0"), "line2": line("4.0,7.0 2.0,-17.0"), "poly1": polygon("1.0,1.0 1.0,4.0 3.0,4.0 3.0,1.0"), "poly2": polygon("3.1,1.0 2.9,4.0 7.0,4.0 7.0,1.0"), "rec": rectangle("0.0,0.0 4.0,4.0"), "circle" : circle("1.0,1.0 10.0"), "point": point("43.5083,-79.3007")}
+{"id": 7, "docid": 7, "val1": 3, "title": "Distributed Databases", "kwds": "enterprisecamp torcamp", "line1": line("0.0,5.0 4.0,7.1"), "line2": line("4.0,7.0 2.0,-17.0"), "poly1": polygon("-5.0,-2.0 -4.0,-1.0 -3.0,-1.0 -2.0,-2.0 -4.0,-4.0 -5.0,-3.0"), "poly2": polygon("3.0,1.0 3.0,4.0 7.0,4.0 7.0,1.0"), "rec": rectangle("3.0,6.0 5.0,7.0"), "circle" : circle("13.0,75.0 1.0"), "point": point("43.5083,-79.3007")}
+{"id": 8, "docid": 8, "val1": 2, "title": "An Object-Oriented DBMS War Story  Developing a Genome Mapping Database in C++", "kwds": "enterprisecamp torcamp", "line1": line("4.0,7.0 2.0,17.0"), "line2": line("4.0,7.0 2.0,17.0"), "poly1": polygon("-5.0,-2.0 -4.0,-1.0 -3.0,-1.0 -2.0,-2.0 -4.0,-4.0 -5.0,-3.0"), "poly2": polygon("-3.0,-3.0 -1.0,-3.0 -3.0,-5.0"), "rec": rectangle("0.0,0.0 4.0,4.0"), "circle" : circle("76.0,87.0 50.0"), "point": point("43.5083,-79.3007")}
+{"id": 9, "docid": 9, "val1": 6, "title": "Cooperative Transactions for Multiuser Environments", "kwds": "sign ahead", "line1": line("5.0,1.0 5.0,4.0"), "line2": line("5.0,8.0 5.0,1.0"), "poly1": polygon("1.0,1.0 1.0,4.0 3.0,4.0 3.0,1.0"), "poly2": polygon("5.0,1.0 5.0,4.0 7.0,4.0 7.0,1.0"), "rec": rectangle("0.0,0.0 4.0,4.0"), "circle" : circle("11.0,14.0 15.0"), "point": point("5.0,1.0")}
+{"id": 10, "docid": 10, "val1": 8, "title": "Schema Architecture of the UniSQL/M Multidatabase System", "kwds": "sign ahead", "line1": line("1.0,2.0 3.0,4.0"), "line2": line("5.0,8.0 5.0,1.0"), "poly1": polygon("6.01,1.0 6.0,4.0 12.0,4.0 12.0,1.0"), "poly2": polygon("5.0,1.0 5.0,4.0 7.0,4.0 7.0,1.0"), "rec": rectangle("0.0,0.0 4.0,4.0"), "circle" : circle("1.0,76.0 17.0"), "point": point("2.0,3.0")}
+{"id": 11, "docid": 11, "val1": 19, "title": "Physical Object Management", "kwds": "sign ahead", "line1": line("1.0,2.0 3.0,4.0"), "line2": line("5.0,8.0 5.0,1.0"), "poly1": polygon("4.9,0.1 4.9,4.0 12.0,4.0 12.0,1.0"), "poly2": polygon("5.0,1.0 5.0,4.0 7.0,4.0 7.0,1.0"), "rec": rectangle("0.0,0.0 4.0,4.0"), "circle" : circle("22.0,35.0 144.0"), "point": point("4.9,0.0")}
+{"id": 12, "docid": 12, "val1": 13, "title": "Introduction to Part 1  Next-Generation Database Technology", "kwds": "sign ahead", "line1": line("1.0,2.0 3.0,4.0"), "line2": line("5.0,8.0 5.0,1.0"), "poly1": polygon("4.0,1.0 4.0,4.0 12.0,4.0 12.0,1.0"), "poly2": polygon("5.0,1.0 5.0,4.0 7.0,4.0 7.0,1.0"), "rec": rectangle("0.0,0.0 4.0,4.0"), "circle" : circle("1.0,23.0 12.0"), "point": point("6.0,3.0")}
+{"id": 13, "docid": 13, "val1": 11, "title": "Object-Oriented Database Systems  Promises, Reality, and Future", "kwds": "sign ahead", "line1": line("1.0,2.0 3.0,4.0"), "line2": line("5.0,8.0 5.0,1.0"), "poly1": polygon("6.0,1.0 6.0,4.0 12.0,4.0 12.0,1.0"), "poly2": polygon("5.0,1.0 5.0,4.0 7.0,4.0 7.0,1.0"), "rec": rectangle("0.0,0.0 4.0,4.0"), "circle" : circle("30.0,11.0 11.0"), "point": point("5.0,5.0")}
+{"id": 14, "docid": 14, "val1": 20, "title": "Introduction to Part 2  Technology for Interoperating Legacy Databases", "kwds": "sign ahead", "line1": line("1.0,2.0 3.0,4.0"), "line2": line("5.0,8.0 5.0,1.0"), "poly1": polygon("5.0,1.0 5.0,4.0 12.0,4.0 12.0,1.0"), "poly2": polygon("5.0,1.0 5.0,4.0 7.0,4.0 7.0,1.0"), "rec": rectangle("0.0,0.0 4.0,4.0"), "circle" : circle("1.0,66.0 17.0"), "point": point("5.1,5.1")}
+{"id": 15, "docid": 15, "val1": 12, "title": "On Resolving Schematic Heterogeneity in Multidatabase Systems", "kwds": "sign ahead", "line1": line("1.0,2.0 3.0,4.0"), "line2": line("5.0,8.0 5.0,1.0"), "poly1": polygon("5.1,1.0 5.1,4.0 12.0,4.0 12.0,1.0"), "poly2": polygon("5.0,1.0 5.0,4.0 7.0,4.0 7.0,1.0"), "rec": rectangle("0.0,0.0 4.0,4.0"), "circle" : circle("12.0,87.0 10.0"), "point": point("-2.0,3.0")}
+{"id": 16, "docid": 16, "val1": 9, "title": "Requirements for a Performance Benchmark for Object-Oriented Database Systems", "kwds": "sign ahead", "line1": line("1.0,2.0 3.0,4.0"), "line2": line("5.0,8.0 5.0,1.0"), "poly1": polygon("5.0,1.0 5.0,4.0 7.0,4.0 7.0,1.0"), "poly2": polygon("5.0,1.0 5.0,4.0 7.0,4.0 7.0,1.0"), "rec": rectangle("0.0,0.0 4.0,4.0"), "circle" : circle("1.0,35.0 10.0"), "point": point("-2.0,3.0")}
+{"id": 17, "docid": 17, "val1": 18, "title": "On View Support in Object-Oriented Databases Systems", "kwds": "sign ahead", "line1": line("4.0,7.0 9.0,7.0"), "line2": line("5.0,8.0 5.0,1.0"), "poly1": polygon("0.0,6.0 0.0,0.0 3.0,0.0 4.0,1.0 6.0,1.0 8.0,0.0 12.0,0.0 13.0,2.0 8.0,2.0 8.0,4.0 11.0,4.0 11.0,6.0 6.0,6.0 4.0,3.0 2.0,6.0"), "poly2": polygon("5.0,1.0 5.0,4.0 7.0,4.0 7.0,1.0"), "rec": rectangle("0.0,0.0 4.0,4.0"), "circle" : circle("1.0,51.0 10.0"), "point": point("4.1,7.0")}
+{"id": 18, "docid": 18, "val1": 15, "title": "The POSC Solution to Managing E&P Data", "kwds": "sign ahead", "line1": line("1.0,2.0 3.0,4.0"), "line2": line("5.0,8.0 5.0,1.0"), "poly1": polygon("5.0,1.0 7.0,1.0 7.0,4.0 6.0,2.0 5.0,4.0"), "poly2": polygon("6.0,3.0 7.0,5.0 6.0,7.0 5.0,5.0"), "rec": rectangle("0.0,0.0 4.0,4.0"), "circle" : circle("43.0,45.0 12.0"), "point": point("-2.0,3.0")}
+{"id": 19, "docid": 19, "val1": 14, "title": "C++ Bindings to an Object Database", "kwds": "sign ahead", "line1": line("1.0,2.0 3.0,4.0"), "line2": line("5.0,8.0 5.0,1.0"), "poly1": polygon("5.0,1.0 7.0,1.0 7.0,4.0 6.0,2.0 5.0,4.0"), "poly2": polygon("6.0,1.0 7.0,5.0 6.0,7.0 5.0,5.0"), "rec": rectangle("0.0,0.0 4.0,4.0"), "circle" : circle("65.0,2.0 13.0"), "point": point("-2.0,3.0")}
+{"id": 20, "docid": 20, "val1": 21, "title": "Authorization in Object-Oriented Databases", "kwds": "sign ahead", "line1": line("20.0,20.0 30.0,40.0"), "line2": line("5.0,8.0 0.0,1.0"), "poly1": polygon("4.0,1.0 4.0,4.0 12.0,4.0 12.0,1.0"), "poly2": polygon("50.0,10.0 50.0,40.0 70.0,40.0 70.0,10.0"), "rec": rectangle("0.0,0.0 4.0,4.0"), "circle" : circle("1.0,23.0 12.0"), "point": point("4.0,3.0")}
+{"id": 21, "docid": 21, "val1": 29, "title": "Physical Object Management", "kwds": "sign ahead", "line1": line("1.0,2.0 3.0,4.0"), "line2": line("5.0,8.0 5.0,1.0"), "poly1": polygon("4.9,0.1 4.9,4.0 12.0,4.0 12.0,1.0"), "poly2": polygon("5.0,1.0 5.0,4.0 7.0,4.0 7.0,1.0"), "rec": rectangle("0.0,0.0 4.0,4.0"), "circle" : circle("22.0,35.0 144.0"), "point": point("4.9,0.0")}
+{"id": 22, "docid": 22, "val1": 22, "title": "Introduction to Part 1  Next-Generation Database Technology", "kwds": "sign ahead", "line1": line("1.0,2.0 3.0,4.0"), "line2": line("5.0,8.0 5.0,1.0"), "poly1": polygon("4.0,1.0 4.0,4.0 12.0,4.0 12.0,1.0"), "poly2": polygon("5.0,1.0 5.0,4.0 7.0,4.0 7.0,1.0"), "rec": rectangle("0.0,0.0 4.0,4.0"), "circle" : circle("1.0,23.0 12.0"), "point": point("6.0,3.0")}
+{"id": 23, "docid": 23, "val1": 25, "title": "Object-Oriented Database Systems  Promises, Reality, and Future", "kwds": "sign ahead", "line1": line("1.0,2.0 3.0,4.0"), "line2": line("5.0,8.0 5.0,1.0"), "poly1": polygon("6.0,1.0 6.0,4.0 12.0,4.0 12.0,1.0"), "poly2": polygon("5.0,1.0 5.0,4.0 7.0,4.0 7.0,1.0"), "rec": rectangle("0.0,0.0 4.0,4.0"), "circle" : circle("30.0,11.0 11.0"), "point": point("5.0,5.0")}
+{"id": 24, "docid": 24, "val1": 24, "title": "Introduction to Part 2  Technology for Interoperating Legacy Databases", "kwds": "sign ahead", "line1": line("1.0,2.0 3.0,4.0"), "line2": line("5.0,8.0 5.0,1.0"), "poly1": polygon("5.0,1.0 5.0,4.0 12.0,4.0 12.0,1.0"), "poly2": polygon("5.0,1.0 5.0,4.0 7.0,4.0 7.0,1.0"), "rec": rectangle("0.0,0.0 4.0,4.0"), "circle" : circle("1.0,66.0 17.0"), "point": point("5.1,5.1")}
+{"id": 25, "docid": 25, "val1": 23, "title": "On Resolving Schematic Heterogeneity in Multidatabase Systems", "kwds": "sign ahead", "line1": line("1.0,2.0 3.0,4.0"), "line2": line("5.0,8.0 5.0,1.0"), "poly1": polygon("5.1,1.0 5.1,4.0 12.0,4.0 12.0,1.0"), "poly2": polygon("5.0,1.0 5.0,4.0 7.0,4.0 7.0,1.0"), "rec": rectangle("0.0,0.0 4.0,4.0"), "circle" : circle("12.0,87.0 10.0"), "point": point("-2.0,3.0")}
+{"id": 26, "docid": 26, "val1": 26, "title": "Requirements for a Performance Benchmark for Object-Oriented Database Systems", "kwds": "sign ahead", "line1": line("1.0,2.0 3.0,4.0"), "line2": line("5.0,8.0 5.0,1.0"), "poly1": polygon("5.0,1.0 5.0,4.0 7.0,4.0 7.0,1.0"), "poly2": polygon("5.0,1.0 5.0,4.0 7.0,4.0 7.0,1.0"), "rec": rectangle("0.0,0.0 4.0,4.0"), "circle" : circle("1.0,35.0 10.0"), "point": point("-2.0,3.0")}
+{"id": 27, "docid": 27, "val1": 27, "title": "On View Support in Object-Oriented Databases Systems", "kwds": "sign ahead", "line1": line("4.0,7.0 9.0,7.0"), "line2": line("5.0,8.0 5.0,1.0"), "poly1": polygon("0.0,6.0 0.0,0.0 3.0,0.0 4.0,1.0 6.0,1.0 8.0,0.0 12.0,0.0 13.0,2.0 8.0,2.0 8.0,4.0 11.0,4.0 11.0,6.0 6.0,6.0 4.0,3.0 2.0,6.0"), "poly2": polygon("5.0,1.0 5.0,4.0 7.0,4.0 7.0,1.0"), "rec": rectangle("0.0,0.0 4.0,4.0"), "circle" : circle("1.0,51.0 10.0"), "point": point("4.1,7.0")}
+{"id": 28, "docid": 28, "val1": 30, "title": "The POSC Solution to Managing E&P Data", "kwds": "sign ahead", "line1": line("1.0,2.0 3.0,4.0"), "line2": line("5.0,8.0 5.0,1.0"), "poly1": polygon("5.0,1.0 7.0,1.0 7.0,4.0 6.0,2.0 5.0,4.0"), "poly2": polygon("6.0,3.0 7.0,5.0 6.0,7.0 5.0,5.0"), "rec": rectangle("0.0,0.0 4.0,4.0"), "circle" : circle("43.0,45.0 12.0"), "point": point("-2.0,3.0")}
+{"id": 29, "docid": 29, "val1": 20, "title": "C++ Bindings to an Object Database", "kwds": "sign ahead", "line1": line("1.0,2.0 3.0,4.0"), "line2": line("5.0,8.0 5.0,1.0"), "poly1": polygon("5.0,1.0 7.0,1.0 7.0,4.0 6.0,2.0 5.0,4.0"), "poly2": polygon("6.0,1.0 7.0,5.0 6.0,7.0 5.0,5.0"), "rec": rectangle("0.0,0.0 4.0,4.0"), "circle" : circle("65.0,2.0 13.0"), "point": point("-2.0,3.0")}
+{"id": 30, "docid": 30, "val1": 28, "title": "Authorization in Object-Oriented Databases", "kwds": "sign ahead", "line1": line("20.0,20.0 30.0,40.0"), "line2": line("5.0,8.0 0.0,1.0"), "poly1": polygon("4.0,1.0 4.0,4.0 12.0,4.0 12.0,1.0"), "poly2": polygon("50.0,10.0 50.0,40.0 70.0,40.0 70.0,10.0"), "rec": rectangle("0.0,0.0 4.0,4.0"), "circle" : circle("1.0,23.0 12.0"), "point": point("4.0,3.0")}
+{"id": 31, "docid": 31, "val1": 37, "title": "Object SQL - A Language for the Design and Implementation of Object Databases", "kwds": "sign ahead", "line1": line("4.0,7.0 9.0,7.0"), "line2": line("5.0,8.0 5.0,1.0"), "poly1": polygon("1.0,1.0 1.0,4.0 3.0,4.0 3.0,1.0"), "poly2": polygon("5.0,1.0 5.0,4.0 7.0,4.0 7.0,1.0"), "rec": rectangle("0.0,0.0 4.2,7.0"), "circle" : circle("1.0,1.0 10.0"), "point": point("4.1,7.0")}
+{"id": 32, "docid": 32, "val1": 31, "title": "OQL[C++]  Extending C++ with an Object Query Capability", "kwds": "factory hosedan", "line1": line("-4.0,2.0 2.0,2.0"), "line2": line("4.0,7.0 2.0,17.0"), "poly1": polygon("1.0,1.0 1.0,4.0 3.0,4.0 3.0,1.0"), "poly2": polygon("5.0,1.0 5.0,4.0 7.0,4.0 7.0,1.0"), "rec": rectangle("0.0,0.0 4.0,4.0"), "circle" : circle("2.0,3.0 2.0"), "point": point("40.2152,-75.0449")}
+{"id": 33, "docid": 33, "val1": 40, "title": "Transaction Management in Multidatabase Systems", "kwds": "enterprisecamp torcamp", "line1": line("3.0,0.0 0.0,4.0"), "line2": line("4.0,7.0 2.0,17.0"), "poly1": polygon("1.0,1.0 1.0,4.0 3.0,4.0 3.0,1.0"), "poly2": polygon("1.0,1.0 1.0,4.0 3.0,4.0 3.0,1.0"), "rec": rectangle("0.0,0.0 4.0,4.0"), "circle" : circle("5.5,1.0 10.0"), "point": point("43.5083,-79.3007")}
+{"id": 34, "docid": 34, "val1": 35, "title": "Multimedia Information Systems  Issues and Approaches", "kwds": "enterprisecamp torcamp", "line1": line("4.0,7.0 2.0,17.0"), "line2": line("4.0,7.0 2.0,17.0"), "poly1": polygon("1.0,1.0 1.0,4.0 3.0,4.0 3.0,1.0 2.0,1.0 1.0,0.0"), "poly2": polygon("2.0,1.0 2.0,2.0 3.0,2.0 3.0,1.0"), "rec": rectangle("0.0,0.0 4.0,4.0"), "circle" : circle("77.0,4.0 30.0"), "point": point("43.5083,-79.3007")}
+{"id": 35, "docid": 35, "val1": 34, "title": "Active Database Systems", "kwds": "enterprisecamp torcamp", "line1": line("4.0,7.0 2.0,17.0"), "line2": line("4.0,7.0 2.0,17.0"), "poly1": polygon("100.0,100.0 100.0,400.0 300.0,400.0 300.0,100.0"), "poly2": polygon("5.0,1.0 5.0,4.0 7.0,4.0 7.0,1.0"), "rec": rectangle("0.0,0.0 4.0,4.0"), "circle" : circle("88.0,1.0 10.0"), "point": point("43.5083,-79.3007")}
+{"id": 36, "docid": 36, "val1": 47, "title": "Where Object-Oriented DBMSs Should Do Better  A Critique Based on Early Experiences", "kwds": "enterprisecamp torcamp", "line1": line("0.0,5.0 1.0,7.0"), "line2": line("4.0,7.0 2.0,-17.0"), "poly1": polygon("1.0,1.0 1.0,4.0 3.0,4.0 3.0,1.0"), "poly2": polygon("3.1,1.0 2.9,4.0 7.0,4.0 7.0,1.0"), "rec": rectangle("0.0,0.0 4.0,4.0"), "circle" : circle("1.0,1.0 10.0"), "point": point("43.5083,-79.3007")}
+{"id": 37, "docid": 37, "val1": 33, "title": "Distributed Databases", "kwds": "enterprisecamp torcamp", "line1": line("0.0,5.0 4.0,7.1"), "line2": line("4.0,7.0 2.0,-17.0"), "poly1": polygon("-5.0,-2.0 -4.0,-1.0 -3.0,-1.0 -2.0,-2.0 -4.0,-4.0 -5.0,-3.0"), "poly2": polygon("3.0,1.0 3.0,4.0 7.0,4.0 7.0,1.0"), "rec": rectangle("3.0,6.0 5.0,7.0"), "circle" : circle("13.0,75.0 1.0"), "point": point("43.5083,-79.3007")}
+{"id": 38, "docid": 38, "val1": 32, "title": "An Object-Oriented DBMS War Story  Developing a Genome Mapping Database in C++", "kwds": "enterprisecamp torcamp", "line1": line("4.0,7.0 2.0,17.0"), "line2": line("4.0,7.0 2.0,17.0"), "poly1": polygon("-5.0,-2.0 -4.0,-1.0 -3.0,-1.0 -2.0,-2.0 -4.0,-4.0 -5.0,-3.0"), "poly2": polygon("-3.0,-3.0 -1.0,-3.0 -3.0,-5.0"), "rec": rectangle("0.0,0.0 4.0,4.0"), "circle" : circle("76.0,87.0 50.0"), "point": point("43.5083,-79.3007")}
+{"id": 39, "docid": 39, "val1": 36, "title": "Cooperative Transactions for Multiuser Environments", "kwds": "sign ahead", "line1": line("5.0,1.0 5.0,4.0"), "line2": line("5.0,8.0 5.0,1.0"), "poly1": polygon("1.0,1.0 1.0,4.0 3.0,4.0 3.0,1.0"), "poly2": polygon("5.0,1.0 5.0,4.0 7.0,4.0 7.0,1.0"), "rec": rectangle("0.0,0.0 4.0,4.0"), "circle" : circle("11.0,14.0 15.0"), "point": point("5.0,1.0")}
+{"id": 40, "docid": 40, "val1": 38, "title": "Schema Architecture of the UniSQL/M Multidatabase System", "kwds": "sign ahead", "line1": line("1.0,2.0 3.0,4.0"), "line2": line("5.0,8.0 5.0,1.0"), "poly1": polygon("6.01,1.0 6.0,4.0 12.0,4.0 12.0,1.0"), "poly2": polygon("5.0,1.0 5.0,4.0 7.0,4.0 7.0,1.0"), "rec": rectangle("0.0,0.0 4.0,4.0"), "circle" : circle("1.0,76.0 17.0"), "point": point("2.0,3.0")}
+{"id": 41, "docid": 41, "val1": 49, "title": "Physical Object Management", "kwds": "sign ahead", "line1": line("1.0,2.0 3.0,4.0"), "line2": line("5.0,8.0 5.0,1.0"), "poly1": polygon("4.9,0.1 4.9,4.0 12.0,4.0 12.0,1.0"), "poly2": polygon("5.0,1.0 5.0,4.0 7.0,4.0 7.0,1.0"), "rec": rectangle("0.0,0.0 4.0,4.0"), "circle" : circle("22.0,35.0 144.0"), "point": point("4.9,0.0")}
+{"id": 42, "docid": 42, "val1": 43, "title": "Introduction to Part 1  Next-Generation Database Technology", "kwds": "sign ahead", "line1": line("1.0,2.0 3.0,4.0"), "line2": line("5.0,8.0 5.0,1.0"), "poly1": polygon("4.0,1.0 4.0,4.0 12.0,4.0 12.0,1.0"), "poly2": polygon("5.0,1.0 5.0,4.0 7.0,4.0 7.0,1.0"), "rec": rectangle("0.0,0.0 4.0,4.0"), "circle" : circle("1.0,23.0 12.0"), "point": point("6.0,3.0")}
+{"id": 43, "docid": 43, "val1": 41, "title": "Object-Oriented Database Systems  Promises, Reality, and Future", "kwds": "sign ahead", "line1": line("1.0,2.0 3.0,4.0"), "line2": line("5.0,8.0 5.0,1.0"), "poly1": polygon("6.0,1.0 6.0,4.0 12.0,4.0 12.0,1.0"), "poly2": polygon("5.0,1.0 5.0,4.0 7.0,4.0 7.0,1.0"), "rec": rectangle("0.0,0.0 4.0,4.0"), "circle" : circle("30.0,11.0 11.0"), "point": point("5.0,5.0")}
+{"id": 44, "docid": 44, "val1": 50, "title": "Introduction to Part 2  Technology for Interoperating Legacy Databases", "kwds": "sign ahead", "line1": line("1.0,2.0 3.0,4.0"), "line2": line("5.0,8.0 5.0,1.0"), "poly1": polygon("5.0,1.0 5.0,4.0 12.0,4.0 12.0,1.0"), "poly2": polygon("5.0,1.0 5.0,4.0 7.0,4.0 7.0,1.0"), "rec": rectangle("0.0,0.0 4.0,4.0"), "circle" : circle("1.0,66.0 17.0"), "point": point("5.1,5.1")}
+{"id": 45, "docid": 45, "val1": 42, "title": "On Resolving Schematic Heterogeneity in Multidatabase Systems", "kwds": "sign ahead", "line1": line("1.0,2.0 3.0,4.0"), "line2": line("5.0,8.0 5.0,1.0"), "poly1": polygon("5.1,1.0 5.1,4.0 12.0,4.0 12.0,1.0"), "poly2": polygon("5.0,1.0 5.0,4.0 7.0,4.0 7.0,1.0"), "rec": rectangle("0.0,0.0 4.0,4.0"), "circle" : circle("12.0,87.0 10.0"), "point": point("-2.0,3.0")}
+{"id": 46, "docid": 46, "val1": 39, "title": "Requirements for a Performance Benchmark for Object-Oriented Database Systems", "kwds": "sign ahead", "line1": line("1.0,2.0 3.0,4.0"), "line2": line("5.0,8.0 5.0,1.0"), "poly1": polygon("5.0,1.0 5.0,4.0 7.0,4.0 7.0,1.0"), "poly2": polygon("5.0,1.0 5.0,4.0 7.0,4.0 7.0,1.0"), "rec": rectangle("0.0,0.0 4.0,4.0"), "circle" : circle("1.0,35.0 10.0"), "point": point("-2.0,3.0")}
+{"id": 47, "docid": 47, "val1": 48, "title": "On View Support in Object-Oriented Databases Systems", "kwds": "sign ahead", "line1": line("4.0,7.0 9.0,7.0"), "line2": line("5.0,8.0 5.0,1.0"), "poly1": polygon("0.0,6.0 0.0,0.0 3.0,0.0 4.0,1.0 6.0,1.0 8.0,0.0 12.0,0.0 13.0,2.0 8.0,2.0 8.0,4.0 11.0,4.0 11.0,6.0 6.0,6.0 4.0,3.0 2.0,6.0"), "poly2": polygon("5.0,1.0 5.0,4.0 7.0,4.0 7.0,1.0"), "rec": rectangle("0.0,0.0 4.0,4.0"), "circle" : circle("1.0,51.0 10.0"), "point": point("4.1,7.0")}
+{"id": 48, "docid": 48, "val1": 45, "title": "The POSC Solution to Managing E&P Data", "kwds": "sign ahead", "line1": line("1.0,2.0 3.0,4.0"), "line2": line("5.0,8.0 5.0,1.0"), "poly1": polygon("5.0,1.0 7.0,1.0 7.0,4.0 6.0,2.0 5.0,4.0"), "poly2": polygon("6.0,3.0 7.0,5.0 6.0,7.0 5.0,5.0"), "rec": rectangle("0.0,0.0 4.0,4.0"), "circle" : circle("43.0,45.0 12.0"), "point": point("-2.0,3.0")}
+{"id": 49, "docid": 49, "val1": 44, "title": "C++ Bindings to an Object Database", "kwds": "sign ahead", "line1": line("1.0,2.0 3.0,4.0"), "line2": line("5.0,8.0 5.0,1.0"), "poly1": polygon("5.0,1.0 7.0,1.0 7.0,4.0 6.0,2.0 5.0,4.0"), "poly2": polygon("6.0,1.0 7.0,5.0 6.0,7.0 5.0,5.0"), "rec": rectangle("0.0,0.0 4.0,4.0"), "circle" : circle("65.0,2.0 13.0"), "point": point("-2.0,3.0")}
+{"id": 50, "docid": 50, "val1": 51, "title": "Authorization in Object-Oriented Databases", "kwds": "sign ahead", "line1": line("20.0,20.0 30.0,40.0"), "line2": line("5.0,8.0 0.0,1.0"), "poly1": polygon("4.0,1.0 4.0,4.0 12.0,4.0 12.0,1.0"), "poly2": polygon("50.0,10.0 50.0,40.0 70.0,40.0 70.0,10.0"), "rec": rectangle("0.0,0.0 4.0,4.0"), "circle" : circle("1.0,23.0 12.0"), "point": point("4.0,3.0")}
+{"id": 51, "docid": 51, "val1": 59, "title": "Physical Object Management", "kwds": "sign ahead", "line1": line("1.0,2.0 3.0,4.0"), "line2": line("5.0,8.0 5.0,1.0"), "poly1": polygon("4.9,0.1 4.9,4.0 12.0,4.0 12.0,1.0"), "poly2": polygon("5.0,1.0 5.0,4.0 7.0,4.0 7.0,1.0"), "rec": rectangle("0.0,0.0 4.0,4.0"), "circle" : circle("22.0,35.0 144.0"), "point": point("4.9,0.0")}
+{"id": 52, "docid": 52, "val1": 52, "title": "Introduction to Part 1  Next-Generation Database Technology", "kwds": "sign ahead", "line1": line("1.0,2.0 3.0,4.0"), "line2": line("5.0,8.0 5.0,1.0"), "poly1": polygon("4.0,1.0 4.0,4.0 12.0,4.0 12.0,1.0"), "poly2": polygon("5.0,1.0 5.0,4.0 7.0,4.0 7.0,1.0"), "rec": rectangle("0.0,0.0 4.0,4.0"), "circle" : circle("1.0,23.0 12.0"), "point": point("6.0,3.0")}
+{"id": 53, "docid": 53, "val1": 55, "title": "Object-Oriented Database Systems  Promises, Reality, and Future", "kwds": "sign ahead", "line1": line("1.0,2.0 3.0,4.0"), "line2": line("5.0,8.0 5.0,1.0"), "poly1": polygon("6.0,1.0 6.0,4.0 12.0,4.0 12.0,1.0"), "poly2": polygon("5.0,1.0 5.0,4.0 7.0,4.0 7.0,1.0"), "rec": rectangle("0.0,0.0 4.0,4.0"), "circle" : circle("30.0,11.0 11.0"), "point": point("5.0,5.0")}
+{"id": 54, "docid": 54, "val1": 54, "title": "Introduction to Part 2  Technology for Interoperating Legacy Databases", "kwds": "sign ahead", "line1": line("1.0,2.0 3.0,4.0"), "line2": line("5.0,8.0 5.0,1.0"), "poly1": polygon("5.0,1.0 5.0,4.0 12.0,4.0 12.0,1.0"), "poly2": polygon("5.0,1.0 5.0,4.0 7.0,4.0 7.0,1.0"), "rec": rectangle("0.0,0.0 4.0,4.0"), "circle" : circle("1.0,66.0 17.0"), "point": point("5.1,5.1")}
+{"id": 55, "docid": 55, "val1": 53, "title": "On Resolving Schematic Heterogeneity in Multidatabase Systems", "kwds": "sign ahead", "line1": line("1.0,2.0 3.0,4.0"), "line2": line("5.0,8.0 5.0,1.0"), "poly1": polygon("5.1,1.0 5.1,4.0 12.0,4.0 12.0,1.0"), "poly2": polygon("5.0,1.0 5.0,4.0 7.0,4.0 7.0,1.0"), "rec": rectangle("0.0,0.0 4.0,4.0"), "circle" : circle("12.0,87.0 10.0"), "point": point("-2.0,3.0")}
+{"id": 56, "docid": 56, "val1": 56, "title": "Requirements for a Performance Benchmark for Object-Oriented Database Systems", "kwds": "sign ahead", "line1": line("1.0,2.0 3.0,4.0"), "line2": line("5.0,8.0 5.0,1.0"), "poly1": polygon("5.0,1.0 5.0,4.0 7.0,4.0 7.0,1.0"), "poly2": polygon("5.0,1.0 5.0,4.0 7.0,4.0 7.0,1.0"), "rec": rectangle("0.0,0.0 4.0,4.0"), "circle" : circle("1.0,35.0 10.0"), "point": point("-2.0,3.0")}
+{"id": 57, "docid": 57, "val1": 57, "title": "On View Support in Object-Oriented Databases Systems", "kwds": "sign ahead", "line1": line("4.0,7.0 9.0,7.0"), "line2": line("5.0,8.0 5.0,1.0"), "poly1": polygon("0.0,6.0 0.0,0.0 3.0,0.0 4.0,1.0 6.0,1.0 8.0,0.0 12.0,0.0 13.0,2.0 8.0,2.0 8.0,4.0 11.0,4.0 11.0,6.0 6.0,6.0 4.0,3.0 2.0,6.0"), "poly2": polygon("5.0,1.0 5.0,4.0 7.0,4.0 7.0,1.0"), "rec": rectangle("0.0,0.0 4.0,4.0"), "circle" : circle("1.0,51.0 10.0"), "point": point("4.1,7.0")}
+{"id": 58, "docid": 58, "val1": 60, "title": "The POSC Solution to Managing E&P Data", "kwds": "sign ahead", "line1": line("1.0,2.0 3.0,4.0"), "line2": line("5.0,8.0 5.0,1.0"), "poly1": polygon("5.0,1.0 7.0,1.0 7.0,4.0 6.0,2.0 5.0,4.0"), "poly2": polygon("6.0,3.0 7.0,5.0 6.0,7.0 5.0,5.0"), "rec": rectangle("0.0,0.0 4.0,4.0"), "circle" : circle("43.0,45.0 12.0"), "point": point("-2.0,3.0")}
+{"id": 59, "docid": 59, "val1": 50, "title": "C++ Bindings to an Object Database", "kwds": "sign ahead", "line1": line("1.0,2.0 3.0,4.0"), "line2": line("5.0,8.0 5.0,1.0"), "poly1": polygon("5.0,1.0 7.0,1.0 7.0,4.0 6.0,2.0 5.0,4.0"), "poly2": polygon("6.0,1.0 7.0,5.0 6.0,7.0 5.0,5.0"), "rec": rectangle("0.0,0.0 4.0,4.0"), "circle" : circle("65.0,2.0 13.0"), "point": point("-2.0,3.0")}
+{"id": 60, "docid": 60, "val1": 58, "title": "Authorization in Object-Oriented Databases", "kwds": "sign ahead", "line1": line("20.0,20.0 30.0,40.0"), "line2": line("5.0,8.0 0.0,1.0"), "poly1": polygon("4.0,1.0 4.0,4.0 12.0,4.0 12.0,1.0"), "poly2": polygon("50.0,10.0 50.0,40.0 70.0,40.0 70.0,10.0"), "rec": rectangle("0.0,0.0 4.0,4.0"), "circle" : circle("1.0,23.0 12.0"), "point": point("4.0,3.0")}
diff --git a/asterix-app/src/test/resources/optimizerts/queries/orderby_limit_01.aql b/asterix-app/src/test/resources/optimizerts/queries/orderby_limit_01.aql
new file mode 100644
index 0000000..bf9aea3
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/queries/orderby_limit_01.aql
@@ -0,0 +1,62 @@
+/*
+ * 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.
+ */
+/*
+ *  Description     : This test is intended to verify that the primary BTree index is used
+ *                  : in the optimized query plan and LIMIT push-down is applied on an external sort with a non primary key field.
+ *  Expected Result : Success
+ */
+
+// Please note this is a Positive test and the BTree index should be used in the plan.
+
+drop dataverse test if exists;
+create dataverse test;
+use dataverse test;
+
+write output to asterix_nc1:"rttest/orderby_limit_01.adm";
+
+create type MyRecord as closed {
+  id: int64,
+  docid: int64,
+  val1: int64,
+  title: string,
+  point: point,
+  kwds: string,
+  line1: line,
+  line2: line,
+  poly1: polygon,
+  poly2: polygon,
+  rec: rectangle,
+  circle: circle
+}
+
+create dataset MyData(MyRecord)
+  primary key id;
+
+create index btree_index_docid on MyData(docid) type btree;
+create index btree_index_val1 on MyData(val1) type btree;
+create index rtree_index_point on MyData(point) type rtree;
+create index rtree_index_rec on MyData(rec) type rtree;
+create index ngram_index_title on MyData(title) type ngram(3);
+create index keyword_index_title on MyData(title) type keyword;
+
+for $o in dataset('MyData')
+where $o.id < 50
+order by $o.docid
+limit 2
+return {"pk":$o.id, "sk":$o.docid}
diff --git a/asterix-app/src/test/resources/optimizerts/queries/orderby_limit_offset_01.aql b/asterix-app/src/test/resources/optimizerts/queries/orderby_limit_offset_01.aql
new file mode 100644
index 0000000..9059c35
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/queries/orderby_limit_offset_01.aql
@@ -0,0 +1,62 @@
+/*
+ * 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.
+ */
+/*
+ *  Description     : This test is intended to verify that the primary BTree index is used
+ *                  : in the optimized query plan and LIMIT with an offset push-down is applied on an external sort with a non primary key field..
+ *  Expected Result : Success
+ */
+
+// Please note this is a Positive test and the BTree index should be used in the plan.
+
+drop dataverse test if exists;
+create dataverse test;
+use dataverse test;
+
+write output to asterix_nc1:"rttest/orderby_limit_offset_01.adm";
+
+create type MyRecord as closed {
+  id: int64,
+  docid: int64,
+  val1: int64,
+  title: string,
+  point: point,
+  kwds: string,
+  line1: line,
+  line2: line,
+  poly1: polygon,
+  poly2: polygon,
+  rec: rectangle,
+  circle: circle
+}
+
+create dataset MyData(MyRecord)
+  primary key id;
+
+create index btree_index_docid on MyData(docid) type btree;
+create index btree_index_val1 on MyData(val1) type btree;
+create index rtree_index_point on MyData(point) type rtree;
+create index rtree_index_rec on MyData(rec) type rtree;
+create index ngram_index_title on MyData(title) type ngram(3);
+create index keyword_index_title on MyData(title) type keyword;
+
+for $o in dataset('MyData')
+where $o.id < 50
+order by $o.docid
+limit 2 offset 2
+return {"pk":$o.id, "sk":$o.docid}
diff --git a/asterix-app/src/test/resources/optimizerts/queries/orderby_limit_primary_index_01.aql b/asterix-app/src/test/resources/optimizerts/queries/orderby_limit_primary_index_01.aql
new file mode 100644
index 0000000..429cf09
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/queries/orderby_limit_primary_index_01.aql
@@ -0,0 +1,62 @@
+/*
+ * 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.
+ */
+/*
+ *  Description     : This test is intended to verify that the primary BTree index is used
+ *                  : in the optimized query plan and LIMIT push-down is applied on an external sort.
+ *  Expected Result : Success
+ */
+
+// Please note this is a Positive test and the BTree index should be used in the plan.
+
+drop dataverse test if exists;
+create dataverse test;
+use dataverse test;
+
+write output to asterix_nc1:"rttest/orderby_limit_primary_index_01.adm";
+
+create type MyRecord as closed {
+  id: int64,
+  docid: int64,
+  val1: int64,
+  title: string,
+  point: point,
+  kwds: string,
+  line1: line,
+  line2: line,
+  poly1: polygon,
+  poly2: polygon,
+  rec: rectangle,
+  circle: circle
+}
+
+create dataset MyData(MyRecord)
+  primary key id;
+
+create index btree_index_docid on MyData(docid) type btree;
+create index btree_index_val1 on MyData(val1) type btree;
+create index rtree_index_point on MyData(point) type rtree;
+create index rtree_index_rec on MyData(rec) type rtree;
+create index ngram_index_title on MyData(title) type ngram(3);
+create index keyword_index_title on MyData(title) type keyword;
+
+for $o in dataset('MyData')
+where $o.id < 50
+order by $o.id
+limit 2
+return {"pk":$o.id, "sk":$o.docid}
diff --git a/asterix-app/src/test/resources/optimizerts/results/btree-index/btree-primary-limit-orderby-01.plan b/asterix-app/src/test/resources/optimizerts/results/btree-index/btree-primary-limit-orderby-01.plan
new file mode 100644
index 0000000..e5eca71
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/results/btree-index/btree-primary-limit-orderby-01.plan
@@ -0,0 +1,17 @@
+-- DISTRIBUTE_RESULT  |UNPARTITIONED|
+  -- ONE_TO_ONE_EXCHANGE  |UNPARTITIONED|
+    -- STREAM_PROJECT  |UNPARTITIONED|
+      -- ASSIGN  |UNPARTITIONED|
+        -- STREAM_LIMIT  |UNPARTITIONED|
+          -- SORT_MERGE_EXCHANGE [$$10(ASC) ]  |PARTITIONED|
+            -- STREAM_LIMIT  |PARTITIONED|
+              -- ONE_TO_ONE_EXCHANGE  |PARTITIONED|
+                -- STABLE_SORT [$$10(ASC)]  |PARTITIONED|
+                  -- ONE_TO_ONE_EXCHANGE  |PARTITIONED|
+                    -- STREAM_PROJECT  |PARTITIONED|
+                      -- ASSIGN  |PARTITIONED|
+                        -- ONE_TO_ONE_EXCHANGE  |PARTITIONED|
+                          -- BTREE_SEARCH  |PARTITIONED|
+                            -- ONE_TO_ONE_EXCHANGE  |PARTITIONED|
+                              -- ASSIGN  |PARTITIONED|
+                                -- EMPTY_TUPLE_SOURCE  |PARTITIONED|
diff --git a/asterix-app/src/test/resources/optimizerts/results/btree-index/btree-primary-limit-orderby-02.plan b/asterix-app/src/test/resources/optimizerts/results/btree-index/btree-primary-limit-orderby-02.plan
new file mode 100644
index 0000000..e7039b2
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/results/btree-index/btree-primary-limit-orderby-02.plan
@@ -0,0 +1,12 @@
+-- DISTRIBUTE_RESULT  |UNPARTITIONED|
+  -- ONE_TO_ONE_EXCHANGE  |UNPARTITIONED|
+    -- STREAM_PROJECT  |UNPARTITIONED|
+      -- ASSIGN  |UNPARTITIONED|
+        -- STREAM_LIMIT  |UNPARTITIONED|
+          -- SORT_MERGE_EXCHANGE [$$9(ASC) ]  |PARTITIONED|
+            -- STREAM_LIMIT  |PARTITIONED|
+              -- ONE_TO_ONE_EXCHANGE  |PARTITIONED|
+                -- BTREE_SEARCH  |PARTITIONED|
+                  -- ONE_TO_ONE_EXCHANGE  |PARTITIONED|
+                    -- ASSIGN  |PARTITIONED|
+                      -- EMPTY_TUPLE_SOURCE  |PARTITIONED|
diff --git a/asterix-app/src/test/resources/optimizerts/results/inlined_q18_large_volume_customer.plan b/asterix-app/src/test/resources/optimizerts/results/inlined_q18_large_volume_customer.plan
index 8b205d6..92f9a29 100644
--- a/asterix-app/src/test/resources/optimizerts/results/inlined_q18_large_volume_customer.plan
+++ b/asterix-app/src/test/resources/optimizerts/results/inlined_q18_large_volume_customer.plan
@@ -6,7 +6,7 @@
           -- SORT_MERGE_EXCHANGE [$$12(DESC), $$11(ASC) ]  |PARTITIONED|
             -- STREAM_LIMIT  |PARTITIONED|
               -- ONE_TO_ONE_EXCHANGE  |PARTITIONED|
-                -- STABLE_SORT [$$12(DESC), $$11(ASC)]  |PARTITIONED|
+                -- STABLE_SORT [topK: 100] [$$12(DESC), $$11(ASC)]  |PARTITIONED|
                   -- ONE_TO_ONE_EXCHANGE  |PARTITIONED|
                     -- PRE_CLUSTERED_GROUP_BY[$$72, $$73]  |PARTITIONED|
                             {
diff --git a/asterix-app/src/test/resources/optimizerts/results/orderby_limit_01.plan b/asterix-app/src/test/resources/optimizerts/results/orderby_limit_01.plan
new file mode 100644
index 0000000..6f139d6
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/results/orderby_limit_01.plan
@@ -0,0 +1,17 @@
+-- DISTRIBUTE_RESULT  |UNPARTITIONED|
+  -- ONE_TO_ONE_EXCHANGE  |UNPARTITIONED|
+    -- STREAM_PROJECT  |UNPARTITIONED|
+      -- ASSIGN  |UNPARTITIONED|
+        -- STREAM_LIMIT  |UNPARTITIONED|
+          -- SORT_MERGE_EXCHANGE [$$10(ASC) ]  |PARTITIONED|
+            -- STREAM_LIMIT  |PARTITIONED|
+              -- ONE_TO_ONE_EXCHANGE  |PARTITIONED|
+                -- STABLE_SORT [topK: 2] [$$10(ASC)]  |PARTITIONED|
+                  -- ONE_TO_ONE_EXCHANGE  |PARTITIONED|
+                    -- STREAM_PROJECT  |PARTITIONED|
+                      -- ASSIGN  |PARTITIONED|
+                        -- ONE_TO_ONE_EXCHANGE  |PARTITIONED|
+                          -- BTREE_SEARCH  |PARTITIONED|
+                            -- ONE_TO_ONE_EXCHANGE  |PARTITIONED|
+                              -- ASSIGN  |PARTITIONED|
+                                -- EMPTY_TUPLE_SOURCE  |PARTITIONED|
diff --git a/asterix-app/src/test/resources/optimizerts/results/orderby_limit_offset_01.plan b/asterix-app/src/test/resources/optimizerts/results/orderby_limit_offset_01.plan
new file mode 100644
index 0000000..ee46a5c
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/results/orderby_limit_offset_01.plan
@@ -0,0 +1,17 @@
+-- DISTRIBUTE_RESULT  |UNPARTITIONED|
+  -- ONE_TO_ONE_EXCHANGE  |UNPARTITIONED|
+    -- STREAM_PROJECT  |UNPARTITIONED|
+      -- ASSIGN  |UNPARTITIONED|
+        -- STREAM_LIMIT  |UNPARTITIONED|
+          -- SORT_MERGE_EXCHANGE [$$10(ASC) ]  |PARTITIONED|
+            -- STREAM_LIMIT  |PARTITIONED|
+              -- ONE_TO_ONE_EXCHANGE  |PARTITIONED|
+                -- STABLE_SORT [topK: 4] [$$10(ASC)]  |PARTITIONED|
+                  -- ONE_TO_ONE_EXCHANGE  |PARTITIONED|
+                    -- STREAM_PROJECT  |PARTITIONED|
+                      -- ASSIGN  |PARTITIONED|
+                        -- ONE_TO_ONE_EXCHANGE  |PARTITIONED|
+                          -- BTREE_SEARCH  |PARTITIONED|
+                            -- ONE_TO_ONE_EXCHANGE  |PARTITIONED|
+                              -- ASSIGN  |PARTITIONED|
+                                -- EMPTY_TUPLE_SOURCE  |PARTITIONED|
diff --git a/asterix-app/src/test/resources/optimizerts/results/orderby_limit_primary_index_01.plan b/asterix-app/src/test/resources/optimizerts/results/orderby_limit_primary_index_01.plan
new file mode 100644
index 0000000..e7039b2
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/results/orderby_limit_primary_index_01.plan
@@ -0,0 +1,12 @@
+-- DISTRIBUTE_RESULT  |UNPARTITIONED|
+  -- ONE_TO_ONE_EXCHANGE  |UNPARTITIONED|
+    -- STREAM_PROJECT  |UNPARTITIONED|
+      -- ASSIGN  |UNPARTITIONED|
+        -- STREAM_LIMIT  |UNPARTITIONED|
+          -- SORT_MERGE_EXCHANGE [$$9(ASC) ]  |PARTITIONED|
+            -- STREAM_LIMIT  |PARTITIONED|
+              -- ONE_TO_ONE_EXCHANGE  |PARTITIONED|
+                -- BTREE_SEARCH  |PARTITIONED|
+                  -- ONE_TO_ONE_EXCHANGE  |PARTITIONED|
+                    -- ASSIGN  |PARTITIONED|
+                      -- EMPTY_TUPLE_SOURCE  |PARTITIONED|
diff --git a/asterix-app/src/test/resources/optimizerts/results/q03_shipping_priority.plan b/asterix-app/src/test/resources/optimizerts/results/q03_shipping_priority.plan
index 0618b41..c4c0c05 100644
--- a/asterix-app/src/test/resources/optimizerts/results/q03_shipping_priority.plan
+++ b/asterix-app/src/test/resources/optimizerts/results/q03_shipping_priority.plan
@@ -6,7 +6,7 @@
           -- SORT_MERGE_EXCHANGE [$$49(DESC), $$4(ASC) ]  |PARTITIONED|
             -- STREAM_LIMIT  |PARTITIONED|
               -- ONE_TO_ONE_EXCHANGE  |PARTITIONED|
-                -- STABLE_SORT [$$49(DESC), $$4(ASC)]  |PARTITIONED|
+                -- STABLE_SORT [topK: 10] [$$49(DESC), $$4(ASC)]  |PARTITIONED|
                   -- ONE_TO_ONE_EXCHANGE  |PARTITIONED|
                     -- EXTERNAL_GROUP_BY[$$55, $$56, $$57]  |PARTITIONED|
                             {
diff --git a/asterix-app/src/test/resources/optimizerts/results/q2.plan b/asterix-app/src/test/resources/optimizerts/results/q2.plan
index 14382c1..87aa995 100644
--- a/asterix-app/src/test/resources/optimizerts/results/q2.plan
+++ b/asterix-app/src/test/resources/optimizerts/results/q2.plan
@@ -6,7 +6,7 @@
           -- SORT_MERGE_EXCHANGE [$$26(DESC) ]  |PARTITIONED|
             -- STREAM_LIMIT  |PARTITIONED|
               -- ONE_TO_ONE_EXCHANGE  |PARTITIONED|
-                -- STABLE_SORT [$$26(DESC)]  |PARTITIONED|
+                -- STABLE_SORT [topK: 5] [$$26(DESC)]  |PARTITIONED|
                   -- ONE_TO_ONE_EXCHANGE  |PARTITIONED|
                     -- PRE_CLUSTERED_GROUP_BY[$$32]  |PARTITIONED|
                             {
diff --git a/asterix-app/src/test/resources/optimizerts/results/sort-cust.plan b/asterix-app/src/test/resources/optimizerts/results/sort-cust.plan
index 66e6049..6faec89 100644
--- a/asterix-app/src/test/resources/optimizerts/results/sort-cust.plan
+++ b/asterix-app/src/test/resources/optimizerts/results/sort-cust.plan
@@ -6,7 +6,7 @@
           -- SORT_MERGE_EXCHANGE [$$7(ASC) ]  |PARTITIONED|
             -- STREAM_LIMIT  |PARTITIONED|
               -- ONE_TO_ONE_EXCHANGE  |PARTITIONED|
-                -- STABLE_SORT [$$7(ASC)]  |PARTITIONED|
+                -- STABLE_SORT [topK: 10] [$$7(ASC)]  |PARTITIONED|
                   -- ONE_TO_ONE_EXCHANGE  |PARTITIONED|
                     -- ASSIGN  |PARTITIONED|
                       -- STREAM_PROJECT  |PARTITIONED|
diff --git a/asterix-app/src/test/resources/runtimets/queries/index-selection/btree-index-limit-orderby-01/btree-index-limit-orderby-01.1.ddl.aql b/asterix-app/src/test/resources/runtimets/queries/index-selection/btree-index-limit-orderby-01/btree-index-limit-orderby-01.1.ddl.aql
new file mode 100644
index 0000000..09a4c40
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries/index-selection/btree-index-limit-orderby-01/btree-index-limit-orderby-01.1.ddl.aql
@@ -0,0 +1,53 @@
+/*
+ * 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.
+ */
+
+/*
+ *  Description     : Limit Push-down into an external sort after an index-search - order by a non primary key field.
+ *  Expected Result : Success
+ *
+*/
+
+drop dataverse test if exists;
+create dataverse test;
+use dataverse test;
+
+create type MyRecord as closed {
+  id: int64,
+  docid: int64,
+  val1: int64,
+  title: string,
+  point: point,
+  kwds: string,
+  line1: line,
+  line2: line,
+  poly1: polygon,
+  poly2: polygon,
+  rec: rectangle,
+  circle: circle
+}
+
+create dataset MyData(MyRecord)
+  primary key id;
+
+create index btree_index_docid on MyData(docid) type btree;
+create index btree_index_val1 on MyData(val1) type btree;
+create index rtree_index_point on MyData(point) type rtree;
+create index rtree_index_rec on MyData(rec) type rtree;
+create index ngram_index_title on MyData(title) type ngram(3);
+create index keyword_index_title on MyData(title) type keyword;
diff --git a/asterix-app/src/test/resources/runtimets/queries/index-selection/btree-index-limit-orderby-01/btree-index-limit-orderby-01.2.update.aql b/asterix-app/src/test/resources/runtimets/queries/index-selection/btree-index-limit-orderby-01/btree-index-limit-orderby-01.2.update.aql
new file mode 100644
index 0000000..e1ab937
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries/index-selection/btree-index-limit-orderby-01/btree-index-limit-orderby-01.2.update.aql
@@ -0,0 +1,31 @@
+/*
+ * 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.
+ */
+
+/*
+ *  Description     : Limit Push-down into an external sort after an index-search - order by a non primary key field.
+ *  Expected Result : Success
+ *
+*/
+
+ use dataverse test;
+
+load dataset MyData
+using "org.apache.asterix.external.dataset.adapter.NCFileSystemAdapter"
+(("path"="asterix_nc1://data/spatial/spatialData2.json"),("format"="adm"));
+
diff --git a/asterix-app/src/test/resources/runtimets/queries/index-selection/btree-index-limit-orderby-01/btree-index-limit-orderby-01.3.query.aql b/asterix-app/src/test/resources/runtimets/queries/index-selection/btree-index-limit-orderby-01/btree-index-limit-orderby-01.3.query.aql
new file mode 100644
index 0000000..5df7363
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries/index-selection/btree-index-limit-orderby-01/btree-index-limit-orderby-01.3.query.aql
@@ -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.
+ */
+
+/*
+ *  Description     : Limit Push-down into an external sort after an index-search - order by a non primary key field.
+ *  Expected Result : Success
+ *
+*/
+
+use dataverse test;
+
+for $o in dataset('MyData')
+where $o.id < 50
+order by $o.docid
+limit 2
+return {"pk":$o.id, "sk":$o.docid}
diff --git a/asterix-app/src/test/resources/runtimets/queries/index-selection/btree-index-limit-orderby-02/btree-index-limit-orderby-02.1.ddl.aql b/asterix-app/src/test/resources/runtimets/queries/index-selection/btree-index-limit-orderby-02/btree-index-limit-orderby-02.1.ddl.aql
new file mode 100644
index 0000000..e821faf
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries/index-selection/btree-index-limit-orderby-02/btree-index-limit-orderby-02.1.ddl.aql
@@ -0,0 +1,53 @@
+/*
+ * 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.
+ */
+
+/*
+ *  Description     : Limit Push-down into an external sort after an index-search - order by the primary key field.
+ *  Expected Result : Success
+ *
+*/
+
+drop dataverse test if exists;
+create dataverse test;
+use dataverse test;
+
+create type MyRecord as closed {
+  id: int64,
+  docid: int64,
+  val1: int64,
+  title: string,
+  point: point,
+  kwds: string,
+  line1: line,
+  line2: line,
+  poly1: polygon,
+  poly2: polygon,
+  rec: rectangle,
+  circle: circle
+}
+
+create dataset MyData(MyRecord)
+  primary key id;
+
+create index btree_index_docid on MyData(docid) type btree;
+create index btree_index_val1 on MyData(val1) type btree;
+create index rtree_index_point on MyData(point) type rtree;
+create index rtree_index_rec on MyData(rec) type rtree;
+create index ngram_index_title on MyData(title) type ngram(3);
+create index keyword_index_title on MyData(title) type keyword;
diff --git a/asterix-app/src/test/resources/runtimets/queries/index-selection/btree-index-limit-orderby-02/btree-index-limit-orderby-02.2.update.aql b/asterix-app/src/test/resources/runtimets/queries/index-selection/btree-index-limit-orderby-02/btree-index-limit-orderby-02.2.update.aql
new file mode 100644
index 0000000..07eb916
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries/index-selection/btree-index-limit-orderby-02/btree-index-limit-orderby-02.2.update.aql
@@ -0,0 +1,31 @@
+/*
+ * 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.
+ */
+
+/*
+ *  Description     : Limit Push-down into an external sort after an index-search - order by the primary key field.
+ *  Expected Result : Success
+ *
+*/
+
+ use dataverse test;
+
+load dataset MyData
+using "org.apache.asterix.external.dataset.adapter.NCFileSystemAdapter"
+(("path"="asterix_nc1://data/spatial/spatialData2.json"),("format"="adm"));
+
diff --git a/asterix-app/src/test/resources/runtimets/queries/index-selection/btree-index-limit-orderby-02/btree-index-limit-orderby-02.3.query.aql b/asterix-app/src/test/resources/runtimets/queries/index-selection/btree-index-limit-orderby-02/btree-index-limit-orderby-02.3.query.aql
new file mode 100644
index 0000000..95db56e
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries/index-selection/btree-index-limit-orderby-02/btree-index-limit-orderby-02.3.query.aql
@@ -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.
+ */
+
+/*
+ *  Description     : Limit Push-down into an external sort after an index-search - order by the primary key field.
+ *  Expected Result : Success
+ *
+*/
+
+use dataverse test;
+
+for $o in dataset('MyData')
+where $o.id < 50
+order by $o.id
+limit 2
+return {"pk":$o.id, "sk":$o.docid}
diff --git a/asterix-app/src/test/resources/runtimets/queries/orderby_limit/orderby_limit_01/orderby_limit_01.1.ddl.aql b/asterix-app/src/test/resources/runtimets/queries/orderby_limit/orderby_limit_01/orderby_limit_01.1.ddl.aql
new file mode 100644
index 0000000..09a4c40
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries/orderby_limit/orderby_limit_01/orderby_limit_01.1.ddl.aql
@@ -0,0 +1,53 @@
+/*
+ * 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.
+ */
+
+/*
+ *  Description     : Limit Push-down into an external sort after an index-search - order by a non primary key field.
+ *  Expected Result : Success
+ *
+*/
+
+drop dataverse test if exists;
+create dataverse test;
+use dataverse test;
+
+create type MyRecord as closed {
+  id: int64,
+  docid: int64,
+  val1: int64,
+  title: string,
+  point: point,
+  kwds: string,
+  line1: line,
+  line2: line,
+  poly1: polygon,
+  poly2: polygon,
+  rec: rectangle,
+  circle: circle
+}
+
+create dataset MyData(MyRecord)
+  primary key id;
+
+create index btree_index_docid on MyData(docid) type btree;
+create index btree_index_val1 on MyData(val1) type btree;
+create index rtree_index_point on MyData(point) type rtree;
+create index rtree_index_rec on MyData(rec) type rtree;
+create index ngram_index_title on MyData(title) type ngram(3);
+create index keyword_index_title on MyData(title) type keyword;
diff --git a/asterix-app/src/test/resources/runtimets/queries/orderby_limit/orderby_limit_01/orderby_limit_01.2.update.aql b/asterix-app/src/test/resources/runtimets/queries/orderby_limit/orderby_limit_01/orderby_limit_01.2.update.aql
new file mode 100644
index 0000000..e1ab937
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries/orderby_limit/orderby_limit_01/orderby_limit_01.2.update.aql
@@ -0,0 +1,31 @@
+/*
+ * 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.
+ */
+
+/*
+ *  Description     : Limit Push-down into an external sort after an index-search - order by a non primary key field.
+ *  Expected Result : Success
+ *
+*/
+
+ use dataverse test;
+
+load dataset MyData
+using "org.apache.asterix.external.dataset.adapter.NCFileSystemAdapter"
+(("path"="asterix_nc1://data/spatial/spatialData2.json"),("format"="adm"));
+
diff --git a/asterix-app/src/test/resources/runtimets/queries/orderby_limit/orderby_limit_01/orderby_limit_01.3.query.aql b/asterix-app/src/test/resources/runtimets/queries/orderby_limit/orderby_limit_01/orderby_limit_01.3.query.aql
new file mode 100644
index 0000000..5df7363
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries/orderby_limit/orderby_limit_01/orderby_limit_01.3.query.aql
@@ -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.
+ */
+
+/*
+ *  Description     : Limit Push-down into an external sort after an index-search - order by a non primary key field.
+ *  Expected Result : Success
+ *
+*/
+
+use dataverse test;
+
+for $o in dataset('MyData')
+where $o.id < 50
+order by $o.docid
+limit 2
+return {"pk":$o.id, "sk":$o.docid}
diff --git a/asterix-app/src/test/resources/runtimets/queries/orderby_limit/orderby_limit_offset_01/orderby_limit_offset_01.1.ddl.aql b/asterix-app/src/test/resources/runtimets/queries/orderby_limit/orderby_limit_offset_01/orderby_limit_offset_01.1.ddl.aql
new file mode 100644
index 0000000..d4e0b40
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries/orderby_limit/orderby_limit_offset_01/orderby_limit_offset_01.1.ddl.aql
@@ -0,0 +1,53 @@
+/*
+ * 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.
+ */
+
+/*
+ *  Description     : Limit with offset Push-down into an external sort after an index-search - order by a non primary key field.
+ *  Expected Result : Success
+ *
+*/
+
+drop dataverse test if exists;
+create dataverse test;
+use dataverse test;
+
+create type MyRecord as closed {
+  id: int64,
+  docid: int64,
+  val1: int64,
+  title: string,
+  point: point,
+  kwds: string,
+  line1: line,
+  line2: line,
+  poly1: polygon,
+  poly2: polygon,
+  rec: rectangle,
+  circle: circle
+}
+
+create dataset MyData(MyRecord)
+  primary key id;
+
+create index btree_index_docid on MyData(docid) type btree;
+create index btree_index_val1 on MyData(val1) type btree;
+create index rtree_index_point on MyData(point) type rtree;
+create index rtree_index_rec on MyData(rec) type rtree;
+create index ngram_index_title on MyData(title) type ngram(3);
+create index keyword_index_title on MyData(title) type keyword;
diff --git a/asterix-app/src/test/resources/runtimets/queries/orderby_limit/orderby_limit_offset_01/orderby_limit_offset_01.2.update.aql b/asterix-app/src/test/resources/runtimets/queries/orderby_limit/orderby_limit_offset_01/orderby_limit_offset_01.2.update.aql
new file mode 100644
index 0000000..c69007b
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries/orderby_limit/orderby_limit_offset_01/orderby_limit_offset_01.2.update.aql
@@ -0,0 +1,31 @@
+/*
+ * 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.
+ */
+
+/*
+ *  Description     : Limit with offset Push-down into an external sort after an index-search - order by a non primary key field.
+ *  Expected Result : Success
+ *
+*/
+
+ use dataverse test;
+
+load dataset MyData
+using "org.apache.asterix.external.dataset.adapter.NCFileSystemAdapter"
+(("path"="asterix_nc1://data/spatial/spatialData2.json"),("format"="adm"));
+
diff --git a/asterix-app/src/test/resources/runtimets/queries/orderby_limit/orderby_limit_offset_01/orderby_limit_offset_01.3.query.aql b/asterix-app/src/test/resources/runtimets/queries/orderby_limit/orderby_limit_offset_01/orderby_limit_offset_01.3.query.aql
new file mode 100644
index 0000000..4948dde
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries/orderby_limit/orderby_limit_offset_01/orderby_limit_offset_01.3.query.aql
@@ -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.
+ */
+
+/*
+ *  Description     : Limit with offset Push-down into an external sort after an index-search - order by a non primary key field.
+ *  Expected Result : Success
+ *
+*/
+
+use dataverse test;
+
+for $o in dataset('MyData')
+where $o.id < 50
+order by $o.docid
+limit 2 offset 2
+return {"pk":$o.id, "sk":$o.docid}
diff --git a/asterix-app/src/test/resources/runtimets/queries/orderby_limit/orderby_limit_primary_index_01/orderby_limit_primary_index_01.1.ddl.aql b/asterix-app/src/test/resources/runtimets/queries/orderby_limit/orderby_limit_primary_index_01/orderby_limit_primary_index_01.1.ddl.aql
new file mode 100644
index 0000000..e821faf
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries/orderby_limit/orderby_limit_primary_index_01/orderby_limit_primary_index_01.1.ddl.aql
@@ -0,0 +1,53 @@
+/*
+ * 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.
+ */
+
+/*
+ *  Description     : Limit Push-down into an external sort after an index-search - order by the primary key field.
+ *  Expected Result : Success
+ *
+*/
+
+drop dataverse test if exists;
+create dataverse test;
+use dataverse test;
+
+create type MyRecord as closed {
+  id: int64,
+  docid: int64,
+  val1: int64,
+  title: string,
+  point: point,
+  kwds: string,
+  line1: line,
+  line2: line,
+  poly1: polygon,
+  poly2: polygon,
+  rec: rectangle,
+  circle: circle
+}
+
+create dataset MyData(MyRecord)
+  primary key id;
+
+create index btree_index_docid on MyData(docid) type btree;
+create index btree_index_val1 on MyData(val1) type btree;
+create index rtree_index_point on MyData(point) type rtree;
+create index rtree_index_rec on MyData(rec) type rtree;
+create index ngram_index_title on MyData(title) type ngram(3);
+create index keyword_index_title on MyData(title) type keyword;
diff --git a/asterix-app/src/test/resources/runtimets/queries/orderby_limit/orderby_limit_primary_index_01/orderby_limit_primary_index_01.2.update.aql b/asterix-app/src/test/resources/runtimets/queries/orderby_limit/orderby_limit_primary_index_01/orderby_limit_primary_index_01.2.update.aql
new file mode 100644
index 0000000..07eb916
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries/orderby_limit/orderby_limit_primary_index_01/orderby_limit_primary_index_01.2.update.aql
@@ -0,0 +1,31 @@
+/*
+ * 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.
+ */
+
+/*
+ *  Description     : Limit Push-down into an external sort after an index-search - order by the primary key field.
+ *  Expected Result : Success
+ *
+*/
+
+ use dataverse test;
+
+load dataset MyData
+using "org.apache.asterix.external.dataset.adapter.NCFileSystemAdapter"
+(("path"="asterix_nc1://data/spatial/spatialData2.json"),("format"="adm"));
+
diff --git a/asterix-app/src/test/resources/runtimets/queries/orderby_limit/orderby_limit_primary_index_01/orderby_limit_primary_index_01.3.query.aql b/asterix-app/src/test/resources/runtimets/queries/orderby_limit/orderby_limit_primary_index_01/orderby_limit_primary_index_01.3.query.aql
new file mode 100644
index 0000000..95db56e
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries/orderby_limit/orderby_limit_primary_index_01/orderby_limit_primary_index_01.3.query.aql
@@ -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.
+ */
+
+/*
+ *  Description     : Limit Push-down into an external sort after an index-search - order by the primary key field.
+ *  Expected Result : Success
+ *
+*/
+
+use dataverse test;
+
+for $o in dataset('MyData')
+where $o.id < 50
+order by $o.id
+limit 2
+return {"pk":$o.id, "sk":$o.docid}
diff --git a/asterix-app/src/test/resources/runtimets/results/index-selection/btree-index-limit-orderby-01/btree-index-limit-orderby-01.1.adm b/asterix-app/src/test/resources/runtimets/results/index-selection/btree-index-limit-orderby-01/btree-index-limit-orderby-01.1.adm
new file mode 100644
index 0000000..77076cd
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results/index-selection/btree-index-limit-orderby-01/btree-index-limit-orderby-01.1.adm
@@ -0,0 +1,2 @@
+{ "pk": 1, "sk": 1 }
+{ "pk": 2, "sk": 2 }
diff --git a/asterix-app/src/test/resources/runtimets/results/index-selection/btree-index-limit-orderby-02/btree-index-limit-orderby-02.1.adm b/asterix-app/src/test/resources/runtimets/results/index-selection/btree-index-limit-orderby-02/btree-index-limit-orderby-02.1.adm
new file mode 100644
index 0000000..77076cd
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results/index-selection/btree-index-limit-orderby-02/btree-index-limit-orderby-02.1.adm
@@ -0,0 +1,2 @@
+{ "pk": 1, "sk": 1 }
+{ "pk": 2, "sk": 2 }
diff --git a/asterix-app/src/test/resources/runtimets/results/orderby_limit/orderby_limit_01/orderby_limit_01.1.adm b/asterix-app/src/test/resources/runtimets/results/orderby_limit/orderby_limit_01/orderby_limit_01.1.adm
new file mode 100644
index 0000000..77076cd
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results/orderby_limit/orderby_limit_01/orderby_limit_01.1.adm
@@ -0,0 +1,2 @@
+{ "pk": 1, "sk": 1 }
+{ "pk": 2, "sk": 2 }
diff --git a/asterix-app/src/test/resources/runtimets/results/orderby_limit/orderby_limit_offset_01/orderby_limit_offset_01.1.adm b/asterix-app/src/test/resources/runtimets/results/orderby_limit/orderby_limit_offset_01/orderby_limit_offset_01.1.adm
new file mode 100644
index 0000000..1c4d1bd
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results/orderby_limit/orderby_limit_offset_01/orderby_limit_offset_01.1.adm
@@ -0,0 +1,2 @@
+{ "pk": 3, "sk": 3 }
+{ "pk": 4, "sk": 4 }
diff --git a/asterix-app/src/test/resources/runtimets/results/orderby_limit/orderby_limit_primary_index_01/orderby_limit_primary_index_01.1.adm b/asterix-app/src/test/resources/runtimets/results/orderby_limit/orderby_limit_primary_index_01/orderby_limit_primary_index_01.1.adm
new file mode 100644
index 0000000..77076cd
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results/orderby_limit/orderby_limit_primary_index_01/orderby_limit_primary_index_01.1.adm
@@ -0,0 +1,2 @@
+{ "pk": 1, "sk": 1 }
+{ "pk": 2, "sk": 2 }
diff --git a/asterix-app/src/test/resources/runtimets/testsuite.xml b/asterix-app/src/test/resources/runtimets/testsuite.xml
index 9b03eaf..ac1f8f2 100644
--- a/asterix-app/src/test/resources/runtimets/testsuite.xml
+++ b/asterix-app/src/test/resources/runtimets/testsuite.xml
@@ -4284,6 +4284,23 @@
             </compilation-unit>
         </test-case>
     </test-group>
+    <test-group name="orderby_limit">
+        <test-case FilePath="orderby_limit">
+            <compilation-unit name="orderby_limit_01">
+                <output-dir compare="Text">orderby_limit_01</output-dir>
+            </compilation-unit>
+        </test-case>
+        <test-case FilePath="orderby_limit">
+            <compilation-unit name="orderby_limit_offset_01">
+                <output-dir compare="Text">orderby_limit_offset_01</output-dir>
+            </compilation-unit>
+        </test-case>
+        <test-case FilePath="orderby_limit">
+            <compilation-unit name="orderby_limit_primary_index_01">
+                <output-dir compare="Text">orderby_limit_primary_index_01</output-dir>
+            </compilation-unit>
+        </test-case>
+    </test-group>
     <test-group name="quantifiers">
         <test-case FilePath="quantifiers">
             <compilation-unit name="everysat_01">

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

Gerrit-MessageType: merged
Gerrit-Change-Id: I19aa4ce402b1834d9f68320acb72d7635a41a837
Gerrit-PatchSet: 9
Gerrit-Project: asterixdb
Gerrit-Branch: master
Gerrit-Owner: Taewoo Kim <wa...@gmail.com>
Gerrit-Reviewer: Jenkins <je...@fulliautomatix.ics.uci.edu>
Gerrit-Reviewer: Jianfeng Jia <ji...@gmail.com>
Gerrit-Reviewer: Taewoo Kim <wa...@gmail.com>
Gerrit-Reviewer: Yingyi Bu <bu...@gmail.com>
Gerrit-Reviewer: Young-Seok Kim <ki...@gmail.com>


Change in asterixdb[master]: ASTERIXDB-1157: Pushdown Limit

Posted by "Taewoo Kim (Code Review)" <do...@asterixdb.incubator.apache.org>.
Taewoo Kim has posted comments on this change.

Change subject: ASTERIXDB-1157: Pushdown Limit
......................................................................


Patch Set 5:

@Yingyi: never mind. The rule is fired after CopyLimitDownRule. And, it looks like we need to skip record-merge or get-records-fields for this rule.

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

Gerrit-MessageType: comment
Gerrit-Change-Id: I19aa4ce402b1834d9f68320acb72d7635a41a837
Gerrit-PatchSet: 5
Gerrit-Project: asterixdb
Gerrit-Branch: master
Gerrit-Owner: Taewoo Kim <wa...@gmail.com>
Gerrit-Reviewer: Jenkins <je...@fulliautomatix.ics.uci.edu>
Gerrit-Reviewer: Jianfeng Jia <ji...@gmail.com>
Gerrit-Reviewer: Taewoo Kim <wa...@gmail.com>
Gerrit-Reviewer: Yingyi Bu <bu...@gmail.com>
Gerrit-Reviewer: Young-Seok Kim <ki...@gmail.com>
Gerrit-HasComments: No

Change in asterixdb[master]: ASTERIXDB-1157: Implemented Limit Pushdown into Order (Exter...

Posted by "Yingyi Bu (Code Review)" <do...@asterixdb.incubator.apache.org>.
Yingyi Bu has posted comments on this change.

Change subject: ASTERIXDB-1157: Implemented Limit Pushdown into Order (ExternalSort)
......................................................................


Patch Set 2:

(8 comments)

https://asterix-gerrit.ics.uci.edu/#/c/617/2/asterix-algebra/src/main/java/org/apache/asterix/optimizer/rules/PushLimitIntoOrderByRule.java
File asterix-algebra/src/main/java/org/apache/asterix/optimizer/rules/PushLimitIntoOrderByRule.java:

Line 116:                 && limitOp.getOffset().getValue().getExpressionTag() == LogicalExpressionTag.CONSTANT) {
if limitOp.getOffset().getValue().getExpressionTag() != LogicalExpressionTag.CONSTANT, we'd have to return false.


https://asterix-gerrit.ics.uci.edu/#/c/617/2/asterix-app/src/test/resources/optimizerts/queries/btree-index/btree-primary-limit-orderby-01.aql
File asterix-app/src/test/resources/optimizerts/queries/btree-index/btree-primary-limit-orderby-01.aql:

Line 28: create dataverse test;
The test name as well as its directory is a bit confusing. 
Can you rename it to "orderby_limit_01" move this test to a the top level directory optimizerts/queries/?


Line 61: limit 2
Could you add another test case where offset is not null.


https://asterix-gerrit.ics.uci.edu/#/c/617/2/asterix-app/src/test/resources/optimizerts/queries/btree-index/btree-primary-limit-orderby-02.aql
File asterix-app/src/test/resources/optimizerts/queries/btree-index/btree-primary-limit-orderby-02.aql:

Line 29: use dataverse test;
Can you rename this test case to "orderby_limit_primary_index" move this test to the top level directory optimizerts/queries/?


https://asterix-gerrit.ics.uci.edu/#/c/617/2/asterix-app/src/test/resources/optimizerts/results/btree-index/btree-primary-limit-orderby-01.plan
File asterix-app/src/test/resources/optimizerts/results/btree-index/btree-primary-limit-orderby-01.plan:

Line 9:                 -- STABLE_SORT [$$10(ASC)]  |PARTITIONED|
Could you add the "topK" information in the pretty printing of STABLE_SORT?

For example:

-- STABLE_SORT [topK=5] [$$10(ASC)]


https://asterix-gerrit.ics.uci.edu/#/c/617/2/asterix-app/src/test/resources/runtimets/queries/index-selection/btree-index-limit-orderby-01/btree-index-limit-orderby-01.1.ddl.aql
File asterix-app/src/test/resources/runtimets/queries/index-selection/btree-index-limit-orderby-01/btree-index-limit-orderby-01.1.ddl.aql:

Line 18:  */
rename the test and move it to a new directory:
runtimets/queries/orderby_limit/


https://asterix-gerrit.ics.uci.edu/#/c/617/2/asterix-app/src/test/resources/runtimets/queries/index-selection/btree-index-limit-orderby-01/btree-index-limit-orderby-01.3.query.aql
File asterix-app/src/test/resources/runtimets/queries/index-selection/btree-index-limit-orderby-01/btree-index-limit-orderby-01.3.query.aql:

Line 30: order by $o.docid
add another test where offset != null


https://asterix-gerrit.ics.uci.edu/#/c/617/2/asterix-app/src/test/resources/runtimets/queries/index-selection/btree-index-limit-orderby-02/btree-index-limit-orderby-02.1.ddl.aql
File asterix-app/src/test/resources/runtimets/queries/index-selection/btree-index-limit-orderby-02/btree-index-limit-orderby-02.1.ddl.aql:

Line 29: 
rename the test and move it to a new directory:
runtimets/queries/orderby_limit/


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

Gerrit-MessageType: comment
Gerrit-Change-Id: I19aa4ce402b1834d9f68320acb72d7635a41a837
Gerrit-PatchSet: 2
Gerrit-Project: asterixdb
Gerrit-Branch: master
Gerrit-Owner: Taewoo Kim <wa...@gmail.com>
Gerrit-Reviewer: Jenkins <je...@fulliautomatix.ics.uci.edu>
Gerrit-Reviewer: Jianfeng Jia <ji...@gmail.com>
Gerrit-Reviewer: Taewoo Kim <wa...@gmail.com>
Gerrit-Reviewer: Yingyi Bu <bu...@gmail.com>
Gerrit-Reviewer: Young-Seok Kim <ki...@gmail.com>
Gerrit-HasComments: Yes

Change in asterixdb[master]: ASTERIXDB-1157: Pushdown Limit

Posted by "Jenkins (Code Review)" <do...@asterixdb.incubator.apache.org>.
Jenkins has posted comments on this change.

Change subject: ASTERIXDB-1157: Pushdown Limit
......................................................................


Patch Set 5: Verified-1

Build Unstable 

https://asterix-jenkins.ics.uci.edu/job/asterix-gerrit-topic/672/ : UNSTABLE

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

Gerrit-MessageType: comment
Gerrit-Change-Id: I19aa4ce402b1834d9f68320acb72d7635a41a837
Gerrit-PatchSet: 5
Gerrit-Project: asterixdb
Gerrit-Branch: master
Gerrit-Owner: Taewoo Kim <wa...@gmail.com>
Gerrit-Reviewer: Jenkins <je...@fulliautomatix.ics.uci.edu>
Gerrit-Reviewer: Jianfeng Jia <ji...@gmail.com>
Gerrit-Reviewer: Taewoo Kim <wa...@gmail.com>
Gerrit-Reviewer: Yingyi Bu <bu...@gmail.com>
Gerrit-Reviewer: Young-Seok Kim <ki...@gmail.com>
Gerrit-HasComments: No

Change in asterixdb[master]: ASTERIXDB-1157: Pushdown Limit

Posted by "Taewoo Kim (Code Review)" <do...@asterixdb.incubator.apache.org>.
Taewoo Kim has posted comments on this change.

Change subject: ASTERIXDB-1157: Pushdown Limit
......................................................................


Patch Set 5:

@Yingyi:

After I enable ConstantFoldingRule, the following tests fail. If I disable ContantFolding after CopyLimitDownRule, it works fine. What could be a reason? Basically it throws an IO.EOFException. I am not sure why this happens. Actually, this exception happens after "RemoveUnusedAssignRule".

org.apache.asterix.test.runtime.ExecutionTest.test[ExecutionTest 728: records/get-record-fields: documentation-example]
org.apache.asterix.test.runtime.ExecutionTest.test[ExecutionTest 742: records/record-merge: documentation-example]
org.apache.asterix.test.runtime.SqlppExecutionTest.test[SqlppExecutionTest 656: records/get-record-fields: documentation-example]

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

Gerrit-MessageType: comment
Gerrit-Change-Id: I19aa4ce402b1834d9f68320acb72d7635a41a837
Gerrit-PatchSet: 5
Gerrit-Project: asterixdb
Gerrit-Branch: master
Gerrit-Owner: Taewoo Kim <wa...@gmail.com>
Gerrit-Reviewer: Jenkins <je...@fulliautomatix.ics.uci.edu>
Gerrit-Reviewer: Jianfeng Jia <ji...@gmail.com>
Gerrit-Reviewer: Taewoo Kim <wa...@gmail.com>
Gerrit-Reviewer: Yingyi Bu <bu...@gmail.com>
Gerrit-Reviewer: Young-Seok Kim <ki...@gmail.com>
Gerrit-HasComments: No

Change in asterixdb[master]: ASTERIXDB-1157: Pushdown Limit

Posted by "Taewoo Kim (Code Review)" <do...@asterixdb.incubator.apache.org>.
Hello Jenkins,

I'd like you to reexamine a change.  Please visit

    https://asterix-gerrit.ics.uci.edu/617

to look at the new patch set (#3).

Change subject: ASTERIXDB-1157: Pushdown Limit
......................................................................

ASTERIXDB-1157: Pushdown Limit

- Limit Pushdown into an Order (ExternalSort) operator.

Change-Id: I19aa4ce402b1834d9f68320acb72d7635a41a837
---
M asterix-algebra/src/main/java/org/apache/asterix/optimizer/base/RuleCollections.java
A asterix-algebra/src/main/java/org/apache/asterix/optimizer/rules/PushLimitIntoOrderByRule.java
M asterix-algebra/src/main/java/org/apache/asterix/optimizer/rules/am/AccessMethodUtils.java
A asterix-app/data/spatial/spatialData2.json
A asterix-app/src/test/resources/optimizerts/queries/orderby_limit_01.aql
A asterix-app/src/test/resources/optimizerts/queries/orderby_limit_offset_01.aql
A asterix-app/src/test/resources/optimizerts/queries/orderby_limit_primary_index_01.aql
A asterix-app/src/test/resources/optimizerts/results/btree-index/btree-primary-limit-orderby-01.plan
A asterix-app/src/test/resources/optimizerts/results/btree-index/btree-primary-limit-orderby-02.plan
A asterix-app/src/test/resources/optimizerts/results/orderby_limit_01.plan
A asterix-app/src/test/resources/optimizerts/results/orderby_limit_offset_01.plan
A asterix-app/src/test/resources/optimizerts/results/orderby_limit_primary_index_01.plan
A asterix-app/src/test/resources/runtimets/queries/index-selection/btree-index-limit-orderby-01/btree-index-limit-orderby-01.1.ddl.aql
A asterix-app/src/test/resources/runtimets/queries/index-selection/btree-index-limit-orderby-01/btree-index-limit-orderby-01.2.update.aql
A asterix-app/src/test/resources/runtimets/queries/index-selection/btree-index-limit-orderby-01/btree-index-limit-orderby-01.3.query.aql
A asterix-app/src/test/resources/runtimets/queries/index-selection/btree-index-limit-orderby-02/btree-index-limit-orderby-02.1.ddl.aql
A asterix-app/src/test/resources/runtimets/queries/index-selection/btree-index-limit-orderby-02/btree-index-limit-orderby-02.2.update.aql
A asterix-app/src/test/resources/runtimets/queries/index-selection/btree-index-limit-orderby-02/btree-index-limit-orderby-02.3.query.aql
A asterix-app/src/test/resources/runtimets/queries/orderby_limit/orderby_limit_01/orderby_limit_01.1.ddl.aql
A asterix-app/src/test/resources/runtimets/queries/orderby_limit/orderby_limit_01/orderby_limit_01.2.update.aql
A asterix-app/src/test/resources/runtimets/queries/orderby_limit/orderby_limit_01/orderby_limit_01.3.query.aql
A asterix-app/src/test/resources/runtimets/queries/orderby_limit/orderby_limit_offset_01/orderby_limit_offset_01.1.ddl.aql
A asterix-app/src/test/resources/runtimets/queries/orderby_limit/orderby_limit_offset_01/orderby_limit_offset_01.2.update.aql
A asterix-app/src/test/resources/runtimets/queries/orderby_limit/orderby_limit_offset_01/orderby_limit_offset_01.3.query.aql
A asterix-app/src/test/resources/runtimets/queries/orderby_limit/orderby_limit_primary_index_01/orderby_limit_primary_index_01.1.ddl.aql
A asterix-app/src/test/resources/runtimets/queries/orderby_limit/orderby_limit_primary_index_01/orderby_limit_primary_index_01.2.update.aql
A asterix-app/src/test/resources/runtimets/queries/orderby_limit/orderby_limit_primary_index_01/orderby_limit_primary_index_01.3.query.aql
A asterix-app/src/test/resources/runtimets/results/index-selection/btree-index-limit-orderby-01/btree-index-limit-orderby-01.1.adm
A asterix-app/src/test/resources/runtimets/results/index-selection/btree-index-limit-orderby-02/btree-index-limit-orderby-02.1.adm
A asterix-app/src/test/resources/runtimets/results/orderby_limit/orderby_limit_01/orderby_limit_01.1.adm
A asterix-app/src/test/resources/runtimets/results/orderby_limit/orderby_limit_offset_01/orderby_limit_offset_01.1.adm
A asterix-app/src/test/resources/runtimets/results/orderby_limit/orderby_limit_primary_index_01/orderby_limit_primary_index_01.1.adm
M asterix-app/src/test/resources/runtimets/testsuite.xml
33 files changed, 1,107 insertions(+), 0 deletions(-)


  git pull ssh://asterix-gerrit.ics.uci.edu:29418/asterixdb refs/changes/17/617/3
-- 
To view, visit https://asterix-gerrit.ics.uci.edu/617
To unsubscribe, visit https://asterix-gerrit.ics.uci.edu/settings

Gerrit-MessageType: newpatchset
Gerrit-Change-Id: I19aa4ce402b1834d9f68320acb72d7635a41a837
Gerrit-PatchSet: 3
Gerrit-Project: asterixdb
Gerrit-Branch: master
Gerrit-Owner: Taewoo Kim <wa...@gmail.com>
Gerrit-Reviewer: Jenkins <je...@fulliautomatix.ics.uci.edu>
Gerrit-Reviewer: Jianfeng Jia <ji...@gmail.com>
Gerrit-Reviewer: Taewoo Kim <wa...@gmail.com>
Gerrit-Reviewer: Yingyi Bu <bu...@gmail.com>
Gerrit-Reviewer: Young-Seok Kim <ki...@gmail.com>

Change in asterixdb[master]: ASTERIXDB-1157: Implemented Limit Pushdown into Order (Exter...

Posted by "Jenkins (Code Review)" <do...@asterixdb.incubator.apache.org>.
Jenkins has posted comments on this change.

Change subject: ASTERIXDB-1157: Implemented Limit Pushdown into Order (ExternalSort)
......................................................................


Patch Set 1:

Build Started https://asterix-jenkins.ics.uci.edu/job/asterix-gerrit-notopic/799/

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

Gerrit-MessageType: comment
Gerrit-Change-Id: I19aa4ce402b1834d9f68320acb72d7635a41a837
Gerrit-PatchSet: 1
Gerrit-Project: asterixdb
Gerrit-Branch: master
Gerrit-Owner: Taewoo Kim <wa...@gmail.com>
Gerrit-Reviewer: Jenkins <je...@fulliautomatix.ics.uci.edu>
Gerrit-HasComments: No

Change in asterixdb[master]: ASTERIXDB-1157: Implemented Limit Pushdown into Order (Exter...

Posted by "Jenkins (Code Review)" <do...@asterixdb.incubator.apache.org>.
Jenkins has posted comments on this change.

Change subject: ASTERIXDB-1157: Implemented Limit Pushdown into Order (ExternalSort)
......................................................................


Patch Set 2: Verified+1

Build Successful 

https://asterix-jenkins.ics.uci.edu/job/asterix-gerrit-topic/656/ : SUCCESS

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

Gerrit-MessageType: comment
Gerrit-Change-Id: I19aa4ce402b1834d9f68320acb72d7635a41a837
Gerrit-PatchSet: 2
Gerrit-Project: asterixdb
Gerrit-Branch: master
Gerrit-Owner: Taewoo Kim <wa...@gmail.com>
Gerrit-Reviewer: Jenkins <je...@fulliautomatix.ics.uci.edu>
Gerrit-Reviewer: Jianfeng Jia <ji...@gmail.com>
Gerrit-Reviewer: Yingyi Bu <bu...@gmail.com>
Gerrit-Reviewer: Young-Seok Kim <ki...@gmail.com>
Gerrit-HasComments: No

Change in asterixdb[master]: ASTERIXDB-1157: Pushdown Limit

Posted by "Jenkins (Code Review)" <do...@asterixdb.incubator.apache.org>.
Jenkins has posted comments on this change.

Change subject: ASTERIXDB-1157: Pushdown Limit
......................................................................


Patch Set 8: Verified+1

Build Successful 

https://asterix-jenkins.ics.uci.edu/job/asterix-gerrit-topic/684/ : SUCCESS

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

Gerrit-MessageType: comment
Gerrit-Change-Id: I19aa4ce402b1834d9f68320acb72d7635a41a837
Gerrit-PatchSet: 8
Gerrit-Project: asterixdb
Gerrit-Branch: master
Gerrit-Owner: Taewoo Kim <wa...@gmail.com>
Gerrit-Reviewer: Jenkins <je...@fulliautomatix.ics.uci.edu>
Gerrit-Reviewer: Jianfeng Jia <ji...@gmail.com>
Gerrit-Reviewer: Taewoo Kim <wa...@gmail.com>
Gerrit-Reviewer: Yingyi Bu <bu...@gmail.com>
Gerrit-Reviewer: Young-Seok Kim <ki...@gmail.com>
Gerrit-HasComments: No

Change in asterixdb[master]: ASTERIXDB-1157: Implemented Limit Pushdown into Order (Exter...

Posted by "Jenkins (Code Review)" <do...@asterixdb.incubator.apache.org>.
Jenkins has posted comments on this change.

Change subject: ASTERIXDB-1157: Implemented Limit Pushdown into Order (ExternalSort)
......................................................................


Patch Set 1: Verified-1

Build Failed 

https://asterix-jenkins.ics.uci.edu/job/asterix-gerrit-notopic/799/ : ABORTED

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

Gerrit-MessageType: comment
Gerrit-Change-Id: I19aa4ce402b1834d9f68320acb72d7635a41a837
Gerrit-PatchSet: 1
Gerrit-Project: asterixdb
Gerrit-Branch: master
Gerrit-Owner: Taewoo Kim <wa...@gmail.com>
Gerrit-Reviewer: Jenkins <je...@fulliautomatix.ics.uci.edu>
Gerrit-HasComments: No

Change in asterixdb[master]: ASTERIXDB-1157: Pushdown Limit

Posted by "Jenkins (Code Review)" <do...@asterixdb.incubator.apache.org>.
Jenkins has posted comments on this change.

Change subject: ASTERIXDB-1157: Pushdown Limit
......................................................................


Patch Set 3:

Build Started https://asterix-jenkins.ics.uci.edu/job/asterix-gerrit-topic/669/

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

Gerrit-MessageType: comment
Gerrit-Change-Id: I19aa4ce402b1834d9f68320acb72d7635a41a837
Gerrit-PatchSet: 3
Gerrit-Project: asterixdb
Gerrit-Branch: master
Gerrit-Owner: Taewoo Kim <wa...@gmail.com>
Gerrit-Reviewer: Jenkins <je...@fulliautomatix.ics.uci.edu>
Gerrit-Reviewer: Jianfeng Jia <ji...@gmail.com>
Gerrit-Reviewer: Taewoo Kim <wa...@gmail.com>
Gerrit-Reviewer: Yingyi Bu <bu...@gmail.com>
Gerrit-Reviewer: Young-Seok Kim <ki...@gmail.com>
Gerrit-HasComments: No

Change in asterixdb[master]: ASTERIXDB-1157: Pushdown Limit

Posted by "Jenkins (Code Review)" <do...@asterixdb.incubator.apache.org>.
Jenkins has posted comments on this change.

Change subject: ASTERIXDB-1157: Pushdown Limit
......................................................................


Patch Set 4: Verified+1

Build Successful 

https://asterix-jenkins.ics.uci.edu/job/asterix-gerrit-topic/671/ : SUCCESS

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

Gerrit-MessageType: comment
Gerrit-Change-Id: I19aa4ce402b1834d9f68320acb72d7635a41a837
Gerrit-PatchSet: 4
Gerrit-Project: asterixdb
Gerrit-Branch: master
Gerrit-Owner: Taewoo Kim <wa...@gmail.com>
Gerrit-Reviewer: Jenkins <je...@fulliautomatix.ics.uci.edu>
Gerrit-Reviewer: Jianfeng Jia <ji...@gmail.com>
Gerrit-Reviewer: Taewoo Kim <wa...@gmail.com>
Gerrit-Reviewer: Yingyi Bu <bu...@gmail.com>
Gerrit-Reviewer: Young-Seok Kim <ki...@gmail.com>
Gerrit-HasComments: No

Change in asterixdb[master]: ASTERIXDB-1157: Pushdown Limit

Posted by "Taewoo Kim (Code Review)" <do...@asterixdb.incubator.apache.org>.
Hello Jenkins,

I'd like you to reexamine a change.  Please visit

    https://asterix-gerrit.ics.uci.edu/617

to look at the new patch set (#5).

Change subject: ASTERIXDB-1157: Pushdown Limit
......................................................................

ASTERIXDB-1157: Pushdown Limit

- Limit Pushdown into an Order (ExternalSort) operator.

Change-Id: I19aa4ce402b1834d9f68320acb72d7635a41a837
---
M asterix-algebra/src/main/java/org/apache/asterix/optimizer/base/RuleCollections.java
A asterix-algebra/src/main/java/org/apache/asterix/optimizer/rules/PushLimitIntoOrderByRule.java
M asterix-algebra/src/main/java/org/apache/asterix/optimizer/rules/am/AccessMethodUtils.java
A asterix-app/data/spatial/spatialData2.json
A asterix-app/src/test/resources/optimizerts/queries/orderby_limit_01.aql
A asterix-app/src/test/resources/optimizerts/queries/orderby_limit_offset_01.aql
A asterix-app/src/test/resources/optimizerts/queries/orderby_limit_primary_index_01.aql
A asterix-app/src/test/resources/optimizerts/results/btree-index/btree-primary-limit-orderby-01.plan
A asterix-app/src/test/resources/optimizerts/results/btree-index/btree-primary-limit-orderby-02.plan
M asterix-app/src/test/resources/optimizerts/results/inlined_q18_large_volume_customer.plan
A asterix-app/src/test/resources/optimizerts/results/orderby_limit_01.plan
A asterix-app/src/test/resources/optimizerts/results/orderby_limit_offset_01.plan
A asterix-app/src/test/resources/optimizerts/results/orderby_limit_primary_index_01.plan
M asterix-app/src/test/resources/optimizerts/results/q03_shipping_priority.plan
M asterix-app/src/test/resources/optimizerts/results/q2.plan
M asterix-app/src/test/resources/optimizerts/results/sort-cust.plan
A asterix-app/src/test/resources/runtimets/queries/index-selection/btree-index-limit-orderby-01/btree-index-limit-orderby-01.1.ddl.aql
A asterix-app/src/test/resources/runtimets/queries/index-selection/btree-index-limit-orderby-01/btree-index-limit-orderby-01.2.update.aql
A asterix-app/src/test/resources/runtimets/queries/index-selection/btree-index-limit-orderby-01/btree-index-limit-orderby-01.3.query.aql
A asterix-app/src/test/resources/runtimets/queries/index-selection/btree-index-limit-orderby-02/btree-index-limit-orderby-02.1.ddl.aql
A asterix-app/src/test/resources/runtimets/queries/index-selection/btree-index-limit-orderby-02/btree-index-limit-orderby-02.2.update.aql
A asterix-app/src/test/resources/runtimets/queries/index-selection/btree-index-limit-orderby-02/btree-index-limit-orderby-02.3.query.aql
A asterix-app/src/test/resources/runtimets/queries/orderby_limit/orderby_limit_01/orderby_limit_01.1.ddl.aql
A asterix-app/src/test/resources/runtimets/queries/orderby_limit/orderby_limit_01/orderby_limit_01.2.update.aql
A asterix-app/src/test/resources/runtimets/queries/orderby_limit/orderby_limit_01/orderby_limit_01.3.query.aql
A asterix-app/src/test/resources/runtimets/queries/orderby_limit/orderby_limit_offset_01/orderby_limit_offset_01.1.ddl.aql
A asterix-app/src/test/resources/runtimets/queries/orderby_limit/orderby_limit_offset_01/orderby_limit_offset_01.2.update.aql
A asterix-app/src/test/resources/runtimets/queries/orderby_limit/orderby_limit_offset_01/orderby_limit_offset_01.3.query.aql
A asterix-app/src/test/resources/runtimets/queries/orderby_limit/orderby_limit_primary_index_01/orderby_limit_primary_index_01.1.ddl.aql
A asterix-app/src/test/resources/runtimets/queries/orderby_limit/orderby_limit_primary_index_01/orderby_limit_primary_index_01.2.update.aql
A asterix-app/src/test/resources/runtimets/queries/orderby_limit/orderby_limit_primary_index_01/orderby_limit_primary_index_01.3.query.aql
A asterix-app/src/test/resources/runtimets/results/index-selection/btree-index-limit-orderby-01/btree-index-limit-orderby-01.1.adm
A asterix-app/src/test/resources/runtimets/results/index-selection/btree-index-limit-orderby-02/btree-index-limit-orderby-02.1.adm
A asterix-app/src/test/resources/runtimets/results/orderby_limit/orderby_limit_01/orderby_limit_01.1.adm
A asterix-app/src/test/resources/runtimets/results/orderby_limit/orderby_limit_offset_01/orderby_limit_offset_01.1.adm
A asterix-app/src/test/resources/runtimets/results/orderby_limit/orderby_limit_primary_index_01/orderby_limit_primary_index_01.1.adm
M asterix-app/src/test/resources/runtimets/testsuite.xml
37 files changed, 1,083 insertions(+), 4 deletions(-)


  git pull ssh://asterix-gerrit.ics.uci.edu:29418/asterixdb refs/changes/17/617/5
-- 
To view, visit https://asterix-gerrit.ics.uci.edu/617
To unsubscribe, visit https://asterix-gerrit.ics.uci.edu/settings

Gerrit-MessageType: newpatchset
Gerrit-Change-Id: I19aa4ce402b1834d9f68320acb72d7635a41a837
Gerrit-PatchSet: 5
Gerrit-Project: asterixdb
Gerrit-Branch: master
Gerrit-Owner: Taewoo Kim <wa...@gmail.com>
Gerrit-Reviewer: Jenkins <je...@fulliautomatix.ics.uci.edu>
Gerrit-Reviewer: Jianfeng Jia <ji...@gmail.com>
Gerrit-Reviewer: Taewoo Kim <wa...@gmail.com>
Gerrit-Reviewer: Yingyi Bu <bu...@gmail.com>
Gerrit-Reviewer: Young-Seok Kim <ki...@gmail.com>

Change in asterixdb[master]: ASTERIXDB-1157: Pushdown Limit

Posted by "Jenkins (Code Review)" <do...@asterixdb.incubator.apache.org>.
Jenkins has posted comments on this change.

Change subject: ASTERIXDB-1157: Pushdown Limit
......................................................................


Patch Set 8:

Build Started https://asterix-jenkins.ics.uci.edu/job/asterix-gerrit-topic/684/

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

Gerrit-MessageType: comment
Gerrit-Change-Id: I19aa4ce402b1834d9f68320acb72d7635a41a837
Gerrit-PatchSet: 8
Gerrit-Project: asterixdb
Gerrit-Branch: master
Gerrit-Owner: Taewoo Kim <wa...@gmail.com>
Gerrit-Reviewer: Jenkins <je...@fulliautomatix.ics.uci.edu>
Gerrit-Reviewer: Jianfeng Jia <ji...@gmail.com>
Gerrit-Reviewer: Taewoo Kim <wa...@gmail.com>
Gerrit-Reviewer: Yingyi Bu <bu...@gmail.com>
Gerrit-Reviewer: Young-Seok Kim <ki...@gmail.com>
Gerrit-HasComments: No

Change in asterixdb[master]: ASTERIXDB-1157: Pushdown Limit

Posted by "Taewoo Kim (Code Review)" <do...@asterixdb.incubator.apache.org>.
Taewoo Kim has posted comments on this change.

Change subject: ASTERIXDB-1157: Pushdown Limit
......................................................................


Patch Set 4:

(1 comment)

https://asterix-gerrit.ics.uci.edu/#/c/617/4/asterix-algebra/src/main/java/org/apache/asterix/optimizer/rules/PushLimitIntoOrderByRule.java
File asterix-algebra/src/main/java/org/apache/asterix/optimizer/rules/PushLimitIntoOrderByRule.java:

Line 115:             // a copied non-topmost LIMIT can contain NUMERIC-ADD to add the given limit value + offset value
> Should we let ConstantFoldingRule deal with that else-if block?
Throughout the compilation, this LIMIT remains as "NUMERIC_ADD", it doesn't contain a constant that is resulted from ConstantFoldingRule.


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

Gerrit-MessageType: comment
Gerrit-Change-Id: I19aa4ce402b1834d9f68320acb72d7635a41a837
Gerrit-PatchSet: 4
Gerrit-Project: asterixdb
Gerrit-Branch: master
Gerrit-Owner: Taewoo Kim <wa...@gmail.com>
Gerrit-Reviewer: Jenkins <je...@fulliautomatix.ics.uci.edu>
Gerrit-Reviewer: Jianfeng Jia <ji...@gmail.com>
Gerrit-Reviewer: Taewoo Kim <wa...@gmail.com>
Gerrit-Reviewer: Yingyi Bu <bu...@gmail.com>
Gerrit-Reviewer: Young-Seok Kim <ki...@gmail.com>
Gerrit-HasComments: Yes

Change in asterixdb[master]: ASTERIXDB-1157: Pushdown Limit

Posted by "Taewoo Kim (Code Review)" <do...@asterixdb.incubator.apache.org>.
Taewoo Kim has posted comments on this change.

Change subject: ASTERIXDB-1157: Pushdown Limit
......................................................................


Patch Set 7:

(2 comments)

https://asterix-gerrit.ics.uci.edu/#/c/617/7/asterix-algebra/src/main/java/org/apache/asterix/optimizer/rules/ConstantFoldingRule.java
File asterix-algebra/src/main/java/org/apache/asterix/optimizer/rules/ConstantFoldingRule.java:

Line 87:     private final ImmutableSet<FunctionIdentifier> funcIDSetThatShouldNotBeApplied = ImmutableSet.of(
> static? and rename the variable according to static variable convention?
Done


Line 195:             if (expr.getFunctionIdentifier().equals(AsterixBuiltinFunctions.OPEN_RECORD_CONSTRUCTOR)) {
> can you move this also into funcIDSetThatShouldNotBeApplied?
Done


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

Gerrit-MessageType: comment
Gerrit-Change-Id: I19aa4ce402b1834d9f68320acb72d7635a41a837
Gerrit-PatchSet: 7
Gerrit-Project: asterixdb
Gerrit-Branch: master
Gerrit-Owner: Taewoo Kim <wa...@gmail.com>
Gerrit-Reviewer: Jenkins <je...@fulliautomatix.ics.uci.edu>
Gerrit-Reviewer: Jianfeng Jia <ji...@gmail.com>
Gerrit-Reviewer: Taewoo Kim <wa...@gmail.com>
Gerrit-Reviewer: Yingyi Bu <bu...@gmail.com>
Gerrit-Reviewer: Young-Seok Kim <ki...@gmail.com>
Gerrit-HasComments: Yes