net.sf.saffron.oj.xlat
Class InternalTranslator

java.lang.Object
  |
  +--net.sf.saffron.oj.xlat.InternalTranslator
Direct Known Subclasses:
AggInternalTranslator

class InternalTranslator
extends Object

Converts an Openjava expression into a row-expression.

For example, the filter expression emp.sal > 50 from select * from emp where emp.sal > 50 becomes $input0.sal > 50. And emp.deptno == dept.deptno becomes $input.$0.deptno == $input.$1.deptno.

Any queries are wrapped as InternalTranslator.RexQuery nodes. They will be expanded later.

See Also:
AggInternalTranslator

Nested Class Summary
(package private) static class InternalTranslator.RexQuery
          Temporary holder for a scalar query which has not been translated yet.
 
Field Summary
(package private)  SaffronRel[] inputs
           
private static HashMap mapUnaryOpToRex
           
protected  QueryEnvironment qenv
           
(package private)  QueryInfo queryInfo
           
protected  JavaRexBuilder rexBuilder
           
 
Constructor Summary
(package private) InternalTranslator(QueryInfo queryInfo, SaffronRel[] inputs, JavaRexBuilder rexBuilder)
           
 
Method Summary
private  SqlOperator binaryOpToSql(int op)
          Translates an operator code from Openjava (BinaryExpression.DIVIDE et cetera) to row-expression.
private static HashMap createBinaryMap()
           
private static HashMap createUnaryMap()
           
 RexNode evaluateDown(BinaryExpression p)
           
 RexNode evaluateDown(ConditionalExpression p)
           
 RexNode evaluateDown(FieldAccess p)
           
private  RexNode evaluateDown(Literal literal)
           
 RexNode evaluateDown(MethodCall call)
           
 RexNode evaluateDown(UnaryExpression p)
           
 RexNode evaluateDown(Variable p)
           
 Expression evaluateUp(AliasedExpression p)
           
 RexNode go(ParseTree p)
           
(package private)  QueryInfo.LookupResult lookupExp(String name)
          Returns an expression with which to reference a from-list item.
private  SqlOperator translateFun(String name)
           
private  RexKind unaryOpToRex(int op)
          Translates an operator code from Openjava (UnaryExpression.BIT_NOT et cetera) to row-expression.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

queryInfo

QueryInfo queryInfo

inputs

SaffronRel[] inputs

rexBuilder

protected final JavaRexBuilder rexBuilder

qenv

protected final QueryEnvironment qenv

mapUnaryOpToRex

private static final HashMap mapUnaryOpToRex
Constructor Detail

InternalTranslator

InternalTranslator(QueryInfo queryInfo,
                   SaffronRel[] inputs,
                   JavaRexBuilder rexBuilder)
Method Detail

createUnaryMap

private static HashMap createUnaryMap()

createBinaryMap

private static HashMap createBinaryMap()

go

public RexNode go(ParseTree p)

evaluateDown

private RexNode evaluateDown(Literal literal)

evaluateDown

public RexNode evaluateDown(FieldAccess p)

evaluateDown

public RexNode evaluateDown(UnaryExpression p)

unaryOpToRex

private RexKind unaryOpToRex(int op)
Translates an operator code from Openjava (UnaryExpression.BIT_NOT et cetera) to row-expression.


binaryOpToSql

private SqlOperator binaryOpToSql(int op)
Translates an operator code from Openjava (BinaryExpression.DIVIDE et cetera) to row-expression.


evaluateDown

public RexNode evaluateDown(BinaryExpression p)

evaluateDown

public RexNode evaluateDown(ConditionalExpression p)

evaluateDown

public RexNode evaluateDown(MethodCall call)

translateFun

private SqlOperator translateFun(String name)

evaluateDown

public RexNode evaluateDown(Variable 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