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

The following examples show how to use org.apache.hadoop.hive.ql.io.HiveFileFormatUtils. These examples are extracted from open source projects. 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 Project: flink   Source File: HiveShimV100.java    License: 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 Project: flink   Source File: HiveShimV100.java    License: 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 Project: flink   Source File: HiveShimV110.java    License: 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 Project: flink   Source File: HiveShimV110.java    License: 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);
	}
}