org.apache.hadoop.hive.ql.io.HiveFileFormatUtils Java Examples

The following examples show how to use org.apache.hadoop.hive.ql.io.HiveFileFormatUtils. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: HiveShimV100.java    From flink with Apache License 2.0 5 votes vote down vote up
@Override
public FileSinkOperator.RecordWriter getHiveRecordWriter(JobConf jobConf, Class outputFormatClz,
		Class<? extends Writable> outValClz, boolean isCompressed, Properties tableProps, Path outPath) {
	try {
		Class utilClass = HiveFileFormatUtils.class;
		HiveOutputFormat outputFormat = (HiveOutputFormat) outputFormatClz.newInstance();
		Method utilMethod = utilClass.getDeclaredMethod("getRecordWriter", JobConf.class, HiveOutputFormat.class,
				Class.class, boolean.class, Properties.class, Path.class, Reporter.class);
		return (FileSinkOperator.RecordWriter) utilMethod.invoke(null,
				jobConf, outputFormat, outValClz, isCompressed, tableProps, outPath, Reporter.NULL);
	} catch (Exception e) {
		throw new CatalogException("Failed to create Hive RecordWriter", e);
	}
}
 
Example #2
Source File: HiveShimV100.java    From flink with Apache License 2.0 5 votes vote down vote up
@Override
public Class getHiveOutputFormatClass(Class outputFormatClz) {
	try {
		Class utilClass = HiveFileFormatUtils.class;
		Method utilMethod = utilClass.getDeclaredMethod("getOutputFormatSubstitute", Class.class, boolean.class);
		Class res = (Class) utilMethod.invoke(null, outputFormatClz, false);
		Preconditions.checkState(res != null, "No Hive substitute output format for " + outputFormatClz);
		return res;
	} catch (NoSuchMethodException | IllegalAccessException | InvocationTargetException e) {
		throw new FlinkHiveException("Failed to get HiveOutputFormat for " + outputFormatClz, e);
	}
}
 
Example #3
Source File: HiveShimV110.java    From flink with Apache License 2.0 5 votes vote down vote up
@Override
public FileSinkOperator.RecordWriter getHiveRecordWriter(JobConf jobConf, Class outputFormatClz,
		Class<? extends Writable> outValClz, boolean isCompressed, Properties tableProps, Path outPath) {
	try {
		Class utilClass = HiveFileFormatUtils.class;
		OutputFormat outputFormat = (OutputFormat) outputFormatClz.newInstance();
		Method utilMethod = utilClass.getDeclaredMethod("getRecordWriter", JobConf.class, OutputFormat.class,
				Class.class, boolean.class, Properties.class, Path.class, Reporter.class);
		return (FileSinkOperator.RecordWriter) utilMethod.invoke(null,
				jobConf, outputFormat, outValClz, isCompressed, tableProps, outPath, Reporter.NULL);
	} catch (Exception e) {
		throw new CatalogException("Failed to create Hive RecordWriter", e);
	}
}
 
Example #4
Source File: HiveShimV110.java    From flink with Apache License 2.0 5 votes vote down vote up
@Override
public Class getHiveOutputFormatClass(Class outputFormatClz) {
	try {
		Class utilClass = HiveFileFormatUtils.class;
		Method utilMethod = utilClass.getDeclaredMethod("getOutputFormatSubstitute", Class.class);
		Class res = (Class) utilMethod.invoke(null, outputFormatClz);
		Preconditions.checkState(res != null, "No Hive substitute output format for " + outputFormatClz);
		return res;
	} catch (NoSuchMethodException | IllegalAccessException | InvocationTargetException e) {
		throw new FlinkHiveException("Failed to get HiveOutputFormat for " + outputFormatClz, e);
	}
}