org.objectweb.medor.query.lib
Class BasicQueryNode

java.lang.Object
  extended byorg.objectweb.medor.lib.BasicTupleStructure
      extended byorg.objectweb.medor.query.lib.BasicQueryTree
          extended byorg.objectweb.medor.query.lib.BasicQueryNode
All Implemented Interfaces:
Cloneable, java.lang.Cloneable, FilteredQueryTree, QueryNode, QueryTree, TupleStructure
Direct Known Subclasses:
Cartesian, Intersection, JoinProject, Nest, Project, SelectProject, Union, Unnest

public abstract class BasicQueryNode
extends BasicQueryTree
implements QueryNode

A BasicQueryNode is an implementation of QueryNode. It also implements QueryIndexGenerator and RWTupleStructure (it is its own TupleStructure).

Author:
Sebastien Chassande-Barrioz

Field Summary
protected  java.util.List children
           
protected  Expression filter
           
protected  int[] indexes
          Contains ranges of attribute to be projected from the tuple resulting of the concatenation of the tuples from the children QueryTrees.
protected  TupleLoader tupleLoader
           
 
Fields inherited from class org.objectweb.medor.query.lib.BasicQueryTree
debug, distinct, log, name, orderfields
 
Fields inherited from class org.objectweb.medor.lib.BasicTupleStructure
fields, name2field
 
Constructor Summary
BasicQueryNode(java.lang.String _name, OptimizationMetaData optimizationMD)
           
 
Method Summary
 CalculatedField addCalculatedField(java.lang.String name, PType type, Expression exp)
          Creates and adds a CalculatedField to the TupleStructure of the QueryNode.
protected  void addChild(QueryTree qt)
           
protected  void addField(Field f)
          Adds a Field to the current RWTupleStructure
 PropagatedField addPropagatedField(java.lang.String name, PType type, QueryTreeField[] anc)
          Creates and adds a PropagatedField to the TupleStructure of the QueryNode.
 java.lang.Object clone()
           
 QueryTree[] getChildren()
          It retreives the array of the QueryTree used by this QueryNode.
 boolean getDistinct()
          Tests whether the results should be distinct or not.
protected  java.lang.String getFieldName(java.lang.String nodeName, java.lang.String fieldName)
           
 java.lang.String getName()
          It returns the name of the query tree.
 OptimizationMetaData getOptimizationMetaData()
          It retrieves the meta information about the optimization.
 Expression getQueryFilter()
          Retrieves the filter associated to the QueryTree.
 TupleLoader getTupleLoader()
          Returns the TupleLoader currently associated with this QueryNode.
 TupleStructure getTupleStructure()
          Returns the TupleStructure associated to the QueryTree.
abstract  short getType()
          It retrieves the operation type of the current QueryNode.
 QueryTreeField removeField(java.lang.String name)
          Removes a Field.
 QueryTreeField replace(QueryTreeField old, QueryTreeField neo)
           
 void setDistinct(boolean distinct)
          Indicates whether evaluating the QueryTree should return unique results (duplicate elimination) or not.
 void setQueryFilter(Expression filter)
          The setQueryFilter method will be overwritten for implementations which do not support the operation.
 void setTupleLoader(TupleLoader loader)
          Associates a TupleLoader with this QueryNode.
 void updateCalculatedField(java.lang.String name, Expression e)
           
protected  void updateChildren()
          Updates the list of children by screening all Fields and the query filter.
 void updatePropagatedField(java.lang.String name, QueryTreeField[] previous)
           
 
Methods inherited from class org.objectweb.medor.query.lib.BasicQueryTree
getOrderBy, setOrderBy
 
Methods inherited from class org.objectweb.medor.lib.BasicTupleStructure
contains, contains, getField, getField, getFieldRank, getFields, getSize
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface org.objectweb.medor.query.api.QueryTree
getOrderBy, setOrderBy
 

Field Detail

children

protected java.util.List children

tupleLoader

protected TupleLoader tupleLoader

filter

protected Expression filter

indexes

protected int[] indexes
Contains ranges of attribute to be projected from the tuple resulting of the concatenation of the tuples from the children QueryTrees.

Constructor Detail

BasicQueryNode

public BasicQueryNode(java.lang.String _name,
                      OptimizationMetaData optimizationMD)
Method Detail

clone

public java.lang.Object clone()
                       throws java.lang.CloneNotSupportedException
Specified by:
clone in interface Cloneable
Overrides:
clone in class BasicQueryTree
Throws:
java.lang.CloneNotSupportedException

getName

public java.lang.String getName()
Description copied from interface: QueryTree
It returns the name of the query tree.

Specified by:
getName in interface QueryTree
Overrides:
getName in class BasicQueryTree

addPropagatedField

public PropagatedField addPropagatedField(java.lang.String name,
                                          PType type,
                                          QueryTreeField[] anc)
                                   throws MedorException
Creates and adds a PropagatedField to the TupleStructure of the QueryNode.

Specified by:
addPropagatedField in interface QueryNode
Parameters:
name - is the name of the Field to be added.
type - is the PType of the Field to be added.
anc - are the origin Fields for the PropagatedField to be created.
Returns:
the newly created PropagatedField
Throws:
MedorException - when a Field with the same name already exists.

addCalculatedField

public CalculatedField addCalculatedField(java.lang.String name,
                                          PType type,
                                          Expression exp)
                                   throws MedorException
Creates and adds a CalculatedField to the TupleStructure of the QueryNode.

Specified by:
addCalculatedField in interface QueryNode
Parameters:
name - is the name of the Field to be added.
type - is the PType of the Field to be added.
exp - is the Expression for calculating the new Field.
Returns:
the newly created CalculatedField
Throws:
MedorException - when a Field with the same name already exists.

removeField

public QueryTreeField removeField(java.lang.String name)
                           throws MedorException
Removes a Field.

Specified by:
removeField in interface QueryNode
Parameters:
name - is the name of the Field to be removed.
Returns:
the Field which has been removed, or null if no such Field could be removed.
Throws:
MedorException - when no Field with such name exist.

getChildren

public QueryTree[] getChildren()
Description copied from interface: QueryNode
It retreives the array of the QueryTree used by this QueryNode.

Specified by:
getChildren in interface QueryNode

replace

public QueryTreeField replace(QueryTreeField old,
                              QueryTreeField neo)
Specified by:
replace in interface QueryNode

getOptimizationMetaData

public OptimizationMetaData getOptimizationMetaData()
Description copied from interface: QueryNode
It retrieves the meta information about the optimization.

Specified by:
getOptimizationMetaData in interface QueryNode

setQueryFilter

public void setQueryFilter(Expression filter)
                    throws java.lang.UnsupportedOperationException
The setQueryFilter method will be overwritten for implementations which do not support the operation.

Specified by:
setQueryFilter in interface FilteredQueryTree
Parameters:
filter - is the Expression representing the query filter of the current QueryNode.
Throws:
java.lang.UnsupportedOperationException - when it is not supported (for Union, Intersection, Cartesian, Projection).
See Also:
Expression

getQueryFilter

public Expression getQueryFilter()
Description copied from interface: FilteredQueryTree
Retrieves the filter associated to the QueryTree. This filter is represented by an Expression.

Specified by:
getQueryFilter in interface FilteredQueryTree
Returns:
the query filter Expression associated to the QueryNode.
See Also:
Expression

getType

public abstract short getType()
Description copied from interface: QueryNode
It retrieves the operation type of the current QueryNode.

Specified by:
getType in interface QueryNode

getTupleStructure

public TupleStructure getTupleStructure()
Description copied from interface: QueryTree
Returns the TupleStructure associated to the QueryTree. Note that the Fields cannot be added by manipulating the TupleStructure, but by using either constructors in the case of a QueryLeaf, or by using the addXXXFields methods in the case of QueryNodes.

Specified by:
getTupleStructure in interface QueryTree
Overrides:
getTupleStructure in class BasicQueryTree

getTupleLoader

public TupleLoader getTupleLoader()
Description copied from interface: QueryNode
Returns the TupleLoader currently associated with this QueryNode. Note that TupleLoaders are only used at evaluation time.

Specified by:
getTupleLoader in interface QueryNode

setTupleLoader

public void setTupleLoader(TupleLoader loader)
Description copied from interface: QueryNode
Associates a TupleLoader with this QueryNode.

Specified by:
setTupleLoader in interface QueryNode

updatePropagatedField

public void updatePropagatedField(java.lang.String name,
                                  QueryTreeField[] previous)
                           throws MedorException
Specified by:
updatePropagatedField in interface QueryNode
Throws:
MedorException

updateCalculatedField

public void updateCalculatedField(java.lang.String name,
                                  Expression e)
                           throws MedorException
Specified by:
updateCalculatedField in interface QueryNode
Throws:
MedorException

setDistinct

public void setDistinct(boolean distinct)
Description copied from interface: QueryTree
Indicates whether evaluating the QueryTree should return unique results (duplicate elimination) or not.

The default should be that duplicates are not eliminated (distinct is false).

Specified by:
setDistinct in interface QueryTree
Overrides:
setDistinct in class BasicQueryTree

getDistinct

public boolean getDistinct()
Description copied from interface: QueryTree
Tests whether the results should be distinct or not.

Specified by:
getDistinct in interface QueryTree
Overrides:
getDistinct in class BasicQueryTree

addField

protected void addField(Field f)
Adds a Field to the current RWTupleStructure

Parameters:
f - The Field to be added.

updateChildren

protected void updateChildren()
Updates the list of children by screening all Fields and the query filter.


getFieldName

protected java.lang.String getFieldName(java.lang.String nodeName,
                                        java.lang.String fieldName)

addChild

protected void addChild(QueryTree qt)