03 Mar 2013, 16:03
Generic-user-small

Paul Williams (2 posts)

Hi,

I’m struggling to run the put_multiple_columns.rb script to import data into hbase.

I’ve tried using java org.jruby.Main, and hbase org.jruby.Main followed by the script.

My edited scripts changed top lines from

import ‘blah’

to

include Java
import blah

but this did not work.

Most recently, I’ve downloaded the example again from the site and try to run it like :

fred:~ will$ hbase org.jruby.Main ~/src/learning/7_dbs_in_7_weeks/hbase/put_multiple_columns.rb
NoMethodError: undefined method `import’ for main:Object (root) at /Users/will/src/learning/7_dbs_in_7_weeks/hbase/put_multiple_columns.rb:9

Any ideas?

03 Mar 2013, 16:45
Generic-user-small

Paul Williams (2 posts)

In the end, I hacked the scripts and the following seems to work..

-

  1. Excerpted from “Seven Databases in Seven Weeks”,
  2. published by The Pragmatic Bookshelf.
  3. Copyrights apply to this code. It may not be used to create training material,
  4. courses, books, articles, and the like. Contact us if you are in doubt.
  5. We make no guarantees that this code is fit for any purpose.
  6. Visit http://www.pragmaticprogrammer.com/titles/rwdata for more book information. #-
    include Java
    import org.apache.hadoop.hbase.client.HTable
    import org.apache.hadoop.hbase.client.Put
    import org.apache.hadoop.hbase.HBaseConfiguration

def jbytes( *args ) args.map { |arg| arg.to_s.to_java_bytes }
end

puts( @hbase)

conf = HBaseConfiguration.new
table = HTable.new( conf, “wiki” )

p = Put.new( *jbytes( “Home” ) )

p.add( *jbytes( “text”, ””, “Hello world” ) )
p.add( *jbytes( “revision”, “author”, “jimbo” ) )
p.add( *jbytes( “revision”, “comment”, “my first edit” ) )

table.put( p )

  You must be logged in to comment