如何读取hdfs上的avro文件

有什么api,或者例子吗?
标签: avro、hdfs、api、读取、例子、面试
  • 风自在
    2016-08-11 11:49:31 1楼#1层
    Path path = new Path("/path/on/hdfs");
    Configuration config = new Configuration(); // make this your Hadoop env config
    SeekableInput input = new FsInput(path, config);
    DatumReader<GenericRecord> reader = new GenericDatumReader<GenericRecord>();
    FileReader<GenericRecord> fileReader = DataFileReader.openReader(input, reader);
    
    for (GenericRecord datum : fileReader) {
        System.out.println("value = " + datum);
    }
    
    fileReader.close(); // also closes underlying FsInput
  • 回复
隐藏