-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathOperator.java
More file actions
76 lines (68 loc) · 1.52 KB
/
Operator.java
File metadata and controls
76 lines (68 loc) · 1.52 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
/**
*
*/
package sjdb;
import java.util.List;
import java.util.ArrayList;
import java.util.Iterator;
/**
* This abstract class represents an operator in a query, and
* is subclassed by UnaryOperator and BinaryOperator.
* @author nmg
*
*/
public abstract class Operator {
/**
* The list of child operators that feed their outputs to
* this operator.
*/
protected ArrayList<Operator> inputs;
/**
* The relation produced by this operator as output.
*/
protected Relation output;
public Operator() {
this.inputs = new ArrayList<Operator>();
}
/**
* Return an arraylist containing the child operators of this
* operator.
* @return Child operators
*/
public List<Operator> getInputs() {
List<Operator> inputs = new ArrayList<Operator>();
inputs.addAll(this.inputs);
return inputs;
}
/**
* Add a child operator to this operator
* @param op Child operator
*/
protected void addOperator(Operator op) {
this.inputs.add(op);
}
/**
* Return the relation produced by this operator as output.
* @return Output relation
*/
public Relation getOutput() {
return this.output;
}
/**
* Set the relation produced by this operator as output.
* @param reln Output relation
*/
public void setOutput(Relation reln) {
this.output = reln;
}
/**
* Accept a visitor to this operator.
* @param visitor Visitor to be accepted
*/
public void accept(PlanVisitor visitor) {
Iterator<Operator> iter = this.inputs.iterator();
while (iter.hasNext()){
iter.next().accept(visitor);
}
}
}