hadoop之sequenceFile

来源:互联网 发布:硬座火车座位图片知乎 编辑:程序博客网 时间:2024/05/16 13:02

http://www.zgxue.com/198/1984184.html


--------------------------Demo

protected void setup(Context context) throws IOException, InterruptedException {Configuration conf = context.getConfiguration();// 设置配置文件名System.setProperty("config-file", conf.get("config-file"));URI[] uris = context.getCacheFiles();if (uris != null) {for (URI uri : uris) {String filename = uri.toString().substring(uri.toString().lastIndexOf("/") + 1);log.info(BaseConstant.LOG_PREFIX + "cache file is " + filename);Reader reader = new SequenceFile.Reader(conf, Reader.file(new Path(filename)));LongWritable key = new LongWritable();Text value = new Text();while (reader.next(key, value)) {String[] datas = value.toString().split("\\|");    }    reader.close();}}}


0 0