asterixdb-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ima...@apache.org
Subject incubator-asterixdb git commit: Make index selection deterministic when multiple avaialbe indexes are available.
Date Wed, 13 May 2015 22:04:52 GMT
Repository: incubator-asterixdb
Updated Branches:
  refs/heads/master 7515fc5cd -> f61bdb807


Make index selection deterministic when multiple avaialbe indexes are available.

The priority of indexes is as follows:
1. First choice primary B+ tree
2. Second choice some other B+ tree
3. Third choice some R tree
4. Finally, choose based on index/dataset/dataverse name strings.

Change-Id: I5a24d9ab407568c3241cdaf9255643e912874384
Reviewed-on: https://asterix-gerrit.ics.uci.edu/264
Tested-by: Jenkins <jenkins@fulliautomatix.ics.uci.edu>
Reviewed-by: Ian Maxon <imaxon@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/f61bdb80
Tree: http://git-wip-us.apache.org/repos/asf/incubator-asterixdb/tree/f61bdb80
Diff: http://git-wip-us.apache.org/repos/asf/incubator-asterixdb/diff/f61bdb80

Branch: refs/heads/master
Commit: f61bdb8072c0382fb0ec38d35cc3af408e5dea01
Parents: 7515fc5
Author: Yingyi Bu <yingyi@couchbase.com>
Authored: Wed May 13 13:31:37 2015 -0700
Committer: Ian Maxon <imaxon@uci.edu>
Committed: Wed May 13 15:02:53 2015 -0700

----------------------------------------------------------------------
 .../rules/am/AccessMethodAnalysisContext.java   |  9 +++--
 .../word-fuzzyeq-jaccard_04.plan                |  6 +--
 .../word-fuzzyeq-jaccard_04.plan                |  4 +-
 .../word-jaccard-check_04.plan                  |  4 +-
 .../inverted-index-join/word-jaccard_04.plan    |  4 +-
 .../rtree-index-join/query-issue838.plan        |  6 +--
 .../ics/asterix/metadata/entities/Index.java    | 40 +++++++++++++++++++-
 7 files changed, 56 insertions(+), 17 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-asterixdb/blob/f61bdb80/asterix-algebra/src/main/java/edu/uci/ics/asterix/optimizer/rules/am/AccessMethodAnalysisContext.java
----------------------------------------------------------------------
diff --git a/asterix-algebra/src/main/java/edu/uci/ics/asterix/optimizer/rules/am/AccessMethodAnalysisContext.java
b/asterix-algebra/src/main/java/edu/uci/ics/asterix/optimizer/rules/am/AccessMethodAnalysisContext.java
index 28d55f3..44d3572 100644
--- a/asterix-algebra/src/main/java/edu/uci/ics/asterix/optimizer/rules/am/AccessMethodAnalysisContext.java
+++ b/asterix-algebra/src/main/java/edu/uci/ics/asterix/optimizer/rules/am/AccessMethodAnalysisContext.java
@@ -15,8 +15,9 @@
 package edu.uci.ics.asterix.optimizer.rules.am;
 
 import java.util.ArrayList;
-import java.util.HashMap;
 import java.util.List;
+import java.util.Map;
+import java.util.TreeMap;
 
 import org.apache.commons.lang3.mutable.Mutable;
 
@@ -36,13 +37,13 @@ public class AccessMethodAnalysisContext {
     // Contains candidate indexes and a list of (integer,integer) tuples that index into
matchedFuncExprs and matched variable inside this expr.
     // We are mapping from candidate indexes to a list of function expressions 
     // that match one of the index's expressions.
-    public HashMap<Index, List<Pair<Integer, Integer>>> indexExprsAndVars
= new HashMap<Index, List<Pair<Integer, Integer>>>();
+    public Map<Index, List<Pair<Integer, Integer>>> indexExprsAndVars =
new TreeMap<Index, List<Pair<Integer, Integer>>>();
 
     // Maps from index to the dataset it is indexing.
-    public HashMap<Index, Dataset> indexDatasetMap = new HashMap<Index, Dataset>();
+    public Map<Index, Dataset> indexDatasetMap = new TreeMap<Index, Dataset>();
     
     // Maps from an index to the number of matched fields in the query plan (for performing
prefix search)
-    public HashMap<Index, Integer> indexNumMatchedKeys = new HashMap<Index, Integer>();
+    public Map<Index, Integer> indexNumMatchedKeys = new TreeMap<Index, Integer>();
 
     // variables for resetting null placeholder for left-outer-join
     private Mutable<ILogicalOperator> lojGroupbyOpRef = null;

http://git-wip-us.apache.org/repos/asf/incubator-asterixdb/blob/f61bdb80/asterix-app/src/test/resources/optimizerts/results/nested-open-index/inverted-index-join/word-fuzzyeq-jaccard_04.plan
----------------------------------------------------------------------
diff --git a/asterix-app/src/test/resources/optimizerts/results/nested-open-index/inverted-index-join/word-fuzzyeq-jaccard_04.plan
b/asterix-app/src/test/resources/optimizerts/results/nested-open-index/inverted-index-join/word-fuzzyeq-jaccard_04.plan
index 1aec683..6dcb9fa 100644
--- a/asterix-app/src/test/resources/optimizerts/results/nested-open-index/inverted-index-join/word-fuzzyeq-jaccard_04.plan
+++ b/asterix-app/src/test/resources/optimizerts/results/nested-open-index/inverted-index-join/word-fuzzyeq-jaccard_04.plan
@@ -4,12 +4,12 @@
       -- ASSIGN  |PARTITIONED|
         -- STREAM_PROJECT  |PARTITIONED|
           -- ONE_TO_ONE_EXCHANGE  |PARTITIONED|
-            -- HYBRID_HASH_JOIN [$$30][$$21]  |PARTITIONED|
+            -- HYBRID_HASH_JOIN [$$30][$$20]  |PARTITIONED|
               -- ONE_TO_ONE_EXCHANGE  |PARTITIONED|
                 -- DATASOURCE_SCAN  |PARTITIONED|
                   -- ONE_TO_ONE_EXCHANGE  |PARTITIONED|
                     -- EMPTY_TUPLE_SOURCE  |PARTITIONED|
-              -- HASH_PARTITION_EXCHANGE [$$21]  |PARTITIONED|
+              -- HASH_PARTITION_EXCHANGE [$$20]  |PARTITIONED|
                 -- STREAM_PROJECT  |PARTITIONED|
                   -- STREAM_SELECT  |PARTITIONED|
                     -- ASSIGN  |PARTITIONED|
@@ -29,4 +29,4 @@
                                                 -- ONE_TO_ONE_EXCHANGE  |PARTITIONED|
                                                   -- DATASOURCE_SCAN  |PARTITIONED|
                                                     -- ONE_TO_ONE_EXCHANGE  |PARTITIONED|
-                                                      -- EMPTY_TUPLE_SOURCE  |PARTITIONED|
\ No newline at end of file
+                                                      -- EMPTY_TUPLE_SOURCE  |PARTITIONED|

http://git-wip-us.apache.org/repos/asf/incubator-asterixdb/blob/f61bdb80/asterix-app/src/test/resources/optimizerts/results/open-index-enforced/inverted-index-join/word-fuzzyeq-jaccard_04.plan
----------------------------------------------------------------------
diff --git a/asterix-app/src/test/resources/optimizerts/results/open-index-enforced/inverted-index-join/word-fuzzyeq-jaccard_04.plan
b/asterix-app/src/test/resources/optimizerts/results/open-index-enforced/inverted-index-join/word-fuzzyeq-jaccard_04.plan
index 10b34a3..420d3ea 100644
--- a/asterix-app/src/test/resources/optimizerts/results/open-index-enforced/inverted-index-join/word-fuzzyeq-jaccard_04.plan
+++ b/asterix-app/src/test/resources/optimizerts/results/open-index-enforced/inverted-index-join/word-fuzzyeq-jaccard_04.plan
@@ -4,12 +4,12 @@
       -- ASSIGN  |PARTITIONED|
         -- STREAM_PROJECT  |PARTITIONED|
           -- ONE_TO_ONE_EXCHANGE  |PARTITIONED|
-            -- HYBRID_HASH_JOIN [$$24][$$15]  |PARTITIONED|
+            -- HYBRID_HASH_JOIN [$$24][$$14]  |PARTITIONED|
               -- ONE_TO_ONE_EXCHANGE  |PARTITIONED|
                 -- DATASOURCE_SCAN  |PARTITIONED|
                   -- ONE_TO_ONE_EXCHANGE  |PARTITIONED|
                     -- EMPTY_TUPLE_SOURCE  |PARTITIONED|
-              -- HASH_PARTITION_EXCHANGE [$$15]  |PARTITIONED|
+              -- HASH_PARTITION_EXCHANGE [$$14]  |PARTITIONED|
                 -- STREAM_PROJECT  |PARTITIONED|
                   -- STREAM_SELECT  |PARTITIONED|
                     -- ASSIGN  |PARTITIONED|

http://git-wip-us.apache.org/repos/asf/incubator-asterixdb/blob/f61bdb80/asterix-app/src/test/resources/optimizerts/results/open-index-enforced/inverted-index-join/word-jaccard-check_04.plan
----------------------------------------------------------------------
diff --git a/asterix-app/src/test/resources/optimizerts/results/open-index-enforced/inverted-index-join/word-jaccard-check_04.plan
b/asterix-app/src/test/resources/optimizerts/results/open-index-enforced/inverted-index-join/word-jaccard-check_04.plan
index 27e8085..5b169eb 100644
--- a/asterix-app/src/test/resources/optimizerts/results/open-index-enforced/inverted-index-join/word-jaccard-check_04.plan
+++ b/asterix-app/src/test/resources/optimizerts/results/open-index-enforced/inverted-index-join/word-jaccard-check_04.plan
@@ -4,12 +4,12 @@
       -- ASSIGN  |PARTITIONED|
         -- STREAM_PROJECT  |PARTITIONED|
           -- ONE_TO_ONE_EXCHANGE  |PARTITIONED|
-            -- HYBRID_HASH_JOIN [$$25][$$16]  |PARTITIONED|
+            -- HYBRID_HASH_JOIN [$$25][$$15]  |PARTITIONED|
               -- ONE_TO_ONE_EXCHANGE  |PARTITIONED|
                 -- DATASOURCE_SCAN  |PARTITIONED|
                   -- ONE_TO_ONE_EXCHANGE  |PARTITIONED|
                     -- EMPTY_TUPLE_SOURCE  |PARTITIONED|
-              -- HASH_PARTITION_EXCHANGE [$$16]  |PARTITIONED|
+              -- HASH_PARTITION_EXCHANGE [$$15]  |PARTITIONED|
                 -- STREAM_PROJECT  |PARTITIONED|
                   -- STREAM_SELECT  |PARTITIONED|
                     -- ASSIGN  |PARTITIONED|

http://git-wip-us.apache.org/repos/asf/incubator-asterixdb/blob/f61bdb80/asterix-app/src/test/resources/optimizerts/results/open-index-enforced/inverted-index-join/word-jaccard_04.plan
----------------------------------------------------------------------
diff --git a/asterix-app/src/test/resources/optimizerts/results/open-index-enforced/inverted-index-join/word-jaccard_04.plan
b/asterix-app/src/test/resources/optimizerts/results/open-index-enforced/inverted-index-join/word-jaccard_04.plan
index 27e8085..5b169eb 100644
--- a/asterix-app/src/test/resources/optimizerts/results/open-index-enforced/inverted-index-join/word-jaccard_04.plan
+++ b/asterix-app/src/test/resources/optimizerts/results/open-index-enforced/inverted-index-join/word-jaccard_04.plan
@@ -4,12 +4,12 @@
       -- ASSIGN  |PARTITIONED|
         -- STREAM_PROJECT  |PARTITIONED|
           -- ONE_TO_ONE_EXCHANGE  |PARTITIONED|
-            -- HYBRID_HASH_JOIN [$$25][$$16]  |PARTITIONED|
+            -- HYBRID_HASH_JOIN [$$25][$$15]  |PARTITIONED|
               -- ONE_TO_ONE_EXCHANGE  |PARTITIONED|
                 -- DATASOURCE_SCAN  |PARTITIONED|
                   -- ONE_TO_ONE_EXCHANGE  |PARTITIONED|
                     -- EMPTY_TUPLE_SOURCE  |PARTITIONED|
-              -- HASH_PARTITION_EXCHANGE [$$16]  |PARTITIONED|
+              -- HASH_PARTITION_EXCHANGE [$$15]  |PARTITIONED|
                 -- STREAM_PROJECT  |PARTITIONED|
                   -- STREAM_SELECT  |PARTITIONED|
                     -- ASSIGN  |PARTITIONED|

http://git-wip-us.apache.org/repos/asf/incubator-asterixdb/blob/f61bdb80/asterix-app/src/test/resources/optimizerts/results/rtree-index-join/query-issue838.plan
----------------------------------------------------------------------
diff --git a/asterix-app/src/test/resources/optimizerts/results/rtree-index-join/query-issue838.plan
b/asterix-app/src/test/resources/optimizerts/results/rtree-index-join/query-issue838.plan
index c43cac1..29d64e7 100644
--- a/asterix-app/src/test/resources/optimizerts/results/rtree-index-join/query-issue838.plan
+++ b/asterix-app/src/test/resources/optimizerts/results/rtree-index-join/query-issue838.plan
@@ -15,9 +15,9 @@
                             -- RTREE_SEARCH  |PARTITIONED|
                               -- BROADCAST_EXCHANGE  |PARTITIONED|
                                 -- ASSIGN  |PARTITIONED|
-                                  -- ASSIGN  |PARTITIONED|
-                                    -- STREAM_PROJECT  |PARTITIONED|
+                                  -- STREAM_PROJECT  |PARTITIONED|
+                                    -- ASSIGN  |PARTITIONED|
                                       -- ONE_TO_ONE_EXCHANGE  |PARTITIONED|
                                         -- DATASOURCE_SCAN  |PARTITIONED|
                                           -- ONE_TO_ONE_EXCHANGE  |PARTITIONED|
-                                            -- EMPTY_TUPLE_SOURCE  |PARTITIONED|
\ No newline at end of file
+                                            -- EMPTY_TUPLE_SOURCE  |PARTITIONED|

http://git-wip-us.apache.org/repos/asf/incubator-asterixdb/blob/f61bdb80/asterix-metadata/src/main/java/edu/uci/ics/asterix/metadata/entities/Index.java
----------------------------------------------------------------------
diff --git a/asterix-metadata/src/main/java/edu/uci/ics/asterix/metadata/entities/Index.java
b/asterix-metadata/src/main/java/edu/uci/ics/asterix/metadata/entities/Index.java
index 1e47e21..eb11d60 100644
--- a/asterix-metadata/src/main/java/edu/uci/ics/asterix/metadata/entities/Index.java
+++ b/asterix-metadata/src/main/java/edu/uci/ics/asterix/metadata/entities/Index.java
@@ -31,7 +31,7 @@ import edu.uci.ics.hyracks.algebricks.common.utils.Pair;
 /**
  * Metadata describing an index.
  */
-public class Index implements IMetadataEntity {
+public class Index implements IMetadataEntity, Comparable<Index> {
 
     private static final long serialVersionUID = 1L;
 
@@ -210,4 +210,42 @@ public class Index implements IMetadataEntity {
     public Object dropFromCache(MetadataCache cache) {
         return cache.dropIndex(this);
     }
+
+    @Override
+    public int compareTo(Index otherIndex) {
+        /** Gives a primary index first priority. */
+        if (isPrimaryIndex && !otherIndex.isPrimaryIndex) {
+            return -1;
+        }
+        if (!isPrimaryIndex && otherIndex.isPrimaryIndex) {
+            return 1;
+        }
+
+        /** Gives a B-Tree index the second priority. */
+        if (indexType == IndexType.BTREE && otherIndex.indexType != IndexType.BTREE)
{
+            return -1;
+        }
+        if (indexType != IndexType.BTREE && otherIndex.indexType == IndexType.BTREE)
{
+            return 1;
+        }
+
+        /** Gives a R-Tree index the third priority */
+        if (indexType == IndexType.RTREE && otherIndex.indexType != IndexType.RTREE)
{
+            return -1;
+        }
+        if (indexType != IndexType.RTREE && otherIndex.indexType == IndexType.RTREE)
{
+            return 1;
+        }
+
+        /** Finally, compares based on names. */
+        int result = indexName.compareTo(otherIndex.getIndexName());
+        if (result != 0) {
+            return result;
+        }
+        result = datasetName.compareTo(otherIndex.getDatasetName());
+        if (result != 0) {
+            return result;
+        }
+        return dataverseName.compareTo(otherIndex.getDataverseName());
+    }
 }


Mime
View raw message