paolo@bimodesign.com | +34 608 61 64 10

NoSQL

        

HBase - Shell

In this post I'll show some tips and tricks using the Hbase shell. The post will be updated when I'll find new interesting commands.

Snapshot
- list_snapshots

HbaseShell > list_snapshots

- Create

HbaseShell > snapshot ‘table’, ‘nombreSnapshot’
HbaseShell > clone snapshot (para averiguar que haya ido todo bien)
HbaseShell > disable table
HbaseShell > drop table

Note: to delete the table
- Delete, delete data.
- Disable y Drop (in this sequence), delete the data and drop the table
- Truncate, delete the data, drop the table and create a new table with the same structure

- Recover a Snapshot

HbaseShell > disable ‘table’
HbaseShell > restore_snapshot 'NombreSnapshot'
HbaseShell > enable ‘table’

Nota: The restore operation requires the table to be disabled, and the table will be restored to the state at the time when the snapshot was taken, changing both data and schema if required.

- Clone into another tabla

HbaseShell > clone_snapshot 'NombreSnapshot', 'NewTestTable'

Nota: The clone operation, doesn't involve data copies, and a change to the cloned table doesn't impact the snapshot or the original table.

Filter (examples)
Starting from this usefull link http://www.hadooptpoint.com/filters-in-hbase-shell/ and considering that we can list the list of the shell filters typing this

HbaseShell > show_filters
-------------
DependentColumnFilter
KeyOnlyFilter
ColumnCountGetFilter
SingleColumnValueFilter
PrefixFilter
SingleColumnValueExcludeFilter
FirstKeyOnlyFilter
ColumnRangeFilter
TimestampsFilter
FamilyFilter
QualifierFilter
ColumnPrefixFilter
RowFilter
MultipleColumnPrefixFilter
InclusiveStopFilter
PageFilter
ValueFilter
ColumnPaginationFilter

those are some examples:

HbaseShell > scan ‘files’, {columns => ‘D:VC’, filter => “valueFilter (!=, ‘binary:\x00’)”}
Where:
D -> Column
VC -> Field
binary:\x00’ -> Value of where condition

scan 'TREE_V2', {STARTROW=>'123456', COLUMN=>'PRUEBA',STOPROW=>'123456'}

Note that I find if exist some data into family/column "PRUEBA" only for a single key. The start y stop rowKeys are the same.