>From <[email protected]>:
[email protected] has uploaded this change for review. (
https://asterix-gerrit.ics.uci.edu/c/asterixdb/+/17953 )
Change subject: [ASTERIXDB-3303][COMP] Projection Sizes continued
......................................................................
[ASTERIXDB-3303][COMP] Projection Sizes continued
Change-Id: I543da55af0c71961c84dfcafd8257f6e5e608cf9
---
M
asterixdb/asterix-algebra/src/main/java/org/apache/asterix/optimizer/rules/cbo/JoinEnum.java
1 file changed, 25 insertions(+), 11 deletions(-)
git pull ssh://asterix-gerrit.ics.uci.edu:29418/asterixdb
refs/changes/53/17953/1
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 244279d..35e56cb 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
@@ -39,7 +39,6 @@
import org.apache.asterix.metadata.declared.SampleDataSource;
import org.apache.asterix.metadata.entities.Index;
import org.apache.asterix.om.base.AOrderedList;
-import org.apache.asterix.om.base.ARecord;
import org.apache.asterix.om.base.IAObject;
import org.apache.asterix.om.constants.AsterixConstantValue;
import org.apache.asterix.om.functions.BuiltinFunctions;
@@ -866,7 +865,6 @@
}
double origDatasetCard, finalDatasetCard, sampleCard;
- ILogicalOperator parent =
findDataSourceScanOperatorParent(leafInput);
DataSourceScanOperator scanOp =
findDataSourceScanOperator(leafInput);
if (scanOp == null) {
continue; // what happens to the cards and sizes then?
this may happen in case of in lists
@@ -885,8 +883,15 @@
List<List<IAObject>> result;
SelectOperator selop = (SelectOperator)
findASelectOp(leafInput);
+ if (selop == null) { // add a SelectOperator with TRUE
condition. The code below becomes simpler with a select operator.
+ selop = new SelectOperator(new
MutableObject<>(ConstantExpression.TRUE));
+ ILogicalOperator op = selop;
+ op.getInputs().add(new MutableObject<>(leafInput));
+ leafInput = op;
+ }
+ ILogicalOperator parent =
findDataSourceScanOperatorParent(leafInput);
- if (jn.getCardinality() == jn.getOrigCardinality() && selop !=
null) { // this means there was no selectivity hint provided
+ if (jn.getCardinality() == jn.getOrigCardinality()) { // this
means there was no selectivity hint provided
SampleDataSource sampledatasource =
getSampleDataSource(scanOp);
DataSourceScanOperator deepCopyofScan =
(DataSourceScanOperator)
OperatorManipulationUtil.bottomUpCopyOperators(scanOp);
@@ -900,9 +905,15 @@
result = stats.runSamplingQuery(this.optCtx, leafInput);
double predicateCardinality =
stats.findPredicateCardinality(result);
- double projectedSize = -1.0;
+ double projectedSize;
if (predicateCardinality > 0.0) { // otherwise, we get
nulls for the averages
projectedSize = stats.findProjectedSize(result);
+ } else { // in case we did not get any tuples from the
sample, get the size by setting the predicate to true.
+ ILogicalExpression saveExpr =
selop.getCondition().getValue();
+ selop.getCondition().setValue(ConstantExpression.TRUE);
+ result = stats.runSamplingQuery(this.optCtx,
leafInput);
+ projectedSize = stats.findProjectedSize(result);
+ selop.getCondition().setValue(saveExpr); // restore
the expression
}
if (predicateCardinality == 0.0) {
predicateCardinality = 0.0001 *
idxDetails.getSampleCardinalityTarget();
@@ -922,13 +933,7 @@
// now switch the input back.
parent.getInputs().get(0).setValue(scanOp);
jn.setCardinality(finalDatasetCard);
- if (projectedSize > 0.0) {
- jn.setAvgDocSize(projectedSize);
- } else {
- ARecord record = (ARecord) (((IAObject)
((List<IAObject>) (result.get(0))).get(0)));
- int fields = record.numberOfFields();
- jn.setAvgDocSize(fields * 100); // cant think of
anything better... cards are more important anyway
- }
+ jn.setAvgDocSize(projectedSize);
}
}
dataScanPlan = jn.addSingleDatasetPlans();
--
To view, visit https://asterix-gerrit.ics.uci.edu/c/asterixdb/+/17953
To unsubscribe, or for help writing mail filters, visit
https://asterix-gerrit.ics.uci.edu/settings
Gerrit-Project: asterixdb
Gerrit-Branch: master
Gerrit-Change-Id: I543da55af0c71961c84dfcafd8257f6e5e608cf9
Gerrit-Change-Number: 17953
Gerrit-PatchSet: 1
Gerrit-Owner: [email protected]
Gerrit-MessageType: newchange