hadoop-common-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Apache Wiki <wikidi...@apache.org>
Subject [Hadoop Wiki] Trivial Update of "Hbase/Shell" by stack
Date Wed, 18 Jun 2008 19:35:13 GMT
Dear Wiki user,

You have subscribed to a wiki page or wiki category on "Hadoop Wiki" for change notification.

The following page has been changed by stack:
http://wiki.apache.org/hadoop/Hbase/Shell

The comment on the change is:
Notes on shell

------------------------------------------------------------------------------
  This page describes the JRuby IRB-based HBase Shell added in HBase 0.2.x.  It replaces the
SQL-like [:Hbase/HbaseShell: HQL], the Shell found in HBase versions 0.1.x and previous. 
Some discussion of new shell requirements can be found in the [:Hbase/Shell/Replacement: Shell
Replacement] document.
  
- == Examples ==
+ == Commands ==
+ TODO: Full exposition.
+ 
+ == Basics ==
+ 
+ A few command-line arguments can be passed the shell.  Pass ''--help'' to see whats available:
e.g. ''durruti:~ stack$ ./bin/hbase shell --help''.  For example, its possible to point the
shell at a cluster other than the one that is set in the ''hbase-site.xml'' using the ''--master=MASTER''
option.
+ 
+ == Anatomy Lesson ==
+ The HBase Shell is a ruby script, ''${HBASE_HOME}/bin/hirb.rb'', that is passed to the JRuby
class ''org.jruby.Main'' (See ''${HBASE_HOME}/bin/shell'' and search for org.jruby.Main to
see how its done).
+ 
+ The ''hirb.rb' script defines a set of hbase methods (get, set, scan, etc.), sets some environment
variables, imports a few hbase-particular modules -- a results Formatter and a ruby wrapper
around the ''HBaseAdmin'' and ''HTable'' java classes that can be found at ''${HBASE_HOME}/bin/HBase.rb''
-- and then starts up a subclass of IRB, named HIRB (IRB is the name of the interactive Ruby
interpreter; for an untainted irb experience, type 'irb' on a system that has ruby installed).
 The subclassing is done to alter slightly some of the usual IRB behaviors.  For instance,
every command invocation returns a result and the result is printed to the terminal even if
the result is nil.  The subclass intercepts nil emissions and just suppresses them.
+ 
+ Anything you can do in irb, or at least in its JRuby equivalent, ''jirb'', you should be
able to do in HBase Shell.
+ 
+ == Scripting ==
+ 
+ You can pass scripts to the HBase Shell by doing the following:
+ 
+ {{{durruti:~ stack$ ${HBASE_HOME}/bin/hbase shell PATH_TO_SCRIPT}}}
+ 
+ Your script can lean on the methods provided by the HBase Shell.
+ 
+ For more control, you may prefer manipulating HTable and HBaseAdmin methods directly.  For
example, if you would do your own formatting or you are storing structures that are mangled
when manipulated in HBase Shell.  In this case, you might pass your scripts directly to JRuby
by doing:
+ 
+ {{{durruti:~ stack$ ${HBASE_HOME}/bin/hbase org.jruby.Main PATH_TO_SCRIPT}}}
+ 
+ For examples writing straight ruby manhandling hbase client instances, see the scripts on
this page: [:Hbase/JRuby] (Ignore the sections that have you fetching the jruby jar and the
prefacing your scripts with the '#!' bang magic).
  
  == Useful Tricks ==
+ 
  === irbrc ===
  Create an ''.irbrc'' file for yourself in your home directory.  Add HBase Shell customizations.
 A useful one is command history:
  

Mime
View raw message