From e7f5eea91c296fc80f184404743accc5b849a15e Mon Sep 17 00:00:00 2001 From: Michael Stack Date: Wed, 7 Nov 2012 21:07:05 +0000 Subject: [PATCH] HBASE-6969 Avoid unneceseary regular expression matching in ruby code for "list" command git-svn-id: https://svn.apache.org/repos/asf/hbase/trunk@1406805 13f79535-47bb-0310-9956-ffa450edef68 --- hbase-server/src/main/ruby/hbase/admin.rb | 4 ++-- hbase-server/src/main/ruby/shell/commands/list.rb | 3 +-- 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/hbase-server/src/main/ruby/hbase/admin.rb b/hbase-server/src/main/ruby/hbase/admin.rb index 69e6343527f..5dd4a76fcb0 100644 --- a/hbase-server/src/main/ruby/hbase/admin.rb +++ b/hbase-server/src/main/ruby/hbase/admin.rb @@ -39,8 +39,8 @@ module Hbase #---------------------------------------------------------------------------------------------- # Returns a list of tables in hbase - def list - @admin.listTables.map { |t| t.getNameAsString } + def list(regex = ".*") + @admin.listTables(regex).map { |t| t.getNameAsString } end #---------------------------------------------------------------------------------------------- diff --git a/hbase-server/src/main/ruby/shell/commands/list.rb b/hbase-server/src/main/ruby/shell/commands/list.rb index 16af27b9c09..c43e0c4a347 100644 --- a/hbase-server/src/main/ruby/shell/commands/list.rb +++ b/hbase-server/src/main/ruby/shell/commands/list.rb @@ -34,8 +34,7 @@ EOF now = Time.now formatter.header([ "TABLE" ]) - regex = /#{regex}/ unless regex.is_a?(Regexp) - list = admin.list.grep(regex) + list = admin.list(regex) list.each do |table| formatter.row([ table ]) end