1
2
3
4 package net.sf.bddbddb.ir.lowlevel;
5
6 import java.util.Collections;
7 import java.util.LinkedList;
8 import java.util.List;
9
10 import net.sf.bddbddb.BDDRelation;
11 import net.sf.bddbddb.Relation;
12 import net.sf.bddbddb.ir.Operation;
13
14 /***
15 * Project
16 *
17 * @author jwhaley
18 * @version $Id: BDDProject.java 445 2005-02-21 02:32:50Z cs343 $
19 */
20 public class BDDProject extends LowLevelOperation {
21 BDDRelation r0, r1;
22 List
23 /***
24 * @param r0
25 * @param r1
26 */
27 public BDDProject(BDDRelation r0, BDDRelation r1) {
28 super();
29 this.r0 = r0;
30 this.r1 = r1;
31 this.domainProjectSet = new LinkedList(r1.getBDDDomains());
32 this.domainProjectSet.removeAll(r0.getBDDDomains());
33 }
34
35
36
37
38
39
40 public String toString() {
41 return r0.toString() + " = " + getExpressionString();
42 }
43
44
45
46
47
48
49 public String getExpressionString() {
50 return "bddproject(" + r1.toString() + "," + domainProjectSet.toString() + ")";
51 }
52
53
54
55
56
57
58 public Object visit(LowLevelOperationVisitor i) {
59 return i.visit(this);
60 }
61
62
63
64
65
66
67 public Relation getRelationDest() {
68 return r0;
69 }
70
71
72
73
74
75
76 public List getSrcs() {
77 return Collections.singletonList(r1);
78 }
79
80 /***
81 * @return Returns the source relation.
82 */
83 public Relation getSrc() {
84 return r1;
85 }
86
87 /***
88 * @return list of domains being projected
89 */
90 public List
91 return domainProjectSet;
92 }
93
94
95
96
97 public Operation copy() {
98 return new BDDProject(r0, r1);
99 }
100
101
102
103
104
105
106
107 public void replaceSrc(Relation r_old, Relation r_new) {
108 if (r1 == r_old) r1 = (BDDRelation) r_new;
109 }
110
111
112
113
114
115
116 public void setRelationDest(Relation r0) {
117 this.r0 = (BDDRelation) r0;
118 }
119 }