HBASE-20463 Ruby 1.8 syntax fixes. branches-1 specific addendum to HBASE-20276
Signed-off-by: Huaxiang Sun <h...@apache.org> Project: http://git-wip-us.apache.org/repos/asf/hbase/repo Commit: http://git-wip-us.apache.org/repos/asf/hbase/commit/ff0c1418 Tree: http://git-wip-us.apache.org/repos/asf/hbase/tree/ff0c1418 Diff: http://git-wip-us.apache.org/repos/asf/hbase/diff/ff0c1418 Branch: refs/heads/branch-1.4 Commit: ff0c14182c19967305a6894fa21988709ef41ff6 Parents: e075492 Author: Sean Busbey <bus...@apache.org> Authored: Wed Apr 18 16:33:03 2018 -0500 Committer: Sean Busbey <bus...@apache.org> Committed: Fri Apr 20 12:46:37 2018 -0500 ---------------------------------------------------------------------- hbase-shell/src/main/ruby/hbase/table.rb | 13 +++++++++---- hbase-shell/src/main/ruby/shell/commands/get_splits.rb | 6 ++++-- 2 files changed, 13 insertions(+), 6 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/hbase/blob/ff0c1418/hbase-shell/src/main/ruby/hbase/table.rb ---------------------------------------------------------------------- diff --git a/hbase-shell/src/main/ruby/hbase/table.rb b/hbase-shell/src/main/ruby/hbase/table.rb index 3e3fb8e..4109006 100644 --- a/hbase-shell/src/main/ruby/hbase/table.rb +++ b/hbase-shell/src/main/ruby/hbase/table.rb @@ -718,14 +718,19 @@ EOF #---------------------------------------------------------------------------------------------- # Get the split points for the table + # Disable multiline block chain because we need it to stay under width + # in ruby 1.8. + # rubocop:disable Style/MultilineBlockChain def _get_splits_internal() - locator = @table.getRegionLocator() - locator.getAllRegionLocations() - .map { |i| Bytes.toStringBinary(i.getRegionInfo().getStartKey) } - .delete_if { |k| k == "" } + locator = @table.getRegionLocator + locator.getAllRegionLocations.map do |i| + Bytes.toStringBinary(i.getRegionInfo.getStartKey) + end.delete_if { |k| k == '' } ensure locator.close() end end + # rubocop:enable Style/MultilineBlockChain + # rubocop:enable Metrics/ClassLength end http://git-wip-us.apache.org/repos/asf/hbase/blob/ff0c1418/hbase-shell/src/main/ruby/shell/commands/get_splits.rb ---------------------------------------------------------------------- diff --git a/hbase-shell/src/main/ruby/shell/commands/get_splits.rb b/hbase-shell/src/main/ruby/shell/commands/get_splits.rb index 26be15f..c090427 100644 --- a/hbase-shell/src/main/ruby/shell/commands/get_splits.rb +++ b/hbase-shell/src/main/ruby/shell/commands/get_splits.rb @@ -36,12 +36,14 @@ EOF get_splits(table(table)) end + # Disable format string because it doesn't work in ruby 1.8 + # rubocop:disable Style/FormatStringToken def get_splits(table) splits = table._get_splits_internal() - puts(format('Total number of splits = %<numsplits>d', - numsplits: (splits.size + 1))) + puts(format('Total number of splits = %d', (splits.size + 1))) splits end + # rubocop:enable Style/FormatStringToken end end end