public abstract class RelDataTypeFactoryImpl extends Object implements RelDataTypeFactory
RelDataTypeFactory.| Modifier and Type | Class and Description |
|---|---|
class |
RelDataTypeFactoryImpl.JavaType
Type which is based upon a Java class.
|
private static class |
RelDataTypeFactoryImpl.Key
Key to the data type cache.
|
RelDataTypeFactory.Builder, RelDataTypeFactory.FieldInfo, RelDataTypeFactory.FieldInfoBuilder| Modifier and Type | Field and Description |
|---|---|
private static com.google.common.cache.LoadingCache<Object,RelDataType> |
CACHE
Global cache.
|
private static Map<Class,RelDataTypeFamily> |
CLASS_FAMILIES |
protected RelDataTypeSystem |
typeSystem |
| Modifier | Constructor and Description |
|---|---|
protected |
RelDataTypeFactoryImpl(RelDataTypeSystem typeSystem)
Creates a type factory.
|
| Modifier and Type | Method and Description |
|---|---|
private static void |
addFields(RelDataType type,
List<RelDataTypeField> fieldList)
Adds all fields in
type to fieldList,
renumbering the fields (if necessary) to ensure that their index
matches their position in the list. |
RelDataTypeFactory.FieldInfoBuilder |
builder()
Creates a
RelDataTypeFactory.FieldInfoBuilder. |
protected RelDataType |
canonize(RelDataType type)
Registers a type, or returns the existing type if it is already
registered.
|
protected RelDataType |
canonize(StructKind kind,
List<String> names,
List<RelDataType> types)
Looks up a type using a temporary key, and if not present, creates
a permanent key and type.
|
private RelDataType |
copyRecordType(RelRecordType type,
boolean ignoreNullable,
boolean nullable) |
private RelDataType |
copySimpleType(RelDataType type,
boolean nullable) |
RelDataType |
copyType(RelDataType type)
Duplicates a type, making a deep copy.
|
RelDataType |
createDecimalProduct(RelDataType type1,
RelDataType type2)
Infers the return type of a decimal multiplication.
|
RelDataType |
createDecimalQuotient(RelDataType type1,
RelDataType type2)
Rules:
Let p1, s1 be the precision and scale of the first operand
Let p2, s2 be the precision and scale of the second operand
Let p, s be the precision and scale of the result
Let d be the number of whole digits in the result
Then the result type is a decimal with:
d = p1 - s1 + s2
s < max(6, s1 + p2 + 1)
p = d + s
p and s are capped at their maximum values
|
RelDataType |
createJavaType(Class clazz)
Creates a type that corresponds to a Java class.
|
RelDataType |
createJoinType(RelDataType... types)
Creates a cartesian product type.
|
RelDataType |
createStructType(List<? extends Map.Entry<String,RelDataType>> fieldList)
Creates a type that represents a structured collection of fieldList,
obtaining the field information from a list of (name, type) pairs.
|
RelDataType |
createStructType(List<RelDataType> typeList,
List<String> fieldNameList)
Creates a type that represents a structured collection of fields.
|
RelDataType |
createStructType(RelDataTypeFactory.FieldInfo fieldInfo)
Creates a type that represents a structured collection of fields,
obtaining the field information via a callback.
|
RelDataType |
createStructType(StructKind kind,
List<RelDataType> typeList,
List<String> fieldNameList)
Creates a type that represents a structured collection of fields, given
lists of the names and types of the fields.
|
RelDataType |
createTypeWithNullability(RelDataType type,
boolean nullable)
Creates a type that is the same as another type but with possibly
different nullability.
|
private List<RelDataTypeFieldImpl> |
fieldsOf(Class clazz) |
Charset |
getDefaultCharset() |
private static List<RelDataTypeField> |
getFieldList(List<RelDataType> types)
Returns a list of the fields in a list of types.
|
private static void |
getTypeList(com.google.common.collect.ImmutableList<RelDataType> inTypes,
List<RelDataType> flatTypes)
Returns a list of all atomic types in a list.
|
RelDataTypeSystem |
getTypeSystem()
Returns the type system.
|
static boolean |
isJavaType(RelDataType t) |
RelDataType |
leastRestrictive(List<RelDataType> types)
Returns the most general of a set of types (that is, one type to which
they can all be cast), or null if conversion is not possible.
|
protected RelDataType |
leastRestrictiveStructuredType(List<RelDataType> types) |
boolean |
useDoubleMultiplication(RelDataType type1,
RelDataType type2)
Returns whether a decimal multiplication should be implemented by casting
arguments to double values.
|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitcreateArrayType, createMapType, createMultisetType, createSqlIntervalType, createSqlType, createSqlType, createSqlType, createTypeWithCharsetAndCollation, createUnknownTypeprivate static final com.google.common.cache.LoadingCache<Object,RelDataType> CACHE
private static final Map<Class,RelDataTypeFamily> CLASS_FAMILIES
protected final RelDataTypeSystem typeSystem
protected RelDataTypeFactoryImpl(RelDataTypeSystem typeSystem)
public RelDataTypeSystem getTypeSystem()
RelDataTypeFactorygetTypeSystem in interface RelDataTypeFactorypublic RelDataType createJavaType(Class clazz)
RelDataTypeFactorycreateJavaType in interface RelDataTypeFactoryclazz - the Java class used to define the typepublic RelDataType createJoinType(RelDataType... types)
RelDataTypeFactorycreateJoinType in interface RelDataTypeFactorytypes - array of types to be joinedpublic RelDataType createStructType(List<RelDataType> typeList, List<String> fieldNameList)
RelDataTypeFactorycreateStructType(StructKind.FULLY_QUALIFIED, typeList,
fieldNameList).createStructType in interface RelDataTypeFactorypublic RelDataType createStructType(StructKind kind, List<RelDataType> typeList, List<String> fieldNameList)
RelDataTypeFactorycreateStructType in interface RelDataTypeFactorykind - Name resolution policytypeList - types of the fieldsfieldNameList - names of the fieldspublic RelDataType createStructType(RelDataTypeFactory.FieldInfo fieldInfo)
RelDataTypeFactorycreateStructType in interface RelDataTypeFactoryfieldInfo - callback for field informationpublic final RelDataType createStructType(List<? extends Map.Entry<String,RelDataType>> fieldList)
RelDataTypeFactorycreateStructType in interface RelDataTypeFactoryfieldList - List of (name, type) pairspublic RelDataType leastRestrictive(List<RelDataType> types)
RelDataTypeFactoryleastRestrictive(INT, NUMERIC(3, 2)) could be
NUMERIC(12, 2).leastRestrictive in interface RelDataTypeFactorytypes - input types to be combined using union (not null, not empty)protected RelDataType leastRestrictiveStructuredType(List<RelDataType> types)
private RelDataType copySimpleType(RelDataType type, boolean nullable)
private RelDataType copyRecordType(RelRecordType type, boolean ignoreNullable, boolean nullable)
public RelDataType copyType(RelDataType type)
RelDataTypeFactorycopyType in interface RelDataTypeFactorytype - input typepublic RelDataType createTypeWithNullability(RelDataType type, boolean nullable)
RelDataTypeFactorycreateTypeWithNullability in interface RelDataTypeFactorytype - input typenullable - true to request a nullable type; false to request a NOT
NULL typeprotected RelDataType canonize(RelDataType type)
NullPointerException - if type is nullprotected RelDataType canonize(StructKind kind, List<String> names, List<RelDataType> types)
This approach allows us to use a cheap temporary key. A permanent key is more expensive, because it must be immutable and not hold references into other data structures.
private static List<RelDataTypeField> getFieldList(List<RelDataType> types)
private static void getTypeList(com.google.common.collect.ImmutableList<RelDataType> inTypes, List<RelDataType> flatTypes)
private static void addFields(RelDataType type, List<RelDataTypeField> fieldList)
type to fieldList,
renumbering the fields (if necessary) to ensure that their index
matches their position in the list.public static boolean isJavaType(RelDataType t)
private List<RelDataTypeFieldImpl> fieldsOf(Class clazz)
public RelDataType createDecimalProduct(RelDataType type1, RelDataType type2)
Implement RelDataTypeFactory with SQL 2003 compliant behavior. Let p1, s1 be the precision and scale of the first operand Let p2, s2 be the precision and scale of the second operand Let p, s be the precision and scale of the result, Then the result type is a decimal with:
p and s are capped at their maximum values
createDecimalProduct in interface RelDataTypeFactorytype1 - type of the first operandtype2 - type of the second operandSQL:2003 Part 2 Section 6.26public boolean useDoubleMultiplication(RelDataType type1, RelDataType type2)
RelDataTypeFactoryPre-condition: createDecimalProduct(type1, type2) != null
useDoubleMultiplication in interface RelDataTypeFactorypublic RelDataType createDecimalQuotient(RelDataType type1, RelDataType type2)
createDecimalQuotient in interface RelDataTypeFactorytype1 - type of the first operandtype2 - type of the second operandSQL:2003 Part 2 Section 6.26public Charset getDefaultCharset()
getDefaultCharset in interface RelDataTypeFactoryCharset for string typespublic RelDataTypeFactory.FieldInfoBuilder builder()
RelDataTypeFactoryRelDataTypeFactory.FieldInfoBuilder.
But since FieldInfoBuilder is deprecated, we recommend that you use
its base class RelDataTypeFactory.Builder, which is not deprecated.builder in interface RelDataTypeFactoryCopyright © 2012–2018 The Apache Software Foundation. All rights reserved.