Index: hbase-client/src/main/java/org/apache/hadoop/hbase/client/HTable.java =================================================================== --- hbase-client/src/main/java/org/apache/hadoop/hbase/client/HTable.java (revision 1499374) +++ hbase-client/src/main/java/org/apache/hadoop/hbase/client/HTable.java (working copy) @@ -1474,6 +1474,23 @@ } } + /** + * Get the split keys of the currently open table. + * + * @return Array of split keys + * @throws IOException + */ + public byte[][] getSplitKeys() throws IOException { + List splitKeysList = new ArrayList(); + for (HRegionInfo regionInfo : getRegionLocations().keySet()) { + if (Bytes.equals(regionInfo.getStartKey(), HConstants.EMPTY_BYTE_ARRAY)) { + continue; + } + splitKeysList.add(regionInfo.getStartKey()); + } + return splitKeysList.toArray(new byte[splitKeysList.size()][]); + } + private List getStartKeysInRange(byte[] start, byte[] end) throws IOException { if (start == null) { Index: hbase-server/src/main/ruby/hbase/admin.rb =================================================================== --- hbase-server/src/main/ruby/hbase/admin.rb (revision 1499374) +++ hbase-server/src/main/ruby/hbase/admin.rb (working copy) @@ -342,8 +342,6 @@ # 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) table_description = h_table.getTableDescriptor() yield 'Disabling table...' if block_given? disable(table_name) @@ -352,7 +350,7 @@ drop(table_name) yield 'Creating table with region boundaries...' if block_given? - @admin.createTable(table_description, splits) + @admin.createTable(table_description, h_table.getSplitKeys()) end #----------------------------------------------------------------------------------------------