asterixdb-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Taewoo Kim (Code Review)" <do-not-re...@asterix-gerrit.ics.uci.edu>
Subject Change in asterixdb[master]: Fixed issue 920: consecutive index-nested-loop joins fail. C...
Date Sat, 08 Aug 2015 03:43:29 GMT
Taewoo Kim has uploaded a new change for review.

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

Change subject: Fixed issue 920: consecutive index-nested-loop joins fail. Change-Id: I63e445950aaf5f1e756757c9f1d6167a6fe6b12b
......................................................................

Fixed issue 920: consecutive index-nested-loop joins fail.
Change-Id: I63e445950aaf5f1e756757c9f1d6167a6fe6b12b
---
M asterix-algebra/src/main/java/edu/uci/ics/asterix/optimizer/rules/am/AbstractIntroduceAccessMethodRule.java
M asterix-algebra/src/main/java/edu/uci/ics/asterix/optimizer/rules/am/OptimizableOperatorSubTree.java
A asterix-app/data/index-join/results.adm
A asterix-app/data/index-join/tw_messages.adm
A asterix-app/data/index-join/tw_users.adm
A asterix-app/src/test/resources/runtimets/queries/index-join/btree-index-nested-loop-join/btree-index-nested-loop-join.1.ddl.aql
A asterix-app/src/test/resources/runtimets/queries/index-join/btree-index-nested-loop-join/btree-index-nested-loop-join.2.update.aql
A asterix-app/src/test/resources/runtimets/queries/index-join/btree-index-nested-loop-join/btree-index-nested-loop-join.3.query.aql
A asterix-app/src/test/resources/runtimets/results/index-join/btree-index-nested-loop-join/btree-index-nested-loop-join.1.adm
M asterix-app/src/test/resources/runtimets/testsuite.xml
10 files changed, 357 insertions(+), 54 deletions(-)


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

diff --git a/asterix-algebra/src/main/java/edu/uci/ics/asterix/optimizer/rules/am/AbstractIntroduceAccessMethodRule.java
b/asterix-algebra/src/main/java/edu/uci/ics/asterix/optimizer/rules/am/AbstractIntroduceAccessMethodRule.java
index 0e4270a..f58ede0 100644
--- a/asterix-algebra/src/main/java/edu/uci/ics/asterix/optimizer/rules/am/AbstractIntroduceAccessMethodRule.java
+++ b/asterix-algebra/src/main/java/edu/uci/ics/asterix/optimizer/rules/am/AbstractIntroduceAccessMethodRule.java
@@ -505,6 +505,7 @@
             // Try to match variables from optFuncExpr to datasourcescan if not
             // already matched in assigns.
             List<LogicalVariable> dsVarList = subTree.getDataSourceVariables();
+
             for (int varIndex = 0; varIndex < dsVarList.size(); varIndex++) {
                 LogicalVariable var = dsVarList.get(varIndex);
                 int funcVarIndex = optFuncExpr.findLogicalVar(var);
@@ -528,6 +529,41 @@
                             subTree, analysisCtx);
                 }
             }
+
+            // If there is one more datasource in the subtree, we need to scan that datasource,
too.
+            List<LogicalVariable> additionalDsVarList = null;
+
+            if (subTree.hasAdditionalDataSource()) {
+                additionalDsVarList = new ArrayList<LogicalVariable>();
+                for (int i = 0; i < subTree.additionalDataSourceRefs.size(); i++) {
+                    additionalDsVarList.addAll(subTree.getAdditionalDataSourceVariables(i));
+                }
+                for (int varIndex = 0; varIndex < additionalDsVarList.size(); varIndex++)
{
+                    LogicalVariable var = additionalDsVarList.get(varIndex);
+                    int funcVarIndex = optFuncExpr.findLogicalVar(var);
+                    // No matching var in optFuncExpr.
+                    if (funcVarIndex == -1) {
+                        continue;
+                    }
+                    // The variable value is one of the partitioning fields.
+                    List<String> fieldName = DatasetUtils.getPartitioningKeys(subTree.additionalDatasets.get(varIndex))
+                            .get(varIndex);
+                    IAType fieldType = (IAType) context.getOutputTypeEnvironment(
+                            subTree.additionalDataSourceRefs.get(varIndex).getValue()).getVarType(var);
+                    // Set the fieldName in the corresponding matched function
+                    // expression, and remember matching subtree.
+                    optFuncExpr.setFieldName(funcVarIndex, fieldName);
+                    optFuncExpr.setOptimizableSubTree(funcVarIndex, subTree);
+                    optFuncExpr.setSourceVar(funcVarIndex, var);
+                    optFuncExpr.setLogicalExpr(funcVarIndex, new VariableReferenceExpression(var));
+                    setTypeTag(context, subTree, optFuncExpr, funcVarIndex);
+                    if (subTree.hasAdditionalDataSourceScan()) {
+                        fillIndexExprs(datasetIndexes, fieldName, fieldType, optFuncExpr,
optFuncExprIndex,
+                                funcVarIndex, subTree, analysisCtx);
+                    }
+                }
+            }
+
             optFuncExprIndex++;
         }
     }
@@ -544,7 +580,7 @@
      * Returns the field name corresponding to the assigned variable at
      * varIndex. Returns null if the expr at varIndex does not yield to a field
      * access function after following a set of allowed functions.
-     * 
+     *
      * @throws AlgebricksException
      */
     protected List<String> getFieldNameFromSubTree(IOptimizableFuncExpr optFuncExpr,
@@ -655,7 +691,7 @@
                         parentFuncExpr);
 
                 if (parentFieldNames == null) {
-                    //Nested assign was not a field access. 
+                    //Nested assign was not a field access.
                     //We will not use index
                     return null;
                 }
diff --git a/asterix-algebra/src/main/java/edu/uci/ics/asterix/optimizer/rules/am/OptimizableOperatorSubTree.java
b/asterix-algebra/src/main/java/edu/uci/ics/asterix/optimizer/rules/am/OptimizableOperatorSubTree.java
index aa7a6ac..5000919 100644
--- a/asterix-algebra/src/main/java/edu/uci/ics/asterix/optimizer/rules/am/OptimizableOperatorSubTree.java
+++ b/asterix-algebra/src/main/java/edu/uci/ics/asterix/optimizer/rules/am/OptimizableOperatorSubTree.java
@@ -44,7 +44,7 @@
 
 /**
  * Operator subtree that matches the following patterns, and provides convenient access to
its nodes:
- * (select)? <-- (assign | unnest)* <-- (datasource scan | unnest-map)
+ * (select)? <-- (assign | unnest)* <-- (datasource scan | unnest-map)*
  */
 public class OptimizableOperatorSubTree {
 
@@ -62,9 +62,17 @@
     public final List<AbstractLogicalOperator> assignsAndUnnests = new ArrayList<AbstractLogicalOperator>();
     public Mutable<ILogicalOperator> dataSourceRef = null;
     public DataSourceType dataSourceType = DataSourceType.NO_DATASOURCE;
+
     // Dataset and type metadata. Set in setDatasetAndTypeMetadata().
     public Dataset dataset = null;
     public ARecordType recordType = null;
+
+    // Additional datasources can exist if IntroduceJoinAccessMethodRule has been applied.
+    // (E.g. There are index-nested-loop-joins in the plan.)
+    public List<Mutable<ILogicalOperator>> additionalDataSourceRefs = null;
+    public List<DataSourceType> additionalDataSourceTypes = null;
+    public List<Dataset> additionalDatasets = null;
+    public List<ARecordType> additionalRecordTypes = null;
 
     public boolean initFromSubTree(Mutable<ILogicalOperator> subTreeOpRef) {
         reset();
@@ -101,6 +109,7 @@
 
     private boolean initializeDataSource(Mutable<ILogicalOperator> subTreeOpRef) {
         AbstractLogicalOperator subTreeOp = (AbstractLogicalOperator) subTreeOpRef.getValue();
+
         if (subTreeOp.getOperatorTag() == LogicalOperatorTag.DATASOURCESCAN) {
             dataSourceType = DataSourceType.DATASOURCE_SCAN;
             dataSourceRef = subTreeOpRef;
@@ -114,19 +123,69 @@
             dataSourceRef = subTreeOpRef;
             return true;
         } else if (subTreeOp.getOperatorTag() == LogicalOperatorTag.UNNEST_MAP) {
-            UnnestMapOperator unnestMapOp = (UnnestMapOperator) subTreeOp;
-            ILogicalExpression unnestExpr = unnestMapOp.getExpressionRef().getValue();
-            if (unnestExpr.getExpressionTag() == LogicalExpressionTag.FUNCTION_CALL) {
-                AbstractFunctionCallExpression f = (AbstractFunctionCallExpression) unnestExpr;
-                if (f.getFunctionIdentifier().equals(AsterixBuiltinFunctions.INDEX_SEARCH))
{
-                    AccessMethodJobGenParams jobGenParams = new AccessMethodJobGenParams();
-                    jobGenParams.readFromFuncArgs(f.getArguments());
-                    if (jobGenParams.isPrimaryIndex()) {
-                        dataSourceType = DataSourceType.PRIMARY_INDEX_LOOKUP;
-                        dataSourceRef = subTreeOpRef;
-                        return true;
+            // There can be multiple unnest-map or datasource-scan operators
+            // if index-nested-loop-join has been applied by IntroduceJoinAccessMethodRule.
+            // So, we need to traverse the whole path from the subTreeOp.
+            boolean dataSourceFound = false;
+            while (true) {
+                if (subTreeOp.getOperatorTag() == LogicalOperatorTag.UNNEST_MAP) {
+                    UnnestMapOperator unnestMapOp = (UnnestMapOperator) subTreeOp;
+                    ILogicalExpression unnestExpr = unnestMapOp.getExpressionRef().getValue();
+
+                    if (unnestExpr.getExpressionTag() == LogicalExpressionTag.FUNCTION_CALL)
{
+                        AbstractFunctionCallExpression f = (AbstractFunctionCallExpression)
unnestExpr;
+                        if (f.getFunctionIdentifier().equals(AsterixBuiltinFunctions.INDEX_SEARCH))
{
+                            AccessMethodJobGenParams jobGenParams = new AccessMethodJobGenParams();
+                            jobGenParams.readFromFuncArgs(f.getArguments());
+                            if (jobGenParams.isPrimaryIndex()) {
+                                if (dataSourceRef == null) {
+                                    dataSourceRef = subTreeOpRef;
+                                    dataSourceType = DataSourceType.PRIMARY_INDEX_LOOKUP;
+                                } else {
+                                    // One datasource already exists. This is an additional
datasource.
+                                    if (additionalDataSourceRefs == null) {
+                                        initializeAddtionalDataSources();
+                                    }
+                                    additionalDataSourceTypes.add(DataSourceType.PRIMARY_INDEX_LOOKUP);
+                                    additionalDataSourceRefs.add(subTreeOpRef);
+                                }
+                                dataSourceFound = true;
+                            }
+                        }
                     }
+                } else if (subTreeOp.getOperatorTag() == LogicalOperatorTag.DATASOURCESCAN)
{
+                    if (additionalDataSourceRefs == null) {
+                        initializeAddtionalDataSources();
+                    }
+                    additionalDataSourceTypes.add(DataSourceType.DATASOURCE_SCAN);
+                    additionalDataSourceRefs.add(subTreeOpRef);
+                    dataSourceFound = true;
+                } else if (subTreeOp.getOperatorTag() == LogicalOperatorTag.EXTERNAL_LOOKUP)
{
+                    if (additionalDataSourceRefs == null) {
+                        initializeAddtionalDataSources();
+                    }
+                    additionalDataSourceTypes.add(DataSourceType.EXTERNAL_SCAN);
+                    additionalDataSourceRefs.add(subTreeOpRef);
+                    dataSourceFound = true;
+                } else if (subTreeOp.getOperatorTag() == LogicalOperatorTag.EMPTYTUPLESOURCE)
{
+                    if (additionalDataSourceRefs == null) {
+                        initializeAddtionalDataSources();
+                    }
+                    additionalDataSourceTypes.add(DataSourceType.COLLECTION_SCAN);
+                    additionalDataSourceRefs.add(subTreeOpRef);
                 }
+
+                // Traverse the subtree while there are operators in the path.
+                if (subTreeOp.hasInputs()) {
+                    subTreeOpRef = subTreeOp.getInputs().get(0);
+                    subTreeOp = (AbstractLogicalOperator) subTreeOpRef.getValue();
+                } else {
+                    break;
+                }
+            }
+
+            if (dataSourceFound) {
+                return true;
             }
         }
 
@@ -140,48 +199,93 @@
     public boolean setDatasetAndTypeMetadata(AqlMetadataProvider metadataProvider) throws
AlgebricksException {
         String dataverseName = null;
         String datasetName = null;
-        switch (dataSourceType) {
-            case DATASOURCE_SCAN:
-                DataSourceScanOperator dataSourceScan = (DataSourceScanOperator) dataSourceRef.getValue();
-                Pair<String, String> datasetInfo = AnalysisUtil.getDatasetInfo(dataSourceScan);
-                dataverseName = datasetInfo.first;
-                datasetName = datasetInfo.second;
-                break;
-            case PRIMARY_INDEX_LOOKUP:
-                AbstractUnnestOperator unnestMapOp = (AbstractUnnestOperator) dataSourceRef.getValue();
-                ILogicalExpression unnestExpr = unnestMapOp.getExpressionRef().getValue();
-                AbstractFunctionCallExpression f = (AbstractFunctionCallExpression) unnestExpr;
-                AccessMethodJobGenParams jobGenParams = new AccessMethodJobGenParams();
-                jobGenParams.readFromFuncArgs(f.getArguments());
-                datasetName = jobGenParams.getDatasetName();
-                dataverseName = jobGenParams.getDataverseName();
-                break;
-            case EXTERNAL_SCAN:
-                ExternalDataLookupOperator externalScan = (ExternalDataLookupOperator) dataSourceRef.getValue();
-                datasetInfo = AnalysisUtil.getDatasetInfo(externalScan);
-                dataverseName = datasetInfo.first;
-                datasetName = datasetInfo.second;
-                break;
-            case COLLECTION_SCAN:
-                return true;
-            case NO_DATASOURCE:
-            default:
+
+        Dataset ds = null;
+        ARecordType rType = null;
+
+        List<Mutable<ILogicalOperator>> sourceOpRefs = new ArrayList<Mutable<ILogicalOperator>>();
+        List<DataSourceType> dsTypes = new ArrayList<DataSourceType>();
+
+        sourceOpRefs.add(dataSourceRef);
+        dsTypes.add(dataSourceType);
+
+        // If there are multiple datasources in the subtree, we need to find the dataset
for these.
+        if (additionalDataSourceRefs != null) {
+            for (int i = 0; i < additionalDataSourceRefs.size(); i++) {
+                sourceOpRefs.add(additionalDataSourceRefs.get(i));
+                dsTypes.add(additionalDataSourceTypes.get(i));
+            }
+        }
+
+        for (int i = 0; i < sourceOpRefs.size(); i++) {
+            switch (dsTypes.get(i)) {
+                case DATASOURCE_SCAN:
+                    DataSourceScanOperator dataSourceScan = (DataSourceScanOperator) sourceOpRefs.get(i).getValue();
+                    Pair<String, String> datasetInfo = AnalysisUtil.getDatasetInfo(dataSourceScan);
+                    dataverseName = datasetInfo.first;
+                    datasetName = datasetInfo.second;
+                    break;
+                case PRIMARY_INDEX_LOOKUP:
+                    AbstractUnnestOperator unnestMapOp = (AbstractUnnestOperator) sourceOpRefs.get(i).getValue();
+                    ILogicalExpression unnestExpr = unnestMapOp.getExpressionRef().getValue();
+                    AbstractFunctionCallExpression f = (AbstractFunctionCallExpression) unnestExpr;
+                    AccessMethodJobGenParams jobGenParams = new AccessMethodJobGenParams();
+                    jobGenParams.readFromFuncArgs(f.getArguments());
+                    datasetName = jobGenParams.getDatasetName();
+                    dataverseName = jobGenParams.getDataverseName();
+                    break;
+                case EXTERNAL_SCAN:
+                    ExternalDataLookupOperator externalScan = (ExternalDataLookupOperator)
sourceOpRefs.get(i)
+                            .getValue();
+                    datasetInfo = AnalysisUtil.getDatasetInfo(externalScan);
+                    dataverseName = datasetInfo.first;
+                    datasetName = datasetInfo.second;
+                    break;
+                case COLLECTION_SCAN:
+                    if (i != 0) {
+                        additionalDatasets.add(null);
+                        additionalRecordTypes.add(null);
+                    }
+                    continue;
+                case NO_DATASOURCE:
+                default:
+                    return false;
+            }
+            if (dataverseName == null || datasetName == null) {
                 return false;
+            }
+            // Find the dataset corresponding to the datasource in the metadata.
+            ds = metadataProvider.findDataset(dataverseName, datasetName);
+            if (ds == null) {
+                throw new AlgebricksException("No metadata for dataset " + datasetName);
+            }
+            // Get the record type for that dataset.
+            IAType itemType = metadataProvider.findType(dataverseName, ds.getItemTypeName());
+            if (itemType.getTypeTag() != ATypeTag.RECORD) {
+                if (i == 0) {
+                    return false;
+                } else {
+                    additionalDatasets.add(null);
+                    additionalRecordTypes.add(null);
+                }
+            }
+            rType = (ARecordType) itemType;
+
+            // First index is always the primary datasource in this subtree.
+            if (i == 0) {
+                dataset = ds;
+                recordType = rType;
+            } else {
+                additionalDatasets.add(ds);
+                additionalRecordTypes.add(rType);
+            }
+
+            dataverseName = null;
+            datasetName = null;
+            ds = null;
+            rType = null;
         }
-        if (dataverseName == null || datasetName == null) {
-            return false;
-        }
-        // Find the dataset corresponding to the datasource in the metadata.
-        dataset = metadataProvider.findDataset(dataverseName, datasetName);
-        if (dataset == null) {
-            throw new AlgebricksException("No metadata for dataset " + datasetName);
-        }
-        // Get the record type for that dataset.
-        IAType itemType = metadataProvider.findType(dataverseName, dataset.getItemTypeName());
-        if (itemType.getTypeTag() != ATypeTag.RECORD) {
-            return false;
-        }
-        recordType = (ARecordType) itemType;
+
         return true;
     }
 
@@ -189,8 +293,32 @@
         return dataSourceType != DataSourceType.NO_DATASOURCE;
     }
 
+    public boolean hasAdditionalDataSource() {
+        boolean dataSourceFound = false;
+        if (additionalDataSourceTypes != null) {
+            for (int i = 0; i < additionalDataSourceTypes.size(); i++) {
+                if (additionalDataSourceTypes.get(i) != DataSourceType.NO_DATASOURCE) {
+                    dataSourceFound = true;
+                    break;
+                }
+            }
+        }
+        return dataSourceFound;
+    }
+
     public boolean hasDataSourceScan() {
         return dataSourceType == DataSourceType.DATASOURCE_SCAN;
+    }
+
+    public boolean hasAdditionalDataSourceScan() {
+        if (additionalDataSourceTypes != null) {
+            for (int i = 0; i < additionalDataSourceTypes.size(); i++) {
+                if (additionalDataSourceTypes.get(i) == DataSourceType.DATASOURCE_SCAN) {
+                    return true;
+                }
+            }
+        }
+        return false;
     }
 
     public void reset() {
@@ -200,8 +328,12 @@
         assignsAndUnnests.clear();
         dataSourceRef = null;
         dataSourceType = DataSourceType.NO_DATASOURCE;
+        additionalDataSourceRefs = null;
+        additionalDataSourceTypes = null;
         dataset = null;
+        additionalDatasets = null;
         recordType = null;
+        additionalRecordTypes = null;
     }
 
     public void getPrimaryKeyVars(List<LogicalVariable> target) throws AlgebricksException
{
@@ -239,4 +371,31 @@
                 throw new AlgebricksException("The subtree does not have any data source.");
         }
     }
+
+    public List<LogicalVariable> getAdditionalDataSourceVariables(int idx) throws AlgebricksException
{
+        if (additionalDataSourceRefs != null && additionalDataSourceRefs.size() >
idx) {
+            switch (additionalDataSourceTypes.get(idx)) {
+                case DATASOURCE_SCAN:
+                case EXTERNAL_SCAN:
+                case PRIMARY_INDEX_LOOKUP:
+                    AbstractScanOperator scanOp = (AbstractScanOperator) additionalDataSourceRefs.get(idx).getValue();
+                    return scanOp.getVariables();
+                case COLLECTION_SCAN:
+                    return new ArrayList<LogicalVariable>();
+                case NO_DATASOURCE:
+                default:
+                    throw new AlgebricksException("The subtree does not have any additional
data sources.");
+            }
+        } else {
+            return null;
+        }
+    }
+
+    public void initializeAddtionalDataSources() {
+        additionalDataSourceRefs = new ArrayList<Mutable<ILogicalOperator>>();
+        additionalDataSourceTypes = new ArrayList<DataSourceType>();
+        additionalDatasets = new ArrayList<Dataset>();
+        additionalRecordTypes = new ArrayList<ARecordType>();
+    }
+
 }
diff --git a/asterix-app/data/index-join/results.adm b/asterix-app/data/index-join/results.adm
new file mode 100644
index 0000000..6f04907
--- /dev/null
+++ b/asterix-app/data/index-join/results.adm
@@ -0,0 +1,8 @@
+{ "vertexid": 8, "rank": double("4.3815337979687034E-10d") }
+{ "vertexid": 9, "rank": double("4.3815337979687034E-10d") }
+{ "vertexid": 13, "rank": double("4.3815337979687034E-10d") }
+{ "vertexid": 17, "rank": double("4.3815337979687034E-10d") }
+{ "vertexid": 22, "rank": double("4.3815337979687034E-10d") }
+{ "vertexid": 24, "rank": double("4.3815337979687034E-10d") }
+{ "vertexid": 25, "rank": double("4.3815337979687034E-10d") }
+{ "vertexid": 34, "rank": double("4.3815337979687034E-10d") }
\ No newline at end of file
diff --git a/asterix-app/data/index-join/tw_messages.adm b/asterix-app/data/index-join/tw_messages.adm
new file mode 100644
index 0000000..445b84c
--- /dev/null
+++ b/asterix-app/data/index-join/tw_messages.adm
@@ -0,0 +1,13 @@
+{"tweetid":1,"user":"AaliyahAckerley@136","sender-location":point("35.65,84.93"),"send-time":datetime("2005-02-14T10:10:00"),"forward-from":-1,"retweet-from":-1,"referred-topics":{{"motorola","customer-service"}},"message-text":"
like motorola the customer-service is amazing"}
+{"tweetid":2,"user":"VerniaHerndon_714","sender-location":point("45.37,82.91"),"send-time":datetime("2007-04-27T10:10:00"),"forward-from":-1,"retweet-from":-1,"referred-topics":{{"sprint","network"}},"message-text":"
hate sprint its network is horrible:("}
+{"tweetid":3,"user":"VerniaHerndon_714","sender-location":point("31.54,73.22"),"send-time":datetime("2009-12-20T10:10:00"),"forward-from":-1,"retweet-from":-1,"referred-topics":{{"motorola","signal"}},"message-text":"
love motorola the signal is good:)"}
+{"tweetid":4,"user":"VerniaHerndon_714","sender-location":point("35.64,71.08"),"send-time":datetime("2006-03-19T10:10:00"),"forward-from":-1,"retweet-from":-1,"referred-topics":{{"at&t","voicemail-service"}},"message-text":"
like at&t its voicemail-service is awesome"}
+{"tweetid":5,"user":"VerniaHerndon_714","sender-location":point("40.69,92.3"),"send-time":datetime("2008-04-08T10:10:00"),"forward-from":-1,"retweet-from":-1,"referred-topics":{{"iphone","plan"}},"message-text":"
love iphone the plan is amazing:)"}
+{"tweetid":6,"user":"VerniaHerndon_714","sender-location":point("35.53,97.61"),"send-time":datetime("2010-01-05T10:10:00"),"forward-from":-1,"retweet-from":-1,"referred-topics":{{"at&t","network"}},"message-text":"
like at&t its network is good"}
+{"tweetid":7,"user":"VerniaHerndon_714","sender-location":point("25.29,85.77"),"send-time":datetime("2008-10-08T10:10:00"),"forward-from":-1,"retweet-from":-1,"referred-topics":{{"at&t","speed"}},"message-text":"
can't stand at&t its speed is terrible:("}
+{"tweetid":8,"user":"VerniaHerndon_714","sender-location":point("26.08,83.01"),"send-time":datetime("2007-04-14T10:10:00"),"forward-from":8831723361,"retweet-from":-1,"referred-topics":{{"motorola","network"}},"message-text":"
hate motorola the network is horrible"}
+{"tweetid":9,"user":"VerniaHerndon_714","sender-location":point("40.38,73.48"),"send-time":datetime("2006-10-10T10:10:00"),"forward-from":-1,"retweet-from":3258345607,"referred-topics":{{"verizon","shortcut-menu"}},"message-text":"
love verizon the shortcut-menu is awesome:)"}
+{"tweetid":10,"user":"VerniaHerndon_714","sender-location":point("47.42,68.06"),"send-time":datetime("2011-11-18T10:10:00"),"forward-from":-1,"retweet-from":-1,"referred-topics":{{"samsung","customization"}},"message-text":"
love samsung the customization is mind-blowing"}
+{"tweetid":11,"user":"VerniaHerndon_714","sender-location":point("27.95,95.22"),"send-time":datetime("2006-10-24T10:10:00"),"forward-from":-1,"retweet-from":-1,"referred-topics":{{"at&t","voice-clarity"}},"message-text":"
dislike at&t the voice-clarity is bad"}
+{"tweetid":12,"user":"VerniaHerndon_714","sender-location":point("37.68,96.92"),"send-time":datetime("2007-06-28T10:10:00"),"forward-from":-1,"retweet-from":-1,"referred-topics":{{"samsung","customization"}},"message-text":"
dislike samsung its customization is OMG:("}
+{"tweetid":13,"user":"VerniaHerndon_714","sender-location":point("33.25,67.32"),"send-time":datetime("2007-08-19T10:10:00"),"forward-from":1231614665,"retweet-from":-1,"referred-topics":{{"sprint","plan"}},"message-text":"
love sprint the plan is good"}
\ No newline at end of file
diff --git a/asterix-app/data/index-join/tw_users.adm b/asterix-app/data/index-join/tw_users.adm
new file mode 100644
index 0000000..299adc3
--- /dev/null
+++ b/asterix-app/data/index-join/tw_users.adm
@@ -0,0 +1,12 @@
+{"screen-name":"AaliyahAckerley@136","lang":"en","friends_count":6148151,"statuses_count":131,"name":"Aaliyah
Ackerley","followers_count":4843658}
+{"screen-name":"AaliyahAckerley_586","lang":"en","friends_count":14590365,"statuses_count":54,"name":"Aaliyah
Ackerley","followers_count":1866794}
+{"screen-name":"AaliyahAdams#87","lang":"en","friends_count":3808840,"statuses_count":385,"name":"Aaliyah
Adams","followers_count":7511412}
+{"screen-name":"AaliyahAdams#977","lang":"en","friends_count":11060186,"statuses_count":452,"name":"Aaliyah
Adams","followers_count":240575}
+{"screen-name":"AaliyahAdams_995","lang":"en","friends_count":12240342,"statuses_count":466,"name":"Aaliyah
Adams","followers_count":9042070}
+{"screen-name":"AaliyahAgg#257","lang":"en","friends_count":1787009,"statuses_count":49,"name":"Aaliyah
Agg","followers_count":1368140}
+{"screen-name":"AaliyahAgg$544","lang":"en","friends_count":9576364,"statuses_count":14,"name":"Aaliyah
Agg","followers_count":11032599}
+{"screen-name":"AaliyahAkers#573","lang":"en","friends_count":871157,"statuses_count":439,"name":"Aaliyah
Akers","followers_count":10481754}
+{"screen-name":"AaliyahAlbright@317","lang":"en","friends_count":12759158,"statuses_count":257,"name":"Aaliyah
Albright","followers_count":1769056}
+{"screen-name":"VerniaHerndon_714","lang":"en","friends_count":12388156,"statuses_count":448,"name":"Aaliyah
Alcocke","followers_count":594008}
+{"screen-name":"AaliyahAlcocke_869","lang":"en","friends_count":2365292,"statuses_count":442,"name":"Aaliyah
Alcocke","followers_count":8066644}
+{"screen-name":"AaliyahAlington@332","lang":"en","friends_count":9864476,"statuses_count":153,"name":"Aaliyah
Alington","followers_count":3071616}
diff --git a/asterix-app/src/test/resources/runtimets/queries/index-join/btree-index-nested-loop-join/btree-index-nested-loop-join.1.ddl.aql
b/asterix-app/src/test/resources/runtimets/queries/index-join/btree-index-nested-loop-join/btree-index-nested-loop-join.1.ddl.aql
new file mode 100644
index 0000000..f31e58a
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries/index-join/btree-index-nested-loop-join/btree-index-nested-loop-join.1.ddl.aql
@@ -0,0 +1,42 @@
+/*
+ * Description    : Index Nested Loop Join on three datasets. Two index nested loop joins
should be nested properly.
+ * Success        : Yes
+ */
+
+drop dataverse test if exists;
+create dataverse test;
+
+use dataverse test;
+
+create type TwitterUserType as {
+	screen-name: string,
+	lang: string,
+	friends_count: int32,
+	statuses_count: int32,
+	name: string,
+	followers_count: int32
+}
+
+create type TweetMessageType as {
+	tweetid: int64,
+	user: string,
+	sender-location: point,
+	send-time: datetime,
+	forward-from: int64,
+	retweet-from: int64,
+	referred-topics: {{ string }},
+	message-text: string
+}
+
+create type ResultType as {
+	vertexid: int64,
+	rank: double
+}
+
+create dataset TwitterUsers(TwitterUserType) primary key screen-name;
+
+create dataset TweetMessages(TweetMessageType) primary key tweetid;
+
+create dataset results(ResultType) primary key vertexid;
+
+
diff --git a/asterix-app/src/test/resources/runtimets/queries/index-join/btree-index-nested-loop-join/btree-index-nested-loop-join.2.update.aql
b/asterix-app/src/test/resources/runtimets/queries/index-join/btree-index-nested-loop-join/btree-index-nested-loop-join.2.update.aql
new file mode 100644
index 0000000..d6be87a
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries/index-join/btree-index-nested-loop-join/btree-index-nested-loop-join.2.update.aql
@@ -0,0 +1,13 @@
+use dataverse test;
+
+load dataset TweetMessages
+using "edu.uci.ics.asterix.external.dataset.adapter.NCFileSystemAdapter"
+(("path"="nc1://data/index-join/tw_messages.adm"),("format"="adm"));
+
+load dataset TwitterUsers
+using "edu.uci.ics.asterix.external.dataset.adapter.NCFileSystemAdapter"
+(("path"="nc1://data/index-join/tw_users.adm"),("format"="adm"));
+
+load dataset results
+using "edu.uci.ics.asterix.external.dataset.adapter.NCFileSystemAdapter"
+(("path"="nc1://data/index-join/results.adm"),("format"="adm"));
diff --git a/asterix-app/src/test/resources/runtimets/queries/index-join/btree-index-nested-loop-join/btree-index-nested-loop-join.3.query.aql
b/asterix-app/src/test/resources/runtimets/queries/index-join/btree-index-nested-loop-join/btree-index-nested-loop-join.3.query.aql
new file mode 100644
index 0000000..5cb73aa
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries/index-join/btree-index-nested-loop-join/btree-index-nested-loop-join.3.query.aql
@@ -0,0 +1,11 @@
+use dataverse test;
+
+for $tu in dataset TwitterUsers
+for $tm in dataset TweetMessages
+for $r in dataset results
+    where
+       $r.vertexid /*+ indexnl */ = $tm.tweetid
+       and
+       $tm.user  /*+ indexnl */ = $tu.screen-name
+    order by $tm.tweetid
+	return $tm.tweetid;
diff --git a/asterix-app/src/test/resources/runtimets/results/index-join/btree-index-nested-loop-join/btree-index-nested-loop-join.1.adm
b/asterix-app/src/test/resources/runtimets/results/index-join/btree-index-nested-loop-join/btree-index-nested-loop-join.1.adm
new file mode 100644
index 0000000..4f7a33a
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results/index-join/btree-index-nested-loop-join/btree-index-nested-loop-join.1.adm
@@ -0,0 +1,4 @@
+[ 8
+, 9
+, 13
+ ]
diff --git a/asterix-app/src/test/resources/runtimets/testsuite.xml b/asterix-app/src/test/resources/runtimets/testsuite.xml
index 898d847..9c79c19 100644
--- a/asterix-app/src/test/resources/runtimets/testsuite.xml
+++ b/asterix-app/src/test/resources/runtimets/testsuite.xml
@@ -2475,6 +2475,11 @@
     </test-group> -->
     <test-group name="index-join">
         <test-case FilePath="index-join">
+            <compilation-unit name="btree-index-nested-loop-join">
+                <output-dir compare="Text">btree-index-nested-loop-join</output-dir>
+            </compilation-unit>
+        </test-case>
+        <test-case FilePath="index-join">
             <compilation-unit name="btree-primary-equi-join">
                 <output-dir compare="Text">btree-primary-equi-join</output-dir>
             </compilation-unit>

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

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

Mime
View raw message