public interface PhysType
Consists of the SQL row type (returned by getRowType()), the Java
type of the row (returned by getJavaRowType()), and methods to
generate expressions to access fields, generate records, and so forth.
Together, the records encapsulate how the logical type maps onto the physical
type.
| Modifier and Type | Method and Description |
|---|---|
List<Expression> |
accessors(Expression parameter,
List<Integer> argList) |
Expression |
comparer()
Returns a expression that yields a comparer, or null if this type
is comparable.
|
Expression |
convertTo(Expression expression,
PhysType targetPhysType)
Converts an enumerable of this physical type to an enumerable that uses a
given physical type for its rows.
|
Class |
fieldClass(int field)
Returns the Java class of the field with the given ordinal.
|
boolean |
fieldNullable(int index)
Returns whether a given field allows null values.
|
Expression |
fieldReference(Expression expression,
int field)
Generates a reference to a given field in an expression.
|
Expression |
fieldReference(Expression expression,
int field,
Type storageType)
Generates a reference to a given field in an expression.
|
Expression |
generateAccessor(List<Integer> fields)
Generates an accessor function for a given list of fields.
|
Pair<Expression,Expression> |
generateCollationKey(List<RelFieldCollation> collations)
Returns a lambda to create a collation key and a comparator.
|
Expression |
generateComparator(RelCollation collation)
Returns a comparator.
|
Expression |
generateSelector(ParameterExpression parameter,
List<Integer> fields)
Generates a selector for the given fields from an expression, with the
default row format.
|
Expression |
generateSelector(ParameterExpression parameter,
List<Integer> fields,
JavaRowFormat targetFormat)
Generates a lambda expression that is a selector for the given fields from
an expression.
|
Expression |
generateSelector(ParameterExpression parameter,
List<Integer> fields,
List<Integer> usedFields,
JavaRowFormat targetFormat)
Generates a lambda expression that is a selector for the given fields from
an expression.
|
JavaRowFormat |
getFormat()
Returns the format.
|
Type |
getJavaFieldType(int field)
Returns the Java class that is used to store the field with the given
ordinal.
|
Type |
getJavaRowType()
Returns the Java type (often a Class) that represents a row.
|
RelDataType |
getRowType()
Returns the SQL row type.
|
PhysType |
makeNullable(boolean nullable)
Returns a copy of this type that allows nulls if
nullable is
true. |
PhysType |
project(List<Integer> integers,
boolean indicator,
JavaRowFormat format)
Projects a given collection of fields from this input record, optionally
with indicator fields, into a particular preferred output format.
|
PhysType |
project(List<Integer> integers,
JavaRowFormat format)
Projects a given collection of fields from this input record, into
a particular preferred output format.
|
Expression |
record(List<Expression> expressions)
Generates an expression that creates a record for a row, initializing
its fields with the given expressions.
|
Expression |
selector(ParameterExpression parameter,
List<Integer> fields,
JavaRowFormat targetFormat)
Generates a selector for the given fields from an expression.
|
Type getJavaRowType()
Object[].class.Type getJavaFieldType(int field)
For instance, when the java row type is Object[], the java
field type is Object even if the field is not nullable.
RelDataType getRowType()
Class fieldClass(int field)
boolean fieldNullable(int index)
Expression fieldReference(Expression expression, int field)
For example given expression=employee and field=2,
generates
employee.deptnoexpression - Expressionfield - Ordinal of fieldExpression fieldReference(Expression expression, int field, Type storageType)
This method optimizes for the target storage type (i.e. avoids casts).
For example given expression=employee and field=2,
generates
employee.deptnoexpression - Expressionfield - Ordinal of fieldstorageType - optional hint for storage classExpression generateAccessor(List<Integer> fields)
List (implementing Object.hashCode() and
Object.equals(Object) per that interface) and also implements
Comparable.
For example:
new Function1<Employee, Object[]> {
public Object[] apply(Employee v1) {
return FlatLists.of(v1.<fieldN>, v1.<fieldM>);
}
}
Expression generateSelector(ParameterExpression parameter, List<Integer> fields)
Expression generateSelector(ParameterExpression parameter, List<Integer> fields, JavaRowFormat targetFormat)
Expression generateSelector(ParameterExpression parameter, List<Integer> fields, List<Integer> usedFields, JavaRowFormat targetFormat)
usedFields must be a subset of fields.
For each field, there is a corresponding indicator field.
If a field is used, its value is assigned and its indicator is left
false.
If a field is not used, its value is not assigned and its indicator is
set to true;
This will become a value of 1 when GROUPING(field) is called.
Expression selector(ParameterExpression parameter, List<Integer> fields, JavaRowFormat targetFormat)
PhysType project(List<Integer> integers, JavaRowFormat format)
PhysType project(List<Integer> integers, boolean indicator, JavaRowFormat format)
The output format is optimized if there are 0 or 1 fields and indicators are disabled.
Pair<Expression,Expression> generateCollationKey(List<RelFieldCollation> collations)
Expression generateComparator(RelCollation collation)
generateCollationKey(java.util.List), this comparator acts on the
whole element.Expression comparer()
Expression record(List<Expression> expressions)
expressions - Expression to initialize each fieldJavaRowFormat getFormat()
List<Expression> accessors(Expression parameter, List<Integer> argList)
PhysType makeNullable(boolean nullable)
nullable is
true.Expression convertTo(Expression expression, PhysType targetPhysType)
Copyright © 2012–2015 The Apache Software Foundation. All rights reserved.