Taewoo Kim has uploaded a new change for review.

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

Change subject: ASTERIXDB-1154: index-left-outer-join with LIMIT now works.
......................................................................

ASTERIXDB-1154: index-left-outer-join with LIMIT now works.

Change-Id: I93591e6cc5aa19751466136a7ecdee871ba67f83
---
M 
asterix-algebra/src/main/java/org/apache/asterix/optimizer/rules/am/OptimizableOperatorSubTree.java
A 
asterix-app/src/test/resources/runtimets/queries/index-leftouterjoin/probe-pidx-with-join-btree-sidx1-orderby-limit-01/probe-pidx-with-join-btree-sidx1-orderby-limit-01.1.ddl.aql
A 
asterix-app/src/test/resources/runtimets/queries/index-leftouterjoin/probe-pidx-with-join-btree-sidx1-orderby-limit-01/probe-pidx-with-join-btree-sidx1-orderby-limit-01.2.update.aql
A 
asterix-app/src/test/resources/runtimets/queries/index-leftouterjoin/probe-pidx-with-join-btree-sidx1-orderby-limit-01/probe-pidx-with-join-btree-sidx1-orderby-limit-01.3.query.aql
M asterix-app/src/test/resources/runtimets/testsuite.xml
5 files changed, 143 insertions(+), 3 deletions(-)


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

diff --git 
a/asterix-algebra/src/main/java/org/apache/asterix/optimizer/rules/am/OptimizableOperatorSubTree.java
 
b/asterix-algebra/src/main/java/org/apache/asterix/optimizer/rules/am/OptimizableOperatorSubTree.java
index 8d28c62..a8b8787 100644
--- 
a/asterix-algebra/src/main/java/org/apache/asterix/optimizer/rules/am/OptimizableOperatorSubTree.java
+++ 
b/asterix-algebra/src/main/java/org/apache/asterix/optimizer/rules/am/OptimizableOperatorSubTree.java
@@ -21,8 +21,6 @@
 import java.util.ArrayList;
 import java.util.List;
 
-import org.apache.commons.lang3.mutable.Mutable;
-
 import org.apache.asterix.metadata.declared.AqlMetadataProvider;
 import org.apache.asterix.metadata.entities.Dataset;
 import org.apache.asterix.metadata.utils.DatasetUtils;
@@ -31,6 +29,7 @@
 import org.apache.asterix.om.types.ATypeTag;
 import org.apache.asterix.om.types.IAType;
 import org.apache.asterix.optimizer.base.AnalysisUtil;
+import org.apache.commons.lang3.mutable.Mutable;
 import org.apache.hyracks.algebricks.common.exceptions.AlgebricksException;
 import org.apache.hyracks.algebricks.common.utils.Pair;
 import org.apache.hyracks.algebricks.core.algebra.base.ILogicalExpression;
@@ -85,7 +84,17 @@
         // Examine the op's children to match the expected patterns.
         AbstractLogicalOperator subTreeOp = (AbstractLogicalOperator) 
subTreeOpRef.getValue();
         do {
-            // Skip select operator.
+            // Skip LIMIT operator if exists.
+            if (subTreeOp.getOperatorTag() == LogicalOperatorTag.LIMIT) {
+                subTreeOpRef = subTreeOp.getInputs().get(0);
+                subTreeOp = (AbstractLogicalOperator) subTreeOpRef.getValue();
+            }
+            // Skip ORDER operator if exists.
+            if (subTreeOp.getOperatorTag() == LogicalOperatorTag.ORDER) {
+                subTreeOpRef = subTreeOp.getInputs().get(0);
+                subTreeOp = (AbstractLogicalOperator) subTreeOpRef.getValue();
+            }
+            // Skip SELECT operator.
             if (subTreeOp.getOperatorTag() == LogicalOperatorTag.SELECT) {
                 subTreeOpRef = subTreeOp.getInputs().get(0);
                 subTreeOp = (AbstractLogicalOperator) subTreeOpRef.getValue();
diff --git 
a/asterix-app/src/test/resources/runtimets/queries/index-leftouterjoin/probe-pidx-with-join-btree-sidx1-orderby-limit-01/probe-pidx-with-join-btree-sidx1-orderby-limit-01.1.ddl.aql
 
b/asterix-app/src/test/resources/runtimets/queries/index-leftouterjoin/probe-pidx-with-join-btree-sidx1-orderby-limit-01/probe-pidx-with-join-btree-sidx1-orderby-limit-01.1.ddl.aql
new file mode 100644
index 0000000..63d1234
--- /dev/null
+++ 
b/asterix-app/src/test/resources/runtimets/queries/index-leftouterjoin/probe-pidx-with-join-btree-sidx1-orderby-limit-01/probe-pidx-with-join-btree-sidx1-orderby-limit-01.1.ddl.aql
@@ -0,0 +1,56 @@
+/*
+ * 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  : Test that left-outer-join may use two available indexes, one 
for primary index in prob subtree and another for secondary btree index in 
index subtree.
+ *                             : There is also LIMIT in the left (outer) side.
+ * Issue        : ASTERIXDB-1154
+ * Expected Res : Success
+ */
+
+drop dataverse test if exists;
+create dataverse test;
+use dataverse test;
+
+create type TwitterUserType as closed {
+    screen-name: string,
+    lang: string,
+    friends-count: int64,
+    statuses-count: int64,
+    name: string,
+    followers-count: int64
+}
+
+create type TweetMessageType as closed {
+    tweetid: int64,
+        user: TwitterUserType,
+        sender-location: point,
+    send-time: datetime,
+        referred-topics: {{ string }},
+    message-text: string,
+    countA: int64,
+    countB: int64
+}
+
+create dataset TweetMessages(TweetMessageType)
+primary key tweetid;
+
+create index twmSndLocIx on TweetMessages(sender-location) type rtree;
+create index msgCountAIx on TweetMessages(countA) type btree;
+create index msgCountBIx on TweetMessages(countB) type btree;
+create index msgTextIx on TweetMessages(message-text) type keyword;
diff --git 
a/asterix-app/src/test/resources/runtimets/queries/index-leftouterjoin/probe-pidx-with-join-btree-sidx1-orderby-limit-01/probe-pidx-with-join-btree-sidx1-orderby-limit-01.2.update.aql
 
b/asterix-app/src/test/resources/runtimets/queries/index-leftouterjoin/probe-pidx-with-join-btree-sidx1-orderby-limit-01/probe-pidx-with-join-btree-sidx1-orderby-limit-01.2.update.aql
new file mode 100644
index 0000000..ad8d3ad
--- /dev/null
+++ 
b/asterix-app/src/test/resources/runtimets/queries/index-leftouterjoin/probe-pidx-with-join-btree-sidx1-orderby-limit-01/probe-pidx-with-join-btree-sidx1-orderby-limit-01.2.update.aql
@@ -0,0 +1,30 @@
+/*
+ * 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  : Test that left-outer-join may use two available indexes, one 
for primary index in prob subtree and another for secondary btree index in 
index subtree.
+ *                             : There is also LIMIT in the left (outer) side.
+ * Issue        : ASTERIXDB-1154
+ * Expected Res : Success
+ */
+
+use dataverse test;
+
+load dataset TweetMessages 
+using "org.apache.asterix.external.dataset.adapter.NCFileSystemAdapter"
+(("path"="nc1://data/twitter/tw_for_indexleftouterjoin.adm"),("format"="adm"));
diff --git 
a/asterix-app/src/test/resources/runtimets/queries/index-leftouterjoin/probe-pidx-with-join-btree-sidx1-orderby-limit-01/probe-pidx-with-join-btree-sidx1-orderby-limit-01.3.query.aql
 
b/asterix-app/src/test/resources/runtimets/queries/index-leftouterjoin/probe-pidx-with-join-btree-sidx1-orderby-limit-01/probe-pidx-with-join-btree-sidx1-orderby-limit-01.3.query.aql
new file mode 100644
index 0000000..04c8847
--- /dev/null
+++ 
b/asterix-app/src/test/resources/runtimets/queries/index-leftouterjoin/probe-pidx-with-join-btree-sidx1-orderby-limit-01/probe-pidx-with-join-btree-sidx1-orderby-limit-01.3.query.aql
@@ -0,0 +1,40 @@
+/*
+ * 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  : Test that left-outer-join may use two available indexes, one 
for primary index in prob subtree and another for secondary btree index in 
index subtree.
+ *                             : There is also LIMIT in the left (outer) side.
+ * Issue        : ASTERIXDB-1154
+ * Expected Res : Success
+ */
+
+use dataverse test;
+
+for $t1 in dataset('TweetMessages')
+where $t1.tweetid < int64("10")
+order by $t1.tweetid
+limit 3
+return {
+"tweetid1": $t1.tweetid,
+"count1":$t1.countA,
+"t2info": for $t2 in dataset('TweetMessages')
+          where $t1.countA /* +indexnl */= $t2.countB
+          order by $t2.tweetid
+          return {"tweetid2": $t2.tweetid,
+                  "count2":$t2.countB}
+};
diff --git a/asterix-app/src/test/resources/runtimets/testsuite.xml 
b/asterix-app/src/test/resources/runtimets/testsuite.xml
index aef2b54..c6e61e5 100644
--- a/asterix-app/src/test/resources/runtimets/testsuite.xml
+++ b/asterix-app/src/test/resources/runtimets/testsuite.xml
@@ -6431,6 +6431,11 @@
                 <output-dir 
compare="Text">probe-pidx-with-join-invidx-sidx2</output-dir>
             </compilation-unit>
         </test-case>
+        <test-case FilePath="index-leftouterjoin">
+            <compilation-unit 
name="probe-pidx-with-join-btree-sidx1-orderby-limit-01">
+                <output-dir 
compare="Text">probe-pidx-with-join-btree-sidx1-orderby-limit-01</output-dir>
+            </compilation-unit>
+        </test-case>
     </test-group>
     <test-group name="distinct">
         <test-case FilePath="distinct">

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

Gerrit-MessageType: newchange
Gerrit-Change-Id: I93591e6cc5aa19751466136a7ecdee871ba67f83
Gerrit-PatchSet: 1
Gerrit-Project: asterixdb
Gerrit-Branch: master
Gerrit-Owner: Taewoo Kim <[email protected]>

Reply via email to