5 public class ImplicitSchema {
7 SetAnalysis setanalysis;
8 public ImplicitSchema(State state) {
10 this.setanalysis=new SetAnalysis(state);
13 public void update() {
16 updaterelationconstraints();
19 void updaterelationconstraints() {
20 Vector reldescriptors=state.stRelations.getAllDescriptors();
21 for(int i=0;i<reldescriptors.size();i++) {
22 RelationDescriptor rd=(RelationDescriptor) reldescriptors.get(i);
23 Constraint c=new Constraint();
25 /* Construct quantifier */
26 RelationQuantifier rq=new RelationQuantifier();
27 String varname1=new String("partitionvar1");
28 String varname2=new String("partitionvar2");
29 VarDescriptor var1=new VarDescriptor(varname1);
30 VarDescriptor var2=new VarDescriptor(varname2);
31 c.getSymbolTable().add(var1);
32 c.getSymbolTable().add(var2);
33 var1.setType(rd.getDomain().getType());
34 var2.setType(rd.getRange().getType());
35 rq.setTuple(var1,var2);
39 VarExpr ve1=new VarExpr(varname1);
40 SetExpr se1=new SetExpr(rd.getDomain());
41 LogicStatement incpred1=new InclusionPredicate(ve1,se1);
43 VarExpr ve2=new VarExpr(varname2);
44 SetExpr se2=new SetExpr(rd.getRange());
45 LogicStatement incpred2=new InclusionPredicate(ve2,se2);
46 c.setLogicStatement(new LogicStatement(LogicStatement.AND,incpred1,incpred2));
47 state.vConstraints.add(c);
51 void updateconstraints() {
52 Vector setdescriptors=state.stSets.getAllDescriptors();
53 for(int i=0;i<setdescriptors.size();i++) {
54 SetDescriptor sd=(SetDescriptor) setdescriptors.get(i);
55 if(sd.isPartition()) {
56 Constraint c=new Constraint();
58 /* Construct quantifier */
59 SetQuantifier sq=new SetQuantifier();
60 String varname=new String("partitionvar");
61 VarDescriptor var=new VarDescriptor(varname);
62 c.getSymbolTable().add(var);
63 var.setType(sd.getType());
68 /*Construct logic statement*/
69 LogicStatement ls=null;
70 for(int j=0;j<sd.getSubsets().size();j++) {
71 LogicStatement conj=null;
72 for(int k=0;k<sd.getSubsets().size();k++) {
73 VarExpr ve=new VarExpr(varname);
74 SetExpr se=new SetExpr((SetDescriptor) sd.getSubsets().get(k));
75 LogicStatement incpred=new InclusionPredicate(ve,se);
77 incpred=new LogicStatement(LogicStatement.NOT ,incpred);
82 conj=new LogicStatement(LogicStatement.AND, conj, incpred);
87 ls=new LogicStatement(LogicStatement.OR, ls, conj);
89 c.setLogicStatement(ls);
90 state.vConstraints.add(c);
96 Vector oldrules=state.vRules;
97 Vector newrules=new Vector();
98 for(int i=0;i<oldrules.size();i++) {
99 Rule r=(Rule)oldrules.get(i);
100 if (r.inclusion instanceof SetInclusion) {
101 SetDescriptor sd=((SetInclusion)r.inclusion).getSet();
102 Set supersets=setanalysis.getSuperset(sd);
104 for(Iterator superit=supersets.iterator();superit.hasNext();) {
105 SetDescriptor sd1=(SetDescriptor)superit.next();
108 nr.quantifiers=r.quantifiers;
109 nr.isstatic=r.isstatic;
110 nr.isdelay=r.isdelay;
111 nr.inclusion=new SetInclusion(((SetInclusion)r.inclusion).elementexpr,sd1);
117 oldrules.addAll(newrules);