openjava.ptree.util
Class ClassMap

java.lang.Object
  |
  +--openjava.ptree.util.ClassMap

public class ClassMap
extends Object

A ClassMap is ...

Since:
Jun 5, 2002
Version:
$Id: //open/saffron/src/openjava/ptree/util/ClassMap.java#2 $
Author:
jhyde

Field Summary
private static int id
           
private static ClassMap instance
           
(package private)  Hashtable mapKey2SyntheticClass
          Map a HashableArray (which is just a wrapper around an array of classes and names to the SyntheticClass which implements that array of types.
(package private)  Class syntheticSuperClass
          Class from which synthetic classes should be subclassed.
 
Constructor Summary
ClassMap(Class syntheticSuperClass)
           
 
Method Summary
private static void addAtomicClasses(Vector classesVector, OJClass clazz)
           
private  OJClass create(OJClass declarer, OJClass[] classes, String[] fieldNames, boolean isJoin)
           
 OJClass createJoin(OJClass declarer, OJClass[] classes)
          Creates a SyntheticClass, or if there is already one with the same number and type of fields, returns that.
 OJClass createProject(OJClass declarer, OJClass[] classes, String[] fieldNames)
          Creates a SyntheticClass with named fields.
static ClassMap instance()
           
private  ClassDeclaration makeDeclaration(String className, OJClass[] classes, String[] fieldNames)
           
 OJClass makeJoinType(OJClass declarer, OJClass left, OJClass right)
          Make the type of a join.
static void setInstance(ClassMap _instance)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

mapKey2SyntheticClass

Hashtable mapKey2SyntheticClass
Map a HashableArray (which is just a wrapper around an array of classes and names to the SyntheticClass which implements that array of types.


syntheticSuperClass

Class syntheticSuperClass
Class from which synthetic classes should be subclassed.


id

private static int id

instance

private static ClassMap instance
Constructor Detail

ClassMap

public ClassMap(Class syntheticSuperClass)
Method Detail

setInstance

public static void setInstance(ClassMap _instance)

instance

public static ClassMap instance()

createProject

public OJClass createProject(OJClass declarer,
                             OJClass[] classes,
                             String[] fieldNames)
Creates a SyntheticClass with named fields. We don't check whether there is an equivalent class -- all classes with named fields are different.


create

private OJClass create(OJClass declarer,
                       OJClass[] classes,
                       String[] fieldNames,
                       boolean isJoin)

makeDeclaration

private ClassDeclaration makeDeclaration(String className,
                                         OJClass[] classes,
                                         String[] fieldNames)

createJoin

public OJClass createJoin(OJClass declarer,
                          OJClass[] classes)
Creates a SyntheticClass, or if there is already one with the same number and type of fields, returns that.


makeJoinType

public OJClass makeJoinType(OJClass declarer,
                            OJClass left,
                            OJClass right)

Make the type of a join. There are two kinds of classes. A real class exists in the developer's environment. A synthetic class is constructed by the Saffron system to describe the intermediate and final results of a query. We are at liberty to modify synthetic classes.

If we join class C1 to class C2, the result is a synthetic class:

 class SC1 {
     C1 $f0;
     C2 $f1;
 }
 
Suppose that we now join class C3 to this; you would expect the result type to be a new synthetic class:
 class SC2 {
     class SC1 {
         C1 $f0;
         C2 $f1;
     } $f0;
     class C3 $f1;
 }
 
Now imagine the type resulting from a 6-way join. It will be very difficult to unpick the nesting in order to reference fields or to permute the join order. Therefore when one or both of the inputs to a join are synthetic, we break them apart and re-construct them. Type of synthetic class SC1 joined to class C3 above is
 class SC3 {
     C1 $f0;
     C2 $f1;
     C3 $f2;
 }
 

There are also row classes, which are synthetic classes arising from projections. The type of

select from (select deptno from dept)
   join emp
   join (select loc.nation, loc.zipcode from loc)
is
 class SC {
     int $f0;
     Emp $f1;
     class RC {
         String nation;
         int zipcode;
     } $f2;
 }
 

This deals with nesting; we still need to deal with the field permutations which occur when we re-order joins. A permutation operator moves fields back to their original positions, so that join transforms preserve type.


addAtomicClasses

private static void addAtomicClasses(Vector classesVector,
                                     OJClass clazz)

SourceForge.net_Logo