From 3b803714c5a8de41efd5b15571773e4f3027807d Mon Sep 17 00:00:00 2001 From: Michael Stack Date: Wed, 29 Oct 2008 18:01:35 +0000 Subject: [PATCH] HBASE-817 Hbase/Shell Truncate git-svn-id: https://svn.apache.org/repos/asf/hadoop/hbase/trunk@708966 13f79535-47bb-0310-9956-ffa450edef68 --- CHANGES.txt | 1 + bin/HBase.rb | 15 +++++++++++++++ bin/hirb.rb | 6 ++++++ 3 files changed, 22 insertions(+) diff --git a/CHANGES.txt b/CHANGES.txt index 5e0c5beda2c..922e83b14b8 100644 --- a/CHANGES.txt +++ b/CHANGES.txt @@ -81,6 +81,7 @@ Release 0.19.0 - Unreleased (Sishen Freecity via Stack) HBASE-960 REST interface: more generic column family configure and also get Rows using offset and limit (Sishen Freecity via Stack) + HBASE-817 Hbase/Shell Truncate NEW FEATURES HBASE-875 Use MurmurHash instead of JenkinsHash [in bloomfilters] diff --git a/bin/HBase.rb b/bin/HBase.rb index 6097c352905..f19ff43b731 100644 --- a/bin/HBase.rb +++ b/bin/HBase.rb @@ -104,6 +104,21 @@ module HBase @formatter.footer(now) end + def truncate(tableName) + now = Time.now + @formatter.header() + hTable = HTable.new(tableName) + tableDescription = hTable.getTableDescriptor() + puts 'Truncating ' + tableName + '; it may take a while' + puts 'Disabling table...' + disable(tableName) + puts 'Dropping table...' + drop(tableName) + puts 'Creating table...' + @admin.createTable(tableDescription) + @formatter.footer(now) + end + # Pass tablename and an array of Hashes def create(tableName, args) now = Time.now diff --git a/bin/hirb.rb b/bin/hirb.rb index fa0100734f9..2c8a7721adc 100644 --- a/bin/hirb.rb +++ b/bin/hirb.rb @@ -190,6 +190,8 @@ HBASE SHELL COMMANDS: hbase> scan '.META.', {COLUMNS => 'info:regioninfo'} hbase> scan 't1', {COLUMNS => ['c1', 'c2'], LIMIT => 10, \\ STARTROW => 'xyz'} + + truncate Disables, drops and recreates the specified table. version Output this HBase version @@ -264,6 +266,10 @@ end def exists(table) admin().exists(table) end + +def truncate(table) + admin().truncate(table) +end # CRUD