You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@asterixdb.apache.org by AsterixDB Code Review <do...@asterix-gerrit.ics.uci.edu> on 2025/07/28 17:14:02 UTC
Change in asterixdb[master]: [ASTERIXDB-3606][COMP]: Refactor plan representation: split PlanNode,...
From Peeyush Gupta <pe...@couchbase.com>:
Attention is currently required from: Ali Alsuliman, Preetham Poluparthi, murali.krishna@couchbase.com.
Peeyush Gupta has posted comments on this change. ( https://asterix-gerrit.ics.uci.edu/c/asterixdb/+/19604 )
Change subject: [ASTERIXDB-3606][COMP]: Refactor plan representation: split PlanNode, use DatasetRegistry, replace index-based tracking
......................................................................
Patch Set 23:
(15 comments)
Patchset:
PS23:
It will be good to check the perf implications of this patch also as it will cause creation of more objects.
File asterixdb/asterix-algebra/src/main/java/org/apache/asterix/optimizer/rules/cbo/AbstractLeafInput.java:
https://asterix-gerrit.ics.uci.edu/c/asterixdb/+/19604/comment/0ec994dd_570a0750
PS23, Line 40: public DataSourceScanOperator findDataSourceScanOperator() {
: ILogicalOperator scanOp = op;
: while (scanOp != null && scanOp.getOperatorTag() != LogicalOperatorTag.EMPTYTUPLESOURCE) {
: if (scanOp.getOperatorTag().equals(LogicalOperatorTag.DATASOURCESCAN)) {
: return (DataSourceScanOperator) scanOp;
: }
: scanOp = scanOp.getInputs().get(0).getValue();
: }
: return null;
: }
nit: This function doesn't really seem that much related here. This seems more like a utility function that takes an operator and finds the data scan operator.
File asterixdb/asterix-algebra/src/main/java/org/apache/asterix/optimizer/rules/cbo/DatasetRegistry.java:
https://asterix-gerrit.ics.uci.edu/c/asterixdb/+/19604/comment/7797ee37_fe8249ad
PS23, Line 45: public class DatasetSubset {
: private Long bitset;
:
: public DatasetSubset(AbstractLeafInput dataset) {
: this.bitset = (1L << datasetMap.get(dataset));
: }
:
: public DatasetSubset() {
: bitset = 0L;
: }
:
: public void addDataset(AbstractLeafInput dataset) {
: bitset |= (1L << datasetMap.get(dataset));
: }
:
: public Long getBitset() {
: return bitset;
: }
:
: @Override
: public boolean equals(Object obj) {
: return obj instanceof DatasetSubset && Objects.equals(bitset, ((DatasetSubset) obj).bitset);
: }
:
: public int size() {
: int count = 0;
: for (int i = 0; i < datasets.size(); i++) {
: if ((bitset & (1L << i)) != 0) {
: count++;
: }
: }
: return count;
: }
:
: @Override
: public String toString() {
: StringBuilder sb = new StringBuilder();
: for (int i = 0; i < datasets.size(); i++) {
: if ((bitset & (1L << i)) != 0) {
: sb.append(datasets.get(i).toString());
: }
: }
: return sb.toString();
: }
:
Seems to me that having DatasetSubset class defined in its own file will improve readability in this and other classes.
https://asterix-gerrit.ics.uci.edu/c/asterixdb/+/19604/comment/24c09a24_03fff879
PS23, Line 92: Union
generally we use function names starting with lower case
https://asterix-gerrit.ics.uci.edu/c/asterixdb/+/19604/comment/d99a00a3_7a6f73ed
PS23, Line 98: Intersect
intersect
https://asterix-gerrit.ics.uci.edu/c/asterixdb/+/19604/comment/2cefcc2d_beba64b3
PS23, Line 92: public DatasetSubset Union(DatasetSubset ds1, DatasetSubset ds2) {
: DatasetSubset result = new DatasetSubset();
: result.bitset = ds1.bitset | ds2.bitset;
: return result;
: }
:
: public DatasetSubset Intersect(DatasetSubset ds1, DatasetSubset ds2) {
: DatasetSubset result = new DatasetSubset();
: result.bitset = ds1.bitset & ds2.bitset;
: return result;
: }
It seems these functions can be static as well
https://asterix-gerrit.ics.uci.edu/c/asterixdb/+/19604/comment/8f2a6211_29864f61
PS23, Line 109: public static boolean equals(DatasetSubset one, DatasetSubset two) {
: return Objects.equals(one.bitset, two.bitset);
: }
why is this function needed? Can't the user just call Object.equals(one, two) as equals is already defined in DatasetSubset.
File asterixdb/asterix-algebra/src/main/java/org/apache/asterix/optimizer/rules/cbo/JoinCondition.java:
https://asterix-gerrit.ics.uci.edu/c/asterixdb/+/19604/comment/ab5b3b26_025d91d3
PS23, Line 41: public DatasetRegistry.DatasetSubset datasetSubset;
: // used for triangle detection; we strictly do not mean left and right here.
: // first and second sides would be more appropriate
: public AbstractLeafInput leftSide;
: public AbstractLeafInput rightSide;
: public DatasetRegistry.DatasetSubset leftSideBits;
: public DatasetRegistry.DatasetSubset rightSideBits;
Why these need to be public? can they be protected or private?
File asterixdb/asterix-algebra/src/main/java/org/apache/asterix/optimizer/rules/cbo/JoinEnum.java:
https://asterix-gerrit.ics.uci.edu/c/asterixdb/+/19604/comment/81d0f175_afd4d029
PS23, Line 866: DatasetRegistry
wont Object.equals work here
File asterixdb/asterix-algebra/src/main/java/org/apache/asterix/optimizer/rules/cbo/JoinNode.java:
https://asterix-gerrit.ics.uci.edu/c/asterixdb/+/19604/comment/70afbf2f_b9458073
PS23, Line 1675: // PlanNode leftPlan = pn.getLeftPlanNode();
: // PlanNode rightPlan = pn.getRightPlanNode();
: // sb.append("planIndexes ").append(leftPlan.getIndex()).append(" ").append(rightPlan.getIndex())
: // .append('\n');
: // sb.append(dumpLeftRightPlanCosts(pn));
This code might be used for debugging purposes. Check if it can be removed. If yes remove the commented out code itself.
File asterixdb/asterix-algebra/src/main/java/org/apache/asterix/optimizer/rules/cbo/PlanRegistry.java:
https://asterix-gerrit.ics.uci.edu/c/asterixdb/+/19604/comment/57a23ce6_eac2b790
PS22, Line 20: package org.apache.asterix.optimizer.rules.cbo;
:
: import java.util.ArrayList;
: import java.util.List;
:
: public class PlanRegistry {
: private final List<AbstractPlanNode> allPlans;
:
: public PlanRegistry() {
: allPlans = new ArrayList<>();
: }
:
: public void addPlan(AbstractPlanNode plan) {
: allPlans.add(plan);
: }
: }
:
Are you planning to use this plan registry in the future or is for some debugging purpose as there is no getter function for allPlans.
File asterixdb/asterix-algebra/src/main/java/org/apache/asterix/optimizer/rules/cbo/RealLeafInput.java:
PS23:
I think UnnestLeafInput is also a type of real leaf input. You can probably rename it to something like DatasetLeafInput or ScanLeafInput or something like that.
https://asterix-gerrit.ics.uci.edu/c/asterixdb/+/19604/comment/5d444aed_b0a8c9ff
PS23, Line 35: public boolean isUnnest() {
Are there chances there will be more types of leaf inputs? If yes, instead of adding isUnnest we should have a function that returns the type (an enum) and then we check equality on that enum. If there will be no more such leaf input types, then this is fine.
File asterixdb/asterix-algebra/src/main/java/org/apache/asterix/optimizer/rules/cbo/Stats.java:
https://asterix-gerrit.ics.uci.edu/c/asterixdb/+/19604/comment/8663d09d_68846dad
PS23, Line 184: (RealLeafInput) joinEnum.leafInputs.get(idx1 - 1),
: (RealLeafInput) joinEnum.leafInputs.get(idx2 - 1)
Can't we use leaf1 and leaf2 here
File asterixdb/asterix-algebra/src/main/java/org/apache/asterix/optimizer/rules/cbo/UnnestLeafInput.java:
https://asterix-gerrit.ics.uci.edu/c/asterixdb/+/19604/comment/99b2553a_581ebc62
PS22, Line 29: this.op = op;
This line can be removed.
--
To view, visit https://asterix-gerrit.ics.uci.edu/c/asterixdb/+/19604
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: I5c5a670fb66b5d525af31a3e8eca1e0c429e7adc
Gerrit-Change-Number: 19604
Gerrit-PatchSet: 23
Gerrit-Owner: Preetham Poluparthi <pr...@apache.org>
Gerrit-Reviewer: Ali Alsuliman <al...@gmail.com>
Gerrit-Reviewer: Anon. E. Moose #1000171
Gerrit-Reviewer: Jenkins <je...@fulliautomatix.ics.uci.edu>
Gerrit-Reviewer: Peeyush Gupta <pe...@couchbase.com>
Gerrit-Reviewer: murali.krishna@couchbase.com
Gerrit-CC: Murtadha Hubail <mh...@apache.org>
Gerrit-Attention: Ali Alsuliman <al...@gmail.com>
Gerrit-Attention: Preetham Poluparthi <pr...@apache.org>
Gerrit-Attention: murali.krishna@couchbase.com
Gerrit-Comment-Date: Mon, 28 Jul 2025 17:14:02 +0000
Gerrit-HasComments: Yes
Gerrit-Has-Labels: No
Gerrit-MessageType: comment