/** * Gets the type information of the component type. * @return The type information of the component type. */ @PublicEvolving public TypeInformation<?> getComponentType() { return BasicTypeInfo.getInfoFor(getComponentClass()); }
public ArrayFieldAccessor(int pos, TypeInformation typeInfo) { if (pos < 0) { throw new CompositeType.InvalidFieldReferenceException("The " + ((Integer) pos).toString() + ". field selected on" + " an array, which is an invalid index."); } checkNotNull(typeInfo, "typeInfo must not be null."); this.pos = pos; this.fieldType = BasicTypeInfo.getInfoFor(typeInfo.getTypeClass().getComponentType()); }
@PublicEvolving public static <X extends Tuple> TupleTypeInfo<X> getBasicTupleTypeInfo(Class<?>... basicTypes) { if (basicTypes == null || basicTypes.length == 0) { throw new IllegalArgumentException(); } TypeInformation<?>[] infos = new TypeInformation<?>[basicTypes.length]; for (int i = 0; i < infos.length; i++) { Class<?> type = basicTypes[i]; if (type == null) { throw new IllegalArgumentException("Type at position " + i + " is null."); } TypeInformation<?> info = BasicTypeInfo.getInfoFor(type); if (info == null) { throw new IllegalArgumentException("Type at position " + i + " is not a basic type."); } infos[i] = info; } @SuppressWarnings("unchecked") TupleTypeInfo<X> tupleInfo = (TupleTypeInfo<X>) new TupleTypeInfo<Tuple>(infos); return tupleInfo; }
@Test public void testBasicTypeInfoInequality() { for (Class<?> clazz1: classes) { for (Class<?> clazz2: classes) { if (!clazz1.equals(clazz2)) { BasicTypeInfo<?> tpeInfo1 = BasicTypeInfo.getInfoFor(clazz1); BasicTypeInfo<?> tpeInfo2 = BasicTypeInfo.getInfoFor(clazz2); assertNotEquals(tpeInfo1, tpeInfo2); } } } } }
@SuppressWarnings("unchecked") @PublicEvolving public static <X extends Tuple> TupleTypeInfo<X> getBasicAndBasicValueTupleTypeInfo(Class<?>... basicTypes) { if (basicTypes == null || basicTypes.length == 0) { throw new IllegalArgumentException(); } TypeInformation<?>[] infos = new TypeInformation<?>[basicTypes.length]; for (int i = 0; i < infos.length; i++) { Class<?> type = basicTypes[i]; if (type == null) { throw new IllegalArgumentException("Type at position " + i + " is null."); } TypeInformation<?> info = BasicTypeInfo.getInfoFor(type); if (info == null) { try { info = ValueTypeInfo.getValueTypeInfo((Class<Value>) type); if (!((ValueTypeInfo<?>) info).isBasicValueType()) { throw new IllegalArgumentException("Type at position " + i + " is not a basic or value type."); } } catch (ClassCastException | InvalidTypesException e) { throw new IllegalArgumentException("Type at position " + i + " is not a basic or value type.", e); } } infos[i] = info; } return (TupleTypeInfo<X>) new TupleTypeInfo<>(infos); }
@Test public void testBasicTypeInfoEquality() { for (Class<?> clazz: classes) { BasicTypeInfo<?> tpeInfo1 = BasicTypeInfo.getInfoFor(clazz); BasicTypeInfo<?> tpeInfo2 = BasicTypeInfo.getInfoFor(clazz); assertEquals(tpeInfo1, tpeInfo2); assertEquals(tpeInfo1.hashCode(), tpeInfo2.hashCode()); } }
componentInfo = BasicTypeInfo.getInfoFor(inTypeInfo.getTypeClass().getComponentType());
TypeInformation<OUT> basicTypeInfo = BasicTypeInfo.getInfoFor(clazz); if (basicTypeInfo != null) { return basicTypeInfo;
if (!(type instanceof Class<?>) || (actual = BasicTypeInfo.getInfoFor((Class<?>) type)) == null) { throw new InvalidTypesException("Basic type expected.");
@Test public void testDataSourcePlain() { try { TestNonRichOutputFormat out = new TestNonRichOutputFormat(); GenericDataSinkBase<String> sink = new GenericDataSinkBase<String>( out, new UnaryOperatorInformation<String, Nothing>(BasicTypeInfo.STRING_TYPE_INFO, BasicTypeInfo.getInfoFor(Nothing.class)), "test_sink"); sink.setInput(source); ExecutionConfig executionConfig = new ExecutionConfig(); executionConfig.disableObjectReuse(); in.reset(); sink.executeOnCollections(asList(TestIOData.NAMES), null, executionConfig); assertEquals(out.output, asList(TestIOData.NAMES)); executionConfig.enableObjectReuse(); out.clear(); in.reset(); sink.executeOnCollections(asList(TestIOData.NAMES), null, executionConfig); assertEquals(out.output, asList(TestIOData.NAMES)); } catch (Exception e) { e.printStackTrace(); fail(e.getMessage()); } }
GenericDataSinkBase<String> sink = new GenericDataSinkBase<String>( out, new UnaryOperatorInformation<String, Nothing>(BasicTypeInfo.STRING_TYPE_INFO, BasicTypeInfo.getInfoFor(Nothing.class)), "test_sink"); sink.setInput(source);
private TypeInformation getTypeInfoForClass(Class typeClass) { // try to create BasicTypeInfo TypeInformation typeInfo = BasicTypeInfo.getInfoFor(typeClass); // create TypeInformation for Writable type if(typeInfo == null && Writable.class.isAssignableFrom(typeClass)) { typeInfo = new WritableTypeInfo(typeClass); } return typeInfo; } }
public ArrayFieldAccessor(int pos, TypeInformation typeInfo) { if (pos < 0) { throw new CompositeType.InvalidFieldReferenceException("The " + ((Integer) pos).toString() + ". field selected on" + " an array, which is an invalid index."); } checkNotNull(typeInfo, "typeInfo must not be null."); this.pos = pos; this.fieldType = BasicTypeInfo.getInfoFor(typeInfo.getTypeClass().getComponentType()); }
/** * Gets the type information of the component type. * @return The type information of the component type. */ @PublicEvolving public TypeInformation<?> getComponentType() { return BasicTypeInfo.getInfoFor(getComponentClass()); }
public ArrayFieldAccessor(int pos, TypeInformation typeInfo) { if (pos < 0) { throw new CompositeType.InvalidFieldReferenceException("The " + ((Integer) pos).toString() + ". field selected on" + " an array, which is an invalid index."); } checkNotNull(typeInfo, "typeInfo must not be null."); this.pos = pos; this.fieldType = BasicTypeInfo.getInfoFor(typeInfo.getTypeClass().getComponentType()); }
public ArrayFieldAccessor(int pos, TypeInformation typeInfo) { if (pos < 0) { throw new CompositeType.InvalidFieldReferenceException("The " + ((Integer) pos).toString() + ". field selected on" + " an array, which is an invalid index."); } checkNotNull(typeInfo, "typeInfo must not be null."); this.pos = pos; this.fieldType = BasicTypeInfo.getInfoFor(typeInfo.getTypeClass().getComponentType()); }
/** * Gets the type information of the component type. * @return The type information of the component type. */ @PublicEvolving public TypeInformation<?> getComponentType() { return BasicTypeInfo.getInfoFor(getComponentClass()); }
@PublicEvolving public static <X extends Tuple> TupleTypeInfo<X> getBasicTupleTypeInfo(Class<?>... basicTypes) { if (basicTypes == null || basicTypes.length == 0) { throw new IllegalArgumentException(); } TypeInformation<?>[] infos = new TypeInformation<?>[basicTypes.length]; for (int i = 0; i < infos.length; i++) { Class<?> type = basicTypes[i]; if (type == null) { throw new IllegalArgumentException("Type at position " + i + " is null."); } TypeInformation<?> info = BasicTypeInfo.getInfoFor(type); if (info == null) { throw new IllegalArgumentException("Type at position " + i + " is not a basic type."); } infos[i] = info; } @SuppressWarnings("unchecked") TupleTypeInfo<X> tupleInfo = (TupleTypeInfo<X>) new TupleTypeInfo<Tuple>(infos); return tupleInfo; }
@PublicEvolving public static <X extends Tuple> TupleTypeInfo<X> getBasicTupleTypeInfo(Class<?>... basicTypes) { if (basicTypes == null || basicTypes.length == 0) { throw new IllegalArgumentException(); } TypeInformation<?>[] infos = new TypeInformation<?>[basicTypes.length]; for (int i = 0; i < infos.length; i++) { Class<?> type = basicTypes[i]; if (type == null) { throw new IllegalArgumentException("Type at position " + i + " is null."); } TypeInformation<?> info = BasicTypeInfo.getInfoFor(type); if (info == null) { throw new IllegalArgumentException("Type at position " + i + " is not a basic type."); } infos[i] = info; } @SuppressWarnings("unchecked") TupleTypeInfo<X> tupleInfo = (TupleTypeInfo<X>) new TupleTypeInfo<Tuple>(infos); return tupleInfo; }
@SuppressWarnings("unchecked") @PublicEvolving public static <X extends Tuple> TupleTypeInfo<X> getBasicAndBasicValueTupleTypeInfo(Class<?>... basicTypes) { if (basicTypes == null || basicTypes.length == 0) { throw new IllegalArgumentException(); } TypeInformation<?>[] infos = new TypeInformation<?>[basicTypes.length]; for (int i = 0; i < infos.length; i++) { Class<?> type = basicTypes[i]; if (type == null) { throw new IllegalArgumentException("Type at position " + i + " is null."); } TypeInformation<?> info = BasicTypeInfo.getInfoFor(type); if (info == null) { try { info = ValueTypeInfo.getValueTypeInfo((Class<Value>) type); if (!((ValueTypeInfo<?>) info).isBasicValueType()) { throw new IllegalArgumentException("Type at position " + i + " is not a basic or value type."); } } catch (ClassCastException | InvalidTypesException e) { throw new IllegalArgumentException("Type at position " + i + " is not a basic or value type.", e); } } infos[i] = info; } return (TupleTypeInfo<X>) new TupleTypeInfo<>(infos); }