hbase-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From st...@apache.org
Subject svn commit: r685257 - in /hadoop/hbase: branches/0.2/CHANGES.txt branches/0.2/bin/Formatter.rb branches/0.2/bin/HBase.rb branches/0.2/bin/hirb.rb trunk/CHANGES.txt trunk/bin/Formatter.rb trunk/bin/HBase.rb trunk/bin/hirb.rb
Date Tue, 12 Aug 2008 18:30:34 GMT
Author: stack
Date: Tue Aug 12 11:30:33 2008
New Revision: 685257

URL: http://svn.apache.org/viewvc?rev=685257&view=rev
Log:
HBASE-813 Add a row counter in the new shell

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

Modified: hadoop/hbase/branches/0.2/CHANGES.txt
URL: http://svn.apache.org/viewvc/hadoop/hbase/branches/0.2/CHANGES.txt?rev=685257&r1=685256&r2=685257&view=diff
==============================================================================
--- hadoop/hbase/branches/0.2/CHANGES.txt (original)
+++ hadoop/hbase/branches/0.2/CHANGES.txt Tue Aug 12 11:30:33 2008
@@ -15,6 +15,7 @@
    HBASE-820   Need mainline to flush when 'Blocking updates' goes up.
                (Jean-Daniel Cryans via Stack)
    HBASE-821   UnknownScanner happens too often (Jean-Daniel Cryans via Stack)
+   HBASE-813   Add a row counter in the new shell (Jean-Daniel Cryans via Stack)
 
 
   IMPROVEMENTS

Modified: hadoop/hbase/branches/0.2/bin/Formatter.rb
URL: http://svn.apache.org/viewvc/hadoop/hbase/branches/0.2/bin/Formatter.rb?rev=685257&r1=685256&r2=685257&view=diff
==============================================================================
--- hadoop/hbase/branches/0.2/bin/Formatter.rb (original)
+++ hadoop/hbase/branches/0.2/bin/Formatter.rb Tue Aug 12 11:30:33 2008
@@ -97,12 +97,15 @@
       @out.printf(spec, str)
     end
 
-    def footer(startTime = nil)
+    def footer(startTime = nil, rowCount = nil)
+      if not rowCount
+        rowCount = @rowCount
+      end
       if not startTime
         return
       end
       # Only output elapsed time and row count if startTime passed
-      @out.puts("%d row(s) in %.4f seconds" % [@rowCount, Time.now - startTime])
+      @out.puts("%d row(s) in %.4f seconds" % [rowCount, Time.now - startTime])
     end
   end
      

Modified: hadoop/hbase/branches/0.2/bin/HBase.rb
URL: http://svn.apache.org/viewvc/hadoop/hbase/branches/0.2/bin/HBase.rb?rev=685257&r1=685256&r2=685257&view=diff
==============================================================================
--- hadoop/hbase/branches/0.2/bin/HBase.rb (original)
+++ hadoop/hbase/branches/0.2/bin/HBase.rb Tue Aug 12 11:30:33 2008
@@ -346,6 +346,26 @@
       end
       @formatter.footer(now)
     end
+    
+    def count(interval = 1000)
+      now = Time.now
+      columns = getAllColumns()
+      cs = columns.to_java(java.lang.String)
+      s = @table.getScanner(cs)
+      count = 0
+      i = s.iterator()
+      @formatter.header("Count may take a long time to complete!")
+      while i.hasNext()
+        r = i.next()
+        count += 1
+        if count % interval == 0
+          @formatter.row(["Current count: " + count.to_s + ", row: " + \
+            (String.from_java_bytes r.getRow())])
+        end
+      end
+      @formatter.footer(now, count)
+    end
+    
   end
 
   # Testing. To run this test, there needs to be an hbase cluster up and

Modified: hadoop/hbase/branches/0.2/bin/hirb.rb
URL: http://svn.apache.org/viewvc/hadoop/hbase/branches/0.2/bin/hirb.rb?rev=685257&r1=685256&r2=685257&view=diff
==============================================================================
--- hadoop/hbase/branches/0.2/bin/hirb.rb (original)
+++ hadoop/hbase/branches/0.2/bin/hirb.rb Tue Aug 12 11:30:33 2008
@@ -113,6 +113,14 @@
            cell VERSIONS, do:
 
            hbase> alter 't1', {NAME => 'f1', VERSIONS => 5}
+           
+ count     Count the number of rows in a table. This operation may take a LONG
+           time (Run '$HADOOP_HOME/bin/hadoop jar hbase.jar rowcount' to run a
+           counting mapreduce job). Current count is shown every 1000 rows by
+           default. Count interval may be optionally specified. Examples:
+           
+           hbase> count 't1'
+           hbase> count 't1', 100000
 
  create    Create table; pass table name, a dictionary of specifications per
            column family, and optionally a dictionary of table configuration.
@@ -273,6 +281,10 @@
   table(table).deleteall(row, column, timestamp)
 end
 
+def count(table, interval = 1000)
+  table(table).count(interval)
+end
+
 # Output a banner message that tells users where to go for help
 puts <<HERE
 HBase Shell; enter 'help<RETURN>' for list of supported commands.

Modified: hadoop/hbase/trunk/CHANGES.txt
URL: http://svn.apache.org/viewvc/hadoop/hbase/trunk/CHANGES.txt?rev=685257&r1=685256&r2=685257&view=diff
==============================================================================
--- hadoop/hbase/trunk/CHANGES.txt (original)
+++ hadoop/hbase/trunk/CHANGES.txt Tue Aug 12 11:30:33 2008
@@ -15,6 +15,7 @@
    HBASE-820   Need mainline to flush when 'Blocking updates' goes up.
                (Jean-Daniel Cryans via Stack)
    HBASE-821   UnknownScanner happens too often (Jean-Daniel Cryans via Stack)
+   HBASE-813   Add a row counter in the new shell (Jean-Daniel Cryans via Stack)
 
 
   IMPROVEMENTS

Modified: hadoop/hbase/trunk/bin/Formatter.rb
URL: http://svn.apache.org/viewvc/hadoop/hbase/trunk/bin/Formatter.rb?rev=685257&r1=685256&r2=685257&view=diff
==============================================================================
--- hadoop/hbase/trunk/bin/Formatter.rb (original)
+++ hadoop/hbase/trunk/bin/Formatter.rb Tue Aug 12 11:30:33 2008
@@ -97,12 +97,15 @@
       @out.printf(spec, str)
     end
 
-    def footer(startTime = nil)
+    def footer(startTime = nil, rowCount = nil)
+      if not rowCount
+        rowCount = @rowCount
+      end
       if not startTime
         return
       end
       # Only output elapsed time and row count if startTime passed
-      @out.puts("%d row(s) in %.4f seconds" % [@rowCount, Time.now - startTime])
+      @out.puts("%d row(s) in %.4f seconds" % [rowCount, Time.now - startTime])
     end
   end
      

Modified: hadoop/hbase/trunk/bin/HBase.rb
URL: http://svn.apache.org/viewvc/hadoop/hbase/trunk/bin/HBase.rb?rev=685257&r1=685256&r2=685257&view=diff
==============================================================================
--- hadoop/hbase/trunk/bin/HBase.rb (original)
+++ hadoop/hbase/trunk/bin/HBase.rb Tue Aug 12 11:30:33 2008
@@ -346,6 +346,26 @@
       end
       @formatter.footer(now)
     end
+    
+    def count(interval = 1000)
+      now = Time.now
+      columns = getAllColumns()
+      cs = columns.to_java(java.lang.String)
+      s = @table.getScanner(cs)
+      count = 0
+      i = s.iterator()
+      @formatter.header("Count may take a long time to complete!")
+      while i.hasNext()
+        r = i.next()
+        count += 1
+        if count % interval == 0
+          @formatter.row(["Current count: " + count.to_s + ", row: " + \
+            (String.from_java_bytes r.getRow())])
+        end
+      end
+      @formatter.footer(now, count)
+    end
+    
   end
 
   # Testing. To run this test, there needs to be an hbase cluster up and

Modified: hadoop/hbase/trunk/bin/hirb.rb
URL: http://svn.apache.org/viewvc/hadoop/hbase/trunk/bin/hirb.rb?rev=685257&r1=685256&r2=685257&view=diff
==============================================================================
--- hadoop/hbase/trunk/bin/hirb.rb (original)
+++ hadoop/hbase/trunk/bin/hirb.rb Tue Aug 12 11:30:33 2008
@@ -113,6 +113,14 @@
            cell VERSIONS, do:
 
            hbase> alter 't1', {NAME => 'f1', VERSIONS => 5}
+           
+ count     Count the number of rows in a table. This operation may take a LONG
+           time (Run '$HADOOP_HOME/bin/hadoop jar hbase.jar rowcount' to run a
+           counting mapreduce job). Current count is shown every 1000 rows by
+           default. Count interval may be optionally specified. Examples:
+           
+           hbase> count 't1'
+           hbase> count 't1', 100000
 
  create    Create table; pass table name, a dictionary of specifications per
            column family, and optionally a dictionary of table configuration.
@@ -273,6 +281,10 @@
   table(table).deleteall(row, column, timestamp)
 end
 
+def count(table, interval = 1000)
+  table(table).count(interval)
+end
+
 # Output a banner message that tells users where to go for help
 puts <<HERE
 HBase Shell; enter 'help<RETURN>' for list of supported commands.



Mime
View raw message