/** * Creates a TypeInformation for a generic type via a utility "type hint". * This method can be used as follows: * <pre> * {@code * TypeInformation<Tuple2<String, Long>> info = TypeInformation.of(new TypeHint<Tuple2<String, Long>>(){}); * } * </pre> * * @param typeHint The hint for the generic type. * @param <T> The generic type. * * @return The TypeInformation object for the type described by the hint. */ public static <T> TypeInformation<T> of(TypeHint<T> typeHint) { return typeHint.getTypeInfo(); } }
@Test public void testTypeInfoDirect() { // simple (non-generic case) TypeHint<String> stringInfo1 = new TypeHint<String>(){}; TypeHint<String> stringInfo2 = new TypeHint<String>(){}; assertEquals(BasicTypeInfo.STRING_TYPE_INFO, stringInfo1.getTypeInfo()); assertTrue(stringInfo1.hashCode() == stringInfo2.hashCode()); assertTrue(stringInfo1.equals(stringInfo2)); assertTrue(stringInfo1.toString().equals(stringInfo2.toString())); // generic case TypeHint<Tuple3<String, Double, Boolean>> generic = new TypeHint<Tuple3<String, Double, Boolean>>(){}; TypeInformation<Tuple3<String, Double, Boolean>> tupleInfo = new TupleTypeInfo<>(BasicTypeInfo.STRING_TYPE_INFO, BasicTypeInfo.DOUBLE_TYPE_INFO, BasicTypeInfo.BOOLEAN_TYPE_INFO); assertEquals(tupleInfo, generic.getTypeInfo()); }
/** * Creates an AbstractDeserializationSchema that returns the TypeInformation * indicated by the given type hint. This constructor is only necessary when creating a generic * implementation, see {@link AbstractDeserializationSchema Generic Use}. * * @param typeHint The TypeHint for the produced type. */ protected AbstractDeserializationSchema(TypeHint<T> typeHint) { checkNotNull(typeHint, "typeHint"); this.type = typeHint.getTypeInfo(); }
/** * Returns a future holding the request result. * @param jobId JobID of the job the queryable state belongs to. * @param queryableStateName Name under which the state is queryable. * @param key The key we are interested in. * @param keyTypeHint A {@link TypeHint} used to extract the type of the key. * @param stateDescriptor The {@link StateDescriptor} of the state we want to query. * @return Future holding the immutable {@link State} object containing the result. */ @PublicEvolving public <K, S extends State, V> CompletableFuture<S> getKvState( final JobID jobId, final String queryableStateName, final K key, final TypeHint<K> keyTypeHint, final StateDescriptor<S, V> stateDescriptor) { Preconditions.checkNotNull(keyTypeHint); TypeInformation<K> keyTypeInfo = keyTypeHint.getTypeInfo(); return getKvState(jobId, queryableStateName, key, keyTypeInfo, stateDescriptor); }
/** * Creates a TypeInformation for a generic type via a utility "type hint". * This method can be used as follows: * <pre> * {@code * TypeInformation<Tuple2<String, Long>> info = TypeInformation.of(new TypeHint<Tuple2<String, Long>>(){}); * } * </pre> * * @param typeHint The hint for the generic type. * @param <T> The generic type. * * @return The TypeInformation object for the type described by the hint. */ public static <T> TypeInformation<T> of(TypeHint<T> typeHint) { return typeHint.getTypeInfo(); } }
/** * Creates a TypeInformation for a generic type via a utility "type hint". * This method can be used as follows: * <pre> * {@code * TypeInformation<Tuple2<String, Long>> info = TypeInformation.of(new TypeHint<Tuple2<String, Long>>(){}); * } * </pre> * * @param typeHint The hint for the generic type. * @param <T> The generic type. * * @return The TypeInformation object for the type described by the hint. */ public static <T> TypeInformation<T> of(TypeHint<T> typeHint) { return typeHint.getTypeInfo(); } }
/** * Creates an AbstractDeserializationSchema that returns the TypeInformation * indicated by the given type hint. This constructor is only necessary when creating a generic * implementation, see {@link AbstractDeserializationSchema Generic Use}. * * @param typeHint The TypeHint for the produced type. */ protected AbstractDeserializationSchema(TypeHint<T> typeHint) { checkNotNull(typeHint, "typeHint"); this.type = typeHint.getTypeInfo(); }
/** * Creates an AbstractDeserializationSchema that returns the TypeInformation * indicated by the given type hint. This constructor is only necessary when creating a generic * implementation, see {@link AbstractDeserializationSchema Generic Use}. * * @param typeHint The TypeHint for the produced type. */ protected AbstractDeserializationSchema(TypeHint<T> typeHint) { checkNotNull(typeHint, "typeHint"); this.type = typeHint.getTypeInfo(); }
/** * Create a reader for reading the state key-value pairs for the given value * state name. The provided type info will be used to deserialize the state * (allowing possible optimizations) */ public static <K, V> KeyedStateReader<K, V, Tuple2<K, V>> forValueStateKVPairs(String stateName, TypeHint<Tuple2<K, V>> tupleTypeHint) { TupleTypeInfo<Tuple2<K, V>> tupleType = (TupleTypeInfo<Tuple2<K, V>>) tupleTypeHint.getTypeInfo(); return forValueStateKVPairs(stateName, tupleType.getTypeAt(0), tupleType.getTypeAt(1)); }
/** * Returns a future holding the request result. * @param jobId JobID of the job the queryable state belongs to. * @param queryableStateName Name under which the state is queryable. * @param key The key we are interested in. * @param keyTypeHint A {@link TypeHint} used to extract the type of the key. * @param stateDescriptor The {@link StateDescriptor} of the state we want to query. * @return Future holding the immutable {@link State} object containing the result. */ @PublicEvolving public <K, S extends State, V> CompletableFuture<S> getKvState( final JobID jobId, final String queryableStateName, final K key, final TypeHint<K> keyTypeHint, final StateDescriptor<S, V> stateDescriptor) { Preconditions.checkNotNull(keyTypeHint); TypeInformation<K> keyTypeInfo = keyTypeHint.getTypeInfo(); return getKvState(jobId, queryableStateName, key, keyTypeInfo, stateDescriptor); }
/** * Returns a future holding the request result. * @param jobId JobID of the job the queryable state belongs to. * @param queryableStateName Name under which the state is queryable. * @param key The key we are interested in. * @param keyTypeHint A {@link TypeHint} used to extract the type of the key. * @param stateDescriptor The {@link StateDescriptor} of the state we want to query. * @return Future holding the immutable {@link State} object containing the result. */ @PublicEvolving public <K, S extends State, V> CompletableFuture<S> getKvState( final JobID jobId, final String queryableStateName, final K key, final TypeHint<K> keyTypeHint, final StateDescriptor<S, V> stateDescriptor) { Preconditions.checkNotNull(keyTypeHint); TypeInformation<K> keyTypeInfo = keyTypeHint.getTypeInfo(); return getKvState(jobId, queryableStateName, key, keyTypeInfo, stateDescriptor); }