Added a hint to AQL to exclude secondary indexes from the query plan.
diff --git a/asterix-algebra/src/main/java/edu/uci/ics/asterix/algebra/base/AsterixOperatorAnnotations.java b/asterix-algebra/src/main/java/edu/uci/ics/asterix/algebra/base/AsterixOperatorAnnotations.java
index bfa6045..3ed2783 100644
--- a/asterix-algebra/src/main/java/edu/uci/ics/asterix/algebra/base/AsterixOperatorAnnotations.java
+++ b/asterix-algebra/src/main/java/edu/uci/ics/asterix/algebra/base/AsterixOperatorAnnotations.java
@@ -19,4 +19,5 @@
public static final String PUSHED_FIELD_ACCESS = "PUSHED_FIELD_ACCESS";
public static final String PUSHED_RUNNABLE_FIELD_ACCESS = "PUSHED_RUNNABLE_FIELD_ACCESS";
public static final String FIELD_TYPE = "FIELD_TYPE";
+ public static final String SKIP_SECONDARY_INDEX_SEARCH_HINT = "SKIP_SECONDARY_INDEX_SEARCH_HINT";
}
diff --git a/asterix-algebra/src/main/java/edu/uci/ics/asterix/optimizer/rules/am/IntroduceSelectAccessMethodRule.java b/asterix-algebra/src/main/java/edu/uci/ics/asterix/optimizer/rules/am/IntroduceSelectAccessMethodRule.java
index f712c23..effbaff 100644
--- a/asterix-algebra/src/main/java/edu/uci/ics/asterix/optimizer/rules/am/IntroduceSelectAccessMethodRule.java
+++ b/asterix-algebra/src/main/java/edu/uci/ics/asterix/optimizer/rules/am/IntroduceSelectAccessMethodRule.java
@@ -20,6 +20,7 @@
import org.apache.commons.lang3.mutable.Mutable;
+import edu.uci.ics.asterix.algebra.base.AsterixOperatorAnnotations;
import edu.uci.ics.asterix.metadata.declared.AqlMetadataProvider;
import edu.uci.ics.asterix.metadata.entities.Index;
import edu.uci.ics.hyracks.algebricks.common.exceptions.AlgebricksException;
@@ -103,7 +104,12 @@
// Choose index to be applied.
Pair<IAccessMethod, Index> chosenIndex = chooseIndex(analyzedAMs);
- if (chosenIndex == null) {
+ if (chosenIndex != null && chosenIndex.second.isPrimaryIndex()) {
+ System.out.println();
+ }
+ if (chosenIndex == null
+ || (select.getAnnotations().containsKey(AsterixOperatorAnnotations.SKIP_SECONDARY_INDEX_SEARCH_HINT) && !chosenIndex.second
+ .isPrimaryIndex())) {
context.addToDontApplySet(this, select);
return false;
}
@@ -131,6 +137,7 @@
// Set and analyze select.
selectRef = opRef;
select = (SelectOperator) op1;
+
// Check that the select's condition is a function call.
ILogicalExpression condExpr = select.getCondition().getValue();
if (condExpr.getExpressionTag() != LogicalExpressionTag.FUNCTION_CALL) {
diff --git a/asterix-algebra/src/main/java/edu/uci/ics/asterix/translator/AqlExpressionToPlanTranslator.java b/asterix-algebra/src/main/java/edu/uci/ics/asterix/translator/AqlExpressionToPlanTranslator.java
index 82cb733..9ac5558 100644
--- a/asterix-algebra/src/main/java/edu/uci/ics/asterix/translator/AqlExpressionToPlanTranslator.java
+++ b/asterix-algebra/src/main/java/edu/uci/ics/asterix/translator/AqlExpressionToPlanTranslator.java
@@ -23,6 +23,7 @@
import org.apache.commons.lang3.mutable.Mutable;
import org.apache.commons.lang3.mutable.MutableObject;
+import edu.uci.ics.asterix.algebra.base.AsterixOperatorAnnotations;
import edu.uci.ics.asterix.aql.base.Clause;
import edu.uci.ics.asterix.aql.base.Expression;
import edu.uci.ics.asterix.aql.base.Expression.Kind;
@@ -926,6 +927,9 @@
SelectOperator s = new SelectOperator(new MutableObject<ILogicalExpression>(p.first));
s.getInputs().add(p.second);
+ if (w.hasSkipSecondaryIndexSearchHint()) {
+ s.getAnnotations().put(AsterixOperatorAnnotations.SKIP_SECONDARY_INDEX_SEARCH_HINT, true);
+ }
return new Pair<ILogicalOperator, LogicalVariable>(s, null);
}
diff --git a/asterix-algebra/src/main/java/edu/uci/ics/asterix/translator/CompiledStatements.java b/asterix-algebra/src/main/java/edu/uci/ics/asterix/translator/CompiledStatements.java
index 25f6f59..edd0d9b 100644
--- a/asterix-algebra/src/main/java/edu/uci/ics/asterix/translator/CompiledStatements.java
+++ b/asterix-algebra/src/main/java/edu/uci/ics/asterix/translator/CompiledStatements.java
@@ -423,15 +423,17 @@
private Expression condition;
private int varCounter;
private AqlMetadataProvider metadataProvider;
+ private final boolean skipSecondaryIndexSearchHint;
public CompiledDeleteStatement(VariableExpr var, String dataverseName, String datasetName,
- Expression condition, int varCounter, AqlMetadataProvider metadataProvider) {
+ Expression condition, int varCounter, boolean skipSecondaryIndexSearchHint, AqlMetadataProvider metadataProvider) {
this.var = var;
this.dataverseName = dataverseName;
this.datasetName = datasetName;
this.condition = condition;
this.varCounter = varCounter;
this.metadataProvider = metadataProvider;
+ this.skipSecondaryIndexSearchHint = skipSecondaryIndexSearchHint;
}
@Override
@@ -451,6 +453,10 @@
public Expression getCondition() {
return condition;
}
+
+ public boolean hasSkipSecondaryIndexSearchHint() {
+ return skipSecondaryIndexSearchHint;
+ }
public Query getQuery() throws AlgebricksException {
@@ -466,7 +472,7 @@
clauseList.add(forClause);
Clause whereClause = null;
if (condition != null) {
- whereClause = new WhereClause(condition);
+ whereClause = new WhereClause(condition, skipSecondaryIndexSearchHint);
clauseList.add(whereClause);
}
diff --git a/asterix-app/src/main/java/edu/uci/ics/asterix/aql/translator/AqlTranslator.java b/asterix-app/src/main/java/edu/uci/ics/asterix/aql/translator/AqlTranslator.java
index 4e276b6..25395e5 100644
--- a/asterix-app/src/main/java/edu/uci/ics/asterix/aql/translator/AqlTranslator.java
+++ b/asterix-app/src/main/java/edu/uci/ics/asterix/aql/translator/AqlTranslator.java
@@ -1395,7 +1395,7 @@
String dataverseName = getActiveDataverseName(stmtDelete.getDataverseName());
CompiledDeleteStatement clfrqs = new CompiledDeleteStatement(stmtDelete.getVariableExpr(), dataverseName,
stmtDelete.getDatasetName().getValue(), stmtDelete.getCondition(), stmtDelete.getVarCounter(),
- metadataProvider);
+ stmtDelete.hasSkipSecondaryIndexSearchHint(), metadataProvider);
JobSpecification compiled = rewriteCompileQuery(metadataProvider, clfrqs.getQuery(), clfrqs);
MetadataManager.INSTANCE.commitTransaction(mdTxnCtx);
diff --git a/asterix-app/src/test/resources/optimizerts/queries/skip-index/dont-skip-primary-index-search-in-delete.aql b/asterix-app/src/test/resources/optimizerts/queries/skip-index/dont-skip-primary-index-search-in-delete.aql
new file mode 100644
index 0000000..6d8435ef
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/queries/skip-index/dont-skip-primary-index-search-in-delete.aql
@@ -0,0 +1,31 @@
+/*
+ * Description : The hint to skip secondary indexes don't apply to the primary index
+ * : This test is intended to verify that the primary index is still used instead of a scan
+ * Expected Result : Success
+ * Date : 21th December 2013
+ */
+
+drop dataverse test if exists;
+create dataverse test;
+
+use dataverse test;
+
+create type AddressType as closed {
+ number: int32,
+ street: string,
+ city: string
+}
+
+create type CustomerType as closed {
+ cid: int32,
+ name: string,
+ age: int32?,
+ address: AddressType?,
+ interests: {{string}},
+ children: [ { name: string, age: int32? } ]
+}
+
+create dataset Customers(CustomerType) primary key cid;
+
+delete $c from dataset Customers /*+ skip-index */ where $c.cid < 10;
+
diff --git a/asterix-app/src/test/resources/optimizerts/queries/skip-index/dont-skip-primary-index.aql b/asterix-app/src/test/resources/optimizerts/queries/skip-index/dont-skip-primary-index.aql
new file mode 100644
index 0000000..114784e
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/queries/skip-index/dont-skip-primary-index.aql
@@ -0,0 +1,24 @@
+/*
+ * Description : The hint to skip secondary indexes don't apply to the primary index
+ * : This test is intended to verify that the primary index is still used instead of a scan
+ * Expected Result : Success
+ * Date : 21th December 2013
+ */
+
+drop dataverse test if exists;
+create dataverse test;
+use dataverse test;
+
+write output to nc1:"rttest/btree-index_btree-primary-16.adm";
+
+create type TestType as open {
+ fname : string,
+ lname : string
+}
+
+create dataset testdst(TestType) primary key fname,lname;
+
+for $emp in dataset('testdst')
+/*+ skip-index */
+where $emp.fname >= "Craig" and $emp.lname >= "Kevin" and $emp.fname <= "Mary" and $emp.lname <= "Tomes"
+return $emp
diff --git a/asterix-app/src/test/resources/optimizerts/queries/skip-index/skip-ngram-index-search-in-delete.aql b/asterix-app/src/test/resources/optimizerts/queries/skip-index/skip-ngram-index-search-in-delete.aql
new file mode 100644
index 0000000..de3b154
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/queries/skip-index/skip-ngram-index-search-in-delete.aql
@@ -0,0 +1,24 @@
+/*
+ * Description : Notice the query hint to avoid using any secondary index to evaluate the predicate in the where clause
+ * Expected Res : Success
+ * Date : 21th December 2013
+ */
+
+drop dataverse test if exists;
+create dataverse test;
+
+use dataverse test;
+
+create type DBLPType as closed {
+ id: int32,
+ dblpid: string,
+ title: string,
+ authors: string,
+ misc: string
+}
+
+create dataset DBLP(DBLPType) primary key id;
+
+create index ngram_index on DBLP(title) type ngram(3);
+
+delete $o from dataset DBLP /*+ skip-index */ where contains($o.title, "Multimedia")
\ No newline at end of file
diff --git a/asterix-app/src/test/resources/optimizerts/queries/skip-index/skip-ngram-index.aql b/asterix-app/src/test/resources/optimizerts/queries/skip-index/skip-ngram-index.aql
new file mode 100644
index 0000000..8b80497
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/queries/skip-index/skip-ngram-index.aql
@@ -0,0 +1,29 @@
+/*
+ * Description : Notice the query hint to avoid using any secondary index to evaluate the predicate in the where clause
+ * Expected Res : Success
+ * Date : 21th December 2013
+ */
+
+drop dataverse test if exists;
+create dataverse test;
+use dataverse test;
+
+create type DBLPType as closed {
+ id: int32,
+ dblpid: string,
+ title: string,
+ authors: string,
+ misc: string
+}
+
+create dataset DBLP(DBLPType) primary key id;
+
+create index ngram_index on DBLP(title) type ngram(3);
+
+write output to nc1:"rttest/inverted-index-basic_ngram-contains.adm";
+
+for $o in dataset('DBLP')
+/*+ skip-index */
+where contains($o.title, "Multimedia")
+order by $o.id
+return $o
\ No newline at end of file
diff --git a/asterix-app/src/test/resources/optimizerts/queries/skip-index/skip-rtree-index-search-in-delete.aql b/asterix-app/src/test/resources/optimizerts/queries/skip-index/skip-rtree-index-search-in-delete.aql
new file mode 100644
index 0000000..1c6b312
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/queries/skip-index/skip-rtree-index-search-in-delete.aql
@@ -0,0 +1,29 @@
+/*
+ * Description : Notice the query hint to avoid using any secondary index to evaluate the predicate in the where clause
+ * Expected Res : Success
+ * Date : 21th December 2013
+ */
+
+drop dataverse test if exists;
+create dataverse test;
+
+use dataverse test;
+
+create type MyRecord as closed {
+ id: int32,
+ 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 rtree_index_point on MyData(point) type rtree;
+
+delete $m from dataset MyData /*+ skip-index */ where spatial-intersect($m.point, create-polygon([0.0,1.0,0.0,4.0,12.0,4.0,12.0,1.0]));
diff --git a/asterix-app/src/test/resources/optimizerts/queries/skip-index/skip-rtree-secondary-index.aql b/asterix-app/src/test/resources/optimizerts/queries/skip-index/skip-rtree-secondary-index.aql
new file mode 100644
index 0000000..55e78fc
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/queries/skip-index/skip-rtree-secondary-index.aql
@@ -0,0 +1,40 @@
+/*
+ * Description : Notice the query hint to avoid using any secondary index to evaluate the predicate in the where clause
+ * Expected Res : Success
+ * Date : 21th December 2013
+ */
+
+drop dataverse test if exists;
+create dataverse test;
+use dataverse test;
+
+create type MyRecord as closed {
+ id: int32,
+ point: point,
+ kwds: string,
+ line1: line,
+ line2: line,
+ poly1: polygon,
+ poly2: polygon,
+ rec: rectangle,
+ circle: circle
+}
+
+create nodegroup group1 if not exists on nc1, nc2;
+
+create dataset MyData(MyRecord)
+ primary key id on group1;
+
+load dataset MyData
+using "edu.uci.ics.asterix.external.dataset.adapter.NCFileSystemAdapter"
+(("path"="nc1://data/spatial/spatialData.json"),("format"="adm")) pre-sorted;
+
+create index rtree_index_point on MyData(point) type rtree;
+
+
+write output to nc1:"rttest/index_rtree-secondary-index.adm";
+
+for $o in dataset('MyData')
+/*+ skip-index */
+where spatial-intersect($o.point, create-polygon([4.0,1.0,4.0,4.0,12.0,4.0,12.0,1.0]))
+return {"id":$o.id}
diff --git a/asterix-app/src/test/resources/optimizerts/queries/skip-index/skip-secondary-btree-index-search-in-delete.aql b/asterix-app/src/test/resources/optimizerts/queries/skip-index/skip-secondary-btree-index-search-in-delete.aql
new file mode 100644
index 0000000..aee356f
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/queries/skip-index/skip-secondary-btree-index-search-in-delete.aql
@@ -0,0 +1,32 @@
+/*
+ * Description : Notice the query hint to avoid using any secondary index to evaluate the predicate in the where clause
+ * Expected Res : Success
+ * Date : 21th December 2013
+ */
+
+drop dataverse test if exists;
+create dataverse test;
+
+use dataverse test;
+
+create type AddressType as closed {
+ number: int32,
+ street: string,
+ city: string
+}
+
+create type CustomerType as closed {
+ cid: int32,
+ name: string,
+ age: int32,
+ address: AddressType?,
+ interests: {{string}},
+ children: [ { name: string, age: int32? } ]
+}
+
+create dataset Customers(CustomerType) primary key cid;
+
+create index age_index on Customers(age);
+
+delete $c from dataset Customers /*+ skip-index */ where $c.age < 20;
+
diff --git a/asterix-app/src/test/resources/optimizerts/queries/skip-index/skip-secondary-btree-index.aql b/asterix-app/src/test/resources/optimizerts/queries/skip-index/skip-secondary-btree-index.aql
new file mode 100644
index 0000000..32a6b06
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/queries/skip-index/skip-secondary-btree-index.aql
@@ -0,0 +1,26 @@
+/*
+ * Description : Notice the query hint to avoid using any secondary index to evaluate the predicate in the where clause
+ * Expected Res : Success
+ * Date : 21th December 2013
+ */
+
+drop dataverse test if exists;
+create dataverse test;
+use dataverse test;
+
+write output to nc1:"rttest/btree-index_btree-secondary-57.adm";
+
+create type TestType as open {
+ id : int32,
+ fname : string,
+ lname : string
+}
+
+create dataset testdst(TestType) primary key id;
+
+create index sec_Idx on testdst(fname);
+
+for $emp in dataset('testdst')
+/*+ skip-index */
+where $emp.fname >= "Max" and $emp.fname <= "Roger"
+return $emp
diff --git a/asterix-app/src/test/resources/optimizerts/queries/skip-index/skip-word-index-search-in-delete.aql b/asterix-app/src/test/resources/optimizerts/queries/skip-index/skip-word-index-search-in-delete.aql
new file mode 100644
index 0000000..a7620c9
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/queries/skip-index/skip-word-index-search-in-delete.aql
@@ -0,0 +1,25 @@
+/*
+ * Description : Notice the query hint to avoid using any secondary index to evaluate the predicate in the where clause
+ * Expected Res : Success
+ * Date : 21th December 2013
+ */
+
+
+drop dataverse test if exists;
+create dataverse test;
+
+use dataverse test;
+
+create type DBLPType as closed {
+ id: int32,
+ dblpid: string,
+ title: string,
+ authors: string,
+ misc: string
+}
+
+create dataset DBLP(DBLPType) primary key id;
+
+create index keyword_index on DBLP(title) type keyword;
+
+delete $o from dataset DBLP /*+ skip-index */ where similarity-jaccard(word-tokens($o.title), word-tokens("Transactions for Cooperative Environments")) >= 0.5f
\ No newline at end of file
diff --git a/asterix-app/src/test/resources/optimizerts/queries/skip-index/skip-word-index.aql b/asterix-app/src/test/resources/optimizerts/queries/skip-index/skip-word-index.aql
new file mode 100644
index 0000000..2c95104
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/queries/skip-index/skip-word-index.aql
@@ -0,0 +1,29 @@
+/*
+ * Description : Notice the query hint to avoid using any secondary index to evaluate the predicate in the where clause
+ * Expected Res : Success
+ * Date : 21th December 2013
+ */
+
+
+drop dataverse test if exists;
+create dataverse test;
+use dataverse test;
+
+create type DBLPType as closed {
+ id: int32,
+ dblpid: string,
+ title: string,
+ authors: string,
+ misc: string
+}
+
+create dataset DBLP(DBLPType) primary key id;
+
+create index keyword_index on DBLP(title) type keyword;
+
+write output to nc1:"rttest/inverted-index-basic_word-jaccard.adm";
+
+for $o in dataset('DBLP')
+/*+ skip-index */
+where similarity-jaccard(word-tokens($o.title), word-tokens("Transactions for Cooperative Environments")) >= 0.5f
+return $o
diff --git a/asterix-app/src/test/resources/optimizerts/results/skip-index/dont-skip-primary-index-search-in-delete.plan b/asterix-app/src/test/resources/optimizerts/results/skip-index/dont-skip-primary-index-search-in-delete.plan
new file mode 100644
index 0000000..64f00d4
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/results/skip-index/dont-skip-primary-index-search-in-delete.plan
@@ -0,0 +1,16 @@
+-- COMMIT |PARTITIONED|
+ -- STREAM_PROJECT |PARTITIONED|
+ -- ONE_TO_ONE_EXCHANGE |PARTITIONED|
+ -- INSERT_DELETE |PARTITIONED|
+ -- ONE_TO_ONE_EXCHANGE |PARTITIONED|
+ -- MATERIALIZE |PARTITIONED|
+ -- HASH_PARTITION_EXCHANGE [$$12] |PARTITIONED|
+ -- ASSIGN |PARTITIONED|
+ -- STREAM_PROJECT |PARTITIONED|
+ -- ASSIGN |PARTITIONED|
+ -- STREAM_PROJECT |PARTITIONED|
+ -- ONE_TO_ONE_EXCHANGE |PARTITIONED|
+ -- BTREE_SEARCH |PARTITIONED|
+ -- ONE_TO_ONE_EXCHANGE |PARTITIONED|
+ -- ASSIGN |PARTITIONED|
+ -- EMPTY_TUPLE_SOURCE |PARTITIONED|
diff --git a/asterix-app/src/test/resources/optimizerts/results/skip-index/dont-skip-primary-index.plan b/asterix-app/src/test/resources/optimizerts/results/skip-index/dont-skip-primary-index.plan
new file mode 100644
index 0000000..6f13ebb
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/results/skip-index/dont-skip-primary-index.plan
@@ -0,0 +1,8 @@
+-- DISTRIBUTE_RESULT |PARTITIONED|
+ -- ONE_TO_ONE_EXCHANGE |PARTITIONED|
+ -- STREAM_PROJECT |PARTITIONED|
+ -- ONE_TO_ONE_EXCHANGE |PARTITIONED|
+ -- BTREE_SEARCH |PARTITIONED|
+ -- ONE_TO_ONE_EXCHANGE |PARTITIONED|
+ -- ASSIGN |PARTITIONED|
+ -- EMPTY_TUPLE_SOURCE |PARTITIONED|
diff --git a/asterix-app/src/test/resources/optimizerts/results/skip-index/skip-ngram-index-search-in-delete.plan b/asterix-app/src/test/resources/optimizerts/results/skip-index/skip-ngram-index-search-in-delete.plan
new file mode 100644
index 0000000..37c6587
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/results/skip-index/skip-ngram-index-search-in-delete.plan
@@ -0,0 +1,21 @@
+-- COMMIT |PARTITIONED|
+ -- STREAM_PROJECT |PARTITIONED|
+ -- ONE_TO_ONE_EXCHANGE |PARTITIONED|
+ -- INDEX_INSERT_DELETE |PARTITIONED|
+ -- ONE_TO_ONE_EXCHANGE |PARTITIONED|
+ -- STREAM_PROJECT |PARTITIONED|
+ -- ASSIGN |PARTITIONED|
+ -- ONE_TO_ONE_EXCHANGE |PARTITIONED|
+ -- INSERT_DELETE |PARTITIONED|
+ -- ONE_TO_ONE_EXCHANGE |PARTITIONED|
+ -- MATERIALIZE |PARTITIONED|
+ -- HASH_PARTITION_EXCHANGE [$$11] |PARTITIONED|
+ -- ASSIGN |PARTITIONED|
+ -- STREAM_PROJECT |PARTITIONED|
+ -- ASSIGN |PARTITIONED|
+ -- STREAM_SELECT |PARTITIONED|
+ -- ASSIGN |PARTITIONED|
+ -- ONE_TO_ONE_EXCHANGE |PARTITIONED|
+ -- DATASOURCE_SCAN |PARTITIONED|
+ -- ONE_TO_ONE_EXCHANGE |PARTITIONED|
+ -- EMPTY_TUPLE_SOURCE |PARTITIONED|
diff --git a/asterix-app/src/test/resources/optimizerts/results/skip-index/skip-ngram-index.plan b/asterix-app/src/test/resources/optimizerts/results/skip-index/skip-ngram-index.plan
new file mode 100644
index 0000000..fa19891
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/results/skip-index/skip-ngram-index.plan
@@ -0,0 +1,9 @@
+-- DISTRIBUTE_RESULT |PARTITIONED|
+ -- ONE_TO_ONE_EXCHANGE |PARTITIONED|
+ -- STREAM_PROJECT |PARTITIONED|
+ -- SORT_MERGE_EXCHANGE [$$5(ASC) ] |PARTITIONED|
+ -- STREAM_SELECT |PARTITIONED|
+ -- ONE_TO_ONE_EXCHANGE |PARTITIONED|
+ -- DATASOURCE_SCAN |PARTITIONED|
+ -- ONE_TO_ONE_EXCHANGE |PARTITIONED|
+ -- EMPTY_TUPLE_SOURCE |PARTITIONED|
\ No newline at end of file
diff --git a/asterix-app/src/test/resources/optimizerts/results/skip-index/skip-rtree-index-search-in-delete.plan b/asterix-app/src/test/resources/optimizerts/results/skip-index/skip-rtree-index-search-in-delete.plan
new file mode 100644
index 0000000..cf609cb
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/results/skip-index/skip-rtree-index-search-in-delete.plan
@@ -0,0 +1,23 @@
+-- COMMIT |PARTITIONED|
+ -- STREAM_PROJECT |PARTITIONED|
+ -- ONE_TO_ONE_EXCHANGE |PARTITIONED|
+ -- INDEX_INSERT_DELETE |PARTITIONED|
+ -- ONE_TO_ONE_EXCHANGE |PARTITIONED|
+ -- STREAM_PROJECT |PARTITIONED|
+ -- ASSIGN |PARTITIONED|
+ -- STREAM_PROJECT |PARTITIONED|
+ -- ASSIGN |PARTITIONED|
+ -- ONE_TO_ONE_EXCHANGE |PARTITIONED|
+ -- INSERT_DELETE |PARTITIONED|
+ -- ONE_TO_ONE_EXCHANGE |PARTITIONED|
+ -- MATERIALIZE |PARTITIONED|
+ -- HASH_PARTITION_EXCHANGE [$$17] |PARTITIONED|
+ -- ASSIGN |PARTITIONED|
+ -- STREAM_PROJECT |PARTITIONED|
+ -- ASSIGN |PARTITIONED|
+ -- STREAM_SELECT |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
diff --git a/asterix-app/src/test/resources/optimizerts/results/skip-index/skip-rtree-secondary-index.plan b/asterix-app/src/test/resources/optimizerts/results/skip-index/skip-rtree-secondary-index.plan
new file mode 100644
index 0000000..8e0e202
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/results/skip-index/skip-rtree-secondary-index.plan
@@ -0,0 +1,10 @@
+-- DISTRIBUTE_RESULT |PARTITIONED|
+ -- ONE_TO_ONE_EXCHANGE |PARTITIONED|
+ -- STREAM_PROJECT |PARTITIONED|
+ -- ASSIGN |PARTITIONED|
+ -- STREAM_PROJECT |PARTITIONED|
+ -- STREAM_SELECT |PARTITIONED|
+ -- ONE_TO_ONE_EXCHANGE |PARTITIONED|
+ -- DATASOURCE_SCAN |PARTITIONED|
+ -- ONE_TO_ONE_EXCHANGE |PARTITIONED|
+ -- EMPTY_TUPLE_SOURCE |PARTITIONED|
\ No newline at end of file
diff --git a/asterix-app/src/test/resources/optimizerts/results/skip-index/skip-secondary-btree-index-search-in-delete.plan b/asterix-app/src/test/resources/optimizerts/results/skip-index/skip-secondary-btree-index-search-in-delete.plan
new file mode 100644
index 0000000..67ec849
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/results/skip-index/skip-secondary-btree-index-search-in-delete.plan
@@ -0,0 +1,21 @@
+-- COMMIT |PARTITIONED|
+ -- STREAM_PROJECT |PARTITIONED|
+ -- ONE_TO_ONE_EXCHANGE |PARTITIONED|
+ -- INDEX_INSERT_DELETE |PARTITIONED|
+ -- ONE_TO_ONE_EXCHANGE |PARTITIONED|
+ -- STREAM_PROJECT |PARTITIONED|
+ -- ASSIGN |PARTITIONED|
+ -- ONE_TO_ONE_EXCHANGE |PARTITIONED|
+ -- INSERT_DELETE |PARTITIONED|
+ -- ONE_TO_ONE_EXCHANGE |PARTITIONED|
+ -- MATERIALIZE |PARTITIONED|
+ -- HASH_PARTITION_EXCHANGE [$$12] |PARTITIONED|
+ -- ASSIGN |PARTITIONED|
+ -- STREAM_PROJECT |PARTITIONED|
+ -- ASSIGN |PARTITIONED|
+ -- STREAM_SELECT |PARTITIONED|
+ -- ASSIGN |PARTITIONED|
+ -- ONE_TO_ONE_EXCHANGE |PARTITIONED|
+ -- DATASOURCE_SCAN |PARTITIONED|
+ -- ONE_TO_ONE_EXCHANGE |PARTITIONED|
+ -- EMPTY_TUPLE_SOURCE |PARTITIONED|
diff --git a/asterix-app/src/test/resources/optimizerts/results/skip-index/skip-secondary-btree-index.plan b/asterix-app/src/test/resources/optimizerts/results/skip-index/skip-secondary-btree-index.plan
new file mode 100644
index 0000000..3693813
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/results/skip-index/skip-secondary-btree-index.plan
@@ -0,0 +1,10 @@
+-- DISTRIBUTE_RESULT |PARTITIONED|
+ -- ONE_TO_ONE_EXCHANGE |PARTITIONED|
+ -- STREAM_PROJECT |PARTITIONED|
+ -- STREAM_SELECT |PARTITIONED|
+ -- ASSIGN |PARTITIONED|
+ -- STREAM_PROJECT |PARTITIONED|
+ -- ONE_TO_ONE_EXCHANGE |PARTITIONED|
+ -- DATASOURCE_SCAN |PARTITIONED|
+ -- ONE_TO_ONE_EXCHANGE |PARTITIONED|
+ -- EMPTY_TUPLE_SOURCE |PARTITIONED|
diff --git a/asterix-app/src/test/resources/optimizerts/results/skip-index/skip-word-index-search-in-delete.plan b/asterix-app/src/test/resources/optimizerts/results/skip-index/skip-word-index-search-in-delete.plan
new file mode 100644
index 0000000..c3b9264
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/results/skip-index/skip-word-index-search-in-delete.plan
@@ -0,0 +1,21 @@
+-- COMMIT |PARTITIONED|
+ -- STREAM_PROJECT |PARTITIONED|
+ -- ONE_TO_ONE_EXCHANGE |PARTITIONED|
+ -- INDEX_INSERT_DELETE |PARTITIONED|
+ -- ONE_TO_ONE_EXCHANGE |PARTITIONED|
+ -- STREAM_PROJECT |PARTITIONED|
+ -- ASSIGN |PARTITIONED|
+ -- ONE_TO_ONE_EXCHANGE |PARTITIONED|
+ -- INSERT_DELETE |PARTITIONED|
+ -- ONE_TO_ONE_EXCHANGE |PARTITIONED|
+ -- MATERIALIZE |PARTITIONED|
+ -- HASH_PARTITION_EXCHANGE [$$14] |PARTITIONED|
+ -- ASSIGN |PARTITIONED|
+ -- STREAM_PROJECT |PARTITIONED|
+ -- ASSIGN |PARTITIONED|
+ -- STREAM_SELECT |PARTITIONED|
+ -- ASSIGN |PARTITIONED|
+ -- ONE_TO_ONE_EXCHANGE |PARTITIONED|
+ -- DATASOURCE_SCAN |PARTITIONED|
+ -- ONE_TO_ONE_EXCHANGE |PARTITIONED|
+ -- EMPTY_TUPLE_SOURCE |PARTITIONED|
diff --git a/asterix-app/src/test/resources/optimizerts/results/skip-index/skip-word-index.plan b/asterix-app/src/test/resources/optimizerts/results/skip-index/skip-word-index.plan
new file mode 100644
index 0000000..ef7eae2
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/results/skip-index/skip-word-index.plan
@@ -0,0 +1,8 @@
+-- DISTRIBUTE_RESULT |PARTITIONED|
+ -- ONE_TO_ONE_EXCHANGE |PARTITIONED|
+ -- STREAM_SELECT |PARTITIONED|
+ -- STREAM_PROJECT |PARTITIONED|
+ -- ONE_TO_ONE_EXCHANGE |PARTITIONED|
+ -- DATASOURCE_SCAN |PARTITIONED|
+ -- ONE_TO_ONE_EXCHANGE |PARTITIONED|
+ -- EMPTY_TUPLE_SOURCE |PARTITIONED|
\ No newline at end of file
diff --git a/asterix-aql/src/main/java/edu/uci/ics/asterix/aql/expression/DeleteStatement.java b/asterix-aql/src/main/java/edu/uci/ics/asterix/aql/expression/DeleteStatement.java
index 770a6d5..6698d16 100644
--- a/asterix-aql/src/main/java/edu/uci/ics/asterix/aql/expression/DeleteStatement.java
+++ b/asterix-aql/src/main/java/edu/uci/ics/asterix/aql/expression/DeleteStatement.java
@@ -27,14 +27,16 @@
private Identifier datasetName;
private Expression condition;
private int varCounter;
+ private final boolean skipSecondaryIndexSearchHint;
public DeleteStatement(VariableExpr vars, Identifier dataverseName, Identifier datasetName, Expression condition,
- int varCounter) {
+ int varCounter, boolean skipSecondaryIndexSearchHint) {
this.vars = vars;
this.dataverseName = dataverseName;
this.datasetName = datasetName;
this.condition = condition;
this.varCounter = varCounter;
+ this.skipSecondaryIndexSearchHint = skipSecondaryIndexSearchHint;
}
@Override
@@ -61,6 +63,10 @@
public int getVarCounter() {
return varCounter;
}
+
+ public boolean hasSkipSecondaryIndexSearchHint() {
+ return skipSecondaryIndexSearchHint;
+ }
@Override
public <R, T> R accept(IAqlExpressionVisitor<R, T> visitor, T arg) throws AsterixException {
diff --git a/asterix-aql/src/main/java/edu/uci/ics/asterix/aql/expression/WhereClause.java b/asterix-aql/src/main/java/edu/uci/ics/asterix/aql/expression/WhereClause.java
index a675308..f136f34 100644
--- a/asterix-aql/src/main/java/edu/uci/ics/asterix/aql/expression/WhereClause.java
+++ b/asterix-aql/src/main/java/edu/uci/ics/asterix/aql/expression/WhereClause.java
@@ -22,6 +22,7 @@
public class WhereClause implements Clause {
private Expression whereExpr;
+ private boolean skipSecondaryIndexSearchHint;
public Expression getWhereExpr() {
return whereExpr;
@@ -31,9 +32,10 @@
this.whereExpr = whereExpr;
}
- public WhereClause(Expression whereExpr) {
+ public WhereClause(Expression whereExpr, boolean skipSecondaryIndexSearchHint) {
super();
this.whereExpr = whereExpr;
+ this.skipSecondaryIndexSearchHint = skipSecondaryIndexSearchHint;
}
public WhereClause() {
@@ -54,4 +56,11 @@
visitor.visit(this, arg);
}
+ public void setSkipSecondaryIndexSearchHint(boolean skipSecondaryIndexSearchHint) {
+ this.skipSecondaryIndexSearchHint = skipSecondaryIndexSearchHint;
+ }
+
+ public boolean hasSkipSecondaryIndexSearchHint() {
+ return skipSecondaryIndexSearchHint;
+ }
}
diff --git a/asterix-aql/src/main/java/edu/uci/ics/asterix/aql/rewrites/CloneAndSubstituteVariablesVisitor.java b/asterix-aql/src/main/java/edu/uci/ics/asterix/aql/rewrites/CloneAndSubstituteVariablesVisitor.java
index 8a8675e..ab5905c 100644
--- a/asterix-aql/src/main/java/edu/uci/ics/asterix/aql/rewrites/CloneAndSubstituteVariablesVisitor.java
+++ b/asterix-aql/src/main/java/edu/uci/ics/asterix/aql/rewrites/CloneAndSubstituteVariablesVisitor.java
@@ -214,7 +214,7 @@
public Pair<IAqlExpression, List<VariableSubstitution>> visitWhereClause(WhereClause wc,
List<VariableSubstitution> arg) throws AsterixException {
Pair<IAqlExpression, List<VariableSubstitution>> p1 = wc.getWhereExpr().accept(this, arg);
- WhereClause newW = new WhereClause((Expression) p1.first);
+ WhereClause newW = new WhereClause((Expression) p1.first, wc.hasSkipSecondaryIndexSearchHint());
return new Pair<IAqlExpression, List<VariableSubstitution>>(newW, p1.second);
}
diff --git a/asterix-aql/src/main/javacc/AQL.jj b/asterix-aql/src/main/javacc/AQL.jj
index eb7b5b5..35f39f0 100644
--- a/asterix-aql/src/main/javacc/AQL.jj
+++ b/asterix-aql/src/main/javacc/AQL.jj
@@ -56,6 +56,7 @@
// optimizer hints
private static final String HASH_GROUP_BY_HINT = "hash";
+ private static final String SKIP_SECONDARY_INDEX_SEARCH_HINT = "skip-index";
private static final String BROADCAST_JOIN_HINT = "bcast";
private static final String INDEXED_NESTED_LOOP_JOIN_HINT = "indexnl";
private static final String INMEMORY_HINT = "inmem";
@@ -695,17 +696,24 @@
VariableExpr var = null;
Expression condition = null;
Pair<Identifier, Identifier> nameComponents;
+ boolean skipSecondaryIndexSearchHint = false;
+ Clause c = null;
}
{
"delete" var = Variable()
{
getCurrentScope().addNewVarSymbolToScope(var.getVar());
}
- "from" <DATASET> nameComponents = QualifiedName()
- (<WHERE> condition = Expression())?
- {
- return new DeleteStatement(var, nameComponents.first, nameComponents.second, condition, getVarCounter());
+ "from" <DATASET> nameComponents = QualifiedName()
+ (c = WhereClause())?
+ {
+ if (c != null) {
+ WhereClause wc = (WhereClause) c;
+ condition = wc.getWhereExpr();
+ skipSecondaryIndexSearchHint = wc.hasSkipSecondaryIndexSearchHint();
}
+ return new DeleteStatement(var, nameComponents.first, nameComponents.second, condition, getVarCounter(), skipSecondaryIndexSearchHint);
+ }
}
UpdateStatement UpdateStatement() throws ParseException:
@@ -1925,7 +1933,14 @@
Expression whereExpr;
}
{
- <WHERE> whereExpr = Expression()
+ <WHERE>
+ {
+ String hint = getHint(token);
+ if (hint != null && hint.equals(SKIP_SECONDARY_INDEX_SEARCH_HINT)) {
+ wc.setSkipSecondaryIndexSearchHint(true);
+ }
+ }
+ whereExpr = Expression()
{
wc.setWhereExpr(whereExpr);
return wc;
diff --git a/pom.xml b/pom.xml
index 026878d..fe6d5b6 100644
--- a/pom.xml
+++ b/pom.xml
@@ -21,8 +21,8 @@
<packaging>pom</packaging>
<properties>
- <algebricks.version>0.2.10</algebricks.version>
- <hyracks.version>0.2.10</hyracks.version>
+ <algebricks.version>0.2.11-SNAPSHOT</algebricks.version>
+ <hyracks.version>0.2.11-SNAPSHOT</hyracks.version>
</properties>
<build>