@Test public void testNonExistingType() { try { WritableTypeConverter.convertWritableToTajoType(DummyWritable.class); } catch (Exception e) { assertEquals(UnsupportedDataTypeException.class, e.getClass()); } }
public static DataType convertWritableToTajoType(Class<? extends Writable> writableClass) throws UnsupportedDataTypeException { if (writableClass == null) return null; Set<Class<?>> parents = ReflectionUtils.getAllSuperTypes(writableClass); if (writableClass == ByteWritable.class || parents.contains(ByteWritable.class)) { return builder.setType(Type.INT1).build(); } if (writableClass == ShortWritable.class || parents.contains(ShortWritable.class)) { return builder.setType(Type.INT2).build(); } if (writableClass == IntWritable.class || parents.contains(IntWritable.class)) { return builder.setType(Type.INT4).build(); } if (writableClass == LongWritable.class || parents.contains(LongWritable.class)) { return builder.setType(Type.INT8).build(); } if (writableClass == HiveCharWritable.class || parents.contains(HiveCharWritable.class)) { return builder.setType(Type.CHAR).build(); } if (writableClass == Text.class || parents.contains(Text.class)) { return builder.setType(Type.TEXT).build(); } if (writableClass == FloatWritable.class || parents.contains(FloatWritable.class)) { return builder.setType(Type.FLOAT4).build(); } if (writableClass == DoubleWritable.class || parents.contains(DoubleWritable.class)) { return builder.setType(Type.FLOAT8).build(); } if (writableClass == DateWritable.class || parents.contains(DateWritable.class)) { return builder.setType(Type.DATE).build(); } if (writableClass == TimestampWritable.class || parents.contains(TimestampWritable.class)) { return builder.setType(Type.TIMESTAMP).build(); } if (writableClass == BytesWritable.class || parents.contains(BytesWritable.class)) { return builder.setType(Type.VARBINARY).build(); } throw new UnsupportedDataTypeException(writableClass.getSimpleName()); }
WritableTypeConverter { public static DataType convertWritableToTajoType(Class<? extends Writable> writableClass) throws UnsupportedDataTypeException { if (writableClass == null) return null; Set<Class<?>> parents = ReflectionUtils.getAllSuperTypes(writableClass); if (writableClass == ByteWritable.class || parents.contains(ByteWritable.class)) { return builder.setType(Type.INT1).build(); } if (writableClass == ShortWritable.class || parents.contains(ShortWritable.class)) { return builder.setType(Type.INT2).build(); } if (writableClass == IntWritable.class || parents.contains(IntWritable.class)) { return builder.setType(Type.INT4).build(); } if (writableClass == LongWritable.class || parents.contains(LongWritable.class)) { return builder.setType(Type.INT8).build(); } if (writableClass == HiveCharWritable.class || parents.contains(HiveCharWritable.class)) { return builder.setType(Type.CHAR).build(); } if (writableClass == Text.class || parents.contains(Text.class)) { return builder.setType(Type.TEXT).build(); } if (writableClass == FloatWritable.class || parents.contains(FloatWritable.class)) { return builder.setType(Type.FLOAT4).build(); } if (writableClass == DoubleWritable.class || parents.contains(DoubleWritable.class)) { return builder.setType(Type.FLOAT8).build(); } if (writableClass == DateWritable.class || parents.contains(DateWritable.class)) { return builder.setType(Type.DATE).build(); } if (writableClass == TimestampWritable.class || parents.contains(TimestampWritable.class)) { return builder.setType(Type.TIMESTAMP).build(); } if (writableClass == BytesWritable.class || parents.contains(BytesWritable.class)) { return builder.setType(Type.VARBINARY).build(); } throw new UnsupportedDataTypeException(writableClass.getSimpleName()); } }
WritableTypeConverter { public static DataType convertWritableToTajoType(Class<? extends Writable> writableClass) throws UnsupportedDataTypeException { if (writableClass == null) return null; Set<Class<?>> parents = ReflectionUtils.getAllSuperTypes(writableClass); if (writableClass == ByteWritable.class || parents.contains(ByteWritable.class)) { return builder.setType(Type.INT1).build(); } if (writableClass == ShortWritable.class || parents.contains(ShortWritable.class)) { return builder.setType(Type.INT2).build(); } if (writableClass == IntWritable.class || parents.contains(IntWritable.class)) { return builder.setType(Type.INT4).build(); } if (writableClass == LongWritable.class || parents.contains(LongWritable.class)) { return builder.setType(Type.INT8).build(); } if (writableClass == HiveCharWritable.class || parents.contains(HiveCharWritable.class)) { return builder.setType(Type.CHAR).build(); } if (writableClass == Text.class || parents.contains(Text.class)) { return builder.setType(Type.TEXT).build(); } if (writableClass == FloatWritable.class || parents.contains(FloatWritable.class)) { return builder.setType(Type.FLOAT4).build(); } if (writableClass == DoubleWritable.class || parents.contains(DoubleWritable.class)) { return builder.setType(Type.FLOAT8).build(); } if (writableClass == DateWritable.class || parents.contains(DateWritable.class)) { return builder.setType(Type.DATE).build(); } if (writableClass == TimestampWritable.class || parents.contains(TimestampWritable.class)) { return builder.setType(Type.TIMESTAMP).build(); } if (writableClass == BytesWritable.class || parents.contains(BytesWritable.class)) { return builder.setType(Type.VARBINARY).build(); } throw new UnsupportedDataTypeException(writableClass.getSimpleName()); }  }
WritableTypeConverter { public static DataType convertWritableToTajoType(Class<? extends Writable> writableClass) throws UnsupportedDataTypeException { if (writableClass == null) return null; Set<Class<?>> parents = ReflectionUtils.getAllSuperTypes(writableClass); if (writableClass == ByteWritable.class || parents.contains(ByteWritable.class)) { return builder.setType(Type.INT1).build(); } if (writableClass == ShortWritable.class || parents.contains(ShortWritable.class)) { return builder.setType(Type.INT2).build(); } if (writableClass == IntWritable.class || parents.contains(IntWritable.class)) { return builder.setType(Type.INT4).build(); } if (writableClass == LongWritable.class || parents.contains(LongWritable.class)) { return builder.setType(Type.INT8).build(); } if (writableClass == HiveCharWritable.class || parents.contains(HiveCharWritable.class)) { return builder.setType(Type.CHAR).build(); } if (writableClass == Text.class || parents.contains(Text.class)) { return builder.setType(Type.TEXT).build(); } if (writableClass == FloatWritable.class || parents.contains(FloatWritable.class)) { return builder.setType(Type.FLOAT4).build(); } if (writableClass == DoubleWritable.class || parents.contains(DoubleWritable.class)) { return builder.setType(Type.FLOAT8).build(); } if (writableClass == DateWritable.class || parents.contains(DateWritable.class)) { return builder.setType(Type.DATE).build(); } if (writableClass == TimestampWritable.class || parents.contains(TimestampWritable.class)) { return builder.setType(Type.TIMESTAMP).build(); } if (writableClass == BytesWritable.class || parents.contains(BytesWritable.class)) { return builder.setType(Type.VARBINARY).build(); } throw new UnsupportedDataTypeException(writableClass.getSimpleName()); }  static DataType convertWritableToTajoType(Class<? extends Writable> writableClass); static Writable convertDatum2Writable(Datum value); static Datum convertWritable2Datum(Writable value); }
WritableTypeConverter { public static DataType convertWritableToTajoType(Class<? extends Writable> writableClass) throws UnsupportedDataTypeException { if (writableClass == null) return null; Set<Class<?>> parents = ReflectionUtils.getAllSuperTypes(writableClass); if (writableClass == ByteWritable.class || parents.contains(ByteWritable.class)) { return builder.setType(Type.INT1).build(); } if (writableClass == ShortWritable.class || parents.contains(ShortWritable.class)) { return builder.setType(Type.INT2).build(); } if (writableClass == IntWritable.class || parents.contains(IntWritable.class)) { return builder.setType(Type.INT4).build(); } if (writableClass == LongWritable.class || parents.contains(LongWritable.class)) { return builder.setType(Type.INT8).build(); } if (writableClass == HiveCharWritable.class || parents.contains(HiveCharWritable.class)) { return builder.setType(Type.CHAR).build(); } if (writableClass == Text.class || parents.contains(Text.class)) { return builder.setType(Type.TEXT).build(); } if (writableClass == FloatWritable.class || parents.contains(FloatWritable.class)) { return builder.setType(Type.FLOAT4).build(); } if (writableClass == DoubleWritable.class || parents.contains(DoubleWritable.class)) { return builder.setType(Type.FLOAT8).build(); } if (writableClass == DateWritable.class || parents.contains(DateWritable.class)) { return builder.setType(Type.DATE).build(); } if (writableClass == TimestampWritable.class || parents.contains(TimestampWritable.class)) { return builder.setType(Type.TIMESTAMP).build(); } if (writableClass == BytesWritable.class || parents.contains(BytesWritable.class)) { return builder.setType(Type.VARBINARY).build(); } throw new UnsupportedDataTypeException(writableClass.getSimpleName()); }  static DataType convertWritableToTajoType(Class<? extends Writable> writableClass); static Writable convertDatum2Writable(Datum value); static Datum convertWritable2Datum(Writable value);  }