import java.util.*; import Zql.*; /* * Initializes data structures for satisfiability purpose and postprocessing */ public class Auxiliary { private static int count = -1; // this table never changes public static Hashtable lookuptable; /* this hashtable is for checking whether a particular attribute belongs to a given relation */ /* the Hashtable lookuptable consists of a String(key) and String(value) the attribute is the key and the relation is the value CURRENTLY WE ARE HARD-CODING THE RELATION NAMES AND ITS ATTRIBUTES. IN FUTURE WE SHOULD GET THIS DATA FROM THE METADATA OBJECT OF THE TABLE FROM THE ORACLE DATABASE */ /* ISSUES: CAPITAL LETTERS, AND STATIC CLASS */ /* ISSUES: ALL TABLES SHOULD HAVE UNIQUE ATTRIBUTE NAMES */ //these are used for constructing the lookuptable private static Hashtable row; private static Hashtable table; public static void init() { // ----------------------------------------------------------- lookuptable = new Hashtable(); String L = new String("L"); String D = new String("D"); String ll = new String("l"); String d = new String("d"); // adding table location "L" lookuptable.put(new String("NAME"),L); lookuptable.put(new String("X"),L); lookuptable.put(new String("Y"),L); //adding table demography "D" lookuptable.put(new String("DNAME"),D); lookuptable.put(new String("AGE"),D); lookuptable.put(new String("SEX"),D); // with lower case lookuptable.put(new String("name"),ll); lookuptable.put(new String("x"),ll); lookuptable.put(new String("y"),ll); lookuptable.put(new String("dname"),d); lookuptable.put(new String("age"),d); lookuptable.put(new String("sex"),d); // ---------------------------------------------------- // initialize direct elimination table; /* x op c = < <= > >_______________________ = | = < <= > >< | <= <<= | < <> | >= >>= | > > */ table = new Hashtable(); String e = new String("="); String l = new String("<"); String le = new String("<="); String g = new String(">"); String ge = new String(">="); String n = new String("-1"); row = new Hashtable(); row.put(e,e); row.put(l,l); row.put(le,le); row.put(g,g); row.put(ge,ge); table.put(e,row); row = new Hashtable(); row.put(e,n); row.put(l,le); row.put(le,le); row.put(g,n); row.put(ge,n); table.put(l,row); row = new Hashtable(); row.put(e,n); row.put(l,l); row.put(le,le); row.put(g,n); row.put(ge,n); table.put(le,row); row = new Hashtable(); row.put(e,n); row.put(l,n); row.put(le,n); row.put(g,ge); row.put(ge,ge); table.put(g,row); row = new Hashtable(); row.put(e,n); row.put(l,n); row.put(le,n); row.put(g,g); row.put(ge,ge); table.put(ge,row); } // this is used to generate a unique query id. Used at the time of creating a QueryObject public static int getQueryID() { count++; return count; } }