hbase-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From apurt...@apache.org
Subject [4/4] hbase git commit: HBASE-12801 Failed to truncate a table while maintaing binary region boundaries (Liu Shaohui)
Date Tue, 13 Jan 2015 03:30:56 GMT
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/eef4ad69
Tree: http://git-wip-us.apache.org/repos/asf/hbase/tree/eef4ad69
Diff: http://git-wip-us.apache.org/repos/asf/hbase/diff/eef4ad69

Branch: refs/heads/0.94
Commit: eef4ad69a5325cd83b3391bea5a3eb327cb24be5
Parents: 72d1726
Author: Andrew Purtell <apurtell@apache.org>
Authored: Mon Jan 12 19:09:02 2015 -0800
Committer: Andrew Purtell <apurtell@apache.org>
Committed: Mon Jan 12 19:24:40 2015 -0800

----------------------------------------------------------------------
 src/main/java/org/apache/hadoop/hbase/util/Bytes.java | 13 +++++++++++++
 src/main/ruby/hbase/admin.rb                          |  4 ++--
 2 files changed, 15 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/hbase/blob/eef4ad69/src/main/java/org/apache/hadoop/hbase/util/Bytes.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/hadoop/hbase/util/Bytes.java b/src/main/java/org/apache/hadoop/hbase/util/Bytes.java
index 6a4c250..3fa1317 100644
--- a/src/main/java/org/apache/hadoop/hbase/util/Bytes.java
+++ b/src/main/java/org/apache/hadoop/hbase/util/Bytes.java
@@ -1648,6 +1648,19 @@ public class Bytes {
     return result;
   }
 
+
+  /**
+   * @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

http://git-wip-us.apache.org/repos/asf/hbase/blob/eef4ad69/src/main/ruby/hbase/admin.rb
----------------------------------------------------------------------
diff --git a/src/main/ruby/hbase/admin.rb b/src/main/ruby/hbase/admin.rb
index 266f1ff..367485b 100644
--- a/src/main/ruby/hbase/admin.rb
+++ b/src/main/ruby/hbase/admin.rb
@@ -330,8 +330,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)


Mime
View raw message