hbase-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From apurt...@apache.org
Subject svn commit: r814093 - in /hadoop/hbase/trunk: CHANGES.txt bin/HBase.rb bin/hirb.rb
Date Sat, 12 Sep 2009 00:11:39 GMT
Author: apurtell
Date: Sat Sep 12 00:11:39 2009
New Revision: 814093

URL: http://svn.apache.org/viewvc?rev=814093&view=rev
Log:
HBASE-1827 Add disabling block cache scanner flag to the shell

Modified:
    hadoop/hbase/trunk/CHANGES.txt
    hadoop/hbase/trunk/bin/HBase.rb
    hadoop/hbase/trunk/bin/hirb.rb

Modified: hadoop/hbase/trunk/CHANGES.txt
URL: http://svn.apache.org/viewvc/hadoop/hbase/trunk/CHANGES.txt?rev=814093&r1=814092&r2=814093&view=diff
==============================================================================
--- hadoop/hbase/trunk/CHANGES.txt (original)
+++ hadoop/hbase/trunk/CHANGES.txt Sat Sep 12 00:11:39 2009
@@ -43,6 +43,7 @@
    HBASE-1687  bin/hbase script doesn't allow for different memory settings for
                each daemon type
    HBASE-1823  Ability for Scanners to bypass the block cache
+   HBASE-1827  Add disabling block cache scanner flag to the shell
 
   OPTIMIZATIONS
 

Modified: hadoop/hbase/trunk/bin/HBase.rb
URL: http://svn.apache.org/viewvc/hadoop/hbase/trunk/bin/HBase.rb?rev=814093&r1=814092&r2=814093&view=diff
==============================================================================
--- hadoop/hbase/trunk/bin/HBase.rb (original)
+++ hadoop/hbase/trunk/bin/HBase.rb Sat Sep 12 00:11:39 2009
@@ -11,10 +11,12 @@
 include_class('java.lang.Long') {|package,name| "J#{name}" }
 include_class('java.lang.Boolean') {|package,name| "J#{name}" }
 
+import org.apache.hadoop.hbase.KeyValue
 import org.apache.hadoop.hbase.client.HBaseAdmin
 import org.apache.hadoop.hbase.client.HTable
 import org.apache.hadoop.hbase.client.Get
 import org.apache.hadoop.hbase.client.Put
+import org.apache.hadoop.hbase.client.Scan
 import org.apache.hadoop.hbase.client.Delete
 import org.apache.hadoop.hbase.HConstants
 import org.apache.hadoop.hbase.io.BatchUpdate
@@ -43,6 +45,7 @@
   LIMIT = "LIMIT"
   METHOD = "METHOD"
   MAXLENGTH = "MAXLENGTH"
+  CACHE_BLOCKS = "CACHE_BLOCKS"
 
   # Wrapper for org.apache.hadoop.hbase.client.HBaseAdmin
   class Admin
@@ -392,42 +395,56 @@
         filter = args["FILTER"] || nil
         startrow = args["STARTROW"] || ""
         stoprow = args["STOPROW"] || nil
-        timestamp = args["TIMESTAMP"] || HConstants::LATEST_TIMESTAMP
+        timestamp = args["TIMESTAMP"] || nil
         columns = args["COLUMNS"] || getAllColumns()
+        cache = args["CACHE_BLOCKS"] || true
         
         if columns.class == String
           columns = [columns]
         elsif columns.class != Array
           raise ArgumentError.new("COLUMNS must be specified as a String or an Array")
         end
-        cs = columns.to_java(java.lang.String)
-        
         if stoprow
-          s = @table.getScanner(cs, startrow, stoprow, timestamp)
+          scan = Scan.new(startrow.to_java_bytes, stoprow.to_java_bytes)
         else
-          s = @table.getScanner(cs, startrow, timestamp, filter) 
+          scan = Scan.new(startrow.to_java_bytes)
+        end
+        for c in columns
+          split = KeyValue.parseColumn(c.to_java_bytes)
+          if split[1] != nil
+            scan.addColumn(split[0], split[1])
+          else
+            scan.addFamily(split[0])
+          end
+        end
+        if filter != nil
+          scan.setFilter(filter)
         end
+        if timestamp != nil
+          scan.setTimeStamp(timestamp)
+        end
+        scan.setCacheBlocks(cache)
       else
-        columns = getAllColumns()
-        s = @table.getScanner(columns.to_java(java.lang.String))
+        scan = Scan.new()
       end
+      s = @table.getScanner(scan)
       count = 0
       @formatter.header(["ROW", "COLUMN+CELL"])
       i = s.iterator()
       while i.hasNext()
-        r = i.next()
+        r = i.next().getRowResult()
         row = String.from_java_bytes r.getRow()
+        count += 1
+        if limit != -1 and count >= limit
+          break
+        end
         for k, v in r
           column = String.from_java_bytes k
           cell = toString(column, v, maxlength)
           @formatter.row([row, "column=%s, %s" % [column, cell]])
         end
-        count += 1
-        if limit != -1 and count >= limit
-          break
-        end
       end
-      @formatter.footer(now)
+      @formatter.footer(now, count)
     end
 
     def put(row, column, value, timestamp = nil)
@@ -529,9 +546,9 @@
     
     def count(interval = 1000)
       now = Time.now
-      columns = getAllColumns()
-      cs = columns.to_java(java.lang.String)
-      s = @table.getScanner(cs)
+      scan = Scan.new()
+      scan.setCacheBlocks(false)
+      s = @table.getScanner(scan)
       count = 0
       i = s.iterator()
       @formatter.header()

Modified: hadoop/hbase/trunk/bin/hirb.rb
URL: http://svn.apache.org/viewvc/hadoop/hbase/trunk/bin/hirb.rb?rev=814093&r1=814092&r2=814093&view=diff
==============================================================================
--- hadoop/hbase/trunk/bin/hirb.rb (original)
+++ hadoop/hbase/trunk/bin/hirb.rb Sat Sep 12 00:11:39 2009
@@ -248,6 +248,12 @@
            hbase> scan '.META.', {COLUMNS => 'info:regioninfo'}
            hbase> scan 't1', {COLUMNS => ['c1', 'c2'], LIMIT => 10, \\
              STARTROW => 'xyz'}
+           
+           For experts, there is an additional option -- CACHE_BLOCKS -- which
+           switches block caching for the scanner on (true) or off (false).  By
+           default it is enabled.  Examples:
+           
+           hbase> scan 't1', {COLUMNS => ['c1', 'c2'], CACHE_BLOCKS => false}
 
  status    Show cluster status. Can be 'summary', 'simple', or 'detailed'. The
            default is 'summary'. Examples:



Mime
View raw message