Store images/videos into Hadoop HDFS -


i store videos/images hadoop hdfs, heard hdfs accepts files text.

to sure, can store videos/images hdfs? if yes, what's way or steps follow that?

it absolutely possible without doing extra. hadoop provides facility read/write binary files. so, practically can converted bytes can stored hdfs(images, videos etc). hadoop provides called sequencefiles. sequencefile flat file consisting of binary key/value pairs. sequencefile provides writer, reader , sorter classes writing, reading , sorting respectively. so, convert image/video file seuencefile , store hdfs. here small piece of code take image file , convert sequencefile, name of file key , image content value :

public class imagetoseq {     public static void main(string args[]) throws exception {          configuration confhadoop = new configuration();              confhadoop.addresource(new path("/hadoop/projects/hadoop-1.0.4/conf/core-site.xml"));         confhadoop.addresource(new path("/hadoop/projects/hadoop-1.0.4/conf/hdfs-site.xml"));            filesystem fs = filesystem.get(confhadoop);         path inpath = new path("/mapin/1.png");         path outpath = new path("/mapin/11.png");         fsdatainputstream in = null;         text key = new text();         byteswritable value = new byteswritable();         sequencefile.writer writer = null;         try{             in = fs.open(inpath);             byte buffer[] = new byte[in.available()];             in.read(buffer);             writer = sequencefile.createwriter(fs, confhadoop, outpath, key.getclass(),value.getclass());             writer.append(new text(inpath.getname()), new byteswritable(buffer));         }catch (exception e) {             system.out.println("exception messages = "+e.getmessage());         }         {             ioutils.closestream(writer);             system.out.println("last line of code....!!!!!!!!!!");         }     } } 

and if intention dump files is, :

bin/hadoop fs -put /src_image_file /dst_image_file 

and if intent more storing files, might find hipi useful. hipi library hadoop's mapreduce framework provides api performing image processing tasks in distributed computing environment.

hth


Comments

Popular posts from this blog

jquery - How can I dynamically add a browser tab? -

node.js - Getting the socket id,user id pair of a logged in user(s) -

keyboard - C++ GetAsyncKeyState alternative -