SlideShare une entreprise Scribd logo
1  sur  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

Contenu connexe

Tendances

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
 

Tendances (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
 

Similaire à 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
 

Similaire à 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
 

Plus de 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
 

Plus de 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...
 

Dernier

1:1定制(UQ毕业证)昆士兰大学毕业证成绩单修改留信学历认证原版一模一样
1:1定制(UQ毕业证)昆士兰大学毕业证成绩单修改留信学历认证原版一模一样1:1定制(UQ毕业证)昆士兰大学毕业证成绩单修改留信学历认证原版一模一样
1:1定制(UQ毕业证)昆士兰大学毕业证成绩单修改留信学历认证原版一模一样vhwb25kk
 
MK KOMUNIKASI DATA (TI)komdat komdat.docx
MK KOMUNIKASI DATA (TI)komdat komdat.docxMK KOMUNIKASI DATA (TI)komdat komdat.docx
MK KOMUNIKASI DATA (TI)komdat komdat.docxUnduhUnggah1
 
Indian Call Girls in Abu Dhabi O5286O24O8 Call Girls in Abu Dhabi By Independ...
Indian Call Girls in Abu Dhabi O5286O24O8 Call Girls in Abu Dhabi By Independ...Indian Call Girls in Abu Dhabi O5286O24O8 Call Girls in Abu Dhabi By Independ...
Indian Call Girls in Abu Dhabi O5286O24O8 Call Girls in Abu Dhabi By Independ...dajasot375
 
原版1:1定制南十字星大学毕业证(SCU毕业证)#文凭成绩单#真实留信学历认证永久存档
原版1:1定制南十字星大学毕业证(SCU毕业证)#文凭成绩单#真实留信学历认证永久存档原版1:1定制南十字星大学毕业证(SCU毕业证)#文凭成绩单#真实留信学历认证永久存档
原版1:1定制南十字星大学毕业证(SCU毕业证)#文凭成绩单#真实留信学历认证永久存档208367051
 
Advanced Machine Learning for Business Professionals
Advanced Machine Learning for Business ProfessionalsAdvanced Machine Learning for Business Professionals
Advanced Machine Learning for Business ProfessionalsVICTOR MAESTRE RAMIREZ
 
RABBIT: A CLI tool for identifying bots based on their GitHub events.
RABBIT: A CLI tool for identifying bots based on their GitHub events.RABBIT: A CLI tool for identifying bots based on their GitHub events.
RABBIT: A CLI tool for identifying bots based on their GitHub events.natarajan8993
 
EMERCE - 2024 - AMSTERDAM - CROSS-PLATFORM TRACKING WITH GOOGLE ANALYTICS.pptx
EMERCE - 2024 - AMSTERDAM - CROSS-PLATFORM  TRACKING WITH GOOGLE ANALYTICS.pptxEMERCE - 2024 - AMSTERDAM - CROSS-PLATFORM  TRACKING WITH GOOGLE ANALYTICS.pptx
EMERCE - 2024 - AMSTERDAM - CROSS-PLATFORM TRACKING WITH GOOGLE ANALYTICS.pptxthyngster
 
Generative AI for Social Good at Open Data Science East 2024
Generative AI for Social Good at Open Data Science East 2024Generative AI for Social Good at Open Data Science East 2024
Generative AI for Social Good at Open Data Science East 2024Colleen Farrelly
 
DBA Basics: Getting Started with Performance Tuning.pdf
DBA Basics: Getting Started with Performance Tuning.pdfDBA Basics: Getting Started with Performance Tuning.pdf
DBA Basics: Getting Started with Performance Tuning.pdfJohn Sterrett
 
dokumen.tips_chapter-4-transient-heat-conduction-mehmet-kanoglu.ppt
dokumen.tips_chapter-4-transient-heat-conduction-mehmet-kanoglu.pptdokumen.tips_chapter-4-transient-heat-conduction-mehmet-kanoglu.ppt
dokumen.tips_chapter-4-transient-heat-conduction-mehmet-kanoglu.pptSonatrach
 
Call Girls In Dwarka 9654467111 Escorts Service
Call Girls In Dwarka 9654467111 Escorts ServiceCall Girls In Dwarka 9654467111 Escorts Service
Call Girls In Dwarka 9654467111 Escorts ServiceSapana Sha
 
Customer Service Analytics - Make Sense of All Your Data.pptx
Customer Service Analytics - Make Sense of All Your Data.pptxCustomer Service Analytics - Make Sense of All Your Data.pptx
Customer Service Analytics - Make Sense of All Your Data.pptxEmmanuel Dauda
 
专业一比一美国俄亥俄大学毕业证成绩单pdf电子版制作修改
专业一比一美国俄亥俄大学毕业证成绩单pdf电子版制作修改专业一比一美国俄亥俄大学毕业证成绩单pdf电子版制作修改
专业一比一美国俄亥俄大学毕业证成绩单pdf电子版制作修改yuu sss
 
Identifying Appropriate Test Statistics Involving Population Mean
Identifying Appropriate Test Statistics Involving Population MeanIdentifying Appropriate Test Statistics Involving Population Mean
Identifying Appropriate Test Statistics Involving Population MeanMYRABACSAFRA2
 
Defining Constituents, Data Vizzes and Telling a Data Story
Defining Constituents, Data Vizzes and Telling a Data StoryDefining Constituents, Data Vizzes and Telling a Data Story
Defining Constituents, Data Vizzes and Telling a Data StoryJeremy Anderson
 
9711147426✨Call In girls Gurgaon Sector 31. SCO 25 escort service
9711147426✨Call In girls Gurgaon Sector 31. SCO 25 escort service9711147426✨Call In girls Gurgaon Sector 31. SCO 25 escort service
9711147426✨Call In girls Gurgaon Sector 31. SCO 25 escort servicejennyeacort
 
GA4 Without Cookies [Measure Camp AMS]
GA4 Without Cookies [Measure Camp AMS]GA4 Without Cookies [Measure Camp AMS]
GA4 Without Cookies [Measure Camp AMS]📊 Markus Baersch
 
IMA MSN - Medical Students Network (2).pptx
IMA MSN - Medical Students Network (2).pptxIMA MSN - Medical Students Network (2).pptx
IMA MSN - Medical Students Network (2).pptxdolaknnilon
 

Dernier (20)

1:1定制(UQ毕业证)昆士兰大学毕业证成绩单修改留信学历认证原版一模一样
1:1定制(UQ毕业证)昆士兰大学毕业证成绩单修改留信学历认证原版一模一样1:1定制(UQ毕业证)昆士兰大学毕业证成绩单修改留信学历认证原版一模一样
1:1定制(UQ毕业证)昆士兰大学毕业证成绩单修改留信学历认证原版一模一样
 
Call Girls in Saket 99530🔝 56974 Escort Service
Call Girls in Saket 99530🔝 56974 Escort ServiceCall Girls in Saket 99530🔝 56974 Escort Service
Call Girls in Saket 99530🔝 56974 Escort Service
 
MK KOMUNIKASI DATA (TI)komdat komdat.docx
MK KOMUNIKASI DATA (TI)komdat komdat.docxMK KOMUNIKASI DATA (TI)komdat komdat.docx
MK KOMUNIKASI DATA (TI)komdat komdat.docx
 
Indian Call Girls in Abu Dhabi O5286O24O8 Call Girls in Abu Dhabi By Independ...
Indian Call Girls in Abu Dhabi O5286O24O8 Call Girls in Abu Dhabi By Independ...Indian Call Girls in Abu Dhabi O5286O24O8 Call Girls in Abu Dhabi By Independ...
Indian Call Girls in Abu Dhabi O5286O24O8 Call Girls in Abu Dhabi By Independ...
 
原版1:1定制南十字星大学毕业证(SCU毕业证)#文凭成绩单#真实留信学历认证永久存档
原版1:1定制南十字星大学毕业证(SCU毕业证)#文凭成绩单#真实留信学历认证永久存档原版1:1定制南十字星大学毕业证(SCU毕业证)#文凭成绩单#真实留信学历认证永久存档
原版1:1定制南十字星大学毕业证(SCU毕业证)#文凭成绩单#真实留信学历认证永久存档
 
Advanced Machine Learning for Business Professionals
Advanced Machine Learning for Business ProfessionalsAdvanced Machine Learning for Business Professionals
Advanced Machine Learning for Business Professionals
 
RABBIT: A CLI tool for identifying bots based on their GitHub events.
RABBIT: A CLI tool for identifying bots based on their GitHub events.RABBIT: A CLI tool for identifying bots based on their GitHub events.
RABBIT: A CLI tool for identifying bots based on their GitHub events.
 
EMERCE - 2024 - AMSTERDAM - CROSS-PLATFORM TRACKING WITH GOOGLE ANALYTICS.pptx
EMERCE - 2024 - AMSTERDAM - CROSS-PLATFORM  TRACKING WITH GOOGLE ANALYTICS.pptxEMERCE - 2024 - AMSTERDAM - CROSS-PLATFORM  TRACKING WITH GOOGLE ANALYTICS.pptx
EMERCE - 2024 - AMSTERDAM - CROSS-PLATFORM TRACKING WITH GOOGLE ANALYTICS.pptx
 
Generative AI for Social Good at Open Data Science East 2024
Generative AI for Social Good at Open Data Science East 2024Generative AI for Social Good at Open Data Science East 2024
Generative AI for Social Good at Open Data Science East 2024
 
DBA Basics: Getting Started with Performance Tuning.pdf
DBA Basics: Getting Started with Performance Tuning.pdfDBA Basics: Getting Started with Performance Tuning.pdf
DBA Basics: Getting Started with Performance Tuning.pdf
 
dokumen.tips_chapter-4-transient-heat-conduction-mehmet-kanoglu.ppt
dokumen.tips_chapter-4-transient-heat-conduction-mehmet-kanoglu.pptdokumen.tips_chapter-4-transient-heat-conduction-mehmet-kanoglu.ppt
dokumen.tips_chapter-4-transient-heat-conduction-mehmet-kanoglu.ppt
 
Call Girls In Dwarka 9654467111 Escorts Service
Call Girls In Dwarka 9654467111 Escorts ServiceCall Girls In Dwarka 9654467111 Escorts Service
Call Girls In Dwarka 9654467111 Escorts Service
 
Customer Service Analytics - Make Sense of All Your Data.pptx
Customer Service Analytics - Make Sense of All Your Data.pptxCustomer Service Analytics - Make Sense of All Your Data.pptx
Customer Service Analytics - Make Sense of All Your Data.pptx
 
E-Commerce Order PredictionShraddha Kamble.pptx
E-Commerce Order PredictionShraddha Kamble.pptxE-Commerce Order PredictionShraddha Kamble.pptx
E-Commerce Order PredictionShraddha Kamble.pptx
 
专业一比一美国俄亥俄大学毕业证成绩单pdf电子版制作修改
专业一比一美国俄亥俄大学毕业证成绩单pdf电子版制作修改专业一比一美国俄亥俄大学毕业证成绩单pdf电子版制作修改
专业一比一美国俄亥俄大学毕业证成绩单pdf电子版制作修改
 
Identifying Appropriate Test Statistics Involving Population Mean
Identifying Appropriate Test Statistics Involving Population MeanIdentifying Appropriate Test Statistics Involving Population Mean
Identifying Appropriate Test Statistics Involving Population Mean
 
Defining Constituents, Data Vizzes and Telling a Data Story
Defining Constituents, Data Vizzes and Telling a Data StoryDefining Constituents, Data Vizzes and Telling a Data Story
Defining Constituents, Data Vizzes and Telling a Data Story
 
9711147426✨Call In girls Gurgaon Sector 31. SCO 25 escort service
9711147426✨Call In girls Gurgaon Sector 31. SCO 25 escort service9711147426✨Call In girls Gurgaon Sector 31. SCO 25 escort service
9711147426✨Call In girls Gurgaon Sector 31. SCO 25 escort service
 
GA4 Without Cookies [Measure Camp AMS]
GA4 Without Cookies [Measure Camp AMS]GA4 Without Cookies [Measure Camp AMS]
GA4 Without Cookies [Measure Camp AMS]
 
IMA MSN - Medical Students Network (2).pptx
IMA MSN - Medical Students Network (2).pptxIMA MSN - Medical Students Network (2).pptx
IMA MSN - Medical Students Network (2).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