Reading and Writing Sequencefile using Hadoop 2.0 Apis -


i looking example using new api read , write sequence files.

effectively need know how use these functions

 createwriter(configuration conf, org.apache.hadoop.io.sequencefile.writer.option... opts)  

the old definition not working me:

sequencefile.createwriter( fs, conf, path, key.getclass(), value.getclass()); 

similarly need know code reading sequence file, follwoing deprecated:

sequencefile.reader(fs, path, conf); 

here way use same -

    string uri = args[0];     configuration conf = new configuration();     path path = new path( uri);      intwritable key = new intwritable();     text value = new text();      compressioncodec codec = new gzipcodec();     sequencefile.writer writer = null;     option optpath = sequencefile.writer.file(path);     option optkey = sequencefile.writer.keyclass(key.getclass());     option optval = sequencefile.writer.valueclass(value.getclass());     option optcom = sequencefile.writer.compression(compressiontype.record,  codec);          writer = sequencefile.createwriter( conf, optpath, optkey, optval, optcom); 

public class sequencefilestest {   @test   public void testseqfilereadwrite() throws ioexception {     configuration conf = new configuration();     filesystem fs = filesystem.getlocal(conf);     path seqfilepath = new path("file.seq");     sequencefile.writer writer = sequencefile.createwriter(conf,             writer.file(seqfilepath), writer.keyclass(text.class),             writer.valueclass(intwritable.class));      writer.append(new text("key1"), new intwritable(1));     writer.append(new text("key2"), new intwritable(2));      writer.close();      sequencefile.reader reader = new sequencefile.reader(conf,             reader.file(seqfilepath));      text key = new text();     intwritable val = new intwritable();      while (reader.next(key, val)) {         system.err.println(key + "\t" + val);     }      reader.close();   } } 

Comments

Popular posts from this blog

Why does Ruby on Rails generate add a blank line to the end of a file? -

keyboard - Smiles and long press feature in Android -

node.js - Bad Request - node js ajax post -