|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object net.sf.farrago.fennel.calc.CalcRexImplementorTableImpl
public class CalcRexImplementorTableImpl
Implementation of CalcRexImplementorTable
, containing implementations
for all standard functions.
Nested Class Summary | |
---|---|
static class |
CalcRexImplementorTableImpl.AbstractCalcRexAggImplementor
Abstract base class for classes which implement CalcRexAggImplementor . |
static class |
CalcRexImplementorTableImpl.AbstractCalcRexImplementor
Abstract base class for classes which implement CalcRexImplementor . |
private static class |
CalcRexImplementorTableImpl.AddCharSetNameInstrImplementor
A Class that gets a specified operand of a call and retrieves its charset name and add it as a vc literal to the program. |
private static class |
CalcRexImplementorTableImpl.BinaryNumericMakeSametypeImplementor
Makes all numeric types the same before calling a given instruction . |
private static class |
CalcRexImplementorTableImpl.BinaryStringMakeSametypeImplementor
Makes all string types the same before calling a given instruction . |
private static class |
CalcRexImplementorTableImpl.CaseImplementor
Implementor for CASE operator. |
private static class |
CalcRexImplementorTableImpl.CastDecimalImplementor
Implementor for casting between char and decimal types. |
private static class |
CalcRexImplementorTableImpl.CastImplementor
Implementor for CAST operator. |
private static class |
CalcRexImplementorTableImpl.CastTimestampToDateImplementor
Implementor for casting from TIMESTAMP to DATE. |
private static class |
CalcRexImplementorTableImpl.CastTimestampToTimeImplementor
Implementor for casting from TIMESTAMP to TIME. |
private static class |
CalcRexImplementorTableImpl.CastTimeToTimestampImplementor
Implementor for casting from TIME to TIMESTAMP. |
private static class |
CalcRexImplementorTableImpl.ConcatImplementor
|
private static class |
CalcRexImplementorTableImpl.CountCalcRexImplementor
Implementation of the COUNT aggregate function, SqlStdOperatorTable.countOperator . |
private static class |
CalcRexImplementorTableImpl.DatetimeRoundingImplementor
Helper to implement CAST to TIMESTAMP or TIME values. |
(package private) static class |
CalcRexImplementorTableImpl.DoubleKeyMap
|
private static class |
CalcRexImplementorTableImpl.FirstValueCalcRexImplementor
Implementation of the FIST_VALUE aggregate function, SqlStdOperatorTable.sumOperator . |
private static class |
CalcRexImplementorTableImpl.HistogramAggRexImplementor
Implementation of the $HISTOGRAM aggregate function (SqlStdOperatorTable.histogramAggFunction , which helps implement MIN,
MAX, FIRST_VALUE, LAST_VALUE in a windowed aggregation scenario. |
private static class |
CalcRexImplementorTableImpl.HistogramResultRexImplementor
Implementation of the operators which extract a result from a histogram: $HISTOGRAM_MIN ,
$HISTOGRAM_MAX ,
$HISTOGRAM_FIRST_VALUE ,
$HISTOGRAM_LAST_VALUE
|
private static class |
CalcRexImplementorTableImpl.IdentityImplementor
Implements the identity operator. |
static class |
CalcRexImplementorTableImpl.InstrDefImplementor
Generic implementor that takes a CalcProgramBuilder.InstructionDef which implements an operator by
generating a call to a given instruction. |
private static class |
CalcRexImplementorTableImpl.IsBoolImplementor
Implements "IS TRUE" and "IS FALSE" operators. |
private static class |
CalcRexImplementorTableImpl.IsNotBoolImplementor
Implements "IS NOT TRUE" and "IS NOT FALSE" operators. |
private static class |
CalcRexImplementorTableImpl.LastValueCalcRexImplementor
Implementation of the LAST_VALUE aggregate function, SqlStdOperatorTable.sumOperator . |
private static class |
CalcRexImplementorTableImpl.MakeOperandsDoubleImplementor
Implementor that will convert a RexCall 's operands to approx
DOUBLE if needed |
private static class |
CalcRexImplementorTableImpl.MinMaxCalcRexImplementor
Implementation of the MIN and MAX aggregate function, SqlStdOperatorTable.sumOperator . |
private static class |
CalcRexImplementorTableImpl.ReinterpretCastImplementor
Implementor for REINTERPRET operator. |
private static class |
CalcRexImplementorTableImpl.SliceImplementor
Implements the internal $SLICE
operator. |
private static class |
CalcRexImplementorTableImpl.SumCalcRexImplementor
Implementation of the SUM aggregate function, SqlStdOperatorTable.sumOperator . |
private static class |
CalcRexImplementorTableImpl.SumEmptyIsZeroCalcRexImplementor
Implementation of the SUM0 aggregate function, SqlStdOperatorTable.sumEmptyIsZeroOperator . |
private static class |
CalcRexImplementorTableImpl.TimeFunctionImplementor
|
private static class |
CalcRexImplementorTableImpl.TrimImplementor
Implements the TRIM function. |
private static class |
CalcRexImplementorTableImpl.UsingInstrImplementor
Implements a call by invoking a given instruction. |
Field Summary | |
---|---|
private Map<SqlAggFunction,CalcRexAggImplementor> |
aggImplementationMap
Maps SqlAggFunction to CalcRexAggImplementor . |
private Map<SqlOperator,CalcRexImplementor> |
operatorImplementationMap
Maps SqlOperator to CalcRexImplementorTableImpl.AbstractCalcRexImplementor . |
protected static SqlStdOperatorTable |
opTab
|
private CalcRexImplementorTable |
parent
Parent implementor table, may be null. |
private static CalcRexImplementorTableImpl |
std
|
Constructor Summary | |
---|---|
CalcRexImplementorTableImpl(CalcRexImplementorTable parent)
Creates an empty table which delegates to another table. |
Method Summary | |
---|---|
protected static CalcReg |
createResultRegister(RexToCalcTranslator translator,
RexCall call)
Creates a register to hold the result of a call. |
CalcRexImplementor |
get(SqlOperator op)
Retrieves the implementor of an operator, or null if there is no implementor registered. |
CalcRexAggImplementor |
getAgg(SqlAggFunction op)
Retrieves the implementor of an aggregate function. |
private static RexCall |
implementFirstOperandWithDouble(RexCall call,
RexToCalcTranslator translator,
RexNode typeNode,
int i,
boolean castBack)
Same as implementFirstOperandWithInt8(org.eigenbase.rex.RexCall, net.sf.farrago.fennel.calc.RexToCalcTranslator, org.eigenbase.rex.RexNode, int, boolean) but with CalcProgramBuilder.OpType.Double instead TODO need to abstract and merge
functionality with implementFirstOperandWithInt8(org.eigenbase.rex.RexCall, net.sf.farrago.fennel.calc.RexToCalcTranslator, org.eigenbase.rex.RexNode, int, boolean) since they both
contain nearly the same code |
private static RexCall |
implementFirstOperandWithDoubleOrInt8(RexCall call,
RexToCalcTranslator translator,
RexNode typeNode,
int i,
boolean castBack)
Converts a binary call (two regs as operands) by converting the first operand to type CalcProgramBuilder.OpType.Int8 for exact types
and CalcProgramBuilder.OpType.Double for approximate types and
then back again. |
private static RexCall |
implementFirstOperandWithInt8(RexCall call,
RexToCalcTranslator translator,
RexNode typeNode,
int i,
boolean castBack)
Converts a binary call (two regs as operands) by converting the first operand to type CalcProgramBuilder.OpType.Int8 if needed and then
back again. |
protected static List<CalcReg> |
implementOperands(RexCall call,
int start,
int stop,
RexToCalcTranslator translator)
Implements all operands to a call between start (inclusive) and stop (exclusive), and returns a list of the registers which hold the results. |
protected static List<CalcReg> |
implementOperands(RexCall call,
RexToCalcTranslator translator)
Implements all operands to a call, and returns a list of the registers which hold the results. |
private static CalcReg |
implementRounding(CalcReg inReg,
RoundingMode roundingMode,
RelDataType toType,
int fromPrecision,
RexToCalcTranslator translator)
Generates code to round 'operand' to the precision in 'toType', if necessary. |
private static CalcReg |
implementRounding(long alpha,
RoundingMode roundingMode,
CalcReg inReg,
RelDataType toType,
RexToCalcTranslator translator)
Generates code to round a value to a multiple of a given multipler. |
private static CalcReg |
implementUsingInstr(CalcProgramBuilder.InstructionDef instr,
RexToCalcTranslator translator,
RexCall call)
Implements a call by invoking a given instruction. |
private CalcRexImplementorTableImpl |
initStandard()
Registers the standard set of functions. |
void |
register(SqlOperator op,
CalcRexImplementor impl)
Registers an operator and its implementor. |
void |
registerAgg(SqlAggFunction agg,
CalcRexAggImplementor impl)
Registers an aggregate function and its implementor. |
protected void |
registerInstr(SqlOperator op,
CalcProgramBuilder.InstructionDef instrDef)
Registers an operator which is implemented in a trivial way by a single calculator instruction. |
static CalcRexImplementorTable |
std()
Returns the table of implementations of all of the standard SQL functions and operators. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
protected static final SqlStdOperatorTable opTab
private static final CalcRexImplementorTableImpl std
private final CalcRexImplementorTable parent
private final Map<SqlOperator,CalcRexImplementor> operatorImplementationMap
SqlOperator
to CalcRexImplementorTableImpl.AbstractCalcRexImplementor
.
private final Map<SqlAggFunction,CalcRexAggImplementor> aggImplementationMap
SqlAggFunction
to CalcRexAggImplementor
.
Constructor Detail |
---|
public CalcRexImplementorTableImpl(CalcRexImplementorTable parent)
std
Method Detail |
---|
public static CalcRexImplementorTable std()
public void register(SqlOperator op, CalcRexImplementor impl)
It is an error if the operator already has an implementor. But if the operator has an implementor in a parent table, it is simply overridden.
protected void registerInstr(SqlOperator op, CalcProgramBuilder.InstructionDef instrDef)
public void registerAgg(SqlAggFunction agg, CalcRexAggImplementor impl)
It is an error if the aggregate function already has an implementor. But if the operator has an implementor in a parent table, it is simply overridden.
public CalcRexImplementor get(SqlOperator op)
CalcRexImplementorTable
get
in interface CalcRexImplementorTable
public CalcRexAggImplementor getAgg(SqlAggFunction op)
CalcRexImplementorTable
getAgg
in interface CalcRexImplementorTable
protected static CalcReg createResultRegister(RexToCalcTranslator translator, RexCall call)
translator
- Translatorcall
- Call
protected static List<CalcReg> implementOperands(RexCall call, RexToCalcTranslator translator)
protected static List<CalcReg> implementOperands(RexCall call, int start, int stop, RexToCalcTranslator translator)
private static CalcReg implementUsingInstr(CalcProgramBuilder.InstructionDef instr, RexToCalcTranslator translator, RexCall call)
instr
- Instructiontranslator
- Translatorcall
- Call to translate
private static RexCall implementFirstOperandWithDoubleOrInt8(RexCall call, RexToCalcTranslator translator, RexNode typeNode, int i, boolean castBack)
CalcProgramBuilder.OpType.Int8
for exact types
and CalcProgramBuilder.OpType.Double
for approximate types and
then back again. Logically it will do something like
private static RexCall implementFirstOperandWithInt8(RexCall call, RexToCalcTranslator translator, RexNode typeNode, int i, boolean castBack)
CalcProgramBuilder.OpType.Int8
if needed and then
back again. Logically it will do something like
private static RexCall implementFirstOperandWithDouble(RexCall call, RexToCalcTranslator translator, RexNode typeNode, int i, boolean castBack)
implementFirstOperandWithInt8(org.eigenbase.rex.RexCall, net.sf.farrago.fennel.calc.RexToCalcTranslator, org.eigenbase.rex.RexNode, int, boolean)
but with CalcProgramBuilder.OpType.Double
instead TODO need to abstract and merge
functionality with implementFirstOperandWithInt8(org.eigenbase.rex.RexCall, net.sf.farrago.fennel.calc.RexToCalcTranslator, org.eigenbase.rex.RexNode, int, boolean)
since they both
contain nearly the same code
private CalcRexImplementorTableImpl initStandard()
private static CalcReg implementRounding(CalcReg inReg, RoundingMode roundingMode, RelDataType toType, int fromPrecision, RexToCalcTranslator translator)
Rounding is to a multiple of 10 ^ (3 - precision), according to the
RoundingMode
strategy of the roundingMode
parameter.
If the result has the same or more precision, generates no code.
inReg
- Register holding input valueroundingMode
- Rounding mode; one of RoundingMode.FLOOR
,
RoundingMode.HALF_UP
, RoundingMode.DOWN
.toType
- Desired target typefromPrecision
- Precision of the input valuetranslator
- Translator
private static CalcReg implementRounding(long alpha, RoundingMode roundingMode, CalcReg inReg, RelDataType toType, RexToCalcTranslator translator)
Supports rounding modes .
alpha
- The multiplier to round toroundingMode
- Rounding mode; one of RoundingMode.FLOOR
,
RoundingMode.HALF_UP
, RoundingMode.DOWN
.inReg
- Register holding input valuetoType
- Type to convert totranslator
- Translator
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |