@Override public TypeInformation<E> getProducedType() { return TypeExtractor.getForClass(this.avroValueType); }
/** * Creates a new data set that contains elements in the iterator. The iterator is splittable, allowing the * framework to create a parallel data source that returns the elements in the iterator. * The iterator must be serializable (as defined in {@link java.io.Serializable}, because the * execution environment may ship the elements into the cluster. * <p> * Because the iterator will remain unmodified until the actual execution happens, the type of data * returned by the iterator must be given explicitly in the form of the type class (this is due to the * fact that the Java compiler erases the generic type information). * * @param iterator The iterator that produces the elements of the data set. * @param type The class of the data produced by the iterator. Must not be a generic class. * @return A DataSet representing the elements in the iterator. * * @see #fromParallelCollection(SplittableIterator, TypeInformation) */ public <X> DataSource<X> fromParallelCollection(SplittableIterator<X> iterator, Class<X> type) { return fromParallelCollection(iterator, TypeExtractor.getForClass(type)); }
/** * Creates a DataSet from the given iterator. Because the iterator will remain unmodified until * the actual execution happens, the type of data returned by the iterator must be given * explicitly in the form of the type class (this is due to the fact that the Java compiler * erases the generic type information). * <p> * The iterator must be serializable (as defined in {@link java.io.Serializable}), because the * framework may move it to a remote environment, if needed. * <p> * Note that this operation will result in a non-parallel data source, i.e. a data source with * a degree of parallelism of one. * * @param data The collection of elements to create the data set from. * @param type The class of the data produced by the iterator. Must not be a generic class. * @return A DataSet representing the elements in the iterator. * * @see #fromCollection(Iterator, TypeInformation) */ public <X> DataSource<X> fromCollection(Iterator<X> data, Class<X> type) { return fromCollection(data, TypeExtractor.getForClass(type)); }
@SuppressWarnings({ "unchecked", "rawtypes" }) public static <X> TypeInformation<X> getForObject(X value) { Validate.notNull(value); // check if we can extract the types from tuples, otherwise work with the class if (value instanceof Tuple) { Tuple t = (Tuple) value; int numFields = t.getArity(); TypeInformation<?>[] infos = new TypeInformation[numFields]; for (int i = 0; i < numFields; i++) { Object field = t.getField(i); if (field == null) { throw new InvalidTypesException("Automatic type extraction is not possible on candidates with null values. " + "Please specify the types directly."); } infos[i] = getForObject(field); } return (TypeInformation<X>) new TupleTypeInfo(value.getClass(), infos); } else { return getForClass((Class<X>) value.getClass()); } }
return getForClass((Class<OUT>) ((ParameterizedType) t).getRawType()); return getForClass((Class<OUT>) t);