Examples of InvalidTypesException


Examples of org.apache.flink.api.common.functions.InvalidTypesException

  private <X> TypeInformation<X> privateGetForClass(Class<X> clazz, ArrayList<Type> typeHierarchy, ParameterizedType clazzTypeHint) {
    Validate.notNull(clazz);
   
    // check for abstract classes or interfaces
    if (!clazz.isPrimitive() && (Modifier.isInterface(clazz.getModifiers()) || (Modifier.isAbstract(clazz.getModifiers()) && !clazz.isArray()))) {
      throw new InvalidTypesException("Interfaces and abstract classes are not valid types: " + clazz);
    }

    if (clazz.equals(Object.class)) {
      // TODO (merging): better throw an exception here. the runtime does not support it yet
      return new GenericTypeInfo<X>(clazz);
    }
   
    // check for arrays
    if (clazz.isArray()) {

      // primitive arrays: int[], byte[], ...
      PrimitiveArrayTypeInfo<X> primitiveArrayInfo = PrimitiveArrayTypeInfo.getInfoFor(clazz);
      if (primitiveArrayInfo != null) {
        return primitiveArrayInfo;
      }
     
      // basic type arrays: String[], Integer[], Double[]
      BasicArrayTypeInfo<X, ?> basicArrayInfo = BasicArrayTypeInfo.getInfoFor(clazz);
      if (basicArrayInfo != null) {
        return basicArrayInfo;
      }
     
      // object arrays
      else {
        return ObjectArrayTypeInfo.getInfoFor(clazz);
      }
    }
   
    // check for writable types
    if(Writable.class.isAssignableFrom(clazz)) {
      return (TypeInformation<X>) WritableTypeInfo.getWritableTypeInfo((Class<? extends Writable>) clazz);
    }
   
    // check for basic types
    TypeInformation<X> basicTypeInfo = BasicTypeInfo.getInfoFor(clazz);
    if (basicTypeInfo != null) {
      return basicTypeInfo;
    }
   
    // check for subclasses of Value
    if (Value.class.isAssignableFrom(clazz)) {
      Class<? extends Value> valueClass = clazz.asSubclass(Value.class);
      return (TypeInformation<X>) ValueTypeInfo.getValueTypeInfo(valueClass);
    }
   
    // check for subclasses of Tuple
    if (Tuple.class.isAssignableFrom(clazz)) {
      throw new InvalidTypesException("Type information extraction for tuples cannot be done based on the class.");
    }


    if (alreadySeen.contains(clazz)) {
      return new GenericTypeInfo<X>(clazz);
View Full Code Here

Examples of org.apache.flink.api.common.functions.InvalidTypesException

      try {
        typeHierarchy.add(fieldType);
        pojoFields.add(new PojoField(field, createTypeInfoWithTypeHierarchy(typeHierarchy, fieldType, null, null) ));
      } catch (InvalidTypesException e) {
        //pojoFields.add(new PojoField(field, new GenericTypeInfo( Object.class ))); // we need kryo to properly serialize this
        throw new InvalidTypesException("Flink is currently unable to serialize this type: "+fieldType+""
            + "\nThe system is internally using the Avro serializer which is not able to handle that type.", e);
      }
    }

    CompositeType<X> pojoType = new PojoTypeInfo<X>(clazz, pojoFields);
View Full Code Here

Examples of org.apache.flink.api.common.functions.InvalidTypesException

      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] = privateGetForObject(field);
      }
View Full Code Here

Examples of org.apache.flink.api.common.functions.InvalidTypesException

  static final <X extends Value> TypeInformation<X> getValueTypeInfo(Class<X> typeClass) {
    if (Value.class.isAssignableFrom(typeClass) && !typeClass.equals(Value.class)) {
      return new ValueTypeInfo<X>(typeClass);
    }
    else {
      throw new InvalidTypesException("The given class is no subclass of " + Value.class.getName());
    }
  }
View Full Code Here

Examples of org.apache.flink.api.common.functions.InvalidTypesException

    // class type e.g. for custom objects
    if (type instanceof Class<?> && ((Class<?>) type).isArray() && BasicTypeInfo.getInfoFor((Class<C>) type) == null) {
      Class<C> array = (Class<C>) type;
      return new ObjectArrayTypeInfo<T, C>(type, array.getComponentType());
    }
    throw new InvalidTypesException("The given type is not a valid object array.");
  }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.