Index: bin/HBase.rb =================================================================== --- bin/HBase.rb (revision 675277) +++ bin/HBase.rb (working copy) @@ -174,14 +174,9 @@ 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 @@ @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 @@ 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 Index: bin/hirb.rb =================================================================== --- bin/hirb.rb (revision 675277) +++ bin/hirb.rb (working copy) @@ -135,17 +135,15 @@ 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 + deleteall Delete all cells in a given row; pass a table name, row, and optionally + a column and timestamp - deletefc Delete all in the named column family. Pass table name and family - + disable Disable the named table: e.g. "hbase> disable 't1'" + drop Drop the named table. Table must first be disabled - disable Disable the named table: e.g. "hbase> disable 't1'" - enable Enable the named table exists Does the named table exist? e.g. "hbase> exists 't1'" @@ -169,14 +167,14 @@ 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. + names and a dictionary of scanner specification that may include + one or more of following: LIMIT, STARTROW, STOPROW, or TIMESTAMP. 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: @@ -192,6 +190,10 @@ NAME, VERSIONS, COMPRESSION, etc. Constants do not need to be quoted. Type 'Object.constants' to see a (messy) list of all constants in the environment. +All column names must contain the delimiting ':' between +column family and qualifier. To match an entire column family, +leave the qualifier empty (ex: 'col_family:'). + This HBase shell is the JRuby IRB with the above HBase-specific commands added. For more on the HBase Shell, see http://wiki.apache.org/hadoop/Hbase/Shell HERE @@ -265,8 +267,9 @@ 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 +277,6 @@ 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.