From 975af636e8a6e1730c3be31d3e4de507f9181fcc Mon Sep 17 00:00:00 2001 From: Michael Stack Date: Wed, 9 Jul 2008 21:39:45 +0000 Subject: [PATCH] HBASE-731 delete, deletefc in HBase shell do not work correctly git-svn-id: https://svn.apache.org/repos/asf/hadoop/hbase/trunk@675348 13f79535-47bb-0310-9956-ffa450edef68 --- CHANGES.txt | 6 +++++- bin/HBase.rb | 35 +++++++++++++++++++++-------------- bin/hirb.rb | 31 +++++++++++++------------------ 3 files changed, 39 insertions(+), 33 deletions(-) diff --git a/CHANGES.txt b/CHANGES.txt index a762cd981a3..57b81dcbc62 100644 --- a/CHANGES.txt +++ b/CHANGES.txt @@ -171,7 +171,11 @@ Trunk (unreleased changes) HBASE-726 Unit tests won't run because of a typo (Sebastien Rainville via Stack) HBASE-727 Client caught in an infinite loop when trying to connect to cached server locations (Izaak Rubin via Stack) - + HBASE-732 shell formatting error with the describe command + (Izaak Rubin via Stack) + HBASE-731 delete, deletefc in HBase shell do not work correctly + (Izaak Rubin via Stack) + IMPROVEMENTS HBASE-559 MR example job to count table rows HBASE-596 DemoClient.py (Ivan Begtin via Stack) diff --git a/bin/HBase.rb b/bin/HBase.rb index eb4694c52f2..4309be9d5ed 100644 --- a/bin/HBase.rb +++ b/bin/HBase.rb @@ -174,14 +174,9 @@ module HBase end # Delete a cell - def delete(row, args) + def delete(row, column, timestamp = HConstants::LATEST_TIMESTAMP) now = Time.now - bu = nil - if timestamp - bu = BatchUpdate.new(row, timestamp) - else - bu = BatchUpdate.new(row) - end + bu = BatchUpdate.new(row, timestamp) bu.delete(column) @table.commit(bu) @formatter.header() @@ -195,13 +190,6 @@ module HBase @formatter.footer(now) end - def deletefc(row, column_family, timestamp = HConstants::LATEST_TIMESTAMP) - now = Time.now - @table.deleteFamily(row, column_family) - @formatter.header() - @formatter.footer(now) - end - def getAllColumns htd = @table.getMetadata() result = [] @@ -403,6 +391,25 @@ module HBase if formatter.rowCount() != 3 raise IOError.new("Failed endrow test") end + # Verify that delete works + table.delete('x1', 'x:1'); + table.scan(['x:1']) + scan1 = formatter.rowCount() + table.scan(['x:']) + scan2 = formatter.rowCount() + if scan1 != 0 or scan2 != 9 + raise IOError.new("Failed delete test") + end + # Verify that deletall works + table.put('x2', 'x:1', 'x:1') + table.deleteall('x2') + table.scan(['x:2']) + scan1 = formatter.rowCount() + table.scan(['x:']) + scan2 = formatter.rowCount() + if scan1 != 0 or scan2 != 8 + raise IOError.new("Failed deleteall test") + end admin.disable(TESTTABLE) admin.drop(TESTTABLE) end diff --git a/bin/hirb.rb b/bin/hirb.rb index 954ad7fe26b..014a962fdd0 100644 --- a/bin/hirb.rb +++ b/bin/hirb.rb @@ -135,16 +135,14 @@ HBASE SHELL COMMANDS: delete Put a delete cell value at specified table/row/column and optionally timestamp coordinates. Deletes must match the deleted cell's coordinates exactly. When scanning, a delete cell suppresses older - versions. Takes arguments like 'put' described below + versions. Takes arguments like the 'put' command described below - deleteall Delete all cells; pass a table name, row and optionally, a column - and timestamp - - deletefc Delete all in the named column family. Pass table name and family - - drop Drop the named table. Table must first be disabled + deleteall Delete all cells in a given row; pass a table name, row, and optionally + a column and timestamp disable Disable the named table: e.g. "hbase> disable 't1'" + + drop Drop the named table. Table must first be disabled enable Enable the named table @@ -169,14 +167,15 @@ HBASE SHELL COMMANDS: hbase> put 't1', 'r1', 'c1', ts1 scan Scan a table; pass table name and optionally an array of column - names and a dictionary of scanner specification that includes one - or more of following: LIMIT, FILTER, STARTROW, STOPROW, or TIMESTAMP. - Examples: + names and a dictionary of scanner specification that may include + one or more of following: LIMIT, STARTROW, STOPROW, or TIMESTAMP. + To scan all members of a column family, leave the qualifier empty + as in 'col_family:'. Examples: hbase> scan '.META.' hbase> scan '.META.', ['info:regioninfo'] hbase> scan 't1', ['c1', 'c2'], {LIMIT => 10, STARTROW => 'xyz'} - + version Output this HBase version GENERAL NOTES: @@ -265,8 +264,9 @@ def scan(table, columns = [], args = {}) table(table).scan(columns, args) end -def delete(table, row, *args) - table(table).get(row, args) +def delete(table, row, column, + timestamp = org.apache.hadoop.hbase.HConstants::LATEST_TIMESTAMP) + table(table).delete(row, column, timestamp) end def deleteall(table, row, column = nil, @@ -274,11 +274,6 @@ def deleteall(table, row, column = nil, table(table).deleteall(row, column, timestamp) end -def deletefc(table, row, column_family, - timestamp = org.apache.hadoop.hbase.HConstants::LATEST_TIMESTAMP) - table(table).get(row, column_family, timestamp) -end - # Output a banner message that tells users where to go for help puts <' for list of supported commands.