How to write and read files in/from Hadoop HDFS using Ruby? How to write and read files in/from Hadoop HDFS using Ruby? hadoop hadoop

How to write and read files in/from Hadoop HDFS using Ruby?


There are two projects in github that fit what you're asking. ruby-hdfs provides native C bindings to HDFS for Ruby. ganapati interfaces with a Thrift server.

You could also make system calls directly to the file system shell. For example:

cmd = "hadoop fs -mkdir #{hdfs_path}"cmd += " 2> /dev/null"system(cmd)if $? == 0  puts 'ok'  exit(0)else  puts "Error: failed to create hdfs://#{hdfs_path}"  exit(2)end