|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES All Classes | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--net.sf.saffron.rel.SaffronRel | +--net.sf.saffron.oj.rel.ExpressionReaderRel
An ExpressionReaderRel
is a relational expression node which
evaluates an expression and returns the results as a relation. Cases:
T[]
, the each result row is of
type T
.
Map
or derives from Hashtable
, each result row contains fields {Object key;
Object value;}
.
Iterator
or derives from
Enumeration
, each result row is an Object
.
NOTE: We support Hashtable
, Enumeration
and Vector
explicitly because Map
,
Iterator
and Map
does not exist until
JDK 1.2.
Example accessing an array:
Emp[] emps; Emp[] males = (select from emps as emp where emp.gender.equals("M"));
The following example shows how you can cast the values returned from a
Hashtable
:
Hashtable nameToDeptno = new Hashtable(); nameToDeptno.put("Fred", new Integer(20)); nameToDeptno.put("Eric", new Integer(10)); nameToDeptno.put("Bill", new Integer(10)); for (i in (select {(String) key, ((Integer) value).intValue() as value} from nameToDeptno)) { print(i.key + " is in dept " + i.value); }
Here we access a value in a Hashtable
by key:
Because the Hashtable is being accessed via its key, the optimizer will probably optimize this code toObject fredDeptno = (select value from nameToDeptno where key.equals("Fred");
nameToDeptno.get("Fred")
.
Field Summary | |
protected CallingConvention |
convention
|
private boolean |
distinct
Whether the rows are distinct; set by deriveRowType() . |
protected RexNode |
exp
|
Fields inherited from class net.sf.saffron.rel.SaffronRel |
cluster, digest, id, rowType |
Constructor Summary | |
ExpressionReaderRel(VolcanoCluster cluster,
RexNode exp,
SaffronType rowType)
Creates an ExpressionReaderRel . |
Method Summary | |
private CallingConvention |
chooseConvention(RexNode exp)
|
Object |
clone()
|
PlanCost |
computeSelfCost(SaffronPlanner planner)
Returns the cost of this plan (not including children). |
protected SaffronType |
deriveRowType()
|
void |
explain(PlanWriter pw)
|
RexNode[] |
getChildExps()
Returns an array of this SaffronRel 's child expressions
(not including the inputs returned by SaffronRel.getInputs() . |
CallingConvention |
getConvention()
Returns a value from CallingConvention . |
RexNode |
getExp()
|
Object |
implement(RelImplementor implementor,
int ordinal)
Create a plan for this expression according to a calling convention. |
boolean |
isDistinct()
Returns whether the same value will not come out twice. |
private static boolean |
isDistinct(ArrayAllocationExpression arrayAlloc)
Returns true if the array allocation expression consists of distinct literals, false otherwise. |
private boolean |
isDistinct(RexNode exp)
|
Methods inherited from class net.sf.saffron.rel.SaffronRel |
childrenAccept, computeDigest, getCluster, getCorrelVariable, getId, getInput, getInputs, getOrCreateCorrelVariable, getQualifier, getQuery, getRelTypeName, getRows, getRowType, getTable, getVariablesStopped, implementFieldAccess, isAccessTo, onRegister, recomputeDigest, register, registerCorrelVariable, replaceInput, setCorrelVariable, toString |
Methods inherited from class java.lang.Object |
equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Field Detail |
protected CallingConvention convention
protected RexNode exp
private boolean distinct
deriveRowType()
.
Constructor Detail |
public ExpressionReaderRel(VolcanoCluster cluster, RexNode exp, SaffronType rowType)
ExpressionReaderRel
.
cluster
- VolcanoCluster
this relational expression
belongs toexp
- expression to evaluaterowType
- row type of the expression; if null, the row type is
deduced from the expression (for example, the row type of a
Iterator
is Object
.
Note that actual row type of the relational expression is
always a record type with a single field. For example, if you
supply an expression of type "java.util.Iterator" and specify that
the row type is "java.lang.String" then the row type will be
"Record{$f0:String}".Method Detail |
public RexNode[] getChildExps()
SaffronRel
SaffronRel
's child expressions
(not including the inputs returned by SaffronRel.getInputs()
. If there
are no child expressions, returns an empty array, not
null
.
getChildExps
in class SaffronRel
public CallingConvention getConvention()
SaffronRel
CallingConvention
.
getConvention
in class SaffronRel
public boolean isDistinct()
SaffronRel
false
, derived classes should override.
isDistinct
in class SaffronRel
public RexNode getExp()
public Object clone()
clone
in class SaffronRel
public PlanCost computeSelfCost(SaffronPlanner planner)
SaffronRel
computeSelfCost
in class SaffronRel
public void explain(PlanWriter pw)
explain
in class SaffronRel
public Object implement(RelImplementor implementor, int ordinal)
SaffronRel
implement
in class SaffronRel
implementor
- implementorordinal
- indicates our position in the pre-, in- and postfix walk
over the tree; ordinal
is -1 when called from the
parent, and i
when called from the
i
th child.protected SaffronType deriveRowType()
deriveRowType
in class SaffronRel
private boolean isDistinct(RexNode exp)
private static boolean isDistinct(ArrayAllocationExpression arrayAlloc)
isDistinct(new String[]
{ "a", "b"})
returns true, isDistinct(new int[] {1,
1+1})
returns false.
private CallingConvention chooseConvention(RexNode exp)
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES All Classes | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |