Unleash the Power of HBase Shell



Similar documents
Data storing and data access

Comparing SQL and NOSQL databases

Advanced Java Client API

HareDB HBase Client Web Version USER MANUAL HAREDB TEAM

Introduction to Hbase Gkavresis Giorgos 1470

Media Upload and Sharing Website using HBASE

Xiaoming Gao Hui Li Thilina Gunarathne

HBase A Comprehensive Introduction. James Chin, Zikai Wang Monday, March 14, 2011 CS 227 (Topics in Database Management) CIT 367

How To Scale Out Of A Nosql Database

Programming Languages CIS 443

Moving from CS 61A Scheme to CS 61B Java

COSC 6397 Big Data Analytics. 2 nd homework assignment Pig and Hive. Edgar Gabriel Spring 2015

Programming Hadoop 5-day, instructor-led BD-106. MapReduce Overview. Hadoop Overview

Big Data and Scripting Systems build on top of Hadoop

Big Data and Scripting Systems build on top of Hadoop

Creating a Java application using Perfect Developer and the Java Develo...

Scaling Up 2 CSE 6242 / CX Duen Horng (Polo) Chau Georgia Tech. HBase, Hive

Getting Started with the Internet Communications Engine

Hadoop Scripting with Jaql & Pig

Spring,2015. Apache Hive BY NATIA MAMAIASHVILI, LASHA AMASHUKELI & ALEKO CHAKHVASHVILI SUPERVAIZOR: PROF. NODAR MOMTSELIDZE

A Scalable Data Transformation Framework using the Hadoop Ecosystem

Introduction to Java Applications Pearson Education, Inc. All rights reserved.

Systems Infrastructure for Data Science. Web Science Group Uni Freiburg WS 2012/13

Serious Threat. Targets for Attack. Characterization of Attack. SQL Injection 4/9/2010 COMP On August 17, 2009, the United States Justice

Open source large scale distributed data management with Google s MapReduce and Bigtable

HBase Schema Design. NoSQL Ma4ers, Cologne, April Lars George Director EMEA Services

HBase. Lecture BigData Analytics. Julian M. Kunkel. University of Hamburg / German Climate Computing Center (DKRZ)

MULTIPLE CHOICE. Choose the one alternative that best completes the statement or answers the question.

Openbus Documentation

Migrating Non-Oracle Databases and their Applications to Oracle Database 12c O R A C L E W H I T E P A P E R D E C E M B E R

ENHANCEMENTS TO SQL SERVER COLUMN STORES. Anuhya Mallempati #

Scaling Up HBase, Hive, Pegasus

Informatica e Sistemi in Tempo Reale

Cloudera Certified Developer for Apache Hadoop

Web Development in Java

HBase Key Design coreservlets.com and Dima May coreservlets.com and Dima May

Example of a Java program

Topics. Parts of a Java Program. Topics (2) CS 146. Introduction To Computers And Java Chapter Objectives To understand:

Storage of Structured Data: BigTable and HBase. New Trends In Distributed Systems MSc Software and Systems

The Hadoop Eco System Shanghai Data Science Meetup

Installing Ruby on Windows XP

Вовченко Алексей, к.т.н., с.н.с. ВМК МГУ ИПИ РАН

Real-Time Handling of Network Monitoring Data Using a Data-Intensive Framework

Computational Mathematics with Python

Apache HBase: the Hadoop Database

Java CPD (I) Frans Coenen Department of Computer Science

Install Java Development Kit (JDK) 1.8

CSE 308. Coding Conventions. Reference

Java Application Developer Certificate Program Competencies

CS 106 Introduction to Computer Science I

Pro Apache Hadoop. Second Edition. Sameer Wadkar. Madhu Siddalingaiah

Lecture 5: Java Fundamentals III

WA2099 Introduction to Java using RAD 8.0 EVALUATION ONLY. Student Labs. Web Age Solutions Inc.

Lecture 10: HBase! Claudia Hauff (Web Information Systems)!

PAINLESS MULTI-DBMS STRATEGY For Magic Developers

Maintaining Stored Procedures in Database Application

Big data is like teenage sex: everyone talks about it, nobody really knows how to do it, everyone thinks everyone else is doing it, so everyone

To Java SE 8, and Beyond (Plan B)

Test Automation Integration with Test Management QAComplete

Computational Mathematics with Python

Basic Java Constructs and Data Types Nuts and Bolts. Looking into Specific Differences and Enhancements in Java compared to C

Knocker main application User manual

Introduction to HP ArcSight ESM Web Services APIs

Automating Security Testing. Mark Fallon Senior Release Manager Oracle

Massachusetts Institute of Technology Department of Electrical Engineering and Computer Science

SQL Injection. SQL Injection. CSCI 4971 Secure Software Principles. Rensselaer Polytechnic Institute. Spring

Scoping (Readings 7.1,7.4,7.6) Parameter passing methods (7.5) Building symbol tables (7.6)

qwertyuiopasdfghjklzxcvbnmqwerty uiopasdfghjklzxcvbnmqwertyuiopasd fghjklzxcvbnmqwertyuiopasdfghjklzx cvbnmqwertyuiopasdfghjklzxcvbnmq

HBase Java Administrative API

Handout 1. Introduction to Java programming language. Java primitive types and operations. Reading keyboard Input using class Scanner.

Google Cloud Data Platform & Services. Gregor Hohpe

CHAPTER 5 INTELLIGENT TECHNIQUES TO PREVENT SQL INJECTION ATTACKS

Big Data. Donald Kossmann & Nesime Tatbul Systems Group ETH Zurich

Architectural patterns for building real time applications with Apache HBase. Andrew Purtell Committer and PMC, Apache HBase

Postgres Plus xdb Replication Server with Multi-Master User s Guide

THE ATLAS DISTRIBUTED DATA MANAGEMENT SYSTEM & DATABASES

1) Which of the following is a constant, according to Java naming conventions? a. PI b. Test c. x d. radius

Log management with Logstash and Elasticsearch. Matteo Dessalvi

Analysis of SQL injection prevention using a proxy server

Introduction to CloudScript

Modern PL/SQL Code Checking and Dependency Analysis

How To Let A Lecturer Know If Someone Is At A Lecture Or If They Are At A Guesthouse

Security Test s i t ng Eileen Donlon CMSC 737 Spring 2008

BIG DATA HANDS-ON WORKSHOP Data Manipulation with Hive and Pig

Python and MongoDB. Why?

White Paper. Optimizing the Performance Of MySQL Cluster

CSCI110 Exercise 4: Database - MySQL

Big Data Frameworks: Scala and Spark Tutorial

Dr. Michael Cohen David Collett Gavin Jackson. Dunedin New Zealand

Penetration Testing with Kali Linux

Computational Mathematics with Python

Introduction to Object-Oriented Programming

D61830GC30. MySQL for Developers. Summary. Introduction. Prerequisites. At Course completion After completing this course, students will be able to:

Introduction to Java

Benchmarking and monitoring tools

Transcription:

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 No query tools like psql, mysql, etc No interactive development tools Can t browse Java primitive data in cells, e.g. Data 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 $ 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.. Shell Commands = HBase DSL (Domain Specific Language) $ 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 Allow calling Java from within JRuby 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 Allow calling Java from within JRuby 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) "import" Java classes result.list.collect { kv puts "#{Bytes.toString(kv.getFamily)}:#{Bytes.toString(kv.getQualifier)}"}

HBase shell JRuby Example - 1 include Java Allow calling Java from within JRuby 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) "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 result.list.collect { kv puts "#{Bytes.toString(kv.getFamily)}:#{Bytes.toString(kv.getQualifier)}"}

HBase shell JRuby Example - 1 include Java Allow calling Java from within JRuby 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) "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. result.list.collect { kv puts "#{Bytes.toString(kv.getFamily)}:#{Bytes.toString(kv.getQualifier)}"}

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 Empty Ruby hash or dictionary 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 end table_name = Bytes.toString(r.getRow).split(",")[0] if not tables.has_key?(table_name) end tables[table_name] = 0 Empty Ruby hash or dictionary tables[table_name] = tables[table_name] + 1 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

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 end table_name = Bytes.toString(r.getRow).split(",")[0] if not tables.has_key?(table_name) end tables[table_name] = 0 Empty Ruby hash or dictionary tables[table_name] = tables[table_name] + 1 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.

HBase shell JRuby Example - 2 # Same include and import statements as Example - 1 htable = HTable.new(HBaseConfiguration.new, ".META.") scanner = htable.getscanner(scan.new()) This example scans the ".META. to get a count of regions by tables and regionserver tables = {} scanner.each do r 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 table_name = Bytes.toString(r.getRow).split(",")[0] if not tables.has_key?(table_name) end tables[table_name] = 0 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. tables[table_name] = tables[table_name] + 1 end tables.keys.each { t puts "Table #{t} has #{tables[t]} regions"} 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