You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@hbase.apache.org by ap...@apache.org on 2015/01/13 04:30:55 UTC
[3/4] hbase git commit: HBASE-12801 Failed to truncate a table while
maintaing binary region boundaries (Liu Shaohui)
HBASE-12801 Failed to truncate a table while maintaing binary region boundaries (Liu Shaohui)
Conflicts:
hbase-shell/src/main/ruby/hbase/admin.rb
Project: http://git-wip-us.apache.org/repos/asf/hbase/repo
Commit: http://git-wip-us.apache.org/repos/asf/hbase/commit/780f6f52
Tree: http://git-wip-us.apache.org/repos/asf/hbase/tree/780f6f52
Diff: http://git-wip-us.apache.org/repos/asf/hbase/diff/780f6f52
Branch: refs/heads/0.98
Commit: 780f6f525e34dd84cbc5490ad3c7178de9b414d6
Parents: 00a50d6
Author: Andrew Purtell <ap...@apache.org>
Authored: Mon Jan 12 19:09:02 2015 -0800
Committer: Andrew Purtell <ap...@apache.org>
Committed: Mon Jan 12 19:10:15 2015 -0800
----------------------------------------------------------------------
.../main/java/org/apache/hadoop/hbase/util/Bytes.java | 12 ++++++++++++
hbase-shell/src/main/ruby/hbase/admin.rb | 4 ++--
2 files changed, 14 insertions(+), 2 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/hbase/blob/780f6f52/hbase-common/src/main/java/org/apache/hadoop/hbase/util/Bytes.java
----------------------------------------------------------------------
diff --git a/hbase-common/src/main/java/org/apache/hadoop/hbase/util/Bytes.java b/hbase-common/src/main/java/org/apache/hadoop/hbase/util/Bytes.java
index c69b242..c2ceb99 100644
--- a/hbase-common/src/main/java/org/apache/hadoop/hbase/util/Bytes.java
+++ b/hbase-common/src/main/java/org/apache/hadoop/hbase/util/Bytes.java
@@ -1785,6 +1785,18 @@ public class Bytes {
}
/**
+ * @param t operands
+ * @return Array of binary byte arrays made from passed array of binary strings
+ */
+ public static byte[][] toBinaryByteArrays(final String[] t) {
+ byte[][] result = new byte[t.length][];
+ for (int i = 0; i < t.length; i++) {
+ result[i] = Bytes.toBytesBinary(t[i]);
+ }
+ return result;
+ }
+
+ /**
* @param column operand
* @return A byte array of a byte array where first and only entry is
* <code>column</code>
http://git-wip-us.apache.org/repos/asf/hbase/blob/780f6f52/hbase-shell/src/main/ruby/hbase/admin.rb
----------------------------------------------------------------------
diff --git a/hbase-shell/src/main/ruby/hbase/admin.rb b/hbase-shell/src/main/ruby/hbase/admin.rb
index ff3770e..bbd2d97 100644
--- a/hbase-shell/src/main/ruby/hbase/admin.rb
+++ b/hbase-shell/src/main/ruby/hbase/admin.rb
@@ -382,8 +382,8 @@ module Hbase
# Truncates table while maintaing region boundaries (deletes all records by recreating the table)
def truncate_preserve(table_name, conf = @conf)
h_table = org.apache.hadoop.hbase.client.HTable.new(conf, table_name)
- splits = h_table.getRegionLocations().keys().map{|i| Bytes.toString(i.getStartKey)}.delete_if{|k| k == ""}.to_java :String
- splits = org.apache.hadoop.hbase.util.Bytes.toByteArrays(splits)
+ splits = h_table.getRegionLocations().keys().map{|i| Bytes.toStringBinary(i.getStartKey)}.delete_if{|k| k == ""}.to_java :String
+ splits = org.apache.hadoop.hbase.util.Bytes.toBinaryByteArrays(splits)
table_description = h_table.getTableDescriptor()
yield 'Disabling table...' if block_given?
disable(table_name)