1#
2#
3# Licensed to the Apache Software Foundation (ASF) under one
4# or more contributor license agreements.  See the NOTICE file
5# distributed with this work for additional information
6# regarding copyright ownership.  The ASF licenses this file
7# to you under the Apache License, Version 2.0 (the
8# "License"); you may not use this file except in compliance
9# with the License.  You may obtain a copy of the License at
10#
11#     http://www.apache.org/licenses/LICENSE-2.0
12#
13# Unless required by applicable law or agreed to in writing, software
14# distributed under the License is distributed on an "AS IS" BASIS,
15# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16# See the License for the specific language governing permissions and
17# limitations under the License.
18#
19
20module Shell
21  module Commands
22    class Deleteall < Command
23      def help
24        return <<-EOF
25Delete all cells in a given row; pass a table name, row, and optionally
26a column and timestamp. Examples:
27
28  hbase> deleteall 'ns1:t1', 'r1'
29  hbase> deleteall 't1', 'r1'
30  hbase> deleteall 't1', 'r1', 'c1'
31  hbase> deleteall 't1', 'r1', 'c1', ts1
32  hbase> deleteall 't1', 'r1', 'c1', ts1, {VISIBILITY=>'PRIVATE|SECRET'}
33
34The same commands also can be run on a table reference. Suppose you had a reference
35t to table 't1', the corresponding command would be:
36
37  hbase> t.deleteall 'r1'
38  hbase> t.deleteall 'r1', 'c1'
39  hbase> t.deleteall 'r1', 'c1', ts1
40  hbase> t.deleteall 'r1', 'c1', ts1, {VISIBILITY=>'PRIVATE|SECRET'}
41EOF
42      end
43
44      def command(table, row, column = nil,
45                  timestamp = org.apache.hadoop.hbase.HConstants::LATEST_TIMESTAMP, args = {})
46        deleteall(table(table), row, column, timestamp, args)
47      end
48
49      def deleteall(table, row, column = nil,
50                    timestamp = org.apache.hadoop.hbase.HConstants::LATEST_TIMESTAMP, args = {})
51        format_simple_command do
52          table._deleteall_internal(row, column, timestamp, args)
53        end
54      end
55    end
56  end
57end
58
59#Add the method table.deleteall that calls deleteall.deleteall
60::Hbase::Table.add_shell_command("deleteall")
61