Re: [jruby-user] Re: Reading binary Files
Christian MICHON <[email protected]>
| Newsgroups | gmane.comp.lang.jruby.user |
|---|---|
| Message-ID | <CACx2yF9Xdu3umenQP3pH2yKL+L-9DZPvb=aRyrQ4h3bWVVbmfg@mail.gmail.com> |
Then please remove the following line from your code: java_import "java.io.File" Good luck! On Sun, Oct 5, 2014 at 11:34 AM, Roger Palma <[email protected]> wrote: > According to the Ruby Documentation, I just use their "file" class, > since my PDFs (here JPGs) are rather small. This seems to work so far, > but might be slower than a stream-based way. It did well for importing 5 > files on my test box, we'll see how it does when running on the real > site with millions of files. Even without my "puts" the HBase shell > produces a lot of messages on screen... > > java_import "org.apache.hadoop.hbase.util.Bytes" > java_import "org.apache.hadoop.hbase.client.HTable" > java_import "org.apache.hadoop.hbase.client.Put" > > > def jbytes(*args) > args.map { |arg| arg.to_s.to_java_bytes } > end > > files = Dir.glob("/home/roger/Downloads/*.jpg") > > files.each { |x| puts "File #{x}" > > inFile = File.new(x) > buffer = inFile.read() > > table = HTable.new(@hbase.configuration, "rb_test") > p = Put.new(*jbytes(File.basename(x))) > > p.add(*jbytes("inhalt", "", buffer)) > > table.put(p) > > table.close() > } > > -- > Posted via http://www.ruby-forum.com/. > > --------------------------------------------------------------------- > To unsubscribe from this list, please visit: > > http://xircles.codehaus.org/manage_email > > > -- Christian