HBASE-12801 Failed to truncate a table while maintaing binary region boundaries (Liu Shaohui)
This commit is contained in:
parent
c32a2c0b16
commit
acc284eec6
|
@ -1993,6 +1993,18 @@ public class Bytes implements Comparable<Bytes> {
|
||||||
return result;
|
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
|
* @param column operand
|
||||||
* @return A byte array of a byte array where first and only entry is
|
* @return A byte array of a byte array where first and only entry is
|
||||||
|
|
|
@ -398,8 +398,8 @@ module Hbase
|
||||||
# Truncates table while maintaing region boundaries (deletes all records by recreating the table)
|
# Truncates table while maintaing region boundaries (deletes all records by recreating the table)
|
||||||
def truncate_preserve(table_name, conf = @conf)
|
def truncate_preserve(table_name, conf = @conf)
|
||||||
h_table = @conn.getTable(table_name)
|
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 = h_table.getRegionLocations().keys().map{|i| Bytes.toStringBinary(i.getStartKey)}.delete_if{|k| k == ""}.to_java :String
|
||||||
splits = org.apache.hadoop.hbase.util.Bytes.toByteArrays(splits)
|
splits = org.apache.hadoop.hbase.util.Bytes.toBinaryByteArrays(splits)
|
||||||
table_description = h_table.getTableDescriptor()
|
table_description = h_table.getTableDescriptor()
|
||||||
yield 'Disabling table...' if block_given?
|
yield 'Disabling table...' if block_given?
|
||||||
disable(table_name)
|
disable(table_name)
|
||||||
|
|
Loading…
Reference in New Issue