[Groonga-commit] groonga/groonga-query-log [master] Parse correctly load command without values by Groonga::Command::Parser

Back to archive index

Haruka Yoshihara null+****@clear*****
Thu Dec 13 14:20:51 JST 2012


Haruka Yoshihara	2012-12-13 14:20:51 +0900 (Thu, 13 Dec 2012)

  New Revision: ed46a16116212e414ee6b2c6fc604076177cf6e8
  https://github.com/groonga/groonga-query-log/commit/ed46a16116212e414ee6b2c6fc604076177cf6e8

  Log:
    Parse correctly load command without values by Groonga::Command::Parser

  Modified files:
    lib/groonga/query-log/analyzer/statistic.rb
    test/test-parser.rb

  Modified: lib/groonga/query-log/analyzer/statistic.rb (+10 -1)
===================================================================
--- lib/groonga/query-log/analyzer/statistic.rb    2012-12-13 13:39:16 +0900 (37c26fd)
+++ lib/groonga/query-log/analyzer/statistic.rb    2012-12-13 14:20:51 +0900 (7501970)
@@ -48,7 +48,16 @@ module Groonga
         end
 
         def command
-          @command ||= Groonga::Command::Parser.parse(@raw_command)
+          Groonga::Command::Parser.parse(@raw_command) do |status, command|
+            case status
+            when :on_load_start
+              @loading = false
+              @command ||= command
+            when :on_command
+              @command ||= command
+            end
+          end
+          @command
         end
 
         def elapsed_in_seconds

  Modified: test/test-parser.rb (+9 -0)
===================================================================
--- test/test-parser.rb    2012-12-13 13:39:16 +0900 (2e45a49)
+++ test/test-parser.rb    2012-12-13 14:20:51 +0900 (54664d8)
@@ -17,6 +17,15 @@
 # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
 
 class ParserTest < Test::Unit::TestCase
+  def test_load
+    @log = <<-EOL
+2012-12-13 11:15:21.628105|0x7fff148c8a50|>load --table Video
+2012-12-13 11:15:21.645119|0x7fff148c8a50|<000000017041150 rc=0
+EOL
+    parsed_command = statistics.first.command
+    assert_instance_of(Groonga::Command::Load, parsed_command)
+  end
+
   private
   def statistics
     statistics = []
-------------- next part --------------
HTML����������������������������...
Download 



More information about the Groonga-commit mailing list
Back to archive index