hbase-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ramkris...@apache.org
Subject hbase git commit: HBASE-13721 - Improve shell scan performances when using LIMIT (JMS)
Date Wed, 20 May 2015 16:54:43 GMT
Repository: hbase
Updated Branches:
  refs/heads/branch-1.1 ebdd45be8 -> 9a61d221c


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/9a61d221
Tree: http://git-wip-us.apache.org/repos/asf/hbase/tree/9a61d221
Diff: http://git-wip-us.apache.org/repos/asf/hbase/diff/9a61d221

Branch: refs/heads/branch-1.1
Commit: 9a61d221c4d0b0b453ee06033d7f8cfd61631acf
Parents: ebdd45b
Author: ramkrishna <ramkrishna.s.vasudevan@gmail.com>
Authored: Wed May 20 22:24:07 2015 +0530
Committer: ramkrishna <ramkrishna.s.vasudevan@gmail.com>
Committed: Wed May 20 22:24:07 2015 +0530

----------------------------------------------------------------------
 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/9a61d221/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 5f810ef..6495554 100644
--- a/hbase-shell/src/main/ruby/hbase/table.rb
+++ b/hbase-shell/src/main/ruby/hbase/table.rb
@@ -425,6 +425,7 @@ EOF
         consistency = args[CONSISTENCY]
         # 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
@@ -460,6 +461,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
         scan.setConsistency(org.apache.hadoop.hbase.client.Consistency.valueOf(consistency))
if consistency
@@ -479,7 +481,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 = {}
@@ -492,10 +494,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)
 
@@ -516,6 +514,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