SlideShare a Scribd company logo
1 of 20
Unleash the Power of HBase Shell 
Big Data Everywhere 
Chicago 2014 
Jayesh Thakrar 
jthakrar@conversant.com
HBase = Truly Big Data Store ……..(well, one of many) 
• Proven 
• Scalable 
• Resilient and highly available (HA) 
• Low-latency 
• OLTP and batch/mapreduce usage 
• True big data store 
 billions of rows 
 millions of columns
However……HBase also makes me…… 
Data 
• No query tools like psql, mysql, etc 
• No interactive development tools 
• Can’t browse Java primitive data in cells, e.g. 
int, long, double, etc. 
• Cell values printed as string if “printable bytes” 
else bytes printed in “hexadecimal” format
But I was somewhat wrong…… 
• HBase shell is a full-fledged jruby shell (jirb) 
• It can exploit the strengths of Ruby and Java 
• With minimal code can retrieve/view data in any HBase row/cell 
• Can possibly use "Ruby-on-Rails" and other frameworks directly 
interfacing with HBase
HBase Shell = JRuby Under the Cover 
HBase Shell Ruby Source Code 
$ cd <HBASE_DIRECTORY> 
$ find . -name '*.rb' -print 
./bin/get-active-master.rb 
./bin/hirb.rb 
./bin/region_mover.rb 
./bin/region_status.rb 
…. 
./lib/ruby/shell/commands/assign.rb 
./lib/ruby/shell/commands/balancer.rb 
… 
./lib/ruby/shell/commands/create.rb 
./lib/ruby/shell/commands/delete.rb 
…..
JRuby under the cover 
HBase Shell Ruby Source Code Shell Commands = HBase DSL (Domain Specific Language) 
$ cd <HBASE_DIRECTORY> 
$ find . -name '*.rb' -print 
./bin/get-active-master.rb 
./bin/hirb.rb 
./bin/region_mover.rb 
./bin/region_status.rb 
…. 
./lib/ruby/shell/commands/assign.rb 
./lib/ruby/shell/commands/balancer.rb 
… 
./lib/ruby/shell/commands/create.rb 
./lib/ruby/shell/commands/delete.rb 
….. 
$ hbase shell 
get 'user', 'AB350000000000000350' 
get('user', 'AB350000000000000350') 
DSL format 
Ruby method format
JRuby under the cover 
HBase Shell Ruby Source Code Shell Commands = HBase DSL (Domain Specific Language) 
$ cd <HBASE_DIRECTORY> 
$ find . -name '*.rb' -print 
./bin/get-active-master.rb 
./bin/hirb.rb 
./bin/region_mover.rb 
./bin/region_status.rb 
…. 
./lib/ruby/shell/commands/assign.rb 
./lib/ruby/shell/commands/balancer.rb 
… 
./lib/ruby/shell/commands/create.rb 
./lib/ruby/shell/commands/delete.rb 
….. 
$ hbase shell 
get 'user', 'AB350000000000000350' 
get('user', 'AB350000000000000350') 
table_name = 'user' 
rowkey = 'AB350000000000000350' 
get(table_name, rowkey) 
DSL format 
Ruby method format
JRuby under the cover 
HBase Shell Ruby Source Code Shell Commands = HBase DSL (Domain Specific Language) 
$ cd <HBASE_DIRECTORY> 
$ find . -name '*.rb' -print 
./bin/get-active-master.rb 
./bin/hirb.rb 
./bin/region_mover.rb 
./bin/region_status.rb 
…. 
./lib/ruby/shell/commands/assign.rb 
./lib/ruby/shell/commands/balancer.rb 
… 
./lib/ruby/shell/commands/create.rb 
./lib/ruby/shell/commands/delete.rb 
….. 
$ hbase shell 
get 'user', 'AB350000000000000350' 
get('user', 'AB350000000000000350') 
table_name = 'user' 
rowkey = 'AB350000000000000350' 
get(table_name, rowkey) 
DSL format 
Ruby method format 
scan 'user', {STARTROW => 'AB350000000000000350', LIMIT => 5} 
scan_options = {STARTROW => rowkey, LIMIT => 5} 
scan table_name, scan_options 
Defining and using Ruby Hash or Dictionary
HBase shell JRuby Example - 1 
include Java 
import org.apache.hadoop.hbase. HBaseConfiguration 
import org.apache.hadoop.hbase.client.HTable 
import org.apache.hadoop.hbase.client.Scan 
import org.apache.hadoop.hbase.client.Get 
import org.apache.hadoop.hbase.client.Result 
import org.apache.hadoop.hbase.util.Bytes 
htable = HTable.new(HBaseConfiguration.new, "sample") 
rowkey = Bytes.toBytes("some_rowkey") 
get = Get.new(rowkey) 
result = htable.get(get) 
result.list.collect {|kv| puts "#{Bytes.toString(kv.getFamily)}:#{Bytes.toString(kv.getQualifier)}"}
HBase shell JRuby Example - 1 
include Java 
import org.apache.hadoop.hbase. HBaseConfiguration 
import org.apache.hadoop.hbase.client.HTable 
import org.apache.hadoop.hbase.client.Scan 
import org.apache.hadoop.hbase.client.Get 
import org.apache.hadoop.hbase.client.Result 
import org.apache.hadoop.hbase.util.Bytes 
htable = HTable.new(HBaseConfiguration.new, "sample") 
rowkey = Bytes.toBytes("some_rowkey") 
get = Get.new(rowkey) 
result = htable.get(get) 
result.list.collect {|kv| puts "#{Bytes.toString(kv.getFamily)}:#{Bytes.toString(kv.getQualifier)}"} 
Allow calling Java from within JRuby
HBase shell JRuby Example - 1 
include Java 
import org.apache.hadoop.hbase. HBaseConfiguration 
import org.apache.hadoop.hbase.client.HTable 
import org.apache.hadoop.hbase.client.Scan 
import org.apache.hadoop.hbase.client.Get 
import org.apache.hadoop.hbase.client.Result 
import org.apache.hadoop.hbase.util.Bytes 
htable = HTable.new(HBaseConfiguration.new, "sample") 
rowkey = Bytes.toBytes("some_rowkey") 
get = Get.new(rowkey) 
result = htable.get(get) 
result.list.collect {|kv| puts "#{Bytes.toString(kv.getFamily)}:#{Bytes.toString(kv.getQualifier)}"} 
Allow calling Java from within JRuby 
"import" Java classes
HBase shell JRuby Example - 1 
include Java 
import org.apache.hadoop.hbase. HBaseConfiguration 
import org.apache.hadoop.hbase.client.HTable 
import org.apache.hadoop.hbase.client.Scan 
import org.apache.hadoop.hbase.client.Get 
import org.apache.hadoop.hbase.client.Result 
import org.apache.hadoop.hbase.util.Bytes 
htable = HTable.new(HBaseConfiguration.new, "sample") 
rowkey = Bytes.toBytes("some_rowkey") 
get = Get.new(rowkey) 
result = htable.get(get) 
result.list.collect {|kv| puts "#{Bytes.toString(kv.getFamily)}:#{Bytes.toString(kv.getQualifier)}"} 
Allow calling Java from within JRuby 
"import" Java classes 
Can invoke HBase Java API 
Jruby variables for Java class instance and static 
and instance method output 
HTable.new = new Htable() in Java
HBase shell JRuby Example - 1 
include Java 
import org.apache.hadoop.hbase.HBaseConfiguration 
import org.apache.hadoop.hbase.client.HTable 
import org.apache.hadoop.hbase.client.Scan 
import org.apache.hadoop.hbase.client.Get 
import org.apache.hadoop.hbase.client.Result 
import org.apache.hadoop.hbase.util.Bytes 
htable = HTable.new(HBaseConfiguration.new, "sample") 
rowkey = Bytes.toBytes("some_rowkey") 
get = Get.new(rowkey) 
result = htable.get(get) 
result.list.collect {|kv| puts "#{Bytes.toString(kv.getFamily)}:#{Bytes.toString(kv.getQualifier)}"} 
Allow calling Java from within JRuby 
"import" Java classes 
Creating Jruby variables for Java class instance 
and static and instance method output 
HTable.new = new Htable() in Java 
Ruby expression: "collect" is a Ruby method for list objects. Here it is made available to 
a Java list thus making available features of both languages transparently and seamlessly.
HBase shell JRuby Example - 2 
# Same include and import statements as Example - 1 
htable = HTable.new(HBaseConfiguration.new, ".META.") 
scanner = htable.getScanner(Scan.new()) 
tables = {} 
scanner.each do |r| 
table_name = Bytes.toString(r.getRow).split(",")[0] 
if not tables.has_key?(table_name) 
tables[table_name] = 0 
end 
tables[table_name] = tables[table_name] + 1 
end 
tables.keys.each { |t| puts "Table #{t} has #{tables[t]} regions"} 
This example scans the ".META.“ 
to get a count of regions by 
tables and regionserver
HBase shell JRuby Example - 2 
# Same include and import statements as Example - 1 
htable = HTable.new(HBaseConfiguration.new, ".META.") 
scanner = htable.getScanner(Scan.new()) 
tables = {} 
scanner.each do |r| 
table_name = Bytes.toString(r.getRow).split(",")[0] 
if not tables.has_key?(table_name) 
tables[table_name] = 0 
end 
tables[table_name] = tables[table_name] + 1 
end 
tables.keys.each { |t| puts "Table #{t} has #{tables[t]} regions"} 
This example scans the ".META.“ 
to get a count of regions by 
tables and regionserver 
Empty Ruby hash or dictionary
HBase shell JRuby Example - 2 
# Same include and import statements as Example - 1 
htable = HTable.new(HBaseConfiguration.new, ".META.") 
scanner = htable.getScanner(Scan.new()) 
tables = {} 
scanner.each do |r| 
table_name = Bytes.toString(r.getRow).split(",")[0] 
if not tables.has_key?(table_name) 
tables[table_name] = 0 
end 
tables[table_name] = tables[table_name] + 1 
end 
tables.keys.each { |t| puts "Table #{t} has #{tables[t]} regions"} 
This example scans the ".META.“ 
to get a count of regions by 
tables and regionserver 
Empty Ruby hash or dictionary 
Example of how to iterate through a Java "iterable". 
Each iteration of scanner gives a "Result" object which is then 
passed to a code block
HBase shell JRuby Example - 2 
# Same include and import statements as Example - 1 
htable = HTable.new(HBaseConfiguration.new, ".META.") 
scanner = htable.getScanner(Scan.new()) 
tables = {} 
scanner.each do |r| 
table_name = Bytes.toString(r.getRow).split(",")[0] 
if not tables.has_key?(table_name) 
tables[table_name] = 0 
end 
tables[table_name] = tables[table_name] + 1 
end 
tables.keys.each { |t| puts "Table #{t} has #{tables[t]} regions"} 
This example scans the ".META.“ 
to get a count of regions by 
tables and regionserver 
Example of how to iterate through a Java "iterable". 
Each iteration of scanner gives a "Result" object which is then 
passed to a code block 
The "code block" can be enclosed by curly braces 
({}) or "do" and "end" keywords. Convention is to 
use {} for single line code blocks and do/end for 
multi-line code blocks. 
Empty Ruby hash or dictionary
HBase shell JRuby Example - 2 
# Same include and import statements as Example - 1 
htable = HTable.new(HBaseConfiguration.new, ".META.") 
scanner = htable.getScanner(Scan.new()) 
tables = {} 
scanner.each do |r| 
table_name = Bytes.toString(r.getRow).split(",")[0] 
if not tables.has_key?(table_name) 
tables[table_name] = 0 
end 
tables[table_name] = tables[table_name] + 1 
end 
tables.keys.each { |t| puts "Table #{t} has #{tables[t]} regions"} 
This example scans the ".META.“ 
to get a count of regions by 
tables and regionserver 
Example of how to iterate through a Java "iterable". 
Each iteration of scanner gives a "Result" object which is then passed to a code block 
The "code block" can be enclosed by curly braces 
({}) or "do" and "end" keywords. Convention is to 
use {} for single line code blocks and do/end for 
multi-line code blocks. 
Empty Ruby hash or dictionary 
Print region count by table using 
an iterator that is passed a code 
block. Compare the code block 
enclosed in {} v/s “do/end” above
HBase shell JRuby Example - 3 
• See https://github.com/JThakrar/hse 
• hbase_shell_extension.rb
To Conclude……. 
• HBase shell 
 is an interactive scripting environment 
 allows mixing of Java and Jruby 
 Is not “recommended” for serious, enterprise/group development that 
requires automated testing, continuous integration, etc. 
• Can use JRuby IDE, provided you add HBase jars using "require" 
e.g. require '<path>/hbase.jar' 
• Can also use your custom Java jars in IDE and/or HBase shell 
• Can even “compile” your code to generate “jars” from your JRuby scripts for 
optimal performance and/or to avoid exposing source code

More Related Content

What's hot

MongoDB - Aggregation Pipeline
MongoDB - Aggregation PipelineMongoDB - Aggregation Pipeline
MongoDB - Aggregation PipelineJason Terpko
 
CQL performance with Apache Cassandra 3.0 (Aaron Morton, The Last Pickle) | C...
CQL performance with Apache Cassandra 3.0 (Aaron Morton, The Last Pickle) | C...CQL performance with Apache Cassandra 3.0 (Aaron Morton, The Last Pickle) | C...
CQL performance with Apache Cassandra 3.0 (Aaron Morton, The Last Pickle) | C...DataStax
 
Hive Object Model
Hive Object ModelHive Object Model
Hive Object ModelZheng Shao
 
Cloudera Impala, updated for v1.0
Cloudera Impala, updated for v1.0Cloudera Impala, updated for v1.0
Cloudera Impala, updated for v1.0Scott Leberknight
 
MongoDB Aggregation
MongoDB Aggregation MongoDB Aggregation
MongoDB Aggregation Amit Ghosh
 
Hive - SerDe and LazySerde
Hive - SerDe and LazySerdeHive - SerDe and LazySerde
Hive - SerDe and LazySerdeZheng Shao
 
Scalding: Reaching Efficient MapReduce
Scalding: Reaching Efficient MapReduceScalding: Reaching Efficient MapReduce
Scalding: Reaching Efficient MapReduceLivePerson
 
Avro, la puissance du binaire, la souplesse du JSON
Avro, la puissance du binaire, la souplesse du JSONAvro, la puissance du binaire, la souplesse du JSON
Avro, la puissance du binaire, la souplesse du JSONAlexandre Victoor
 
Hive data migration (export/import)
Hive data migration (export/import)Hive data migration (export/import)
Hive data migration (export/import)Bopyo Hong
 
Apache avro and overview hadoop tools
Apache avro and overview hadoop toolsApache avro and overview hadoop tools
Apache avro and overview hadoop toolsalireza alikhani
 
MongoDB World 2019: Creating a Self-healing MongoDB Replica Set on GCP Comput...
MongoDB World 2019: Creating a Self-healing MongoDB Replica Set on GCP Comput...MongoDB World 2019: Creating a Self-healing MongoDB Replica Set on GCP Comput...
MongoDB World 2019: Creating a Self-healing MongoDB Replica Set on GCP Comput...MongoDB
 
MongoDB Aggregation Framework
MongoDB Aggregation FrameworkMongoDB Aggregation Framework
MongoDB Aggregation FrameworkCaserta
 
Perl at SkyCon'12
Perl at SkyCon'12Perl at SkyCon'12
Perl at SkyCon'12Tim Bunce
 
Cassandra 3.0 - JSON at scale - StampedeCon 2015
Cassandra 3.0 - JSON at scale - StampedeCon 2015Cassandra 3.0 - JSON at scale - StampedeCon 2015
Cassandra 3.0 - JSON at scale - StampedeCon 2015StampedeCon
 
Aggregation Framework MongoDB Days Munich
Aggregation Framework MongoDB Days MunichAggregation Framework MongoDB Days Munich
Aggregation Framework MongoDB Days MunichNorberto Leite
 
DBD::Gofer 200809
DBD::Gofer 200809DBD::Gofer 200809
DBD::Gofer 200809Tim Bunce
 

What's hot (20)

MongoDB - Aggregation Pipeline
MongoDB - Aggregation PipelineMongoDB - Aggregation Pipeline
MongoDB - Aggregation Pipeline
 
CQL performance with Apache Cassandra 3.0 (Aaron Morton, The Last Pickle) | C...
CQL performance with Apache Cassandra 3.0 (Aaron Morton, The Last Pickle) | C...CQL performance with Apache Cassandra 3.0 (Aaron Morton, The Last Pickle) | C...
CQL performance with Apache Cassandra 3.0 (Aaron Morton, The Last Pickle) | C...
 
wtf is in Java/JDK/wtf7?
wtf is in Java/JDK/wtf7?wtf is in Java/JDK/wtf7?
wtf is in Java/JDK/wtf7?
 
Hive Object Model
Hive Object ModelHive Object Model
Hive Object Model
 
Cloudera Impala, updated for v1.0
Cloudera Impala, updated for v1.0Cloudera Impala, updated for v1.0
Cloudera Impala, updated for v1.0
 
MongoDB Aggregation
MongoDB Aggregation MongoDB Aggregation
MongoDB Aggregation
 
Hive - SerDe and LazySerde
Hive - SerDe and LazySerdeHive - SerDe and LazySerde
Hive - SerDe and LazySerde
 
Scalding: Reaching Efficient MapReduce
Scalding: Reaching Efficient MapReduceScalding: Reaching Efficient MapReduce
Scalding: Reaching Efficient MapReduce
 
Avro, la puissance du binaire, la souplesse du JSON
Avro, la puissance du binaire, la souplesse du JSONAvro, la puissance du binaire, la souplesse du JSON
Avro, la puissance du binaire, la souplesse du JSON
 
Hive data migration (export/import)
Hive data migration (export/import)Hive data migration (export/import)
Hive data migration (export/import)
 
Apache avro and overview hadoop tools
Apache avro and overview hadoop toolsApache avro and overview hadoop tools
Apache avro and overview hadoop tools
 
MongoDB World 2019: Creating a Self-healing MongoDB Replica Set on GCP Comput...
MongoDB World 2019: Creating a Self-healing MongoDB Replica Set on GCP Comput...MongoDB World 2019: Creating a Self-healing MongoDB Replica Set on GCP Comput...
MongoDB World 2019: Creating a Self-healing MongoDB Replica Set on GCP Comput...
 
MongoDB Aggregation Framework
MongoDB Aggregation FrameworkMongoDB Aggregation Framework
MongoDB Aggregation Framework
 
Perl at SkyCon'12
Perl at SkyCon'12Perl at SkyCon'12
Perl at SkyCon'12
 
Cassandra 3.0 - JSON at scale - StampedeCon 2015
Cassandra 3.0 - JSON at scale - StampedeCon 2015Cassandra 3.0 - JSON at scale - StampedeCon 2015
Cassandra 3.0 - JSON at scale - StampedeCon 2015
 
CouchDB-Lucene
CouchDB-LuceneCouchDB-Lucene
CouchDB-Lucene
 
Sql cheat sheet
Sql cheat sheetSql cheat sheet
Sql cheat sheet
 
High Performance tDiary
High Performance tDiaryHigh Performance tDiary
High Performance tDiary
 
Aggregation Framework MongoDB Days Munich
Aggregation Framework MongoDB Days MunichAggregation Framework MongoDB Days Munich
Aggregation Framework MongoDB Days Munich
 
DBD::Gofer 200809
DBD::Gofer 200809DBD::Gofer 200809
DBD::Gofer 200809
 

Similar to Big Data Everywhere Chicago: Unleash the Power of HBase Shell (Conversant)

Code for Startup MVP (Ruby on Rails) Session 2
Code for Startup MVP (Ruby on Rails) Session 2Code for Startup MVP (Ruby on Rails) Session 2
Code for Startup MVP (Ruby on Rails) Session 2Henry S
 
Apache Spark on Apache HBase: Current and Future
Apache Spark on Apache HBase: Current and Future Apache Spark on Apache HBase: Current and Future
Apache Spark on Apache HBase: Current and Future HBaseCon
 
HBaseConEast2016: HBase and Spark, State of the Art
HBaseConEast2016: HBase and Spark, State of the ArtHBaseConEast2016: HBase and Spark, State of the Art
HBaseConEast2016: HBase and Spark, State of the ArtMichael Stack
 
Google apps script database abstraction exposed version
Google apps script database abstraction   exposed versionGoogle apps script database abstraction   exposed version
Google apps script database abstraction exposed versionBruce McPherson
 
Elasticsearch And Ruby [RuPy2012]
Elasticsearch And Ruby [RuPy2012]Elasticsearch And Ruby [RuPy2012]
Elasticsearch And Ruby [RuPy2012]Karel Minarik
 
Spring data iii
Spring data iiiSpring data iii
Spring data iii명철 강
 
Introduction tomongodb
Introduction tomongodbIntroduction tomongodb
Introduction tomongodbLee Theobald
 
Hadoop Integration in Cassandra
Hadoop Integration in CassandraHadoop Integration in Cassandra
Hadoop Integration in CassandraJairam Chandar
 
TDC 2012 - Patterns e Anti-Patterns em Ruby
TDC 2012 - Patterns e Anti-Patterns em RubyTDC 2012 - Patterns e Anti-Patterns em Ruby
TDC 2012 - Patterns e Anti-Patterns em RubyFabio Akita
 
H base introduction & development
H base introduction & developmentH base introduction & development
H base introduction & developmentShashwat Shriparv
 
A Brief Intro to Scala
A Brief Intro to ScalaA Brief Intro to Scala
A Brief Intro to ScalaTim Underwood
 
Softshake 2013: 10 reasons why java developers are jealous of Scala developers
Softshake 2013: 10 reasons why java developers are jealous of Scala developersSoftshake 2013: 10 reasons why java developers are jealous of Scala developers
Softshake 2013: 10 reasons why java developers are jealous of Scala developersMatthew Farwell
 
Introduction to Apache HBase, MapR Tables and Security
Introduction to Apache HBase, MapR Tables and SecurityIntroduction to Apache HBase, MapR Tables and Security
Introduction to Apache HBase, MapR Tables and SecurityMapR Technologies
 

Similar to Big Data Everywhere Chicago: Unleash the Power of HBase Shell (Conversant) (20)

Code for Startup MVP (Ruby on Rails) Session 2
Code for Startup MVP (Ruby on Rails) Session 2Code for Startup MVP (Ruby on Rails) Session 2
Code for Startup MVP (Ruby on Rails) Session 2
 
Apache Spark on Apache HBase: Current and Future
Apache Spark on Apache HBase: Current and Future Apache Spark on Apache HBase: Current and Future
Apache Spark on Apache HBase: Current and Future
 
HBaseConEast2016: HBase and Spark, State of the Art
HBaseConEast2016: HBase and Spark, State of the ArtHBaseConEast2016: HBase and Spark, State of the Art
HBaseConEast2016: HBase and Spark, State of the Art
 
Google apps script database abstraction exposed version
Google apps script database abstraction   exposed versionGoogle apps script database abstraction   exposed version
Google apps script database abstraction exposed version
 
Elasticsearch And Ruby [RuPy2012]
Elasticsearch And Ruby [RuPy2012]Elasticsearch And Ruby [RuPy2012]
Elasticsearch And Ruby [RuPy2012]
 
Spring data iii
Spring data iiiSpring data iii
Spring data iii
 
Introduction tomongodb
Introduction tomongodbIntroduction tomongodb
Introduction tomongodb
 
Hadoop Integration in Cassandra
Hadoop Integration in CassandraHadoop Integration in Cassandra
Hadoop Integration in Cassandra
 
TDC 2012 - Patterns e Anti-Patterns em Ruby
TDC 2012 - Patterns e Anti-Patterns em RubyTDC 2012 - Patterns e Anti-Patterns em Ruby
TDC 2012 - Patterns e Anti-Patterns em Ruby
 
Rails on Oracle 2011
Rails on Oracle 2011Rails on Oracle 2011
Rails on Oracle 2011
 
H base introduction & development
H base introduction & developmentH base introduction & development
H base introduction & development
 
A Brief Intro to Scala
A Brief Intro to ScalaA Brief Intro to Scala
A Brief Intro to Scala
 
Ruby On Rails
Ruby On RailsRuby On Rails
Ruby On Rails
 
Scala in Places API
Scala in Places APIScala in Places API
Scala in Places API
 
Lobos Introduction
Lobos IntroductionLobos Introduction
Lobos Introduction
 
Introduction to Perl and BioPerl
Introduction to Perl and BioPerlIntroduction to Perl and BioPerl
Introduction to Perl and BioPerl
 
מיכאל
מיכאלמיכאל
מיכאל
 
Softshake 2013: 10 reasons why java developers are jealous of Scala developers
Softshake 2013: 10 reasons why java developers are jealous of Scala developersSoftshake 2013: 10 reasons why java developers are jealous of Scala developers
Softshake 2013: 10 reasons why java developers are jealous of Scala developers
 
Introduction to Apache HBase, MapR Tables and Security
Introduction to Apache HBase, MapR Tables and SecurityIntroduction to Apache HBase, MapR Tables and Security
Introduction to Apache HBase, MapR Tables and Security
 
Play!ng with scala
Play!ng with scalaPlay!ng with scala
Play!ng with scala
 

More from BigDataEverywhere

Big Data Everywhere Chicago: Apache Spark Plus Many Other Frameworks -- How S...
Big Data Everywhere Chicago: Apache Spark Plus Many Other Frameworks -- How S...Big Data Everywhere Chicago: Apache Spark Plus Many Other Frameworks -- How S...
Big Data Everywhere Chicago: Apache Spark Plus Many Other Frameworks -- How S...BigDataEverywhere
 
Big Data Everywhere Chicago: Getting Real with the MapR Platform (MapR)
Big Data Everywhere Chicago: Getting Real with the MapR Platform (MapR)Big Data Everywhere Chicago: Getting Real with the MapR Platform (MapR)
Big Data Everywhere Chicago: Getting Real with the MapR Platform (MapR)BigDataEverywhere
 
Big Data Everywhere Chicago: Leading a Healthcare Company to the Big Data Pro...
Big Data Everywhere Chicago: Leading a Healthcare Company to the Big Data Pro...Big Data Everywhere Chicago: Leading a Healthcare Company to the Big Data Pro...
Big Data Everywhere Chicago: Leading a Healthcare Company to the Big Data Pro...BigDataEverywhere
 
Big Data Everywhere Chicago: The Big Data Imperative -- Discovering & Protect...
Big Data Everywhere Chicago: The Big Data Imperative -- Discovering & Protect...Big Data Everywhere Chicago: The Big Data Imperative -- Discovering & Protect...
Big Data Everywhere Chicago: The Big Data Imperative -- Discovering & Protect...BigDataEverywhere
 
Big Data Everywhere Chicago: High Performance Computing - Contributions Towar...
Big Data Everywhere Chicago: High Performance Computing - Contributions Towar...Big Data Everywhere Chicago: High Performance Computing - Contributions Towar...
Big Data Everywhere Chicago: High Performance Computing - Contributions Towar...BigDataEverywhere
 
Big Data Everywhere Chicago: SQL on Hadoop
Big Data Everywhere Chicago: SQL on Hadoop Big Data Everywhere Chicago: SQL on Hadoop
Big Data Everywhere Chicago: SQL on Hadoop BigDataEverywhere
 
Big Data Everywhere Chicago: Platfora - Practices for Customer Analytics on H...
Big Data Everywhere Chicago: Platfora - Practices for Customer Analytics on H...Big Data Everywhere Chicago: Platfora - Practices for Customer Analytics on H...
Big Data Everywhere Chicago: Platfora - Practices for Customer Analytics on H...BigDataEverywhere
 

More from BigDataEverywhere (7)

Big Data Everywhere Chicago: Apache Spark Plus Many Other Frameworks -- How S...
Big Data Everywhere Chicago: Apache Spark Plus Many Other Frameworks -- How S...Big Data Everywhere Chicago: Apache Spark Plus Many Other Frameworks -- How S...
Big Data Everywhere Chicago: Apache Spark Plus Many Other Frameworks -- How S...
 
Big Data Everywhere Chicago: Getting Real with the MapR Platform (MapR)
Big Data Everywhere Chicago: Getting Real with the MapR Platform (MapR)Big Data Everywhere Chicago: Getting Real with the MapR Platform (MapR)
Big Data Everywhere Chicago: Getting Real with the MapR Platform (MapR)
 
Big Data Everywhere Chicago: Leading a Healthcare Company to the Big Data Pro...
Big Data Everywhere Chicago: Leading a Healthcare Company to the Big Data Pro...Big Data Everywhere Chicago: Leading a Healthcare Company to the Big Data Pro...
Big Data Everywhere Chicago: Leading a Healthcare Company to the Big Data Pro...
 
Big Data Everywhere Chicago: The Big Data Imperative -- Discovering & Protect...
Big Data Everywhere Chicago: The Big Data Imperative -- Discovering & Protect...Big Data Everywhere Chicago: The Big Data Imperative -- Discovering & Protect...
Big Data Everywhere Chicago: The Big Data Imperative -- Discovering & Protect...
 
Big Data Everywhere Chicago: High Performance Computing - Contributions Towar...
Big Data Everywhere Chicago: High Performance Computing - Contributions Towar...Big Data Everywhere Chicago: High Performance Computing - Contributions Towar...
Big Data Everywhere Chicago: High Performance Computing - Contributions Towar...
 
Big Data Everywhere Chicago: SQL on Hadoop
Big Data Everywhere Chicago: SQL on Hadoop Big Data Everywhere Chicago: SQL on Hadoop
Big Data Everywhere Chicago: SQL on Hadoop
 
Big Data Everywhere Chicago: Platfora - Practices for Customer Analytics on H...
Big Data Everywhere Chicago: Platfora - Practices for Customer Analytics on H...Big Data Everywhere Chicago: Platfora - Practices for Customer Analytics on H...
Big Data Everywhere Chicago: Platfora - Practices for Customer Analytics on H...
 

Recently uploaded

SR-101-01012024-EN.docx Federal Constitution of the Swiss Confederation
SR-101-01012024-EN.docx  Federal Constitution  of the Swiss ConfederationSR-101-01012024-EN.docx  Federal Constitution  of the Swiss Confederation
SR-101-01012024-EN.docx Federal Constitution of the Swiss ConfederationEfruzAsilolu
 
Top profile Call Girls In Tumkur [ 7014168258 ] Call Me For Genuine Models We...
Top profile Call Girls In Tumkur [ 7014168258 ] Call Me For Genuine Models We...Top profile Call Girls In Tumkur [ 7014168258 ] Call Me For Genuine Models We...
Top profile Call Girls In Tumkur [ 7014168258 ] Call Me For Genuine Models We...nirzagarg
 
Data Analyst Tasks to do the internship.pdf
Data Analyst Tasks to do the internship.pdfData Analyst Tasks to do the internship.pdf
Data Analyst Tasks to do the internship.pdftheeltifs
 
Lecture_2_Deep_Learning_Overview-newone1
Lecture_2_Deep_Learning_Overview-newone1Lecture_2_Deep_Learning_Overview-newone1
Lecture_2_Deep_Learning_Overview-newone1ranjankumarbehera14
 
Top profile Call Girls In Bihar Sharif [ 7014168258 ] Call Me For Genuine Mod...
Top profile Call Girls In Bihar Sharif [ 7014168258 ] Call Me For Genuine Mod...Top profile Call Girls In Bihar Sharif [ 7014168258 ] Call Me For Genuine Mod...
Top profile Call Girls In Bihar Sharif [ 7014168258 ] Call Me For Genuine Mod...nirzagarg
 
Top profile Call Girls In Vadodara [ 7014168258 ] Call Me For Genuine Models ...
Top profile Call Girls In Vadodara [ 7014168258 ] Call Me For Genuine Models ...Top profile Call Girls In Vadodara [ 7014168258 ] Call Me For Genuine Models ...
Top profile Call Girls In Vadodara [ 7014168258 ] Call Me For Genuine Models ...gajnagarg
 
The-boAt-Story-Navigating-the-Waves-of-Innovation.pptx
The-boAt-Story-Navigating-the-Waves-of-Innovation.pptxThe-boAt-Story-Navigating-the-Waves-of-Innovation.pptx
The-boAt-Story-Navigating-the-Waves-of-Innovation.pptxVivek487417
 
怎样办理伦敦大学城市学院毕业证(CITY毕业证书)成绩单学校原版复制
怎样办理伦敦大学城市学院毕业证(CITY毕业证书)成绩单学校原版复制怎样办理伦敦大学城市学院毕业证(CITY毕业证书)成绩单学校原版复制
怎样办理伦敦大学城市学院毕业证(CITY毕业证书)成绩单学校原版复制vexqp
 
Jual Cytotec Asli Obat Aborsi No. 1 Paling Manjur
Jual Cytotec Asli Obat Aborsi No. 1 Paling ManjurJual Cytotec Asli Obat Aborsi No. 1 Paling Manjur
Jual Cytotec Asli Obat Aborsi No. 1 Paling Manjurptikerjasaptiker
 
怎样办理伦敦大学毕业证(UoL毕业证书)成绩单学校原版复制
怎样办理伦敦大学毕业证(UoL毕业证书)成绩单学校原版复制怎样办理伦敦大学毕业证(UoL毕业证书)成绩单学校原版复制
怎样办理伦敦大学毕业证(UoL毕业证书)成绩单学校原版复制vexqp
 
In Riyadh ((+919101817206)) Cytotec kit @ Abortion Pills Saudi Arabia
In Riyadh ((+919101817206)) Cytotec kit @ Abortion Pills Saudi ArabiaIn Riyadh ((+919101817206)) Cytotec kit @ Abortion Pills Saudi Arabia
In Riyadh ((+919101817206)) Cytotec kit @ Abortion Pills Saudi Arabiaahmedjiabur940
 
一比一原版(曼大毕业证书)曼尼托巴大学毕业证成绩单留信学历认证一手价格
一比一原版(曼大毕业证书)曼尼托巴大学毕业证成绩单留信学历认证一手价格一比一原版(曼大毕业证书)曼尼托巴大学毕业证成绩单留信学历认证一手价格
一比一原版(曼大毕业证书)曼尼托巴大学毕业证成绩单留信学历认证一手价格q6pzkpark
 
如何办理英国诺森比亚大学毕业证(NU毕业证书)成绩单原件一模一样
如何办理英国诺森比亚大学毕业证(NU毕业证书)成绩单原件一模一样如何办理英国诺森比亚大学毕业证(NU毕业证书)成绩单原件一模一样
如何办理英国诺森比亚大学毕业证(NU毕业证书)成绩单原件一模一样wsppdmt
 
DATA SUMMIT 24 Building Real-Time Pipelines With FLaNK
DATA SUMMIT 24  Building Real-Time Pipelines With FLaNKDATA SUMMIT 24  Building Real-Time Pipelines With FLaNK
DATA SUMMIT 24 Building Real-Time Pipelines With FLaNKTimothy Spann
 
Discover Why Less is More in B2B Research
Discover Why Less is More in B2B ResearchDiscover Why Less is More in B2B Research
Discover Why Less is More in B2B Researchmichael115558
 
Digital Transformation Playbook by Graham Ware
Digital Transformation Playbook by Graham WareDigital Transformation Playbook by Graham Ware
Digital Transformation Playbook by Graham WareGraham Ware
 
Harnessing the Power of GenAI for BI and Reporting.pptx
Harnessing the Power of GenAI for BI and Reporting.pptxHarnessing the Power of GenAI for BI and Reporting.pptx
Harnessing the Power of GenAI for BI and Reporting.pptxParas Gupta
 
7. Epi of Chronic respiratory diseases.ppt
7. Epi of Chronic respiratory diseases.ppt7. Epi of Chronic respiratory diseases.ppt
7. Epi of Chronic respiratory diseases.pptibrahimabdi22
 
Gartner's Data Analytics Maturity Model.pptx
Gartner's Data Analytics Maturity Model.pptxGartner's Data Analytics Maturity Model.pptx
Gartner's Data Analytics Maturity Model.pptxchadhar227
 

Recently uploaded (20)

SR-101-01012024-EN.docx Federal Constitution of the Swiss Confederation
SR-101-01012024-EN.docx  Federal Constitution  of the Swiss ConfederationSR-101-01012024-EN.docx  Federal Constitution  of the Swiss Confederation
SR-101-01012024-EN.docx Federal Constitution of the Swiss Confederation
 
Top profile Call Girls In Tumkur [ 7014168258 ] Call Me For Genuine Models We...
Top profile Call Girls In Tumkur [ 7014168258 ] Call Me For Genuine Models We...Top profile Call Girls In Tumkur [ 7014168258 ] Call Me For Genuine Models We...
Top profile Call Girls In Tumkur [ 7014168258 ] Call Me For Genuine Models We...
 
Data Analyst Tasks to do the internship.pdf
Data Analyst Tasks to do the internship.pdfData Analyst Tasks to do the internship.pdf
Data Analyst Tasks to do the internship.pdf
 
Lecture_2_Deep_Learning_Overview-newone1
Lecture_2_Deep_Learning_Overview-newone1Lecture_2_Deep_Learning_Overview-newone1
Lecture_2_Deep_Learning_Overview-newone1
 
Top profile Call Girls In Bihar Sharif [ 7014168258 ] Call Me For Genuine Mod...
Top profile Call Girls In Bihar Sharif [ 7014168258 ] Call Me For Genuine Mod...Top profile Call Girls In Bihar Sharif [ 7014168258 ] Call Me For Genuine Mod...
Top profile Call Girls In Bihar Sharif [ 7014168258 ] Call Me For Genuine Mod...
 
Top profile Call Girls In Vadodara [ 7014168258 ] Call Me For Genuine Models ...
Top profile Call Girls In Vadodara [ 7014168258 ] Call Me For Genuine Models ...Top profile Call Girls In Vadodara [ 7014168258 ] Call Me For Genuine Models ...
Top profile Call Girls In Vadodara [ 7014168258 ] Call Me For Genuine Models ...
 
The-boAt-Story-Navigating-the-Waves-of-Innovation.pptx
The-boAt-Story-Navigating-the-Waves-of-Innovation.pptxThe-boAt-Story-Navigating-the-Waves-of-Innovation.pptx
The-boAt-Story-Navigating-the-Waves-of-Innovation.pptx
 
怎样办理伦敦大学城市学院毕业证(CITY毕业证书)成绩单学校原版复制
怎样办理伦敦大学城市学院毕业证(CITY毕业证书)成绩单学校原版复制怎样办理伦敦大学城市学院毕业证(CITY毕业证书)成绩单学校原版复制
怎样办理伦敦大学城市学院毕业证(CITY毕业证书)成绩单学校原版复制
 
Jual Cytotec Asli Obat Aborsi No. 1 Paling Manjur
Jual Cytotec Asli Obat Aborsi No. 1 Paling ManjurJual Cytotec Asli Obat Aborsi No. 1 Paling Manjur
Jual Cytotec Asli Obat Aborsi No. 1 Paling Manjur
 
怎样办理伦敦大学毕业证(UoL毕业证书)成绩单学校原版复制
怎样办理伦敦大学毕业证(UoL毕业证书)成绩单学校原版复制怎样办理伦敦大学毕业证(UoL毕业证书)成绩单学校原版复制
怎样办理伦敦大学毕业证(UoL毕业证书)成绩单学校原版复制
 
In Riyadh ((+919101817206)) Cytotec kit @ Abortion Pills Saudi Arabia
In Riyadh ((+919101817206)) Cytotec kit @ Abortion Pills Saudi ArabiaIn Riyadh ((+919101817206)) Cytotec kit @ Abortion Pills Saudi Arabia
In Riyadh ((+919101817206)) Cytotec kit @ Abortion Pills Saudi Arabia
 
一比一原版(曼大毕业证书)曼尼托巴大学毕业证成绩单留信学历认证一手价格
一比一原版(曼大毕业证书)曼尼托巴大学毕业证成绩单留信学历认证一手价格一比一原版(曼大毕业证书)曼尼托巴大学毕业证成绩单留信学历认证一手价格
一比一原版(曼大毕业证书)曼尼托巴大学毕业证成绩单留信学历认证一手价格
 
如何办理英国诺森比亚大学毕业证(NU毕业证书)成绩单原件一模一样
如何办理英国诺森比亚大学毕业证(NU毕业证书)成绩单原件一模一样如何办理英国诺森比亚大学毕业证(NU毕业证书)成绩单原件一模一样
如何办理英国诺森比亚大学毕业证(NU毕业证书)成绩单原件一模一样
 
DATA SUMMIT 24 Building Real-Time Pipelines With FLaNK
DATA SUMMIT 24  Building Real-Time Pipelines With FLaNKDATA SUMMIT 24  Building Real-Time Pipelines With FLaNK
DATA SUMMIT 24 Building Real-Time Pipelines With FLaNK
 
Discover Why Less is More in B2B Research
Discover Why Less is More in B2B ResearchDiscover Why Less is More in B2B Research
Discover Why Less is More in B2B Research
 
Digital Transformation Playbook by Graham Ware
Digital Transformation Playbook by Graham WareDigital Transformation Playbook by Graham Ware
Digital Transformation Playbook by Graham Ware
 
Abortion pills in Jeddah | +966572737505 | Get Cytotec
Abortion pills in Jeddah | +966572737505 | Get CytotecAbortion pills in Jeddah | +966572737505 | Get Cytotec
Abortion pills in Jeddah | +966572737505 | Get Cytotec
 
Harnessing the Power of GenAI for BI and Reporting.pptx
Harnessing the Power of GenAI for BI and Reporting.pptxHarnessing the Power of GenAI for BI and Reporting.pptx
Harnessing the Power of GenAI for BI and Reporting.pptx
 
7. Epi of Chronic respiratory diseases.ppt
7. Epi of Chronic respiratory diseases.ppt7. Epi of Chronic respiratory diseases.ppt
7. Epi of Chronic respiratory diseases.ppt
 
Gartner's Data Analytics Maturity Model.pptx
Gartner's Data Analytics Maturity Model.pptxGartner's Data Analytics Maturity Model.pptx
Gartner's Data Analytics Maturity Model.pptx
 

Big Data Everywhere Chicago: Unleash the Power of HBase Shell (Conversant)

  • 1. Unleash the Power of HBase Shell Big Data Everywhere Chicago 2014 Jayesh Thakrar jthakrar@conversant.com
  • 2. HBase = Truly Big Data Store ……..(well, one of many) • Proven • Scalable • Resilient and highly available (HA) • Low-latency • OLTP and batch/mapreduce usage • True big data store  billions of rows  millions of columns
  • 3. However……HBase also makes me…… Data • No query tools like psql, mysql, etc • No interactive development tools • Can’t browse Java primitive data in cells, e.g. int, long, double, etc. • Cell values printed as string if “printable bytes” else bytes printed in “hexadecimal” format
  • 4. But I was somewhat wrong…… • HBase shell is a full-fledged jruby shell (jirb) • It can exploit the strengths of Ruby and Java • With minimal code can retrieve/view data in any HBase row/cell • Can possibly use "Ruby-on-Rails" and other frameworks directly interfacing with HBase
  • 5. HBase Shell = JRuby Under the Cover HBase Shell Ruby Source Code $ cd <HBASE_DIRECTORY> $ find . -name '*.rb' -print ./bin/get-active-master.rb ./bin/hirb.rb ./bin/region_mover.rb ./bin/region_status.rb …. ./lib/ruby/shell/commands/assign.rb ./lib/ruby/shell/commands/balancer.rb … ./lib/ruby/shell/commands/create.rb ./lib/ruby/shell/commands/delete.rb …..
  • 6. JRuby under the cover HBase Shell Ruby Source Code Shell Commands = HBase DSL (Domain Specific Language) $ cd <HBASE_DIRECTORY> $ find . -name '*.rb' -print ./bin/get-active-master.rb ./bin/hirb.rb ./bin/region_mover.rb ./bin/region_status.rb …. ./lib/ruby/shell/commands/assign.rb ./lib/ruby/shell/commands/balancer.rb … ./lib/ruby/shell/commands/create.rb ./lib/ruby/shell/commands/delete.rb ….. $ hbase shell get 'user', 'AB350000000000000350' get('user', 'AB350000000000000350') DSL format Ruby method format
  • 7. JRuby under the cover HBase Shell Ruby Source Code Shell Commands = HBase DSL (Domain Specific Language) $ cd <HBASE_DIRECTORY> $ find . -name '*.rb' -print ./bin/get-active-master.rb ./bin/hirb.rb ./bin/region_mover.rb ./bin/region_status.rb …. ./lib/ruby/shell/commands/assign.rb ./lib/ruby/shell/commands/balancer.rb … ./lib/ruby/shell/commands/create.rb ./lib/ruby/shell/commands/delete.rb ….. $ hbase shell get 'user', 'AB350000000000000350' get('user', 'AB350000000000000350') table_name = 'user' rowkey = 'AB350000000000000350' get(table_name, rowkey) DSL format Ruby method format
  • 8. JRuby under the cover HBase Shell Ruby Source Code Shell Commands = HBase DSL (Domain Specific Language) $ cd <HBASE_DIRECTORY> $ find . -name '*.rb' -print ./bin/get-active-master.rb ./bin/hirb.rb ./bin/region_mover.rb ./bin/region_status.rb …. ./lib/ruby/shell/commands/assign.rb ./lib/ruby/shell/commands/balancer.rb … ./lib/ruby/shell/commands/create.rb ./lib/ruby/shell/commands/delete.rb ….. $ hbase shell get 'user', 'AB350000000000000350' get('user', 'AB350000000000000350') table_name = 'user' rowkey = 'AB350000000000000350' get(table_name, rowkey) DSL format Ruby method format scan 'user', {STARTROW => 'AB350000000000000350', LIMIT => 5} scan_options = {STARTROW => rowkey, LIMIT => 5} scan table_name, scan_options Defining and using Ruby Hash or Dictionary
  • 9. HBase shell JRuby Example - 1 include Java import org.apache.hadoop.hbase. HBaseConfiguration import org.apache.hadoop.hbase.client.HTable import org.apache.hadoop.hbase.client.Scan import org.apache.hadoop.hbase.client.Get import org.apache.hadoop.hbase.client.Result import org.apache.hadoop.hbase.util.Bytes htable = HTable.new(HBaseConfiguration.new, "sample") rowkey = Bytes.toBytes("some_rowkey") get = Get.new(rowkey) result = htable.get(get) result.list.collect {|kv| puts "#{Bytes.toString(kv.getFamily)}:#{Bytes.toString(kv.getQualifier)}"}
  • 10. HBase shell JRuby Example - 1 include Java import org.apache.hadoop.hbase. HBaseConfiguration import org.apache.hadoop.hbase.client.HTable import org.apache.hadoop.hbase.client.Scan import org.apache.hadoop.hbase.client.Get import org.apache.hadoop.hbase.client.Result import org.apache.hadoop.hbase.util.Bytes htable = HTable.new(HBaseConfiguration.new, "sample") rowkey = Bytes.toBytes("some_rowkey") get = Get.new(rowkey) result = htable.get(get) result.list.collect {|kv| puts "#{Bytes.toString(kv.getFamily)}:#{Bytes.toString(kv.getQualifier)}"} Allow calling Java from within JRuby
  • 11. HBase shell JRuby Example - 1 include Java import org.apache.hadoop.hbase. HBaseConfiguration import org.apache.hadoop.hbase.client.HTable import org.apache.hadoop.hbase.client.Scan import org.apache.hadoop.hbase.client.Get import org.apache.hadoop.hbase.client.Result import org.apache.hadoop.hbase.util.Bytes htable = HTable.new(HBaseConfiguration.new, "sample") rowkey = Bytes.toBytes("some_rowkey") get = Get.new(rowkey) result = htable.get(get) result.list.collect {|kv| puts "#{Bytes.toString(kv.getFamily)}:#{Bytes.toString(kv.getQualifier)}"} Allow calling Java from within JRuby "import" Java classes
  • 12. HBase shell JRuby Example - 1 include Java import org.apache.hadoop.hbase. HBaseConfiguration import org.apache.hadoop.hbase.client.HTable import org.apache.hadoop.hbase.client.Scan import org.apache.hadoop.hbase.client.Get import org.apache.hadoop.hbase.client.Result import org.apache.hadoop.hbase.util.Bytes htable = HTable.new(HBaseConfiguration.new, "sample") rowkey = Bytes.toBytes("some_rowkey") get = Get.new(rowkey) result = htable.get(get) result.list.collect {|kv| puts "#{Bytes.toString(kv.getFamily)}:#{Bytes.toString(kv.getQualifier)}"} Allow calling Java from within JRuby "import" Java classes Can invoke HBase Java API Jruby variables for Java class instance and static and instance method output HTable.new = new Htable() in Java
  • 13. HBase shell JRuby Example - 1 include Java import org.apache.hadoop.hbase.HBaseConfiguration import org.apache.hadoop.hbase.client.HTable import org.apache.hadoop.hbase.client.Scan import org.apache.hadoop.hbase.client.Get import org.apache.hadoop.hbase.client.Result import org.apache.hadoop.hbase.util.Bytes htable = HTable.new(HBaseConfiguration.new, "sample") rowkey = Bytes.toBytes("some_rowkey") get = Get.new(rowkey) result = htable.get(get) result.list.collect {|kv| puts "#{Bytes.toString(kv.getFamily)}:#{Bytes.toString(kv.getQualifier)}"} Allow calling Java from within JRuby "import" Java classes Creating Jruby variables for Java class instance and static and instance method output HTable.new = new Htable() in Java Ruby expression: "collect" is a Ruby method for list objects. Here it is made available to a Java list thus making available features of both languages transparently and seamlessly.
  • 14. HBase shell JRuby Example - 2 # Same include and import statements as Example - 1 htable = HTable.new(HBaseConfiguration.new, ".META.") scanner = htable.getScanner(Scan.new()) tables = {} scanner.each do |r| table_name = Bytes.toString(r.getRow).split(",")[0] if not tables.has_key?(table_name) tables[table_name] = 0 end tables[table_name] = tables[table_name] + 1 end tables.keys.each { |t| puts "Table #{t} has #{tables[t]} regions"} This example scans the ".META.“ to get a count of regions by tables and regionserver
  • 15. HBase shell JRuby Example - 2 # Same include and import statements as Example - 1 htable = HTable.new(HBaseConfiguration.new, ".META.") scanner = htable.getScanner(Scan.new()) tables = {} scanner.each do |r| table_name = Bytes.toString(r.getRow).split(",")[0] if not tables.has_key?(table_name) tables[table_name] = 0 end tables[table_name] = tables[table_name] + 1 end tables.keys.each { |t| puts "Table #{t} has #{tables[t]} regions"} This example scans the ".META.“ to get a count of regions by tables and regionserver Empty Ruby hash or dictionary
  • 16. HBase shell JRuby Example - 2 # Same include and import statements as Example - 1 htable = HTable.new(HBaseConfiguration.new, ".META.") scanner = htable.getScanner(Scan.new()) tables = {} scanner.each do |r| table_name = Bytes.toString(r.getRow).split(",")[0] if not tables.has_key?(table_name) tables[table_name] = 0 end tables[table_name] = tables[table_name] + 1 end tables.keys.each { |t| puts "Table #{t} has #{tables[t]} regions"} This example scans the ".META.“ to get a count of regions by tables and regionserver Empty Ruby hash or dictionary Example of how to iterate through a Java "iterable". Each iteration of scanner gives a "Result" object which is then passed to a code block
  • 17. HBase shell JRuby Example - 2 # Same include and import statements as Example - 1 htable = HTable.new(HBaseConfiguration.new, ".META.") scanner = htable.getScanner(Scan.new()) tables = {} scanner.each do |r| table_name = Bytes.toString(r.getRow).split(",")[0] if not tables.has_key?(table_name) tables[table_name] = 0 end tables[table_name] = tables[table_name] + 1 end tables.keys.each { |t| puts "Table #{t} has #{tables[t]} regions"} This example scans the ".META.“ to get a count of regions by tables and regionserver Example of how to iterate through a Java "iterable". Each iteration of scanner gives a "Result" object which is then passed to a code block The "code block" can be enclosed by curly braces ({}) or "do" and "end" keywords. Convention is to use {} for single line code blocks and do/end for multi-line code blocks. Empty Ruby hash or dictionary
  • 18. HBase shell JRuby Example - 2 # Same include and import statements as Example - 1 htable = HTable.new(HBaseConfiguration.new, ".META.") scanner = htable.getScanner(Scan.new()) tables = {} scanner.each do |r| table_name = Bytes.toString(r.getRow).split(",")[0] if not tables.has_key?(table_name) tables[table_name] = 0 end tables[table_name] = tables[table_name] + 1 end tables.keys.each { |t| puts "Table #{t} has #{tables[t]} regions"} This example scans the ".META.“ to get a count of regions by tables and regionserver Example of how to iterate through a Java "iterable". Each iteration of scanner gives a "Result" object which is then passed to a code block The "code block" can be enclosed by curly braces ({}) or "do" and "end" keywords. Convention is to use {} for single line code blocks and do/end for multi-line code blocks. Empty Ruby hash or dictionary Print region count by table using an iterator that is passed a code block. Compare the code block enclosed in {} v/s “do/end” above
  • 19. HBase shell JRuby Example - 3 • See https://github.com/JThakrar/hse • hbase_shell_extension.rb
  • 20. To Conclude……. • HBase shell  is an interactive scripting environment  allows mixing of Java and Jruby  Is not “recommended” for serious, enterprise/group development that requires automated testing, continuous integration, etc. • Can use JRuby IDE, provided you add HBase jars using "require" e.g. require '<path>/hbase.jar' • Can also use your custom Java jars in IDE and/or HBase shell • Can even “compile” your code to generate “jars” from your JRuby scripts for optimal performance and/or to avoid exposing source code