asterixdb-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From wangs...@apache.org
Subject [2/2] incubator-asterixdb git commit: ASTERIXDB-1157: Pushdown Limit
Date Fri, 12 Feb 2016 07:51:35 GMT
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 <buyingyi@gmail.com>
Tested-by: Jenkins <jenkins@fulliautomatix.ics.uci.edu>


Project: http://git-wip-us.apache.org/repos/asf/incubator-asterixdb/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-asterixdb/commit/760ce904
Tree: http://git-wip-us.apache.org/repos/asf/incubator-asterixdb/tree/760ce904
Diff: http://git-wip-us.apache.org/repos/asf/incubator-asterixdb/diff/760ce904

Branch: refs/heads/master
Commit: 760ce9041e8c1cbfda3f00c84caf69d0c0f4de33
Parents: a1c45ff
Author: Taewoo Kim <wangsaeu@yahoo.com>
Authored: Thu Feb 11 22:42:21 2016 -0800
Committer: Taewoo Kim <wangsaeu@gmail.com>
Committed: Thu Feb 11 23:46:35 2016 -0800

----------------------------------------------------------------------
 .../asterix/optimizer/base/RuleCollections.java |   5 +
 .../optimizer/rules/ConstantFoldingRule.java    |  22 ++-
 .../rules/PushLimitIntoOrderByRule.java         | 140 +++++++++++++++++++
 .../optimizer/rules/am/AccessMethodUtils.java   |   6 +
 asterix-app/data/spatial/spatialData2.json      |  60 ++++++++
 .../optimizerts/queries/orderby_limit_01.aql    |  62 ++++++++
 .../queries/orderby_limit_offset_01.aql         |  62 ++++++++
 .../queries/orderby_limit_primary_index_01.aql  |  62 ++++++++
 .../btree-primary-limit-orderby-01.plan         |  17 +++
 .../btree-primary-limit-orderby-02.plan         |  12 ++
 .../inlined_q18_large_volume_customer.plan      |   2 +-
 .../optimizerts/results/orderby_limit_01.plan   |  17 +++
 .../results/orderby_limit_offset_01.plan        |  17 +++
 .../results/orderby_limit_primary_index_01.plan |  12 ++
 .../results/q03_shipping_priority.plan          |   2 +-
 .../test/resources/optimizerts/results/q2.plan  |   2 +-
 .../optimizerts/results/sort-cust.plan          |   2 +-
 .../btree-index-limit-orderby-01.1.ddl.aql      |  53 +++++++
 .../btree-index-limit-orderby-01.2.update.aql   |  31 ++++
 .../btree-index-limit-orderby-01.3.query.aql    |  32 +++++
 .../btree-index-limit-orderby-02.1.ddl.aql      |  53 +++++++
 .../btree-index-limit-orderby-02.2.update.aql   |  31 ++++
 .../btree-index-limit-orderby-02.3.query.aql    |  32 +++++
 .../orderby_limit_01/orderby_limit_01.1.ddl.aql |  53 +++++++
 .../orderby_limit_01.2.update.aql               |  31 ++++
 .../orderby_limit_01.3.query.aql                |  32 +++++
 .../orderby_limit_offset_01.1.ddl.aql           |  53 +++++++
 .../orderby_limit_offset_01.2.update.aql        |  31 ++++
 .../orderby_limit_offset_01.3.query.aql         |  32 +++++
 .../orderby_limit_primary_index_01.1.ddl.aql    |  53 +++++++
 .../orderby_limit_primary_index_01.2.update.aql |  31 ++++
 .../orderby_limit_primary_index_01.3.query.aql  |  32 +++++
 .../btree-index-limit-orderby-01.1.adm          |   2 +
 .../btree-index-limit-orderby-02.1.adm          |   2 +
 .../orderby_limit_01/orderby_limit_01.1.adm     |   2 +
 .../orderby_limit_offset_01.1.adm               |   2 +
 .../orderby_limit_primary_index_01.1.adm        |   2 +
 .../src/test/resources/runtimets/testsuite.xml  |  17 +++
 38 files changed, 1102 insertions(+), 7 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-asterixdb/blob/760ce904/asterix-algebra/src/main/java/org/apache/asterix/optimizer/base/RuleCollections.java
----------------------------------------------------------------------
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.PushAggFuncIntoStandaloneAggregateRule
 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 @@ public final class RuleCollections {
         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());

http://git-wip-us.apache.org/repos/asf/incubator-asterixdb/blob/760ce904/asterix-algebra/src/main/java/org/apache/asterix/optimizer/rules/ConstantFoldingRule.java
----------------------------------------------------------------------
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.ScalarFunctionCall
 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,10 +76,22 @@ import org.apache.hyracks.data.std.api.IPointable;
 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 @@ public class ConstantFoldingRule implements IAlgebraicRewriteRule {
         if (context.checkIfInDontApplySet(this, op)) {
             return false;
         }
+
         return op.acceptExpressionTransform(cfv);
     }
 
@@ -172,11 +186,12 @@ public class ConstantFoldingRule implements IAlgebraicRewriteRule {
             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 @@ public class ConstantFoldingRule implements IAlgebraicRewriteRule {
                     return new Pair<Boolean, ILogicalExpression>(changed, expr);
                 }
             }
+
             IScalarEvaluatorFactory fact = _jobGenCtx.getExpressionRuntimeProvider().createEvaluatorFactory(expr,
                     _emptyTypeEnv, _emptySchemas, _jobGenCtx);
             IScalarEvaluator eval = fact.createScalarEvaluator(null);

http://git-wip-us.apache.org/repos/asf/incubator-asterixdb/blob/760ce904/asterix-algebra/src/main/java/org/apache/asterix/optimizer/rules/PushLimitIntoOrderByRule.java
----------------------------------------------------------------------
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;
+    }
+
+}

http://git-wip-us.apache.org/repos/asf/incubator-asterixdb/blob/760ce904/asterix-algebra/src/main/java/org/apache/asterix/optimizer/rules/am/AccessMethodUtils.java
----------------------------------------------------------------------
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.entities.Index;
 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 @@ public class AccessMethodUtils {
         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();

http://git-wip-us.apache.org/repos/asf/incubator-asterixdb/blob/760ce904/asterix-app/data/spatial/spatialData2.json
----------------------------------------------------------------------
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")}

http://git-wip-us.apache.org/repos/asf/incubator-asterixdb/blob/760ce904/asterix-app/src/test/resources/optimizerts/queries/orderby_limit_01.aql
----------------------------------------------------------------------
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}

http://git-wip-us.apache.org/repos/asf/incubator-asterixdb/blob/760ce904/asterix-app/src/test/resources/optimizerts/queries/orderby_limit_offset_01.aql
----------------------------------------------------------------------
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}

http://git-wip-us.apache.org/repos/asf/incubator-asterixdb/blob/760ce904/asterix-app/src/test/resources/optimizerts/queries/orderby_limit_primary_index_01.aql
----------------------------------------------------------------------
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}

http://git-wip-us.apache.org/repos/asf/incubator-asterixdb/blob/760ce904/asterix-app/src/test/resources/optimizerts/results/btree-index/btree-primary-limit-orderby-01.plan
----------------------------------------------------------------------
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|

http://git-wip-us.apache.org/repos/asf/incubator-asterixdb/blob/760ce904/asterix-app/src/test/resources/optimizerts/results/btree-index/btree-primary-limit-orderby-02.plan
----------------------------------------------------------------------
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|

http://git-wip-us.apache.org/repos/asf/incubator-asterixdb/blob/760ce904/asterix-app/src/test/resources/optimizerts/results/inlined_q18_large_volume_customer.plan
----------------------------------------------------------------------
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|
                             {

http://git-wip-us.apache.org/repos/asf/incubator-asterixdb/blob/760ce904/asterix-app/src/test/resources/optimizerts/results/orderby_limit_01.plan
----------------------------------------------------------------------
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|

http://git-wip-us.apache.org/repos/asf/incubator-asterixdb/blob/760ce904/asterix-app/src/test/resources/optimizerts/results/orderby_limit_offset_01.plan
----------------------------------------------------------------------
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|

http://git-wip-us.apache.org/repos/asf/incubator-asterixdb/blob/760ce904/asterix-app/src/test/resources/optimizerts/results/orderby_limit_primary_index_01.plan
----------------------------------------------------------------------
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|

http://git-wip-us.apache.org/repos/asf/incubator-asterixdb/blob/760ce904/asterix-app/src/test/resources/optimizerts/results/q03_shipping_priority.plan
----------------------------------------------------------------------
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|
                             {

http://git-wip-us.apache.org/repos/asf/incubator-asterixdb/blob/760ce904/asterix-app/src/test/resources/optimizerts/results/q2.plan
----------------------------------------------------------------------
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|
                             {

http://git-wip-us.apache.org/repos/asf/incubator-asterixdb/blob/760ce904/asterix-app/src/test/resources/optimizerts/results/sort-cust.plan
----------------------------------------------------------------------
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|

http://git-wip-us.apache.org/repos/asf/incubator-asterixdb/blob/760ce904/asterix-app/src/test/resources/runtimets/queries/index-selection/btree-index-limit-orderby-01/btree-index-limit-orderby-01.1.ddl.aql
----------------------------------------------------------------------
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;

http://git-wip-us.apache.org/repos/asf/incubator-asterixdb/blob/760ce904/asterix-app/src/test/resources/runtimets/queries/index-selection/btree-index-limit-orderby-01/btree-index-limit-orderby-01.2.update.aql
----------------------------------------------------------------------
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"));
+

http://git-wip-us.apache.org/repos/asf/incubator-asterixdb/blob/760ce904/asterix-app/src/test/resources/runtimets/queries/index-selection/btree-index-limit-orderby-01/btree-index-limit-orderby-01.3.query.aql
----------------------------------------------------------------------
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}

http://git-wip-us.apache.org/repos/asf/incubator-asterixdb/blob/760ce904/asterix-app/src/test/resources/runtimets/queries/index-selection/btree-index-limit-orderby-02/btree-index-limit-orderby-02.1.ddl.aql
----------------------------------------------------------------------
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;

http://git-wip-us.apache.org/repos/asf/incubator-asterixdb/blob/760ce904/asterix-app/src/test/resources/runtimets/queries/index-selection/btree-index-limit-orderby-02/btree-index-limit-orderby-02.2.update.aql
----------------------------------------------------------------------
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"));
+

http://git-wip-us.apache.org/repos/asf/incubator-asterixdb/blob/760ce904/asterix-app/src/test/resources/runtimets/queries/index-selection/btree-index-limit-orderby-02/btree-index-limit-orderby-02.3.query.aql
----------------------------------------------------------------------
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}

http://git-wip-us.apache.org/repos/asf/incubator-asterixdb/blob/760ce904/asterix-app/src/test/resources/runtimets/queries/orderby_limit/orderby_limit_01/orderby_limit_01.1.ddl.aql
----------------------------------------------------------------------
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;

http://git-wip-us.apache.org/repos/asf/incubator-asterixdb/blob/760ce904/asterix-app/src/test/resources/runtimets/queries/orderby_limit/orderby_limit_01/orderby_limit_01.2.update.aql
----------------------------------------------------------------------
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"));
+

http://git-wip-us.apache.org/repos/asf/incubator-asterixdb/blob/760ce904/asterix-app/src/test/resources/runtimets/queries/orderby_limit/orderby_limit_01/orderby_limit_01.3.query.aql
----------------------------------------------------------------------
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}

http://git-wip-us.apache.org/repos/asf/incubator-asterixdb/blob/760ce904/asterix-app/src/test/resources/runtimets/queries/orderby_limit/orderby_limit_offset_01/orderby_limit_offset_01.1.ddl.aql
----------------------------------------------------------------------
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;

http://git-wip-us.apache.org/repos/asf/incubator-asterixdb/blob/760ce904/asterix-app/src/test/resources/runtimets/queries/orderby_limit/orderby_limit_offset_01/orderby_limit_offset_01.2.update.aql
----------------------------------------------------------------------
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"));
+

http://git-wip-us.apache.org/repos/asf/incubator-asterixdb/blob/760ce904/asterix-app/src/test/resources/runtimets/queries/orderby_limit/orderby_limit_offset_01/orderby_limit_offset_01.3.query.aql
----------------------------------------------------------------------
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}



Mime
View raw message