diff --git hbase-shell/src/main/ruby/hbase/table.rb hbase-shell/src/main/ruby/hbase/table.rb index 1932043..89b3a39 100644 --- hbase-shell/src/main/ruby/hbase/table.rb +++ hbase-shell/src/main/ruby/hbase/table.rb @@ -163,7 +163,86 @@ EOF def _delete_internal(row, column, timestamp = org.apache.hadoop.hbase.HConstants::LATEST_TIMESTAMP) _deleteall_internal(row, column, timestamp) end - + #------------------------------------------------------------------------------------------------ + # Delete a cell with latest timestamp + def _delete_column_internal(row, column, visibility = nil) + raise ArgumentError, "Row Not Found" if _get_internal(row).nil? + timestamp = org.apache.hadoop.hbase.HConstants::LATEST_TIMESTAMP + d = org.apache.hadoop.hbase.client.Delete.new(row.to_s.to_java_bytes, timestamp) + set_cell_visibility(d, visibility) if visibility + family, qualifier = parse_column_name(column) + d.deleteColumn(family, qualifier) + @table.delete(d) + end + #------------------------------------------------------------------------------------------------ + # Delete a cell with specified timestamp + def _delete_column_timestamp_internal(row, column, timestamp, visibility = nil) + raise ArgumentError, "Row Not Found" if _get_internal(row).nil? + ts = org.apache.hadoop.hbase.HConstants::LATEST_TIMESTAMP + d = org.apache.hadoop.hbase.client.Delete.new(row.to_s.to_java_bytes, ts) + set_cell_visibility(d, visibility) if visibility + family, qualifier = parse_column_name(column) + d.deleteColumn(family, qualifier, timestamp) + @table.delete(d) + end + #------------------------------------------------------------------------------------------------ + # Deletes all versions of the specified column + def _delete_columns_internal(row, column, visibility = nil) + raise ArgumentError, "Row Not Found" if _get_internal(row).nil? + timestamp = org.apache.hadoop.hbase.HConstants::LATEST_TIMESTAMP + d = org.apache.hadoop.hbase.client.Delete.new(row.to_s.to_java_bytes, timestamp) + set_cell_visibility(d, visibility) if visibility + family, qualifier = parse_column_name(column) + d.deleteColumns(family, qualifier) + @table.delete(d) + end + #------------------------------------------------------------------------------------------------ + # Deletes all versions of the specified column with a timestamp less than or equal to the specified timestamp. + def _delete_columns_timestamp_internal(row, column, timestamp, visibility = nil) + raise ArgumentError, "Row Not Found" if _get_internal(row).nil? + raise ArgumentError, "Timestamp not found" if timestamp.nil? + ts = org.apache.hadoop.hbase.HConstants::LATEST_TIMESTAMP + d = org.apache.hadoop.hbase.client.Delete.new(row.to_s.to_java_bytes, ts) + set_cell_visibility(d, visibility) if visibility + family, qualifier = parse_column_name(column) + d.deleteColumns(family, qualifier, timestamp) + @table.delete(d) + end + #------------------------------------------------------------------------------------------------ + # Deletes all versions of the specified family + def _delete_family_internal(row, column, visibility = nil) + raise ArgumentError, "Row Not Found" if _get_internal(row).nil? + timestamp = org.apache.hadoop.hbase.HConstants::LATEST_TIMESTAMP + d = org.apache.hadoop.hbase.client.Delete.new(row.to_s.to_java_bytes, timestamp) + set_cell_visibility(d, visibility) if visibility + family, qualifier = parse_column_name(column) + d.deleteFamily(family) + @table.delete(d) + end + #------------------------------------------------------------------------------------------------ + # Deletes all versions of the specified family with less than or equal to the specified timestamp + def _delete_family_timestamp_internal(row, column, timestamp, visibility = nil) + raise ArgumentError, "Row Not Found" if _get_internal(row).nil? + raise ArgumentError, "Timestamp not found" if timestamp.nil? + ts = org.apache.hadoop.hbase.HConstants::LATEST_TIMESTAMP + d = org.apache.hadoop.hbase.client.Delete.new(row.to_s.to_java_bytes, ts) + set_cell_visibility(d, visibility) if visibility + family, qualifier = parse_column_name(column) + d.deleteFamily(family, timestamp) + @table.delete(d) + end + #------------------------------------------------------------------------------------------------ + # Deletes the specified versions of the specified family + def _delete_family_version_internal(row, column, timestamp, visibility = nil) + raise ArgumentError, "Row Not Found" if _get_internal(row).nil? + raise ArgumentError, "Timestamp not found" if timestamp.nil? + ts = org.apache.hadoop.hbase.HConstants::LATEST_TIMESTAMP + d = org.apache.hadoop.hbase.client.Delete.new(row.to_s.to_java_bytes, ts) + set_cell_visibility(d, visibility) if visibility + family, qualifier = parse_column_name(column) + d.deleteFamilyVersion(family, timestamp) + @table.delete(d) + end #---------------------------------------------------------------------------------------------- # Delete a row def _deleteall_internal(row, column = nil, timestamp = org.apache.hadoop.hbase.HConstants::LATEST_TIMESTAMP) @@ -175,7 +254,6 @@ EOF end @table.delete(d) end - #---------------------------------------------------------------------------------------------- # Increment a counter atomically def _incr_internal(row, column, value = nil, args={}) diff --git hbase-shell/src/main/ruby/shell.rb hbase-shell/src/main/ruby/shell.rb index 62e0396..ca34ac5 100644 --- hbase-shell/src/main/ruby/shell.rb +++ hbase-shell/src/main/ruby/shell.rb @@ -277,6 +277,13 @@ Shell.load_command_group( count delete deleteall + delete_column + delete_column_timeStamp + delete_columns + delete_columns_timeStamp + delete_family + delete_family_timeStamp + delete_familyversion get get_counter incr diff --git hbase-shell/src/main/ruby/shell/commands/delete_column.rb hbase-shell/src/main/ruby/shell/commands/delete_column.rb new file mode 100644 index 0000000..c54cd38 --- /dev/null +++ hbase-shell/src/main/ruby/shell/commands/delete_column.rb @@ -0,0 +1,57 @@ +# +# +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + +module Shell + module Commands + class DeleteColumn < Command + def help + return <<-EOF +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. To delete a cell from 't1' at row 'r1' under column 'c1' +marked with the time 'ts1', do: + + hbase> delete_column 'ns1:t1', 'r1', 'c1' + hbase> delete_column 't1', 'r1', 'c1', + hbase> delete_column 't1', 'r1', 'c1',"PRIVATE&SECRET" + +The same command can also be run on a table reference. Suppose you had a reference +t to table 't1', the corresponding command would be: + + hbase> t.delete_column 'r1', 'c1' + hbase> t.delete_column 'r1', 'c1', "PRIVATE&SECRET" +EOF + end + + def command(table, row, column, visibility = nil) + delete_column(table(table), row, column, visibility) + end + + def delete_column(table, row, column, visibility = nil) + format_simple_command do + table._delete_column_internal(row, column, visibility) + end + end + end + end +end + +#Add the method table.delete that calls delete.delete +::Hbase::Table.add_shell_command("delete") \ No newline at end of file diff --git hbase-shell/src/main/ruby/shell/commands/delete_column_timeStamp.rb hbase-shell/src/main/ruby/shell/commands/delete_column_timeStamp.rb new file mode 100644 index 0000000..698b6ed --- /dev/null +++ hbase-shell/src/main/ruby/shell/commands/delete_column_timeStamp.rb @@ -0,0 +1,57 @@ +# +# +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + +module Shell + module Commands + class DeleteColumnTimeStamp < Command + def help + return <<-EOF +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. To delete a cell from 't1' at row 'r1' under column 'c1' +marked with the time 'ts1', do: + + hbase> delete_column 'ns1:t1', 'r1', 'c1', ts + hbase> delete_column 't1', 'r1', 'c1', ts + hbase> delete_column 't1', 'r1', 'c1', ts,"PRIVATE&SECRET" + +The same command can also be run on a table reference. Suppose you had a reference +t to table 't1', the corresponding command would be: + + hbase> t.delete_column 'r1', 'c1',ts + hbase> t.delete_column 'r1', 'c1', ts, "PRIVATE&SECRET" +EOF + end + + def command(table, row, column, timestamp, visibility = nil) + delete_column_timestamp(table(table), row, column, timestamp, visibility) + end + + def delete_column_timestamp(table, row, column, timestamp, visibility = nil) + format_simple_command do + table._delete_column_timestamp_internal(row, column, timestamp, visibility) + end + end + end + end +end + +#Add the method table.delete that calls delete.delete +::Hbase::Table.add_shell_command("delete") \ No newline at end of file diff --git hbase-shell/src/main/ruby/shell/commands/delete_columns.rb hbase-shell/src/main/ruby/shell/commands/delete_columns.rb new file mode 100644 index 0000000..d750d1e --- /dev/null +++ hbase-shell/src/main/ruby/shell/commands/delete_columns.rb @@ -0,0 +1,57 @@ +# +# +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + +module Shell + module Commands + class DeleteColumns < Command + def help + return <<-EOF +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. To delete a cell from 't1' at row 'r1' under column 'c1' +marked with the time 'ts1', do: + + hbase> delete_columns 'ns1:t1', 'r1', 'c1' + hbase> delete_columns 't1', 'r1', 'c1' + hbase> delete_columns 't1', 'r1', 'c1',"PRIVATE&SECRET" + +The same command can also be run on a table reference. Suppose you had a reference +t to table 't1', the corresponding command would be: + + hbase> t.delete_columns 'r1', 'c1' + hbase> t.delete_columns 'r1', 'c1', "PRIVATE&SECRET" +EOF + end + + def command(table, row, column, visibility = nil) + delete_columns(table(table), row, column, visibility) + end + + def delete_columns(table, row, column, visibility = nil) + format_simple_command do + table._delete_columns_internal(row, column, visibility) + end + end + end + end +end + +#Add the method table.delete that calls delete.delete +::Hbase::Table.add_shell_command("delete") \ No newline at end of file diff --git hbase-shell/src/main/ruby/shell/commands/delete_columns_timeStamp.rb hbase-shell/src/main/ruby/shell/commands/delete_columns_timeStamp.rb new file mode 100644 index 0000000..f9a118d --- /dev/null +++ hbase-shell/src/main/ruby/shell/commands/delete_columns_timeStamp.rb @@ -0,0 +1,57 @@ +# +# +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + +module Shell + module Commands + class DeleteColumnsTimeStamp < Command + def help + return <<-EOF +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. To delete a cell from 't1' at row 'r1' under column 'c1' +marked with the time 'ts1', do: + + hbase> delete_columns_timestamp 'ns1:t1', 'r1', 'c1', ts + hbase> delete_columns_timestamp 't1', 'r1', 'c1', ts + hbase> delete_columns_timestamp 't1', 'r1', 'c1',ts, "PRIVATE&SECRET" + +The same command can also be run on a table reference. Suppose you had a reference +t to table 't1', the corresponding command would be: + + hbase> t.delete_columns_timestamp 'r1', 'c1', ts + hbase> t.delete_columns_timestamp 'r1', 'c1', ts, "PRIVATE&SECRET" +EOF + end + + def command(table, row, column, timestamp, visibility = nil) + delete_columns_timestamp(table(table), row, column, timestamp, visibility) + end + + def delete_columns_timestamp(table, row, column, timestamp, visibility = nil) + format_simple_command do + table._delete_columns_timestamp_internal(row, column, timestamp, visibility) + end + end + end + end +end + +#Add the method table.delete that calls delete.delete +::Hbase::Table.add_shell_command("delete") \ No newline at end of file diff --git hbase-shell/src/main/ruby/shell/commands/delete_family.rb hbase-shell/src/main/ruby/shell/commands/delete_family.rb new file mode 100644 index 0000000..832f54a --- /dev/null +++ hbase-shell/src/main/ruby/shell/commands/delete_family.rb @@ -0,0 +1,57 @@ +# +# +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + +module Shell + module Commands + class DeleteFamily < Command + def help + return <<-EOF +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. To delete a cell from 't1' at row 'r1' under column 'c1' +marked with the time 'ts1', do: + + hbase> delete_family 'ns1:t1', 'r1', 'c1' + hbase> delete_family 't1', 'r1', 'c1' + hbase> delete_family 't1', 'r1', 'c1', "PRIVATE&SECRET" + +The same command can also be run on a table reference. Suppose you had a reference +t to table 't1', the corresponding command would be: + + hbase> t.delete_family 'r1', 'c1' + hbase> t.delete_family 'r1', 'c1', "PRIVATE&SECRET" +EOF + end + + def command(table, row, column, visibility = nil) + delete_family(table(table), row, column, visibility) + end + + def delete_family(table, row, column, visibility = nil) + format_simple_command do + table._delete_family_internal(row, column, visibility) + end + end + end + end +end + +#Add the method table.delete that calls delete.delete +::Hbase::Table.add_shell_command("delete") \ No newline at end of file diff --git hbase-shell/src/main/ruby/shell/commands/delete_family_timeStamp.rb hbase-shell/src/main/ruby/shell/commands/delete_family_timeStamp.rb new file mode 100644 index 0000000..4a617a0 --- /dev/null +++ hbase-shell/src/main/ruby/shell/commands/delete_family_timeStamp.rb @@ -0,0 +1,56 @@ +# +# +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + +module Shell + module Commands + class DeleteFamilyTimeStamp < Command + def help + return <<-EOF +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. To delete a cell from 't1' at row 'r1' under column 'c1' +marked with the time 'ts1', do: + + hbase> delete_family_timestamp 'ns1:t1', 'r1', 'c1', ts + hbase> delete_family_timestamp 't1', 'r1', 'c1', ts + hbase> delete_family_timestamp 't1', 'r1', 'c1',ts, "PRIVATE&SECRET" + +The same command can also be run on a table reference. Suppose you had a reference +t to table 't1', the corresponding command would be: + + hbase> t.delete_family_timestamp 'r1', 'c1', ts + hbase> t.delete_family_timestamp 'r1', 'c1', ts, "PRIVATE&SECRET" +EOF + end + + def command(table, row, column, timestamp, visibility = nil) + delete_family_timestamp(table(table), row, column, timestamp, visibility) + end + + def delete_family_timestamp(table, row, column, timestamp, visibility = nil) + format_simple_command do + table._delete_family_timestamp_internal(row, column, timestamp, visibility) + end + end + end + end +end + +#Add the method table.delete that calls delete.delete diff --git hbase-shell/src/main/ruby/shell/commands/delete_familyversion.rb hbase-shell/src/main/ruby/shell/commands/delete_familyversion.rb new file mode 100644 index 0000000..0bcceb3 --- /dev/null +++ hbase-shell/src/main/ruby/shell/commands/delete_familyversion.rb @@ -0,0 +1,56 @@ +# +# +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + +module Shell + module Commands + class DeleteFamilyversion < Command + def help + return <<-EOF +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. To delete a cell from 't1' at row 'r1' under column 'c1' +marked with the time 'ts1', do: + + hbase> delete_family_version 'ns1:t1', 'r1', 'c1', ts + hbase> delete_family_version 't1', 'r1', 'c1', ts + hbase> delete_family_version 't1', 'r1', 'c1',ts, "PRIVATE&SECRET" + +The same command can also be run on a table reference. Suppose you had a reference +t to table 't1', the corresponding command would be: + + hbase> t.delete_family_version 'r1', 'c1', ts + hbase> t.delete_family_version 'r1', 'c1', ts, "PRIVATE&SECRET" +EOF + end + + def command(table, row, column, timestamp, visibility = nil) + delete_family_version(table(table), row, column, timestamp, visibility) + end + + def delete_family_version(table, row, column, timestamp, visibility = nil) + format_simple_command do + table._delete_family_version_internal(row, column, timestamp, visibility) + end + end + end + end +end + +#Add the method table.delete that calls delete.delete