flink-issues mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "ASF GitHub Bot (JIRA)" <j...@apache.org>
Subject [jira] [Commented] (FLINK-7452) Add helper methods for all built-in Flink types to Types
Date Mon, 02 Oct 2017 14:50:00 GMT

    [ https://issues.apache.org/jira/browse/FLINK-7452?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16188220#comment-16188220
] 

ASF GitHub Bot commented on FLINK-7452:
---------------------------------------

Github user fhueske commented on a diff in the pull request:

    https://github.com/apache/flink/pull/4612#discussion_r142159219
  
    --- Diff: flink-core/src/main/java/org/apache/flink/api/common/typeinfo/Types.java ---
    @@ -19,56 +19,417 @@
     package org.apache.flink.api.common.typeinfo;
     
     import org.apache.flink.annotation.PublicEvolving;
    +import org.apache.flink.api.common.functions.InvalidTypesException;
    +import org.apache.flink.api.java.typeutils.EitherTypeInfo;
    +import org.apache.flink.api.java.typeutils.EnumTypeInfo;
    +import org.apache.flink.api.java.typeutils.GenericTypeInfo;
    +import org.apache.flink.api.java.typeutils.ListTypeInfo;
    +import org.apache.flink.api.java.typeutils.MapTypeInfo;
    +import org.apache.flink.api.java.typeutils.ObjectArrayTypeInfo;
    +import org.apache.flink.api.java.typeutils.PojoField;
    +import org.apache.flink.api.java.typeutils.PojoTypeInfo;
     import org.apache.flink.api.java.typeutils.RowTypeInfo;
    +import org.apache.flink.api.java.typeutils.TupleTypeInfo;
    +import org.apache.flink.api.java.typeutils.TypeExtractor;
    +import org.apache.flink.api.java.typeutils.ValueTypeInfo;
     
    -import java.math.BigDecimal;
    -import java.sql.Date;
    -import java.sql.Time;
    -import java.sql.Timestamp;
    +import java.lang.reflect.Field;
    +import java.util.ArrayList;
    +import java.util.List;
    +import java.util.Map;
     
     /**
    - * This class gives access to the type information of the most most common types.
    + * This class gives access to the type information of the most common types for which
Flink
    + * has built-in serializers and comparators.
    + *
    + * <p>In many cases, Flink tries to analyze generic signatures of functions to
determine return
    + * types automatically. This class is intended for cases where type information has to
be
    + * supplied manually or would result in an inefficient type.
    + *
    + * <p>Please note that the Scala API and Table API provide more specialized Types
classes.
    + * (See <code>org.apache.flink.api.scala.Types</code> and <code>org.apache.flink.table.api.Types</code>)
    + *
    + * <p>A more convenient alternative might be a {@link TypeHint}.
    + *
    + * @see TypeInformation#of(Class) specify type information based on a class that will
be analyzed
    + * @see TypeInformation#of(TypeHint) specify type information based on a {@link TypeHint}
      */
     @PublicEvolving
     public class Types {
     
    -	public static final BasicTypeInfo<String> STRING = BasicTypeInfo.STRING_TYPE_INFO;
    -	public static final BasicTypeInfo<Boolean> BOOLEAN = BasicTypeInfo.BOOLEAN_TYPE_INFO;
    -	public static final BasicTypeInfo<Byte> BYTE = BasicTypeInfo.BYTE_TYPE_INFO;
    -	public static final BasicTypeInfo<Short> SHORT = BasicTypeInfo.SHORT_TYPE_INFO;
    -	public static final BasicTypeInfo<Integer> INT = BasicTypeInfo.INT_TYPE_INFO;
    -	public static final BasicTypeInfo<Long> LONG = BasicTypeInfo.LONG_TYPE_INFO;
    -	public static final BasicTypeInfo<Float> FLOAT = BasicTypeInfo.FLOAT_TYPE_INFO;
    -	public static final BasicTypeInfo<Double> DOUBLE = BasicTypeInfo.DOUBLE_TYPE_INFO;
    -	public static final BasicTypeInfo<BigDecimal> DECIMAL = BasicTypeInfo.BIG_DEC_TYPE_INFO;
    +	/**
    +	 * Returns type information for {@link java.lang.Void}. Does not support a null value.
    +	 */
    +	public static final TypeInformation<?> VOID = BasicTypeInfo.VOID_TYPE_INFO;
    +
    +	/**
    +	 * Returns type information for {@link java.lang.String}. Supports a null value.
    +	 */
    +	public static final TypeInformation<?> STRING = BasicTypeInfo.STRING_TYPE_INFO;
    +
    +	/**
    +	 * Returns type information for both a primitive <code>byte</code> and {@link
java.lang.Byte}.
    +	 * Does not support a null value.
    +	 */
    +	public static final TypeInformation<?> BYTE = BasicTypeInfo.BYTE_TYPE_INFO;
    +
    +	/**
    +	 * Returns type information for both a primitive <code>boolean</code> and
{@link java.lang.Boolean}.
    +	 * Does not support a null value.
    +	 */
    +	public static final TypeInformation<?> BOOLEAN = BasicTypeInfo.BOOLEAN_TYPE_INFO;
    +
    +	/**
    +	 * Returns type information for both a primitive <code>short</code> and
{@link java.lang.Short}.
    +	 * Does not support a null value.
    +	 */
    +	public static final TypeInformation<?> SHORT = BasicTypeInfo.SHORT_TYPE_INFO;
    +
    +	/**
    +	 * Returns type information for both a primitive <code>int</code> and {@link
java.lang.Integer}.
    +	 * Does not support a null value.
    +	 */
    +	public static final TypeInformation<?> INT = BasicTypeInfo.INT_TYPE_INFO;
    +
    +	/**
    +	 * Returns type information for both a primitive <code>long</code> and {@link
java.lang.Long}.
    +	 * Does not support a null value.
    +	 */
    +	public static final TypeInformation<?> LONG = BasicTypeInfo.LONG_TYPE_INFO;
    +
    +	/**
    +	 * Returns type information for both a primitive <code>float</code> and
{@link java.lang.Float}.
    +	 * Does not support a null value.
    +	 */
    +	public static final TypeInformation<?> FLOAT = BasicTypeInfo.FLOAT_TYPE_INFO;
    +
    +	/**
    +	 * Returns type information for both a primitive <code>double</code> and
{@link java.lang.Double}.
    +	 * Does not support a null value.
    +	 */
    +	public static final TypeInformation<?> DOUBLE = BasicTypeInfo.DOUBLE_TYPE_INFO;
    +
    +	/**
    +	 * Returns type information for both a primitive <code>char</code> and {@link
java.lang.Character}.
    +	 * Does not support a null value.
    +	 */
    +	public static final TypeInformation<?> CHAR = BasicTypeInfo.CHAR_TYPE_INFO;
    +
    +	/**
    +	 * Returns type information for {@link java.math.BigDecimal}. Supports a null value.
    +	 */
    +	public static final TypeInformation<?> BIG_DEC = BasicTypeInfo.BIG_DEC_TYPE_INFO;
    +
    +	/**
    +	 * Returns type information for {@link java.math.BigInteger}. Supports a null value.
    +	 */
    +	public static final TypeInformation<?> BIG_INT = BasicTypeInfo.BIG_INT_TYPE_INFO;
    +
    +	/**
    +	 * Returns type information for {@link java.sql.Date}. Supports a null value.
    +	 */
    +	public static final TypeInformation<?> SQL_DATE = SqlTimeTypeInfo.DATE;
    +
    +	/**
    +	 * Returns type information for {@link java.sql.Time}. Supports a null value.
    +	 */
    +	public static final TypeInformation<?> SQL_TIME = SqlTimeTypeInfo.TIME;
     
    -	public static final SqlTimeTypeInfo<Date> SQL_DATE = SqlTimeTypeInfo.DATE;
    -	public static final SqlTimeTypeInfo<Time> SQL_TIME = SqlTimeTypeInfo.TIME;
    -	public static final SqlTimeTypeInfo<Timestamp> SQL_TIMESTAMP = SqlTimeTypeInfo.TIMESTAMP;
    +	/**
    +	 * Returns type information for {@link java.sql.Timestamp}. Supports a null value.
    +	 */
    +	public static final TypeInformation<?> SQL_TIMESTAMP = SqlTimeTypeInfo.TIMESTAMP;
     
     	/**
    -	 * Generates a RowTypeInfo with fields of the given types.
    -	 * The fields have the default names (f0, f1, f2 ..).
    +	 * Returns type information for {@link org.apache.flink.types.Row} with fields of the
given types.
    +	 * A row itself must not be null.
    +	 *
    +	 * <p>A row is a fixed-length, null-aware composite type for storing multiple
values in a
    +	 * deterministic field order. Every field can be null independent of the field's type.
    --- End diff --
    
    "independent of" -> "regardless of"?


> Add helper methods for all built-in Flink types to Types
> --------------------------------------------------------
>
>                 Key: FLINK-7452
>                 URL: https://issues.apache.org/jira/browse/FLINK-7452
>             Project: Flink
>          Issue Type: Improvement
>          Components: Type Serialization System
>            Reporter: Timo Walther
>            Assignee: Timo Walther
>
> Sometimes it is very difficult to provide `TypeInformation` manually, in case some extraction
fails or is not available. {{TypeHint}}s should be the preferred way but this methods can
ensure correct types.
> I propose to add all built-in Flink types to the {{Types}}. Such as:
> {code}
> Types.POJO(MyPojo.class)
> Types.POJO(Map<String, TypeInformation>)
> Types.GENERIC(Object.class)
> Types.TUPLE(TypeInformation, ...)
> Types.MAP(TypeInformation, TypeInformation)
> {code}
> The methods should validate that the returned type is exactly the requested type. And
especially in case of POJO should help creating  {{PojoTypeInfo}}.
> Once this is in place, we can deprecate the {{TypeInfoParser}}.



--
This message was sent by Atlassian JIRA
(v6.4.14#64029)

Mime
View raw message