asterixdb-notifications mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Taewoo Kim (Code Review)" <do-not-re...@asterixdb.incubator.apache.org>
Subject Change in asterixdb[master]: ASTERIXDB-1231: fixed Self-join with index-out-of-bound exce...
Date Sun, 14 Feb 2016 23:18:22 GMT
Taewoo Kim has uploaded a new change for review.

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

Change subject: ASTERIXDB-1231: fixed Self-join with index-out-of-bound exception
......................................................................

ASTERIXDB-1231: fixed Self-join with index-out-of-bound exception

 - Fixed self-join with index-out-of-boud exception during the compilation

Change-Id: I8d5d9cb0cb54473fbe7a5e43934e9608548c1dbb
---
M asterix-algebra/src/main/java/org/apache/asterix/optimizer/rules/am/AbstractIntroduceAccessMethodRule.java
1 file changed, 26 insertions(+), 10 deletions(-)


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

diff --git a/asterix-algebra/src/main/java/org/apache/asterix/optimizer/rules/am/AbstractIntroduceAccessMethodRule.java
b/asterix-algebra/src/main/java/org/apache/asterix/optimizer/rules/am/AbstractIntroduceAccessMethodRule.java
index 1531b8a..cabc1e3 100644
--- a/asterix-algebra/src/main/java/org/apache/asterix/optimizer/rules/am/AbstractIntroduceAccessMethodRule.java
+++ b/asterix-algebra/src/main/java/org/apache/asterix/optimizer/rules/am/AbstractIntroduceAccessMethodRule.java
@@ -168,8 +168,8 @@
                 //                           LENGTH_PARTITIONED_NGRAM_INVIX]
                 IAccessMethod chosenAccessMethod = amEntry.getKey();
                 Index chosenIndex = indexEntry.getKey();
-                boolean isKeywordOrNgramIndexChosen =
-                        chosenIndex.getIndexType() == IndexType.LENGTH_PARTITIONED_WORD_INVIX
+                boolean isKeywordOrNgramIndexChosen = chosenIndex
+                        .getIndexType() == IndexType.LENGTH_PARTITIONED_WORD_INVIX
                         || chosenIndex.getIndexType() == IndexType.LENGTH_PARTITIONED_NGRAM_INVIX
                         || chosenIndex.getIndexType() == IndexType.SINGLE_PARTITION_WORD_INVIX
                         || chosenIndex.getIndexType() == IndexType.SINGLE_PARTITION_NGRAM_INVIX;
@@ -184,7 +184,6 @@
         }
         return result;
     }
-
 
     /**
      * Removes irrelevant access methods candidates, based on whether the
@@ -574,16 +573,33 @@
             // The variable value is one of the partitioning fields.
             List<String> fieldName = null;
             IAType fieldType = null;
+            List<List<String>> subTreePKs = null;
 
             if (!fromAdditionalDataSource) {
-                fieldName = DatasetUtils.getPartitioningKeys(subTree.dataset).get(varIndex);
-                fieldType = (IAType) context.getOutputTypeEnvironment(subTree.dataSourceRef.getValue()).getVarType(var);
+                subTreePKs = DatasetUtils.getPartitioningKeys(subTree.dataset);
+                // Check whether this variable is PK, not a record variable.
+                if (varIndex <= subTreePKs.size() - 1) {
+                    fieldName = subTreePKs.get(varIndex);
+                    fieldType = (IAType) context.getOutputTypeEnvironment(subTree.dataSourceRef.getValue())
+                            .getVarType(var);
+                }
             } else {
-                fieldName = DatasetUtils.getPartitioningKeys(subTree.ixJoinOuterAdditionalDatasets.get(varIndex))
-                        .get(varIndex);
-                fieldType = (IAType) context
-                        .getOutputTypeEnvironment(subTree.ixJoinOuterAdditionalDataSourceRefs.get(varIndex).getValue())
-                        .getVarType(var);
+                // Need to check additional dataset one by one
+                for (int i = 0; i < subTree.ixJoinOuterAdditionalDatasets.size(); i++)
{
+                    if (subTree.ixJoinOuterAdditionalDatasets.get(i) != null) {
+                        subTreePKs = DatasetUtils.getPartitioningKeys(subTree.ixJoinOuterAdditionalDatasets.get(i));
+
+                        // Check whether this variable is PK, not a record variable.
+                        if (subTreePKs.contains(var) && varIndex <= subTreePKs.size()
- 1) {
+                            fieldName = subTreePKs.get(varIndex);
+                            fieldType = (IAType) context
+                                    .getOutputTypeEnvironment(
+                                            subTree.ixJoinOuterAdditionalDataSourceRefs.get(i).getValue())
+                                    .getVarType(var);
+                            break;
+                        }
+                    }
+                }
             }
             // Set the fieldName in the corresponding matched function
             // expression, and remember matching subtree.

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

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

Mime
View raw message