public SpecificDatumWriter(Class<T> c) { super(SpecificData.get().getSchema(c), SpecificData.getForClass(c)); }
/** * For RECORD type schemas, this method returns the SpecificData instance of the class associated with the schema, * in order to get the right conversions for any logical types used. * * @param reader the reader schema * @return the SpecificData associated with the schema's class, or the default instance. */ public static SpecificData getForSchema(Schema reader) { if (reader.getType() == Type.RECORD) { final String className = getClassName(reader); if (className != null) { final Class<?> clazz; try { clazz = Class.forName(className); return getForClass(clazz); } catch (ClassNotFoundException e) { return SpecificData.get(); } } } return SpecificData.get(); }
/** Construct for reading instances of a class. */ public SpecificDatumReader(Class<T> c) { this(SpecificData.getForClass(c)); setSchema(getSpecificData().getSchema(c)); }