You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@hbase.apache.org by ra...@apache.org on 2015/05/20 18:45:14 UTC

hbase git commit: HBASE-13721 - Improve shell scan performances when using LIMIT(JMS)

Repository: hbase
Updated Branches:
  refs/heads/master 132573792 -> 1fbde3abd


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

Branch: refs/heads/master
Commit: 1fbde3abd3c5186540113cfd271f33f8484b1235
Parents: 1325737
Author: ramkrishna <ra...@gmail.com>
Authored: Wed May 20 22:13:27 2015 +0530
Committer: ramkrishna <ra...@gmail.com>
Committed: Wed May 20 22:13:27 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/1fbde3ab/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 9a71fa5..bba81d5 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)