Class PhysTypeImpl
- java.lang.Object
-
- org.apache.calcite.adapter.enumerable.PhysTypeImpl
-
-
Field Summary
Fields Modifier and Type Field Description private java.util.List<java.lang.Class>
fieldClasses
(package private) JavaRowFormat
format
private java.lang.reflect.Type
javaRowClass
private RelDataType
rowType
private JavaTypeFactory
typeFactory
-
Constructor Summary
Constructors Constructor Description PhysTypeImpl(JavaTypeFactory typeFactory, RelDataType rowType, java.lang.reflect.Type javaRowClass, JavaRowFormat format)
Creates a PhysTypeImpl.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description java.util.List<Expression>
accessors(Expression v1, java.util.List<java.lang.Integer> argList)
Expression
comparer()
Returns a expression that yields a comparer, or null if this type is comparable.PhysType
component(int fieldOrdinal)
Returns the physical type of a given field's component type.Expression
convertTo(Expression exp, PhysType targetPhysType)
Converts an enumerable of this physical type to an enumerable that uses a given physical type for its rows.PhysType
field(int ordinal)
Returns the physical type of a field.java.lang.Class
fieldClass(int field)
Returns the Java class of the field with the given ordinal.boolean
fieldNullable(int field)
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, java.lang.reflect.Type storageType)
Generates a reference to a given field in an expression.private java.util.List<Expression>
fieldReferences(Expression parameter, java.util.List<java.lang.Integer> fields)
Expression
generateAccessor(java.util.List<java.lang.Integer> fields)
Generates an accessor function for a given list of fields.Pair<Expression,Expression>
generateCollationKey(java.util.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, java.util.List<java.lang.Integer> fields)
Generates a selector for the given fields from an expression, with the default row format.Expression
generateSelector(ParameterExpression parameter, java.util.List<java.lang.Integer> fields, java.util.List<java.lang.Integer> usedFields, JavaRowFormat targetFormat)
Generates a lambda expression that is a selector for the given fields from an expression.Expression
generateSelector(ParameterExpression parameter, java.util.List<java.lang.Integer> fields, JavaRowFormat targetFormat)
Generates a lambda expression that is a selector for the given fields from an expression.JavaRowFormat
getFormat()
Returns the format.java.lang.reflect.Type
getJavaFieldType(int index)
Returns the Java class that is used to store the field with the given ordinal.java.lang.reflect.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 ifnullable
is true.(package private) static PhysType
of(JavaTypeFactory typeFactory, java.lang.reflect.Type javaRowClass)
static PhysType
of(JavaTypeFactory typeFactory, RelDataType rowType, JavaRowFormat format)
static PhysType
of(JavaTypeFactory typeFactory, RelDataType rowType, JavaRowFormat format, boolean optimize)
PhysType
project(java.util.List<java.lang.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(java.util.List<java.lang.Integer> integers, JavaRowFormat format)
Projects a given collection of fields from this input record, into a particular preferred output format.Expression
record(java.util.List<Expression> expressions)
Generates an expression that creates a record for a row, initializing its fields with the given expressions.Pair<java.lang.reflect.Type,java.util.List<Expression>>
selector(ParameterExpression parameter, java.util.List<java.lang.Integer> fields, JavaRowFormat targetFormat)
Generates a selector for the given fields from an expression.private RelDataType
toStruct(RelDataType type)
-
-
-
Field Detail
-
typeFactory
private final JavaTypeFactory typeFactory
-
rowType
private final RelDataType rowType
-
javaRowClass
private final java.lang.reflect.Type javaRowClass
-
fieldClasses
private final java.util.List<java.lang.Class> fieldClasses
-
format
final JavaRowFormat format
-
-
Constructor Detail
-
PhysTypeImpl
PhysTypeImpl(JavaTypeFactory typeFactory, RelDataType rowType, java.lang.reflect.Type javaRowClass, JavaRowFormat format)
Creates a PhysTypeImpl.
-
-
Method Detail
-
of
public static PhysType of(JavaTypeFactory typeFactory, RelDataType rowType, JavaRowFormat format)
-
of
public static PhysType of(JavaTypeFactory typeFactory, RelDataType rowType, JavaRowFormat format, boolean optimize)
-
of
static PhysType of(JavaTypeFactory typeFactory, java.lang.reflect.Type javaRowClass)
-
getFormat
public JavaRowFormat getFormat()
Description copied from interface:PhysType
Returns the format.
-
project
public PhysType project(java.util.List<java.lang.Integer> integers, JavaRowFormat format)
Description copied from interface:PhysType
Projects a given collection of fields from this input record, into a particular preferred output format. The output format is optimized if there are 0 or 1 fields.
-
project
public PhysType project(java.util.List<java.lang.Integer> integers, boolean indicator, JavaRowFormat format)
Description copied from interface:PhysType
Projects a given collection of fields from this input record, optionally with indicator fields, into a particular preferred output format.The output format is optimized if there are 0 or 1 fields and indicators are disabled.
-
generateSelector
public Expression generateSelector(ParameterExpression parameter, java.util.List<java.lang.Integer> fields)
Description copied from interface:PhysType
Generates a selector for the given fields from an expression, with the default row format.- Specified by:
generateSelector
in interfacePhysType
-
generateSelector
public Expression generateSelector(ParameterExpression parameter, java.util.List<java.lang.Integer> fields, JavaRowFormat targetFormat)
Description copied from interface:PhysType
Generates a lambda expression that is a selector for the given fields from an expression.- Specified by:
generateSelector
in interfacePhysType
-
generateSelector
public Expression generateSelector(ParameterExpression parameter, java.util.List<java.lang.Integer> fields, java.util.List<java.lang.Integer> usedFields, JavaRowFormat targetFormat)
Description copied from interface:PhysType
Generates a lambda expression that is a selector for the given fields from an expression.usedFields
must be a subset offields
. For each field, there is a corresponding indicator field. If a field is used, its value is assigned and its indicator is leftfalse
. If a field is not used, its value is not assigned and its indicator is set totrue
; This will become a value of 1 whenGROUPING(field)
is called.- Specified by:
generateSelector
in interfacePhysType
-
selector
public Pair<java.lang.reflect.Type,java.util.List<Expression>> selector(ParameterExpression parameter, java.util.List<java.lang.Integer> fields, JavaRowFormat targetFormat)
Description copied from interface:PhysType
Generates a selector for the given fields from an expression. Only used by EnumerableWindow.
-
accessors
public java.util.List<Expression> accessors(Expression v1, java.util.List<java.lang.Integer> argList)
-
makeNullable
public PhysType makeNullable(boolean nullable)
Description copied from interface:PhysType
Returns a copy of this type that allows nulls ifnullable
is true.- Specified by:
makeNullable
in interfacePhysType
-
convertTo
public Expression convertTo(Expression exp, PhysType targetPhysType)
Description copied from interface:PhysType
Converts an enumerable of this physical type to an enumerable that uses a given physical type for its rows.
-
generateCollationKey
public Pair<Expression,Expression> generateCollationKey(java.util.List<RelFieldCollation> collations)
Description copied from interface:PhysType
Returns a lambda to create a collation key and a comparator. The comparator is sometimes null.- Specified by:
generateCollationKey
in interfacePhysType
-
generateComparator
public Expression generateComparator(RelCollation collation)
Description copied from interface:PhysType
Returns a comparator. Unlike the comparator returned byPhysType.generateCollationKey(java.util.List)
, this comparator acts on the whole element.- Specified by:
generateComparator
in interfacePhysType
-
getRowType
public RelDataType getRowType()
Description copied from interface:PhysType
Returns the SQL row type.- Specified by:
getRowType
in interfacePhysType
-
record
public Expression record(java.util.List<Expression> expressions)
Description copied from interface:PhysType
Generates an expression that creates a record for a row, initializing its fields with the given expressions. There must be one expression per field.
-
getJavaRowType
public java.lang.reflect.Type getJavaRowType()
Description copied from interface:PhysType
Returns the Java type (often a Class) that represents a row. For example, in one row format, always returnsObject[].class
.- Specified by:
getJavaRowType
in interfacePhysType
-
getJavaFieldType
public java.lang.reflect.Type getJavaFieldType(int index)
Description copied from interface:PhysType
Returns the Java class that is used to store the field with the given ordinal.For instance, when the java row type is
Object[]
, the java field type isObject
even if the field is not nullable.- Specified by:
getJavaFieldType
in interfacePhysType
-
component
public PhysType component(int fieldOrdinal)
Description copied from interface:PhysType
Returns the physical type of a given field's component type.
-
field
public PhysType field(int ordinal)
Description copied from interface:PhysType
Returns the physical type of a field.
-
toStruct
private RelDataType toStruct(RelDataType type)
-
comparer
public Expression comparer()
Description copied from interface:PhysType
Returns a expression that yields a comparer, or null if this type is comparable.
-
fieldReferences
private java.util.List<Expression> fieldReferences(Expression parameter, java.util.List<java.lang.Integer> fields)
-
fieldClass
public java.lang.Class fieldClass(int field)
Description copied from interface:PhysType
Returns the Java class of the field with the given ordinal.- Specified by:
fieldClass
in interfacePhysType
-
fieldNullable
public boolean fieldNullable(int field)
Description copied from interface:PhysType
Returns whether a given field allows null values.- Specified by:
fieldNullable
in interfacePhysType
-
generateAccessor
public Expression generateAccessor(java.util.List<java.lang.Integer> fields)
Description copied from interface:PhysType
Generates an accessor function for a given list of fields. The resulting object is aList
(implementingObject.hashCode()
andObject.equals(Object)
per that interface) and also implementsComparable
.For example:
new Function1<Employee, Object[]> { public Object[] apply(Employee v1) { return FlatLists.of(v1.<fieldN>, v1.<fieldM>); } } }
- Specified by:
generateAccessor
in interfacePhysType
-
fieldReference
public Expression fieldReference(Expression expression, int field)
Description copied from interface:PhysType
Generates a reference to a given field in an expression.For example given
expression=employee
andfield=2
, generatesemployee.deptno
- Specified by:
fieldReference
in interfacePhysType
- Parameters:
expression
- Expressionfield
- Ordinal of field- Returns:
- Expression to access the field of the expression
-
fieldReference
public Expression fieldReference(Expression expression, int field, java.lang.reflect.Type storageType)
Description copied from interface:PhysType
Generates a reference to a given field in an expression.This method optimizes for the target storage type (i.e. avoids casts).
For example given
expression=employee
andfield=2
, generatesemployee.deptno
- Specified by:
fieldReference
in interfacePhysType
- Parameters:
expression
- Expressionfield
- Ordinal of fieldstorageType
- optional hint for storage class- Returns:
- Expression to access the field of the expression
-
-