net.sf.saffron.oj.xlat
Class AggInternalTranslator

java.lang.Object
  |
  +--net.sf.saffron.oj.xlat.InternalTranslator
        |
        +--net.sf.saffron.oj.xlat.AggInternalTranslator

class AggInternalTranslator
extends InternalTranslator

Converts expressions to consist only of constants, references to group by expressions (variables called "$group0", etc.), and calls to aggregate functions (variables called "$agg0", etc.).

These names exist only fleetingly, before AggUnpickler converts them to field references in the output record. But if we did not use them, we could not be sure whether a field reference such as $input0.$f1 had been converted.

Throws NotAGroupException.

See Also:
AggUnpickler

Nested Class Summary
(package private) static class AggInternalTranslator.RexAggVariable
          Reference to an aggregation expression of the current aggregator.
(package private) static class AggInternalTranslator.RexGroupVariable
          Reference to a key of the current aggregator.
(package private) static class InternalTranslator.RexQuery
          Temporary holder for a scalar query which has not been translated yet.
 
Field Summary
(package private)  Vector aggCallVector
           
(package private)  ArrayList aggInputList
           
(package private)  Expression[] groups
           
(package private)  SaffronRel[] inputs
           
(package private)  InternalTranslator nonAggTranslator
           
protected  QueryEnvironment qenv
           
(package private)  QueryInfo queryInfo
           
protected  JavaRexBuilder rexBuilder
           
 
Constructor Summary
(package private) AggInternalTranslator(QueryInfo queryInfo, SaffronRel[] inputs, Expression[] groups, ArrayList aggInputList, Vector aggCallVector, JavaRexBuilder javaRexBuilder)
           
 
Method Summary
 RexNode evaluateDown(BinaryExpression p)
           
 RexNode evaluateDown(ConditionalExpression p)
           
 RexNode evaluateDown(FieldAccess p)
           
 RexNode evaluateDown(MethodCall call)
           
 RexNode evaluateDown(UnaryExpression p)
           
 RexNode evaluateDown(Variable p)
           
 Expression evaluateUp(AliasedExpression p)
           
 RexNode go(ParseTree p)
           
private  Aggregation lookupBuiltinAggregation(MethodCall call, OJClass[] argTypes)
          Creates and returns an aggregation if call is a call to a builtin, otherwise returns null.
private  Aggregation lookupCustomAggregation(MethodCall call, OJClass[] argTypes)
          Creates and returns an aggregation if call is a call to a custom aggregation, null otherwise.
(package private)  QueryInfo.LookupResult lookupExp(String name)
          Returns an expression with which to reference a from-list item.
private  RexNode makeAggExp(Aggregation aggregation, ExpressionList args)
           
private  RexNode toGroupReference(Expression expression, boolean fail)
           
 RexNode unpickle(RexNode rex)
          Removes AggInternalTranslator.RexGroupVariable and AggInternalTranslator.RexAggVariable objects which we created temporarily, before we knew how many groups there were going to be.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

aggInputList

ArrayList aggInputList

nonAggTranslator

InternalTranslator nonAggTranslator

aggCallVector

Vector aggCallVector

groups

Expression[] groups

queryInfo

QueryInfo queryInfo

inputs

SaffronRel[] inputs

rexBuilder

protected final JavaRexBuilder rexBuilder

qenv

protected final QueryEnvironment qenv
Constructor Detail

AggInternalTranslator

AggInternalTranslator(QueryInfo queryInfo,
                      SaffronRel[] inputs,
                      Expression[] groups,
                      ArrayList aggInputList,
                      Vector aggCallVector,
                      JavaRexBuilder javaRexBuilder)
Method Detail

evaluateDown

public RexNode evaluateDown(FieldAccess p)
Overrides:
evaluateDown in class InternalTranslator

evaluateDown

public RexNode evaluateDown(UnaryExpression p)
Overrides:
evaluateDown in class InternalTranslator

evaluateDown

public RexNode evaluateDown(BinaryExpression p)
Overrides:
evaluateDown in class InternalTranslator

evaluateDown

public RexNode evaluateDown(ConditionalExpression p)
Overrides:
evaluateDown in class InternalTranslator

evaluateDown

public RexNode evaluateDown(Variable p)
Overrides:
evaluateDown in class InternalTranslator

evaluateDown

public RexNode evaluateDown(MethodCall call)
Overrides:
evaluateDown in class InternalTranslator

lookupBuiltinAggregation

private Aggregation lookupBuiltinAggregation(MethodCall call,
                                             OJClass[] argTypes)
Creates and returns an aggregation if call is a call to a builtin, otherwise returns null.


lookupCustomAggregation

private Aggregation lookupCustomAggregation(MethodCall call,
                                            OJClass[] argTypes)
Creates and returns an aggregation if call is a call to a custom aggregation, null otherwise.


makeAggExp

private RexNode makeAggExp(Aggregation aggregation,
                           ExpressionList args)

toGroupReference

private RexNode toGroupReference(Expression expression,
                                 boolean fail)

unpickle

public RexNode unpickle(RexNode rex)
Removes AggInternalTranslator.RexGroupVariable and AggInternalTranslator.RexAggVariable objects which we created temporarily, before we knew how many groups there were going to be.


go

public RexNode go(ParseTree p)

evaluateUp

public Expression evaluateUp(AliasedExpression p)

lookupExp

QueryInfo.LookupResult lookupExp(String name)
Returns an expression with which to reference a from-list item.

Parameters:
name - the alias of the from item
Returns:
a Variable or FieldAccess

SourceForge.net_Logo