hbase-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From apurt...@apache.org
Subject hbase git commit: HBASE-13721 - Improve shell scan performances when using LIMIT(JMS)
Date Wed, 20 May 2015 22:47:53 GMT
Repository: hbase
Updated Branches:
  refs/heads/0.98 78c0fc6c7 -> 2b035259d


HBASE-13721 - Improve shell scan performances when using LIMIT(JMS)


Project: http://git-wip-us.apache.org/repos/asf/hbase/repo
Commit: http://git-wip-us.apache.org/repos/asf/hbase/commit/2b035259
Tree: http://git-wip-us.apache.org/repos/asf/hbase/tree/2b035259
Diff: http://git-wip-us.apache.org/repos/asf/hbase/diff/2b035259

Branch: refs/heads/0.98
Commit: 2b035259dc16503b1ff67f6ea577ca588cc33b68
Parents: 78c0fc6
Author: ramkrishna <ramkrishna.s.vasudevan@gmail.com>
Authored: Wed May 20 22:13:27 2015 +0530
Committer: Andrew Purtell <apurtell@apache.org>
Committed: Wed May 20 15:42:19 2015 -0700

----------------------------------------------------------------------
 hbase-shell/src/main/ruby/hbase/table.rb | 12 +++++++-----
 1 file changed, 7 insertions(+), 5 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/hbase/blob/2b035259/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 1d32f3d..d6fce1c 100644
--- a/hbase-shell/src/main/ruby/hbase/table.rb
+++ b/hbase-shell/src/main/ruby/hbase/table.rb
@@ -418,6 +418,7 @@ EOF
         authorizations = args[AUTHORIZATIONS]
         # Normalize column names
         columns = [columns] if columns.class == String
+        limit = args["LIMIT"] || -1
         unless columns.kind_of?(Array)
           raise ArgumentError.new("COLUMNS must be specified as a String or an Array")
         end
@@ -450,6 +451,7 @@ EOF
         scan.setMaxVersions(versions) if versions > 1
         scan.setTimeRange(timerange[0], timerange[1]) if timerange
         scan.setRaw(raw)
+        scan.setCaching(limit) if limit > 0
         set_attributes(scan, attributes) if attributes
         set_authorizations(scan, authorizations) if authorizations
       else
@@ -468,7 +470,7 @@ EOF
     def _scan_internal(args = {})
       raise(ArgumentError, "Arguments should be a Hash") unless args.kind_of?(Hash)
 
-      limit = args.delete("LIMIT") || -1
+      limit = args["LIMIT"] || -1
       maxlength = args.delete("MAXLENGTH") || -1
       count = 0
       res = {}
@@ -481,10 +483,6 @@ EOF
 
       # Iterate results
       while iter.hasNext
-        if limit > 0 && count >= limit
-          break
-        end
-
         row = iter.next
         key = org.apache.hadoop.hbase.util.Bytes::toStringBinary(row.getRow)
 
@@ -505,6 +503,10 @@ EOF
 
         # One more row processed
         count += 1
+        if limit > 0 && count >= limit
+          # If we reached the limit, exit before the next call to hasNext
+          break
+        end
       end
 
       return ((block_given?) ? count : res)


Mime
View raw message