org.makumba.providers.query.mql
Class QueryContext

java.lang.Object
  extended by org.makumba.providers.query.mql.QueryContext

public class QueryContext
extends Object

FROM analysis code. Each query/subquery has its own QueryContext. This is ported from the old OQL parser. Additions: 1) look in the parent query context for labels unknown here 2) more than just LEFT JOIN is supported

Version:
$Id: QueryContext.java,v 1.1 Aug 5, 2008 5:50:39 PM cristi Exp $
Author:
Cristian Bogdan

Nested Class Summary
(package private)  class QueryContext.Join
          the four elements of a join: label1.field1 = label2.field2
 
Field Summary
(package private)  Hashtable<String,String> aliases
          support aliases in query
(package private)  DataDefinitionProvider ddp
           
(package private)  HashSet<String> explicitLabels
          labels defined explicitly in the FROM section of this subquery
(package private)  Vector<NameResolver.TextList> filters
          correlation conditions
(package private)  Hashtable<String,DataDefinition> fromLabels
          labels explicitly defined in OQL FROM
(package private)  MqlNode inTree
           
(package private)  Hashtable<String,String> joinNames
          finder for joins in the form label.field, used in order not to repeat the same join
(package private)  Vector<QueryContext.Join> joins
          the joins needed out of the label.field from this query
(package private)  LinkedHashMap<String,DataDefinition> labels
          associate each label to its makumba type
(package private)  Hashtable<String,MqlNode> projectionLabelSearch
          searcher for projection labels
(package private)  MqlSqlWalker walker
           
 
Constructor Summary
QueryContext(MqlSqlWalker mqlSqlWalker)
           
 
Method Summary
 void addFrom(String frm, antlr.collections.AST labelAST, int joinType)
           
(package private)  String addJoin(String l1, String f1, String name, String f2, DataDefinition type, int joinType, antlr.collections.AST location)
          make a new join with the name and associate the label with the type
 void close()
           
 antlr.collections.AST createFromElement(String path, antlr.collections.AST alias, int joinType)
           
(package private)  DataDefinition findLabelType(String label)
           
(package private)  String getFieldName(String label, String field, NameResolver nr)
          return the database-level name of the given field of the given label
 LinkedHashMap<String,DataDefinition> getLabels()
           
 QueryContext getParent()
           
 Hashtable<String,MqlNode> getProjectionLabelSearch()
           
(package private)  DataDefinition getTableName(String label)
          return the database-level name of the type of the given label
(package private)  String join(String label, String field, String labelf, int joinType, antlr.collections.AST location)
          produce a new label out of label.field, with the indicated labelf name for the result check if the indicated field exists in the type of the label determine the type of the result label if more joins are necesary inbetween (e.g. for sets), add these joins as well
 void selectField(String label, String field, MqlDotNode mqlDotNode)
           
 NameResolver.TextList selectLabel(String label, MqlNode node)
           
 void setParent(QueryContext currentContext)
           
protected  void writeFrom(NameResolver.TextList ret)
          writes the iterator definitions (FROM part)
protected  void writeJoins(NameResolver.TextList ret)
          write the translator-generated joins
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

walker

MqlSqlWalker walker

ddp

DataDefinitionProvider ddp

inTree

MqlNode inTree

labels

LinkedHashMap<String,DataDefinition> labels
associate each label to its makumba type


fromLabels

Hashtable<String,DataDefinition> fromLabels
labels explicitly defined in OQL FROM


aliases

Hashtable<String,String> aliases
support aliases in query


joins

Vector<QueryContext.Join> joins
the joins needed out of the label.field from this query


joinNames

Hashtable<String,String> joinNames
finder for joins in the form label.field, used in order not to repeat the same join


projectionLabelSearch

Hashtable<String,MqlNode> projectionLabelSearch
searcher for projection labels


filters

Vector<NameResolver.TextList> filters
correlation conditions


explicitLabels

HashSet<String> explicitLabels
labels defined explicitly in the FROM section of this subquery

Constructor Detail

QueryContext

public QueryContext(MqlSqlWalker mqlSqlWalker)
Method Detail

setParent

public void setParent(QueryContext currentContext)

getParent

public QueryContext getParent()

createFromElement

public antlr.collections.AST createFromElement(String path,
                                               antlr.collections.AST alias,
                                               int joinType)
                                        throws antlr.SemanticException
Throws:
antlr.SemanticException

close

public void close()

addJoin

String addJoin(String l1,
               String f1,
               String name,
               String f2,
               DataDefinition type,
               int joinType,
               antlr.collections.AST location)
         throws antlr.SemanticException
make a new join with the name and associate the label with the type

Parameters:
joinType -
location -
Throws:
antlr.SemanticException

join

String join(String label,
            String field,
            String labelf,
            int joinType,
            antlr.collections.AST location)
      throws antlr.SemanticException
produce a new label out of label.field, with the indicated labelf name for the result check if the indicated field exists in the type of the label determine the type of the result label if more joins are necesary inbetween (e.g. for sets), add these joins as well

Parameters:
joinType -
-
Throws:
antlr.SemanticException

addFrom

public void addFrom(String frm,
                    antlr.collections.AST labelAST,
                    int joinType)
             throws antlr.SemanticException
Throws:
antlr.SemanticException

findLabelType

DataDefinition findLabelType(String label)

writeFrom

protected void writeFrom(NameResolver.TextList ret)
writes the iterator definitions (FROM part)


getTableName

DataDefinition getTableName(String label)
return the database-level name of the type of the given label


getFieldName

String getFieldName(String label,
                    String field,
                    NameResolver nr)
return the database-level name of the given field of the given label


writeJoins

protected void writeJoins(NameResolver.TextList ret)
write the translator-generated joins


selectLabel

public NameResolver.TextList selectLabel(String label,
                                         MqlNode node)

selectField

public void selectField(String label,
                        String field,
                        MqlDotNode mqlDotNode)
                 throws antlr.SemanticException
Throws:
antlr.SemanticException

getProjectionLabelSearch

public Hashtable<String,MqlNode> getProjectionLabelSearch()

getLabels

public LinkedHashMap<String,DataDefinition> getLabels()