[ASTERIXDB-3046][COMP] Remove the cardinality query property
- user model changes: no
- storage format changes: no
- interface changes: no
Details:
Remove the "cardinality" query property since it is not used.
Change-Id: I0db8655809cef121fb5743dfe2a671508903d17c
Reviewed-on: https://asterix-gerrit.ics.uci.edu/c/asterixdb/+/17231
Reviewed-by: Ali Alsuliman <ali.al.solaiman@gmail.com>
Reviewed-by: Wail Alkowaileet <wael.y.k@gmail.com>
Tested-by: Jenkins <jenkins@fulliautomatix.ics.uci.edu>
Reviewed-on: https://asterix-gerrit.ics.uci.edu/c/asterixdb/+/17331
Reviewed-by: Michael Blow <mblow@apache.org>
Tested-by: Michael Blow <mblow@apache.org>
diff --git a/asterixdb/asterix-algebra/src/main/java/org/apache/asterix/compiler/provider/SqlppCompilationProvider.java b/asterixdb/asterix-algebra/src/main/java/org/apache/asterix/compiler/provider/SqlppCompilationProvider.java
index 7610092..4ad888c 100644
--- a/asterixdb/asterix-algebra/src/main/java/org/apache/asterix/compiler/provider/SqlppCompilationProvider.java
+++ b/asterixdb/asterix-algebra/src/main/java/org/apache/asterix/compiler/provider/SqlppCompilationProvider.java
@@ -90,7 +90,7 @@
StartFeedStatement.WAIT_FOR_COMPLETION, FeedActivityDetails.FEED_POLICY_NAME,
FeedActivityDetails.COLLECT_LOCATIONS, SqlppQueryRewriter.INLINE_WITH_OPTION,
SqlppExpressionToPlanTranslator.REWRITE_IN_AS_OR_OPTION, "hash_merge", "output-record-type",
- "cardinality", DisjunctivePredicateToJoinRule.REWRITE_OR_AS_JOIN_OPTION,
+ DisjunctivePredicateToJoinRule.REWRITE_OR_AS_JOIN_OPTION,
SetAsterixPhysicalOperatorsRule.REWRITE_ATTEMPT_BATCH_ASSIGN,
EquivalenceClassUtils.REWRITE_INTERNAL_QUERYUID_PK, SqlppQueryRewriter.SQL_COMPAT_OPTION));
}
diff --git a/asterixdb/asterix-algebra/src/main/java/org/apache/asterix/optimizer/rules/cbo/EnumerateJoinsRule.java b/asterixdb/asterix-algebra/src/main/java/org/apache/asterix/optimizer/rules/cbo/EnumerateJoinsRule.java
index f389c8e..de28bbc 100644
--- a/asterixdb/asterix-algebra/src/main/java/org/apache/asterix/optimizer/rules/cbo/EnumerateJoinsRule.java
+++ b/asterixdb/asterix-algebra/src/main/java/org/apache/asterix/optimizer/rules/cbo/EnumerateJoinsRule.java
@@ -56,7 +56,6 @@
import org.apache.hyracks.algebricks.core.algebra.operators.logical.EmptyTupleSourceOperator;
import org.apache.hyracks.algebricks.core.algebra.operators.logical.visitors.VariableUtilities;
import org.apache.hyracks.algebricks.core.algebra.prettyprint.IPlanPrettyPrinter;
-import org.apache.hyracks.algebricks.core.rewriter.base.CardHints;
import org.apache.hyracks.algebricks.core.rewriter.base.IAlgebraicRewriteRule;
import org.apache.hyracks.algebricks.core.rewriter.base.PhysicalOptimizationConfig;
import org.apache.logging.log4j.LogManager;
@@ -130,12 +129,10 @@
printPlan(pp, (AbstractLogicalOperator) op, "Original Whole plan2");
int numberOfFromTerms = emptyTupleAndDataSourceOps.size();
- Map<String, Object> querySpecificConfig = context.getMetadataProvider().getConfig();
- CardHints cardHints = CardHints.getCardHintsInfo((String) querySpecificConfig.get("cardinality"));
joinEnum.initEnum((AbstractLogicalOperator) op, cboMode, cboTestMode, numberOfFromTerms,
emptyTupleAndDataSourceOps, joinLeafInputsHashMap, dataSourceEmptyTupleHashMap, internalEdges, joinOps,
- cardHints, context);
+ context);
if (cboMode) {
if (!doAllDataSourcesHaveSamples(emptyTupleAndDataSourceOps, context)) {
diff --git a/asterixdb/asterix-algebra/src/main/java/org/apache/asterix/optimizer/rules/cbo/JoinEnum.java b/asterixdb/asterix-algebra/src/main/java/org/apache/asterix/optimizer/rules/cbo/JoinEnum.java
index f47e577..24509c2 100644
--- a/asterixdb/asterix-algebra/src/main/java/org/apache/asterix/optimizer/rules/cbo/JoinEnum.java
+++ b/asterixdb/asterix-algebra/src/main/java/org/apache/asterix/optimizer/rules/cbo/JoinEnum.java
@@ -67,7 +67,6 @@
import org.apache.hyracks.algebricks.core.algebra.operators.logical.visitors.VariableUtilities;
import org.apache.hyracks.algebricks.core.algebra.prettyprint.IPlanPrettyPrinter;
import org.apache.hyracks.algebricks.core.algebra.util.OperatorManipulationUtil;
-import org.apache.hyracks.algebricks.core.rewriter.base.CardHints;
import org.apache.hyracks.algebricks.core.rewriter.base.PhysicalOptimizationConfig;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
@@ -80,7 +79,6 @@
protected List<PlanNode> allPlans; // list of all plans
protected JoinNode[] jnArray; // array of all join nodes
protected int jnArraySize;
- protected CardHints cardHints; // cardinality hints
protected List<Pair<EmptyTupleSourceOperator, DataSourceScanOperator>> emptyTupleAndDataSourceOps;
protected Map<EmptyTupleSourceOperator, ILogicalOperator> joinLeafInputsHashMap;
protected Map<DataSourceScanOperator, EmptyTupleSourceOperator> dataSourceEmptyTupleHashMap;
@@ -109,15 +107,13 @@
List<Pair<EmptyTupleSourceOperator, DataSourceScanOperator>> emptyTupleAndDataSourceOps,
Map<EmptyTupleSourceOperator, ILogicalOperator> joinLeafInputsHashMap,
Map<DataSourceScanOperator, EmptyTupleSourceOperator> dataSourceEmptyTupleHashMap,
- List<ILogicalOperator> internalEdges, List<ILogicalOperator> joinOps, CardHints cardHints,
- IOptimizationContext context) {
+ List<ILogicalOperator> internalEdges, List<ILogicalOperator> joinOps, IOptimizationContext context) {
this.joinConditions = new ArrayList<>();
this.internalEdges = new ArrayList<>();
this.allPlans = new ArrayList<>();
this.numberOfTerms = numberOfFromTerms;
this.cboMode = cboMode;
this.cboTestMode = cboTestMode;
- this.cardHints = cardHints;
this.connectedJoinGraph = true;
this.optCtx = context;
this.physOptConfig = context.getPhysicalOptimizationConfig();
diff --git a/asterixdb/asterix-algebra/src/main/java/org/apache/asterix/optimizer/rules/cbo/JoinNode.java b/asterixdb/asterix-algebra/src/main/java/org/apache/asterix/optimizer/rules/cbo/JoinNode.java
index d560a13..b0733c7 100644
--- a/asterixdb/asterix-algebra/src/main/java/org/apache/asterix/optimizer/rules/cbo/JoinNode.java
+++ b/asterixdb/asterix-algebra/src/main/java/org/apache/asterix/optimizer/rules/cbo/JoinNode.java
@@ -54,7 +54,6 @@
import org.apache.hyracks.algebricks.core.algebra.operators.logical.AbstractBinaryJoinOperator;
import org.apache.hyracks.algebricks.core.algebra.operators.logical.EmptyTupleSourceOperator;
import org.apache.hyracks.algebricks.core.config.AlgebricksConfig;
-import org.apache.hyracks.algebricks.core.rewriter.base.CardHints;
import org.apache.hyracks.api.exceptions.ErrorCode;
import org.apache.hyracks.api.exceptions.IWarningCollector;
import org.apache.hyracks.api.exceptions.Warning;
@@ -110,24 +109,6 @@
return !IsBaseLevelJoinNode();
}
- protected double findCardinality() {
- CardHints ch = joinEnum.cardHints;
- if (ch == null) {
- return Cost.MAX_CARD;
- }
- List<String> ls = CardHints.isolateVariables(this.datasetNames);
- return ch.findCardinality(ls);
- }
-
- protected double findSize() {
- CardHints ch = joinEnum.cardHints;
- if (ch == null) {
- return Cost.MAX_CARD;
- }
- List<String> ls = CardHints.isolateVariables(this.datasetNames);
- return ch.findSize(ls);
- }
-
public double computeJoinCardinality() {
JoinNode[] jnArray = joinEnum.getJnArray();
List<JoinCondition> joinConditions = joinEnum.getJoinConditions();
diff --git a/hyracks-fullstack/algebricks/algebricks-core/src/main/java/org/apache/hyracks/algebricks/core/rewriter/base/CardHints.java b/hyracks-fullstack/algebricks/algebricks-core/src/main/java/org/apache/hyracks/algebricks/core/rewriter/base/CardHints.java
deleted file mode 100644
index d1cb794..0000000
--- a/hyracks-fullstack/algebricks/algebricks-core/src/main/java/org/apache/hyracks/algebricks/core/rewriter/base/CardHints.java
+++ /dev/null
@@ -1,175 +0,0 @@
-/*
- * 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.
- */
-
-package org.apache.hyracks.algebricks.core.rewriter.base;
-
-import java.util.ArrayList;
-import java.util.Collections;
-import java.util.List;
-import java.util.regex.Matcher;
-import java.util.regex.Pattern;
-
-public class CardHints {
-
- private static final double MAX_CARD = 1.0e200;
-
- private List<List<String>> listRefNames;
- private List<Double> cards;
- private List<Double> sels;
- private List<Double> sizes;
-
- public CardHints() {
- listRefNames = new ArrayList<>();
- cards = new ArrayList<>();
- sels = new ArrayList<>();
- sizes = new ArrayList<>();
- }
-
- public void setCardInfo(List<List<String>> names, List<Double> c, List<Double> s, List<Double> si) {
- listRefNames = names;
- cards = c;
- sels = s;
- sizes = si;
- }
-
- public List<List<String>> getListRefNames() {
- return listRefNames;
- }
-
- public List<Double> getCards() {
- return cards;
- }
-
- public List<Double> getSels() {
- return sels;
- }
-
- public List<Double> getSizes() {
- return sizes;
- }
-
- public static List<String> isolateVariables(List<String> varsLogical) { // comes from the FromList
- Pattern var = Pattern.compile("\\D\\w*");
-
- List<String> vars = new ArrayList<>();
-
- for (String vl : varsLogical) {
- Matcher mat = var.matcher(vl.toString());
- if (mat.find()) {
- vars.add(mat.group());
- }
- }
- Collections.sort(vars);
- return vars;
- }
-
- public double findCardinality(List<String> vars) {
- double card = MAX_CARD; // default value is set to high if no hint information is available
- int i = 0;
- for (List<String> refnames : this.getListRefNames()) {
- if (refnames.equals(vars))
- //return this.getCards().get(i) * this.getSels().get(i);
- {
- return this.getCards().get(i); // we want the original cardinality without any selections
- }
- i++;
- }
- return card;
- }
-
- public double findSize(List<String> vars) {
- int i = 0;
- for (List<String> refnames : this.getListRefNames()) {
- if (refnames.equals(vars)) {
- return this.getSizes().get(i);
- }
- i++;
- }
- return MAX_CARD;
- }
-
- // This routine should not be invoked anymore as we are only providing base hints.
- // But in the event a user does specify mutiple table cards, then this routine will be invoked. Check!
- public double findCardinality(List<String> varsL, List<String> varsR) {
- varsL.addAll(varsR);
- Collections.sort(varsL);
- return this.findCardinality(varsL);
- }
-
- public static CardHints getCardHintsInfo(String hintParams) {
- Pattern var = Pattern.compile("[a-zA-Z]\\w*"); // any word character [a-zA-Z_0-9]
-
- Pattern number = Pattern.compile("\\d+\\.\\d+");
-
- Pattern singleHintPattern =
- Pattern.compile("\\(\\s*\\w+[\\s+\\w+\\s*]*\\s+\\d+\\.\\d+\\s+\\d+\\.\\d+\\s+\\d+\\.\\d+\\s*\\)");
-
- // The above pattern is (id1 id2 ... idn first number second number third number)
- // (o 400.0 0.5) or (o l s 4000.0 0.025) etc
- // Note that the 2nd number which is selectivity is not optional. It can always be set to 1.0.
- List<List<String>> listRefNames = new ArrayList<>();
- List<Double> cards = new ArrayList<>();
- List<Double> sels = new ArrayList<>();
- List<Double> sizes = new ArrayList<>();
- CardHints cardinalityHints = new CardHints();
- if (hintParams != null) {
- Matcher matCHP = singleHintPattern.matcher(hintParams);
-
- while (matCHP.find()) {
- List<String> refNames = new ArrayList<>();
- Double selectivity = 1.0;
- Double cardinality = -1.0;
- Double size = 1.0;
- String matchedGroup = matCHP.group();
- Matcher matVar = var.matcher(matchedGroup);
- Matcher numMat = number.matcher(matchedGroup);
-
- while (matVar.find()) {
- refNames.add(matVar.group()); // find all the ids first
- }
-
- int i = 0;
- while (numMat.find()) {
- i++;
- switch (i) {
- case 1:
- cardinality = Double.parseDouble(numMat.group());
- break;
- case 2:
- selectivity = Double.parseDouble(numMat.group());
- case 3:
- size = Double.parseDouble(numMat.group());
- default: // add error checking here.
- ;
- }
- }
- Collections.sort(refNames);
- listRefNames.add(refNames);
- cards.add(cardinality);
- sels.add(selectivity);
- sizes.add(size);
-
- cardinalityHints.setCardInfo(listRefNames, cards, sels, sizes);
- }
-
- return cardinalityHints;
- }
- return null; // keeps compiler happy.
- }
-}
\ No newline at end of file