use of co.cask.cdap.data.stream.decoder.FormatStreamEventDecoder in project cdap by caskdata.
the class AbstractStreamInputFormat method createStreamEventDecoder.
@SuppressWarnings("unchecked")
protected StreamEventDecoder<K, V> createStreamEventDecoder(Configuration conf) {
Class<? extends StreamEventDecoder> decoderClass = getDecoderClass(conf);
Preconditions.checkNotNull(decoderClass, "Failed to load stream event decoder %s", conf.get(DECODER_TYPE));
try {
// to format the stream body.
if (decoderClass.isAssignableFrom(FormatStreamEventDecoder.class)) {
try {
RecordFormat<StreamEvent, V> bodyFormat = getInitializedFormat(conf);
return (StreamEventDecoder<K, V>) new FormatStreamEventDecoder(bodyFormat);
} catch (Exception e) {
throw new IllegalArgumentException("Unable to get the stream body format.");
}
} else {
return (StreamEventDecoder<K, V>) decoderClass.newInstance();
}
} catch (Exception e) {
throw Throwables.propagate(e);
}
}
Aggregations