>From Preetham Poluparthi <[email protected]>:
Preetham Poluparthi has uploaded this change for review. (
https://asterix-gerrit.ics.uci.edu/c/asterixdb/+/20993?usp=email )
Change subject: [ASTERIXDB-3713][COMP] Support moving replicate operator past
the joins
......................................................................
[ASTERIXDB-3713][COMP] Support moving replicate operator past the joins
- user model changes: no
- storage format changes: no
- interface changes: no
Ext-ref: MB-70862
Change-Id: I7a93684898bacec1b9d782aed424cf854dbdc10d
---
M
hyracks-fullstack/algebricks/algebricks-core/src/main/java/org/apache/hyracks/algebricks/core/algebra/operators/logical/visitors/OperatorDeepCopyVisitor.java
M
hyracks-fullstack/algebricks/algebricks-rewriter/src/main/java/org/apache/hyracks/algebricks/rewriter/rules/ExtractCommonOperatorsRule.java
2 files changed, 21 insertions(+), 6 deletions(-)
git pull ssh://asterix-gerrit.ics.uci.edu:29418/asterixdb
refs/changes/93/20993/1
diff --git
a/hyracks-fullstack/algebricks/algebricks-core/src/main/java/org/apache/hyracks/algebricks/core/algebra/operators/logical/visitors/OperatorDeepCopyVisitor.java
b/hyracks-fullstack/algebricks/algebricks-core/src/main/java/org/apache/hyracks/algebricks/core/algebra/operators/logical/visitors/OperatorDeepCopyVisitor.java
index 8664acf..59cb2b0 100644
---
a/hyracks-fullstack/algebricks/algebricks-core/src/main/java/org/apache/hyracks/algebricks/core/algebra/operators/logical/visitors/OperatorDeepCopyVisitor.java
+++
b/hyracks-fullstack/algebricks/algebricks-core/src/main/java/org/apache/hyracks/algebricks/core/algebra/operators/logical/visitors/OperatorDeepCopyVisitor.java
@@ -438,7 +438,7 @@
@Override
public ILogicalOperator visitWindowOperator(WindowOperator op, Void arg)
throws AlgebricksException {
List<Mutable<ILogicalExpression>> newPartitionExprs = new
ArrayList<>();
- deepCopyExpressionRefs(op.getPartitionExpressions(),
newPartitionExprs);
+ deepCopyExpressionRefs(newPartitionExprs,
op.getPartitionExpressions());
List<Pair<IOrder, Mutable<ILogicalExpression>>> newOrderExprs =
deepCopyOrderAndExpression(op.getOrderExpressions());
List<Pair<IOrder, Mutable<ILogicalExpression>>> newFrameValueExprs =
diff --git
a/hyracks-fullstack/algebricks/algebricks-rewriter/src/main/java/org/apache/hyracks/algebricks/rewriter/rules/ExtractCommonOperatorsRule.java
b/hyracks-fullstack/algebricks/algebricks-rewriter/src/main/java/org/apache/hyracks/algebricks/rewriter/rules/ExtractCommonOperatorsRule.java
index 14a44ac..88cfaad 100644
---
a/hyracks-fullstack/algebricks/algebricks-rewriter/src/main/java/org/apache/hyracks/algebricks/rewriter/rules/ExtractCommonOperatorsRule.java
+++
b/hyracks-fullstack/algebricks/algebricks-rewriter/src/main/java/org/apache/hyracks/algebricks/rewriter/rules/ExtractCommonOperatorsRule.java
@@ -414,13 +414,15 @@
private void genCandidates() throws AlgebricksException {
List<List<Mutable<ILogicalOperator>>> previousEquivalenceClasses = new
ArrayList<>();
- while (equivalenceClasses.size() > 0) {
+ boolean grown = true;
+ while (equivalenceClasses.size() > 0 && grown) {
previousEquivalenceClasses.clear();
for (List<Mutable<ILogicalOperator>> candidates :
equivalenceClasses) {
List<Mutable<ILogicalOperator>> candidatesCopy = new
ArrayList<>(candidates);
previousEquivalenceClasses.add(candidatesCopy);
}
List<Mutable<ILogicalOperator>> currentLevelOpRefs = new
ArrayList<>();
+ grown = false;
for (List<Mutable<ILogicalOperator>> candidates :
equivalenceClasses) {
if (candidates.size() > 0) {
for (Mutable<ILogicalOperator> opRef : candidates) {
@@ -433,11 +435,20 @@
if (currentLevelOpRefs.size() == 0) {
continue;
}
- candidatesGrow(currentLevelOpRefs, candidates);
+ grown |= candidatesGrow(currentLevelOpRefs, candidates);
}
if (currentLevelOpRefs.size() == 0) {
break;
}
+
+ for (int i = equivalenceClasses.size() - 1; i >= 0; i--) {
+ for (int j = i - 1; j >= 0; j--) {
+ if
(equivalenceClasses.get(i).equals(equivalenceClasses.get(j))) {
+ equivalenceClasses.remove(i);
+ break;
+ }
+ }
+ }
prune();
}
if (equivalenceClasses.size() < 1 && previousEquivalenceClasses.size()
> 0) {
@@ -473,15 +484,14 @@
}
}
- private void candidatesGrow(List<Mutable<ILogicalOperator>> opList,
List<Mutable<ILogicalOperator>> candidates) {
+ private boolean candidatesGrow(List<Mutable<ILogicalOperator>> opList,
List<Mutable<ILogicalOperator>> candidates) {
List<Mutable<ILogicalOperator>> previousCandidates = new
ArrayList<>(candidates);
candidates.clear();
- boolean validCandidate = false;
for (Mutable<ILogicalOperator> op : opList) {
List<Mutable<ILogicalOperator>> inputs = op.getValue().getInputs();
+ boolean validCandidate = false;
for (int i = 0; i < inputs.size(); i++) {
Mutable<ILogicalOperator> inputRef = inputs.get(i);
- validCandidate = false;
for (Mutable<ILogicalOperator> candidate : previousCandidates)
{
// if current input is in candidates
if (inputRef.getValue().equals(candidate.getValue())) {
@@ -509,6 +519,11 @@
candidates.add(op);
}
}
+ if (candidates.isEmpty()) {
+ candidates.addAll(previousCandidates);
+ return false;
+ }
+ return true;
}
private void prune() throws AlgebricksException {
--
To view, visit https://asterix-gerrit.ics.uci.edu/c/asterixdb/+/20993?usp=email
To unsubscribe, or for help writing mail filters, visit
https://asterix-gerrit.ics.uci.edu/settings?usp=email
Gerrit-MessageType: newchange
Gerrit-Project: asterixdb
Gerrit-Branch: phoenix
Gerrit-Change-Id: I7a93684898bacec1b9d782aed424cf854dbdc10d
Gerrit-Change-Number: 20993
Gerrit-PatchSet: 1
Gerrit-Owner: Preetham Poluparthi <[email protected]>