Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/hadoop/6.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Hadoop 使用配置单元自定义输出格式处理日志文件_Hadoop_Hive_Output Formatting - Fatal编程技术网

Hadoop 使用配置单元自定义输出格式处理日志文件

Hadoop 使用配置单元自定义输出格式处理日志文件,hadoop,hive,output-formatting,Hadoop,Hive,Output Formatting,我想使用配置单元版本0.7.0处理日志文件,并设置custem inputformat和outputformat。在inputformat中,我将\n替换为@,在outputformat中,我要更改回\n。测试后,我的inputformat运行良好,但outputformat不工作。我想知道为什么。这是代码。谢谢 public class ErrlogOutputFormat, V extends Writable> extends HiveIgnoreKeyTextOutputForm

我想使用配置单元版本0.7.0处理日志文件,并设置custem inputformat和outputformat。在inputformat中,我将\n替换为@,在outputformat中,我要更改回\n。测试后,我的inputformat运行良好,但outputformat不工作。我想知道为什么。这是代码。谢谢

public class ErrlogOutputFormat, V extends Writable> extends HiveIgnoreKeyTextOutputFormat { public static class CustomRecordWriter implements RecordWriter{ RecordWriter writer; BytesWritable bytesWritable; public CustomRecordWriter(RecordWriter writer) { this.writer = writer; bytesWritable = new BytesWritable(); } @Override public void write(Writable w) throws IOException { //String str = ((Text) w).toString().replaceAll("@#@","\n"); String[] str = ((Text) w).toString().split("@#@"); StringBuffer sb = new StringBuffer(); for(String s:str){ sb.append(s).append("\n"); } Text txtReplace = new Text(sb.toString()); System.out.println("------------------------"); System.out.println(txtReplace.toString()); System.out.println("------------------------"); // Get input data // Encode byte[] output = txtReplace.getBytes(); bytesWritable.set(output, 0, output.length); writer.write(bytesWritable); } @Override public void close(boolean abort) throws IOException { writer.close(abort); } } @Override public RecordWriter getHiveRecordWriter(JobConf jc, Path finalOutPath, Class valueClass, boolean isCompressed, Properties tableProperties, Progressable progress) throws IOException { CustomRecordWriter writer = new CustomRecordWriter(super .getHiveRecordWriter(jc, finalOutPath, BytesWritable.class, isCompressed, tableProperties, progress)); return writer; } }
我的hql是:创建存储为INPUTFORMAT com.xh.hiveDW.plugin.errlog.ErrlogInputFormat OUTPUTFORMAT com.xh.hiveDW.plugin.errlog.ErrlogOutputFormat的表hivetest消息字符串;当我将数据加载到表中并选择MessagefromHiveTest时,我无法得到如下结果:2012-02-09 04:26:14952[[ACTIVE]ExecuteThread:'0'用于队列:'weblogic.kernel.Default self-tuning']错误com.opensymphony.webwork.dispatcher.ServletDispatcher-无法执行操作java.net.SocketException:在java.net.SocketOutputStream.socketWriteSocketOutputStream.java:96在java.net.SocketOutputStream.writeSocketOutputStream.java:136