Repository: hbase
Updated Branches:
  refs/heads/0.94 72d17265c -> eef4ad69a
  refs/heads/0.98 00a50d6b9 -> 780f6f525
  refs/heads/branch-1 6e45269f2 -> 40e9c22ea
  refs/heads/master c32a2c0b1 -> acc284eec


HBASE-12801 Failed to truncate a table while maintaing binary region boundaries 
(Liu Shaohui)


Project: http://git-wip-us.apache.org/repos/asf/hbase/repo
Commit: http://git-wip-us.apache.org/repos/asf/hbase/commit/acc284ee
Tree: http://git-wip-us.apache.org/repos/asf/hbase/tree/acc284ee
Diff: http://git-wip-us.apache.org/repos/asf/hbase/diff/acc284ee

Branch: refs/heads/master
Commit: acc284eec6e708088971b495f2ad4d720ee35a40
Parents: c32a2c0
Author: Andrew Purtell <[email protected]>
Authored: Mon Jan 12 19:09:02 2015 -0800
Committer: Andrew Purtell <[email protected]>
Committed: Mon Jan 12 19:09:02 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/acc284ee/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 97c2c36..bec35ee 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
@@ -1994,6 +1994,18 @@ public class Bytes implements Comparable<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/acc284ee/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 f7bcd83..0ce1a56 100644
--- a/hbase-shell/src/main/ruby/hbase/admin.rb
+++ b/hbase-shell/src/main/ruby/hbase/admin.rb
@@ -398,8 +398,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 = @conn.getTable(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)

Reply via email to