rroonga 2.0.0-x86-mingw32 → 2.0.1-x86-mingw32
Sign up to get free protection for your applications and to get access to all the features.
- data/Rakefile +3 -2
- data/ext/groonga/rb-grn-expression.c +4 -3
- data/ext/groonga/rb-grn-object.c +13 -0
- data/ext/groonga/rb-grn-snippet.c +32 -126
- data/ext/groonga/rb-grn.h +14 -11
- data/lib/1.8/groonga.so +0 -0
- data/lib/1.9/groonga.so +0 -0
- data/rroonga-build.rb +1 -1
- data/vendor/local/bin/{grntest.exe → groonga-benchmark.exe} +0 -0
- data/vendor/local/bin/groonga.exe +0 -0
- data/vendor/local/bin/libgroonga-0.dll +0 -0
- data/vendor/local/bin/libmecab-1.dll +0 -0
- data/vendor/local/bin/libmsgpack-3.dll +0 -0
- data/vendor/local/bin/libmsgpackc-2.dll +0 -0
- data/vendor/local/bin/mecab.exe +0 -0
- data/vendor/local/include/groonga/groonga/plugin.h +1 -1
- data/vendor/local/include/groonga/groonga.h +10 -3
- data/vendor/local/lib/groonga/plugins/suggest/suggest.a +0 -0
- data/vendor/local/lib/groonga/plugins/suggest/suggest.dll +0 -0
- data/vendor/local/lib/groonga/plugins/suggest/suggest.dll.a +0 -0
- data/vendor/local/lib/groonga/plugins/tokenizers/mecab.a +0 -0
- data/vendor/local/lib/groonga/plugins/tokenizers/mecab.dll +0 -0
- data/vendor/local/lib/groonga/plugins/tokenizers/mecab.dll.a +0 -0
- data/vendor/local/lib/libgroonga.a +0 -0
- data/vendor/local/lib/libgroonga.dll.a +0 -0
- data/vendor/local/lib/libmecab.a +0 -0
- data/vendor/local/lib/libmecab.dll.a +0 -0
- data/vendor/local/lib/libmsgpack.a +0 -0
- data/vendor/local/lib/libmsgpack.dll.a +0 -0
- data/vendor/local/lib/libmsgpackc.a +0 -0
- data/vendor/local/lib/libmsgpackc.dll.a +0 -0
- data/vendor/local/lib/pkgconfig/groonga.pc +2 -2
- data/vendor/local/libexec/mecab/mecab-cost-train.exe +0 -0
- data/vendor/local/libexec/mecab/mecab-dict-gen.exe +0 -0
- data/vendor/local/libexec/mecab/mecab-dict-index.exe +0 -0
- data/vendor/local/libexec/mecab/mecab-system-eval.exe +0 -0
- data/vendor/local/libexec/mecab/mecab-test-gen.exe +0 -0
- data/vendor/local/share/doc/groonga/en/html/.buildinfo +1 -1
- data/vendor/local/share/doc/groonga/en/html/_sources/commands/suggest.txt +19 -0
- data/vendor/local/share/doc/groonga/en/html/_sources/community.txt +2 -2
- data/vendor/local/share/doc/groonga/en/html/_sources/install.txt +72 -8
- data/vendor/local/share/doc/groonga/en/html/_sources/news.txt +45 -1
- data/vendor/local/share/doc/groonga/en/html/_sources/tutorial/data.txt +112 -33
- data/vendor/local/share/doc/groonga/en/html/_sources/tutorial/introduction.txt +109 -99
- data/vendor/local/share/doc/groonga/en/html/_sources/tutorial/network.txt +76 -40
- data/vendor/local/share/doc/groonga/en/html/_sources/type.txt +30 -21
- data/vendor/local/share/doc/groonga/en/html/_static/favicon.ico +0 -0
- data/vendor/local/share/doc/groonga/en/html/_static/groonga.css +309 -101
- data/vendor/local/share/doc/groonga/en/html/_static/jquery.js +4 -154
- data/vendor/local/share/doc/groonga/en/html/_static/logo.png +0 -0
- data/vendor/local/share/doc/groonga/en/html/_static/navigation-bar.png +0 -0
- data/vendor/local/share/doc/groonga/en/html/_static/underscore.js +29 -21
- data/vendor/local/share/doc/groonga/en/html/characteristic.html +1 -1
- data/vendor/local/share/doc/groonga/en/html/command_version.html +1 -1
- data/vendor/local/share/doc/groonga/en/html/commands/cache_limit.html +1 -1
- data/vendor/local/share/doc/groonga/en/html/commands/check.html +1 -1
- data/vendor/local/share/doc/groonga/en/html/commands/clearlock.html +1 -1
- data/vendor/local/share/doc/groonga/en/html/commands/column_create.html +1 -1
- data/vendor/local/share/doc/groonga/en/html/commands/column_list.html +1 -1
- data/vendor/local/share/doc/groonga/en/html/commands/column_remove.html +1 -1
- data/vendor/local/share/doc/groonga/en/html/commands/define_selector.html +1 -1
- data/vendor/local/share/doc/groonga/en/html/commands/defrag.html +1 -1
- data/vendor/local/share/doc/groonga/en/html/commands/delete.html +1 -1
- data/vendor/local/share/doc/groonga/en/html/commands/dump.html +1 -1
- data/vendor/local/share/doc/groonga/en/html/commands/load.html +1 -1
- data/vendor/local/share/doc/groonga/en/html/commands/log_level.html +1 -1
- data/vendor/local/share/doc/groonga/en/html/commands/log_put.html +1 -1
- data/vendor/local/share/doc/groonga/en/html/commands/log_reopen.html +1 -1
- data/vendor/local/share/doc/groonga/en/html/commands/quit.html +1 -1
- data/vendor/local/share/doc/groonga/en/html/commands/select.html +1 -1
- data/vendor/local/share/doc/groonga/en/html/commands/shutdown.html +1 -1
- data/vendor/local/share/doc/groonga/en/html/commands/status.html +1 -1
- data/vendor/local/share/doc/groonga/en/html/commands/suggest.html +21 -1
- data/vendor/local/share/doc/groonga/en/html/commands/table_create.html +1 -1
- data/vendor/local/share/doc/groonga/en/html/commands/table_list.html +1 -1
- data/vendor/local/share/doc/groonga/en/html/commands/table_remove.html +1 -1
- data/vendor/local/share/doc/groonga/en/html/commands/view_add.html +1 -1
- data/vendor/local/share/doc/groonga/en/html/commands.html +1 -1
- data/vendor/local/share/doc/groonga/en/html/community.html +3 -3
- data/vendor/local/share/doc/groonga/en/html/contribution/development/com.html +1 -1
- data/vendor/local/share/doc/groonga/en/html/contribution/development/document.html +1 -1
- data/vendor/local/share/doc/groonga/en/html/contribution/development/query.html +1 -1
- data/vendor/local/share/doc/groonga/en/html/contribution/development/test.html +1 -1
- data/vendor/local/share/doc/groonga/en/html/contribution/development.html +1 -1
- data/vendor/local/share/doc/groonga/en/html/contribution/documentation/c-api.html +1 -1
- data/vendor/local/share/doc/groonga/en/html/contribution/documentation/i18n.html +1 -1
- data/vendor/local/share/doc/groonga/en/html/contribution/documentation.html +1 -1
- data/vendor/local/share/doc/groonga/en/html/contribution/report.html +1 -1
- data/vendor/local/share/doc/groonga/en/html/contribution.html +1 -1
- data/vendor/local/share/doc/groonga/en/html/executables/grnslap.html +1 -1
- data/vendor/local/share/doc/groonga/en/html/executables/grntest.html +1 -1
- data/vendor/local/share/doc/groonga/en/html/executables/groonga-http.html +1 -1
- data/vendor/local/share/doc/groonga/en/html/executables/groonga-suggest-create-dataset.html +1 -1
- data/vendor/local/share/doc/groonga/en/html/executables/groonga.html +1 -1
- data/vendor/local/share/doc/groonga/en/html/executables.html +1 -1
- data/vendor/local/share/doc/groonga/en/html/expr.html +1 -1
- data/vendor/local/share/doc/groonga/en/html/functions/edit_distance.html +1 -1
- data/vendor/local/share/doc/groonga/en/html/functions/geo_distance.html +1 -1
- data/vendor/local/share/doc/groonga/en/html/functions/geo_in_circle.html +1 -1
- data/vendor/local/share/doc/groonga/en/html/functions/geo_in_rectangle.html +1 -1
- data/vendor/local/share/doc/groonga/en/html/functions/now.html +1 -1
- data/vendor/local/share/doc/groonga/en/html/functions/rand.html +1 -1
- data/vendor/local/share/doc/groonga/en/html/functions.html +1 -1
- data/vendor/local/share/doc/groonga/en/html/genindex.html +1 -1
- data/vendor/local/share/doc/groonga/en/html/geolocation_search.html +1 -1
- data/vendor/local/share/doc/groonga/en/html/index.html +25 -18
- data/vendor/local/share/doc/groonga/en/html/indexing.html +1 -1
- data/vendor/local/share/doc/groonga/en/html/install.html +59 -9
- data/vendor/local/share/doc/groonga/en/html/limitations.html +1 -1
- data/vendor/local/share/doc/groonga/en/html/log.html +1 -1
- data/vendor/local/share/doc/groonga/en/html/news/0.x.html +1 -1
- data/vendor/local/share/doc/groonga/en/html/news/1.0.x.html +1 -1
- data/vendor/local/share/doc/groonga/en/html/news/1.1.x.html +1 -1
- data/vendor/local/share/doc/groonga/en/html/news/1.2.x.html +1 -1
- data/vendor/local/share/doc/groonga/en/html/news/senna.html +1 -1
- data/vendor/local/share/doc/groonga/en/html/news.html +66 -15
- data/vendor/local/share/doc/groonga/en/html/objects.inv +0 -0
- data/vendor/local/share/doc/groonga/en/html/output.html +1 -1
- data/vendor/local/share/doc/groonga/en/html/pseudo_column.html +1 -1
- data/vendor/local/share/doc/groonga/en/html/reference.html +1 -1
- data/vendor/local/share/doc/groonga/en/html/search.html +1 -1
- data/vendor/local/share/doc/groonga/en/html/searchindex.js +1 -1
- data/vendor/local/share/doc/groonga/en/html/spec/search.html +1 -1
- data/vendor/local/share/doc/groonga/en/html/spec.html +1 -1
- data/vendor/local/share/doc/groonga/en/html/suggest/completion.html +1 -1
- data/vendor/local/share/doc/groonga/en/html/suggest/correction.html +1 -1
- data/vendor/local/share/doc/groonga/en/html/suggest/introduction.html +1 -1
- data/vendor/local/share/doc/groonga/en/html/suggest/suggestion.html +1 -1
- data/vendor/local/share/doc/groonga/en/html/suggest/tutorial.html +1 -1
- data/vendor/local/share/doc/groonga/en/html/suggest.html +1 -1
- data/vendor/local/share/doc/groonga/en/html/troubleshooting/different_results_with_the_same_keyword.html +1 -1
- data/vendor/local/share/doc/groonga/en/html/troubleshooting.html +1 -1
- data/vendor/local/share/doc/groonga/en/html/tutorial/data.html +141 -53
- data/vendor/local/share/doc/groonga/en/html/tutorial/drilldown.html +1 -1
- data/vendor/local/share/doc/groonga/en/html/tutorial/index.html +1 -1
- data/vendor/local/share/doc/groonga/en/html/tutorial/introduction.html +112 -106
- data/vendor/local/share/doc/groonga/en/html/tutorial/lexicon.html +1 -1
- data/vendor/local/share/doc/groonga/en/html/tutorial/match_columns.html +1 -1
- data/vendor/local/share/doc/groonga/en/html/tutorial/micro_blog.html +2 -2
- data/vendor/local/share/doc/groonga/en/html/tutorial/network.html +92 -58
- data/vendor/local/share/doc/groonga/en/html/tutorial/patricia_trie.html +1 -1
- data/vendor/local/share/doc/groonga/en/html/tutorial/query_expansion.html +1 -1
- data/vendor/local/share/doc/groonga/en/html/tutorial/search.html +5 -5
- data/vendor/local/share/doc/groonga/en/html/tutorial.html +21 -14
- data/vendor/local/share/doc/groonga/en/html/type.html +30 -22
- data/vendor/local/share/doc/groonga/ja/html/.buildinfo +1 -1
- data/vendor/local/share/doc/groonga/ja/html/_sources/commands/suggest.txt +19 -0
- data/vendor/local/share/doc/groonga/ja/html/_sources/community.txt +2 -2
- data/vendor/local/share/doc/groonga/ja/html/_sources/install.txt +72 -8
- data/vendor/local/share/doc/groonga/ja/html/_sources/news.txt +45 -1
- data/vendor/local/share/doc/groonga/ja/html/_sources/tutorial/data.txt +112 -33
- data/vendor/local/share/doc/groonga/ja/html/_sources/tutorial/introduction.txt +109 -99
- data/vendor/local/share/doc/groonga/ja/html/_sources/tutorial/network.txt +76 -40
- data/vendor/local/share/doc/groonga/ja/html/_sources/type.txt +30 -21
- data/vendor/local/share/doc/groonga/ja/html/_static/favicon.ico +0 -0
- data/vendor/local/share/doc/groonga/ja/html/_static/groonga.css +309 -101
- data/vendor/local/share/doc/groonga/ja/html/_static/jquery.js +4 -154
- data/vendor/local/share/doc/groonga/ja/html/_static/logo.png +0 -0
- data/vendor/local/share/doc/groonga/ja/html/_static/navigation-bar.png +0 -0
- data/vendor/local/share/doc/groonga/ja/html/_static/underscore.js +29 -21
- data/vendor/local/share/doc/groonga/ja/html/characteristic.html +1 -1
- data/vendor/local/share/doc/groonga/ja/html/command_version.html +1 -1
- data/vendor/local/share/doc/groonga/ja/html/commands/cache_limit.html +1 -1
- data/vendor/local/share/doc/groonga/ja/html/commands/check.html +1 -1
- data/vendor/local/share/doc/groonga/ja/html/commands/clearlock.html +1 -1
- data/vendor/local/share/doc/groonga/ja/html/commands/column_create.html +1 -1
- data/vendor/local/share/doc/groonga/ja/html/commands/column_list.html +1 -1
- data/vendor/local/share/doc/groonga/ja/html/commands/column_remove.html +1 -1
- data/vendor/local/share/doc/groonga/ja/html/commands/define_selector.html +1 -1
- data/vendor/local/share/doc/groonga/ja/html/commands/defrag.html +1 -1
- data/vendor/local/share/doc/groonga/ja/html/commands/delete.html +1 -1
- data/vendor/local/share/doc/groonga/ja/html/commands/dump.html +1 -1
- data/vendor/local/share/doc/groonga/ja/html/commands/load.html +1 -1
- data/vendor/local/share/doc/groonga/ja/html/commands/log_level.html +1 -1
- data/vendor/local/share/doc/groonga/ja/html/commands/log_put.html +1 -1
- data/vendor/local/share/doc/groonga/ja/html/commands/log_reopen.html +1 -1
- data/vendor/local/share/doc/groonga/ja/html/commands/quit.html +1 -1
- data/vendor/local/share/doc/groonga/ja/html/commands/select.html +1 -1
- data/vendor/local/share/doc/groonga/ja/html/commands/shutdown.html +1 -1
- data/vendor/local/share/doc/groonga/ja/html/commands/status.html +1 -1
- data/vendor/local/share/doc/groonga/ja/html/commands/suggest.html +19 -1
- data/vendor/local/share/doc/groonga/ja/html/commands/table_create.html +1 -1
- data/vendor/local/share/doc/groonga/ja/html/commands/table_list.html +1 -1
- data/vendor/local/share/doc/groonga/ja/html/commands/table_remove.html +1 -1
- data/vendor/local/share/doc/groonga/ja/html/commands/view_add.html +1 -1
- data/vendor/local/share/doc/groonga/ja/html/commands.html +1 -1
- data/vendor/local/share/doc/groonga/ja/html/community.html +3 -3
- data/vendor/local/share/doc/groonga/ja/html/contribution/development/com.html +1 -1
- data/vendor/local/share/doc/groonga/ja/html/contribution/development/document.html +1 -1
- data/vendor/local/share/doc/groonga/ja/html/contribution/development/query.html +1 -1
- data/vendor/local/share/doc/groonga/ja/html/contribution/development/test.html +1 -1
- data/vendor/local/share/doc/groonga/ja/html/contribution/development.html +1 -1
- data/vendor/local/share/doc/groonga/ja/html/contribution/documentation/c-api.html +1 -1
- data/vendor/local/share/doc/groonga/ja/html/contribution/documentation/i18n.html +1 -1
- data/vendor/local/share/doc/groonga/ja/html/contribution/documentation.html +1 -1
- data/vendor/local/share/doc/groonga/ja/html/contribution/report.html +1 -1
- data/vendor/local/share/doc/groonga/ja/html/contribution.html +1 -1
- data/vendor/local/share/doc/groonga/ja/html/executables/grnslap.html +1 -1
- data/vendor/local/share/doc/groonga/ja/html/executables/grntest.html +1 -1
- data/vendor/local/share/doc/groonga/ja/html/executables/groonga-http.html +1 -1
- data/vendor/local/share/doc/groonga/ja/html/executables/groonga-suggest-create-dataset.html +1 -1
- data/vendor/local/share/doc/groonga/ja/html/executables/groonga.html +1 -1
- data/vendor/local/share/doc/groonga/ja/html/executables.html +1 -1
- data/vendor/local/share/doc/groonga/ja/html/expr.html +1 -1
- data/vendor/local/share/doc/groonga/ja/html/functions/edit_distance.html +1 -1
- data/vendor/local/share/doc/groonga/ja/html/functions/geo_distance.html +1 -1
- data/vendor/local/share/doc/groonga/ja/html/functions/geo_in_circle.html +1 -1
- data/vendor/local/share/doc/groonga/ja/html/functions/geo_in_rectangle.html +1 -1
- data/vendor/local/share/doc/groonga/ja/html/functions/now.html +1 -1
- data/vendor/local/share/doc/groonga/ja/html/functions/rand.html +1 -1
- data/vendor/local/share/doc/groonga/ja/html/functions.html +1 -1
- data/vendor/local/share/doc/groonga/ja/html/genindex.html +1 -1
- data/vendor/local/share/doc/groonga/ja/html/geolocation_search.html +1 -1
- data/vendor/local/share/doc/groonga/ja/html/index.html +25 -18
- data/vendor/local/share/doc/groonga/ja/html/indexing.html +1 -1
- data/vendor/local/share/doc/groonga/ja/html/install.html +72 -22
- data/vendor/local/share/doc/groonga/ja/html/limitations.html +1 -1
- data/vendor/local/share/doc/groonga/ja/html/log.html +1 -1
- data/vendor/local/share/doc/groonga/ja/html/news/0.x.html +1 -1
- data/vendor/local/share/doc/groonga/ja/html/news/1.0.x.html +1 -1
- data/vendor/local/share/doc/groonga/ja/html/news/1.1.x.html +1 -1
- data/vendor/local/share/doc/groonga/ja/html/news/1.2.x.html +1 -1
- data/vendor/local/share/doc/groonga/ja/html/news/senna.html +1 -1
- data/vendor/local/share/doc/groonga/ja/html/news.html +60 -14
- data/vendor/local/share/doc/groonga/ja/html/objects.inv +0 -0
- data/vendor/local/share/doc/groonga/ja/html/output.html +1 -1
- data/vendor/local/share/doc/groonga/ja/html/pseudo_column.html +1 -1
- data/vendor/local/share/doc/groonga/ja/html/reference.html +1 -1
- data/vendor/local/share/doc/groonga/ja/html/search.html +1 -1
- data/vendor/local/share/doc/groonga/ja/html/searchindex.js +1 -1
- data/vendor/local/share/doc/groonga/ja/html/spec/search.html +1 -1
- data/vendor/local/share/doc/groonga/ja/html/spec.html +1 -1
- data/vendor/local/share/doc/groonga/ja/html/suggest/completion.html +1 -1
- data/vendor/local/share/doc/groonga/ja/html/suggest/correction.html +1 -1
- data/vendor/local/share/doc/groonga/ja/html/suggest/introduction.html +1 -1
- data/vendor/local/share/doc/groonga/ja/html/suggest/suggestion.html +1 -1
- data/vendor/local/share/doc/groonga/ja/html/suggest/tutorial.html +1 -1
- data/vendor/local/share/doc/groonga/ja/html/suggest.html +1 -1
- data/vendor/local/share/doc/groonga/ja/html/troubleshooting/different_results_with_the_same_keyword.html +1 -1
- data/vendor/local/share/doc/groonga/ja/html/troubleshooting.html +1 -1
- data/vendor/local/share/doc/groonga/ja/html/tutorial/data.html +141 -53
- data/vendor/local/share/doc/groonga/ja/html/tutorial/drilldown.html +1 -1
- data/vendor/local/share/doc/groonga/ja/html/tutorial/index.html +1 -1
- data/vendor/local/share/doc/groonga/ja/html/tutorial/introduction.html +108 -102
- data/vendor/local/share/doc/groonga/ja/html/tutorial/lexicon.html +1 -1
- data/vendor/local/share/doc/groonga/ja/html/tutorial/match_columns.html +1 -1
- data/vendor/local/share/doc/groonga/ja/html/tutorial/micro_blog.html +2 -2
- data/vendor/local/share/doc/groonga/ja/html/tutorial/network.html +92 -55
- data/vendor/local/share/doc/groonga/ja/html/tutorial/patricia_trie.html +1 -1
- data/vendor/local/share/doc/groonga/ja/html/tutorial/query_expansion.html +1 -1
- data/vendor/local/share/doc/groonga/ja/html/tutorial/search.html +5 -5
- data/vendor/local/share/doc/groonga/ja/html/tutorial.html +21 -14
- data/vendor/local/share/doc/groonga/ja/html/type.html +30 -22
- data/vendor/local/share/doc/groonga/source/commands/suggest.txt +19 -0
- data/vendor/local/share/doc/groonga/source/community.txt +2 -2
- data/vendor/local/share/doc/groonga/source/example/tutorial/data-1.log +2 -15
- data/vendor/local/share/doc/groonga/source/example/tutorial/data-2.log +11 -7
- data/vendor/local/share/doc/groonga/source/example/tutorial/data-3.log +13 -7
- data/vendor/local/share/doc/groonga/source/example/tutorial/data-4.log +13 -0
- data/vendor/local/share/doc/groonga/source/example/tutorial/data-5.log +13 -0
- data/vendor/local/share/doc/groonga/source/example/tutorial/data-6.log +13 -0
- data/vendor/local/share/doc/groonga/source/example/tutorial/data-7.log +10 -0
- data/vendor/local/share/doc/groonga/source/example/tutorial/data-8.log +10 -0
- data/vendor/local/share/doc/groonga/source/example/tutorial/introduction-1.log +0 -2
- data/vendor/local/share/doc/groonga/source/example/tutorial/introduction-10.log +2 -2
- data/vendor/local/share/doc/groonga/source/example/tutorial/introduction-11.log +2 -2
- data/vendor/local/share/doc/groonga/source/example/tutorial/introduction-12.log +2 -2
- data/vendor/local/share/doc/groonga/source/example/tutorial/introduction-13.log +2 -2
- data/vendor/local/share/doc/groonga/source/example/tutorial/introduction-14.log +2 -6
- data/vendor/local/share/doc/groonga/source/example/tutorial/introduction-15.log +6 -2
- data/vendor/local/share/doc/groonga/source/example/tutorial/introduction-16.log +2 -2
- data/vendor/local/share/doc/groonga/source/example/tutorial/introduction-17.log +2 -2
- data/vendor/local/share/doc/groonga/source/example/tutorial/introduction-18.log +5 -0
- data/vendor/local/share/doc/groonga/source/example/tutorial/introduction-2.log +3 -2
- data/vendor/local/share/doc/groonga/source/example/tutorial/introduction-3.log +2 -2
- data/vendor/local/share/doc/groonga/source/example/tutorial/introduction-4.log +1 -3
- data/vendor/local/share/doc/groonga/source/example/tutorial/introduction-5.log +4 -2
- data/vendor/local/share/doc/groonga/source/example/tutorial/introduction-6.log +13 -2
- data/vendor/local/share/doc/groonga/source/example/tutorial/introduction-7.log +2 -13
- data/vendor/local/share/doc/groonga/source/example/tutorial/introduction-8.log +2 -2
- data/vendor/local/share/doc/groonga/source/example/tutorial/introduction-9.log +2 -2
- data/vendor/local/share/doc/groonga/source/example/tutorial/network-1.log +1 -1
- data/vendor/local/share/doc/groonga/source/example/tutorial/network-3.log +6 -6
- data/vendor/local/share/doc/groonga/source/install.txt +72 -8
- data/vendor/local/share/doc/groonga/source/news.txt +45 -1
- data/vendor/local/share/doc/groonga/source/tutorial/data.txt +112 -33
- data/vendor/local/share/doc/groonga/source/tutorial/introduction.txt +109 -99
- data/vendor/local/share/doc/groonga/source/tutorial/network.txt +76 -40
- data/vendor/local/share/doc/groonga/source/type.txt +30 -21
- data/vendor/local/share/groonga/html/admin/css/admin.css +1 -1
- data/vendor/local/share/groonga/html/admin/favicon.ico +0 -0
- data/vendor/local/share/groonga/html/admin/favicon.png +0 -0
- data/vendor/local/share/groonga/html/admin/favicon.svg +107 -547
- data/vendor/local/share/groonga/html/admin/images/groonga.png +0 -0
- data/vendor/local/share/groonga/html/admin/index.html +1 -1
- data/vendor/local/share/groonga/images/logo/groonga-icon-foreground-white.png +0 -0
- data/vendor/local/share/groonga/images/logo/groonga-icon-foreground-white.svg +118 -0
- data/vendor/local/share/groonga/images/logo/groonga-icon-full-size.png +0 -0
- data/vendor/local/share/groonga/images/logo/groonga-icon-full-size.svg +97 -0
- data/vendor/local/share/groonga/images/logo/groonga-icon.png +0 -0
- data/vendor/local/share/groonga/images/logo/groonga-icon.svg +93 -0
- data/vendor/local/share/groonga/images/logo/groonga-logo-foreground-white.png +0 -0
- data/vendor/local/share/groonga/images/logo/groonga-logo-foreground-white.svg +108 -0
- data/vendor/local/share/groonga/images/logo/groonga-logo.png +0 -0
- data/vendor/local/share/groonga/images/logo/groonga-logo.svg +118 -0
- data/vendor/local/share/groonga/images/logo/groonga-powered-by-banner-bar-foreground-white.png +0 -0
- data/vendor/local/share/groonga/images/logo/groonga-powered-by-banner-bar-foreground-white.svg +170 -0
- data/vendor/local/share/groonga/images/logo/groonga-powered-by-banner-bar.png +0 -0
- data/vendor/local/share/groonga/images/logo/groonga-powered-by-banner-bar.svg +186 -0
- data/vendor/local/share/groonga/images/logo/groonga-powered-by-banner-foreground-white.png +0 -0
- data/vendor/local/share/groonga/images/logo/groonga-powered-by-banner-foreground-white.svg +183 -0
- data/vendor/local/share/groonga/images/logo/groonga-powered-by-banner-large.png +0 -0
- data/vendor/local/share/groonga/images/logo/groonga-powered-by-banner-large.svg +179 -0
- data/vendor/local/share/groonga/images/logo/groonga-powered-by-banner.png +0 -0
- data/vendor/local/share/groonga/images/logo/groonga-powered-by-banner.svg +201 -0
- data/vendor/local/share/groonga/images/logo/mroonga-icon-foreground-white.png +0 -0
- data/vendor/local/share/groonga/images/logo/mroonga-icon-foreground-white.svg +106 -0
- data/vendor/local/share/groonga/images/logo/mroonga-icon-full-size.png +0 -0
- data/vendor/local/share/groonga/images/logo/mroonga-icon-full-size.svg +97 -0
- data/vendor/local/share/groonga/images/logo/mroonga-icon.png +0 -0
- data/vendor/local/share/groonga/images/logo/mroonga-icon.svg +93 -0
- data/vendor/local/share/groonga/images/logo/mroonga-logo-foreground-white.png +0 -0
- data/vendor/local/share/groonga/images/logo/mroonga-logo-foreground-white.svg +122 -0
- data/vendor/local/share/groonga/images/logo/mroonga-logo.png +0 -0
- data/vendor/local/share/groonga/images/logo/mroonga-logo.svg +106 -0
- data/vendor/local/share/groonga/images/logo/nroonga-icon-foreground-white.png +0 -0
- data/vendor/local/share/groonga/images/logo/nroonga-icon-foreground-white.svg +106 -0
- data/vendor/local/share/groonga/images/logo/nroonga-icon-full-size.png +0 -0
- data/vendor/local/share/groonga/images/logo/nroonga-icon-full-size.svg +107 -0
- data/vendor/local/share/groonga/images/logo/nroonga-icon.png +0 -0
- data/vendor/local/share/groonga/images/logo/nroonga-icon.svg +93 -0
- data/vendor/local/share/groonga/images/logo/nroonga-logo-foreground-white.png +0 -0
- data/vendor/local/share/groonga/images/logo/nroonga-logo-foreground-white.svg +122 -0
- data/vendor/local/share/groonga/images/logo/nroonga-logo.png +0 -0
- data/vendor/local/share/groonga/images/logo/nroonga-logo.svg +117 -0
- data/vendor/local/share/groonga/images/logo/rroonga-icon-foreground-white.png +0 -0
- data/vendor/local/share/groonga/images/logo/rroonga-icon-foreground-white.svg +106 -0
- data/vendor/local/share/groonga/images/logo/rroonga-icon-full-size.png +0 -0
- data/vendor/local/share/groonga/images/logo/rroonga-icon-full-size.svg +107 -0
- data/vendor/local/share/groonga/images/logo/rroonga-icon.png +0 -0
- data/vendor/local/share/groonga/images/logo/rroonga-icon.svg +93 -0
- data/vendor/local/share/groonga/images/logo/rroonga-logo-foreground-white.png +0 -0
- data/vendor/local/share/groonga/images/logo/rroonga-logo-foreground-white.svg +122 -0
- data/vendor/local/share/groonga/images/logo/rroonga-logo.png +0 -0
- data/vendor/local/share/groonga/images/logo/rroonga-logo.svg +117 -0
- data/vendor/local/share/man/ja/man1/groonga.1 +510 -214
- data/vendor/local/share/man/man1/groonga.1 +510 -211
- metadata +62 -15
- data/vendor/local/bin/groonga-query-log-analyzer +0 -1419
- data/vendor/local/share/doc/groonga/en/html/_static/default.css +0 -278
- data/vendor/local/share/doc/groonga/en/html/_static/footer-bar.png +0 -0
- data/vendor/local/share/doc/groonga/en/html/_static/menu-header.png +0 -0
- data/vendor/local/share/doc/groonga/en/html/_static/sidebar.js +0 -151
- data/vendor/local/share/doc/groonga/ja/html/_static/default.css +0 -278
- data/vendor/local/share/doc/groonga/ja/html/_static/footer-bar.png +0 -0
- data/vendor/local/share/doc/groonga/ja/html/_static/menu-header.png +0 -0
- data/vendor/local/share/doc/groonga/ja/html/_static/sidebar.js +0 -151
@@ -1,1419 +0,0 @@
|
|
1
|
-
#!/usr/bin/ruby
|
2
|
-
|
3
|
-
require 'English'
|
4
|
-
require 'optparse'
|
5
|
-
require 'cgi'
|
6
|
-
require 'thread'
|
7
|
-
require 'shellwords'
|
8
|
-
require 'time'
|
9
|
-
require 'erb'
|
10
|
-
|
11
|
-
# For ruby 1.8.5 on CentOS 5.6.
|
12
|
-
class String
|
13
|
-
unless method_defined?(:start_with?)
|
14
|
-
def start_with?(string)
|
15
|
-
/\A#{Regexp.escape(string)}/ =~ self
|
16
|
-
end
|
17
|
-
end
|
18
|
-
end
|
19
|
-
|
20
|
-
class Array
|
21
|
-
unless method_defined?(:each_slice)
|
22
|
-
def each_slice(n)
|
23
|
-
sub_elements = []
|
24
|
-
each do |element|
|
25
|
-
sub_elements << element
|
26
|
-
if sub_elements.size == n
|
27
|
-
yield(sub_elements)
|
28
|
-
sub_elements = []
|
29
|
-
end
|
30
|
-
end
|
31
|
-
yield(sub_elements) unless sub_elements.empty?
|
32
|
-
end
|
33
|
-
end
|
34
|
-
end
|
35
|
-
|
36
|
-
class GroongaQueryLogAnalyzer
|
37
|
-
class Error < StandardError
|
38
|
-
end
|
39
|
-
|
40
|
-
class UnsupportedReporter < Error
|
41
|
-
end
|
42
|
-
|
43
|
-
def initialize
|
44
|
-
setup_options
|
45
|
-
end
|
46
|
-
|
47
|
-
def run(argv=nil)
|
48
|
-
log_paths = @option_parser.parse!(argv || ARGV)
|
49
|
-
|
50
|
-
stream = @options[:stream]
|
51
|
-
dynamic_sort = @options[:dynamic_sort]
|
52
|
-
statistics = SizedStatistics.new
|
53
|
-
statistics.apply_options(@options)
|
54
|
-
parser = QueryLogParser.new
|
55
|
-
if stream
|
56
|
-
streamer = Streamer.new(create_reporter(statistics))
|
57
|
-
streamer.start
|
58
|
-
process_statistic = lambda do |statistic|
|
59
|
-
streamer << statistic
|
60
|
-
end
|
61
|
-
elsif dynamic_sort
|
62
|
-
process_statistic = lambda do |statistic|
|
63
|
-
statistics << statistic
|
64
|
-
end
|
65
|
-
else
|
66
|
-
full_statistics = []
|
67
|
-
process_statistic = lambda do |statistic|
|
68
|
-
full_statistics << statistic
|
69
|
-
end
|
70
|
-
end
|
71
|
-
if log_paths.empty?
|
72
|
-
parser.parse(ARGF, &process_statistic)
|
73
|
-
else
|
74
|
-
log_paths.each do |log_path|
|
75
|
-
File.open(log_path) do |log|
|
76
|
-
parser.parse(log, &process_statistic)
|
77
|
-
end
|
78
|
-
end
|
79
|
-
end
|
80
|
-
if stream
|
81
|
-
streamer.finish
|
82
|
-
return
|
83
|
-
end
|
84
|
-
statistics.replace(full_statistics) unless dynamic_sort
|
85
|
-
|
86
|
-
reporter = create_reporter(statistics)
|
87
|
-
reporter.apply_options(@options)
|
88
|
-
reporter.report
|
89
|
-
end
|
90
|
-
|
91
|
-
private
|
92
|
-
def setup_options
|
93
|
-
@options = {}
|
94
|
-
@options[:n_entries] = 10
|
95
|
-
@options[:order] = "-elapsed"
|
96
|
-
@options[:color] = :auto
|
97
|
-
@options[:output] = "-"
|
98
|
-
@options[:slow_operation_threshold] = 0.1
|
99
|
-
@options[:slow_response_threshold] = 0.2
|
100
|
-
@options[:reporter] = "console"
|
101
|
-
@options[:dynamic_sort] = true
|
102
|
-
@options[:stream] = false
|
103
|
-
@options[:report_summary] = true
|
104
|
-
|
105
|
-
@option_parser = OptionParser.new do |parser|
|
106
|
-
parser.banner += " LOG1 ..."
|
107
|
-
|
108
|
-
parser.on("-n", "--n-entries=N",
|
109
|
-
Integer,
|
110
|
-
"Show top N entries",
|
111
|
-
"(#{@options[:n_entries]})") do |n|
|
112
|
-
@options[:n_entries] = n
|
113
|
-
end
|
114
|
-
|
115
|
-
available_orders = ["elapsed", "-elapsed", "start-time", "-start-time"]
|
116
|
-
parser.on("--order=ORDER",
|
117
|
-
available_orders,
|
118
|
-
"Sort by ORDER",
|
119
|
-
"available values: [#{available_orders.join(', ')}]",
|
120
|
-
"(#{@options[:order]})") do |order|
|
121
|
-
@options[:order] = order
|
122
|
-
end
|
123
|
-
|
124
|
-
color_options = [
|
125
|
-
[:auto, :auto],
|
126
|
-
["-", false],
|
127
|
-
["no", false],
|
128
|
-
["false", false],
|
129
|
-
["+", true],
|
130
|
-
["yes", true],
|
131
|
-
["true", true],
|
132
|
-
]
|
133
|
-
parser.on("--[no-]color=[auto]",
|
134
|
-
color_options,
|
135
|
-
"Enable color output",
|
136
|
-
"(#{@options[:color]})") do |color|
|
137
|
-
if color.nil?
|
138
|
-
@options[:color] = true
|
139
|
-
else
|
140
|
-
@options[:color] = color
|
141
|
-
end
|
142
|
-
end
|
143
|
-
|
144
|
-
parser.on("--output=PATH",
|
145
|
-
"Output to PATH.",
|
146
|
-
"'-' PATH means standard output.",
|
147
|
-
"(#{@options[:output]})") do |output|
|
148
|
-
@options[:output] = output
|
149
|
-
end
|
150
|
-
|
151
|
-
parser.on("--slow-operation-threshold=THRESHOLD",
|
152
|
-
Float,
|
153
|
-
"Use THRESHOLD seconds to detect slow operations.",
|
154
|
-
"(#{@options[:slow_operation_threshold]})") do |threshold|
|
155
|
-
@options[:slow_operation_threshold] = threshold
|
156
|
-
end
|
157
|
-
|
158
|
-
parser.on("--slow-response-threshold=THRESHOLD",
|
159
|
-
Float,
|
160
|
-
"Use THRESHOLD seconds to detect slow operations.",
|
161
|
-
"(#{@options[:sloq_response_threshold]})") do |threshold|
|
162
|
-
@options[:sloq_response_threshold] = threshold
|
163
|
-
end
|
164
|
-
|
165
|
-
available_reporters = ["console", "json", "html"]
|
166
|
-
parser.on("--reporter=REPORTER",
|
167
|
-
available_reporters,
|
168
|
-
"Reports statistics by REPORTER.",
|
169
|
-
"available values: [#{available_reporters.join(', ')}]",
|
170
|
-
"(#{@options[:reporter]})") do |reporter|
|
171
|
-
@options[:reporter] = reporter
|
172
|
-
end
|
173
|
-
|
174
|
-
parser.on("--[no-]dynamic-sort",
|
175
|
-
"Sorts dynamically.",
|
176
|
-
"Memory and CPU usage reduced for large query log.",
|
177
|
-
"(#{@options[:dynamic_sort]})") do |sort|
|
178
|
-
@options[:dynamic_sort] = sort
|
179
|
-
end
|
180
|
-
|
181
|
-
parser.on("--[no-]stream",
|
182
|
-
"Outputs analyzed query on the fly.",
|
183
|
-
"NOTE: --n-entries and --order are ignored.",
|
184
|
-
"(#{@options[:stream]})") do |stream|
|
185
|
-
@options[:stream] = stream
|
186
|
-
end
|
187
|
-
|
188
|
-
parser.on("--[no-]report-summary",
|
189
|
-
"Reports summary at the end.",
|
190
|
-
"(#{@options[:report_summary]})") do |report_summary|
|
191
|
-
@options[:report_summary] = report_summary
|
192
|
-
end
|
193
|
-
end
|
194
|
-
|
195
|
-
def create_reporter(statistics)
|
196
|
-
case @options[:reporter]
|
197
|
-
when "json"
|
198
|
-
require 'json'
|
199
|
-
JSONQueryLogReporter.new(statistics)
|
200
|
-
when "html"
|
201
|
-
HTMLQueryLogReporter.new(statistics)
|
202
|
-
else
|
203
|
-
ConsoleQueryLogReporter.new(statistics)
|
204
|
-
end
|
205
|
-
end
|
206
|
-
|
207
|
-
def create_stream_reporter
|
208
|
-
case @options[:reporter]
|
209
|
-
when "json"
|
210
|
-
require 'json'
|
211
|
-
StreamJSONQueryLogReporter.new
|
212
|
-
when "html"
|
213
|
-
raise UnsupportedReporter, "HTML reporter doesn't support --stream."
|
214
|
-
else
|
215
|
-
StreamConsoleQueryLogReporter.new
|
216
|
-
end
|
217
|
-
end
|
218
|
-
end
|
219
|
-
|
220
|
-
class Command
|
221
|
-
class << self
|
222
|
-
@@registered_commands = {}
|
223
|
-
def register(name, klass)
|
224
|
-
@@registered_commands[name] = klass
|
225
|
-
end
|
226
|
-
|
227
|
-
def parse(input)
|
228
|
-
if input.start_with?("/d/")
|
229
|
-
parse_uri_path(input)
|
230
|
-
else
|
231
|
-
parse_command_line(input)
|
232
|
-
end
|
233
|
-
end
|
234
|
-
|
235
|
-
private
|
236
|
-
def parse_uri_path(path)
|
237
|
-
name, parameters_string = path.split(/\?/, 2)
|
238
|
-
parameters = {}
|
239
|
-
parameters_string.split(/&/).each do |parameter_string|
|
240
|
-
key, value = parameter_string.split(/\=/, 2)
|
241
|
-
parameters[key] = CGI.unescape(value)
|
242
|
-
end
|
243
|
-
name = name.gsub(/\A\/d\//, '')
|
244
|
-
name, output_type = name.split(/\./, 2)
|
245
|
-
parameters["output_type"] = output_type if output_type
|
246
|
-
command_class = @@registered_commands[name] || self
|
247
|
-
command_class.new(name, parameters)
|
248
|
-
end
|
249
|
-
|
250
|
-
def parse_command_line(command_line)
|
251
|
-
name, *options = Shellwords.shellwords(command_line)
|
252
|
-
parameters = {}
|
253
|
-
options.each_slice(2) do |key, value|
|
254
|
-
parameters[key.gsub(/\A--/, '')] = value
|
255
|
-
end
|
256
|
-
command_class = @@registered_commands[name] || self
|
257
|
-
command_class.new(name, parameters)
|
258
|
-
end
|
259
|
-
end
|
260
|
-
|
261
|
-
attr_reader :name, :parameters
|
262
|
-
def initialize(name, parameters)
|
263
|
-
@name = name
|
264
|
-
@parameters = parameters
|
265
|
-
end
|
266
|
-
|
267
|
-
def ==(other)
|
268
|
-
other.is_a?(self.class) and
|
269
|
-
@name == other.name and
|
270
|
-
@parameters == other.parameters
|
271
|
-
end
|
272
|
-
end
|
273
|
-
|
274
|
-
class SelectCommand < Command
|
275
|
-
register("select", self)
|
276
|
-
|
277
|
-
def sortby
|
278
|
-
@parameters["sortby"]
|
279
|
-
end
|
280
|
-
|
281
|
-
def scorer
|
282
|
-
@parameters["scorer"]
|
283
|
-
end
|
284
|
-
|
285
|
-
def query
|
286
|
-
@parameters["query"]
|
287
|
-
end
|
288
|
-
|
289
|
-
def filter
|
290
|
-
@parameters["filter"]
|
291
|
-
end
|
292
|
-
|
293
|
-
def conditions
|
294
|
-
@conditions ||= filter.split(/(?:&&|&!|\|\|)/).collect do |condition|
|
295
|
-
condition = condition.strip
|
296
|
-
condition = condition.gsub(/\A[\s\(]*/, '')
|
297
|
-
condition = condition.gsub(/[\s\)]*\z/, '') unless /\(/ =~ condition
|
298
|
-
condition
|
299
|
-
end
|
300
|
-
end
|
301
|
-
|
302
|
-
def drilldowns
|
303
|
-
@drilldowns ||= (@parameters["drilldown"] || "").split(/\s*,\s*/)
|
304
|
-
end
|
305
|
-
|
306
|
-
def output_columns
|
307
|
-
@parameters["output_columns"]
|
308
|
-
end
|
309
|
-
end
|
310
|
-
|
311
|
-
class Statistic
|
312
|
-
attr_reader :context_id, :start_time, :raw_command
|
313
|
-
attr_reader :elapsed, :return_code
|
314
|
-
attr_accessor :slow_operation_threshold, :slow_response_threshold
|
315
|
-
def initialize(context_id)
|
316
|
-
@context_id = context_id
|
317
|
-
@start_time = nil
|
318
|
-
@command = nil
|
319
|
-
@raw_command = nil
|
320
|
-
@operations = []
|
321
|
-
@elapsed = nil
|
322
|
-
@return_code = 0
|
323
|
-
@slow_operation_threshold = 0.1
|
324
|
-
@slow_response_threshold = 0.2
|
325
|
-
end
|
326
|
-
|
327
|
-
def start(start_time, command)
|
328
|
-
@start_time = start_time
|
329
|
-
@raw_command = command
|
330
|
-
end
|
331
|
-
|
332
|
-
def finish(elapsed, return_code)
|
333
|
-
@elapsed = elapsed
|
334
|
-
@return_code = return_code
|
335
|
-
end
|
336
|
-
|
337
|
-
def command
|
338
|
-
@command ||= Command.parse(@raw_command)
|
339
|
-
end
|
340
|
-
|
341
|
-
def elapsed_in_seconds
|
342
|
-
nano_seconds_to_seconds(@elapsed)
|
343
|
-
end
|
344
|
-
|
345
|
-
def last_time
|
346
|
-
@start_time + elapsed_in_seconds
|
347
|
-
end
|
348
|
-
|
349
|
-
def slow?
|
350
|
-
elapsed_in_seconds >= @slow_response_threshold
|
351
|
-
end
|
352
|
-
|
353
|
-
def each_operation
|
354
|
-
previous_elapsed = 0
|
355
|
-
ensure_parse_command
|
356
|
-
operation_context_context = {
|
357
|
-
:filter_index => 0,
|
358
|
-
:drilldown_index => 0,
|
359
|
-
}
|
360
|
-
@operations.each_with_index do |operation, i|
|
361
|
-
relative_elapsed = operation[:elapsed] - previous_elapsed
|
362
|
-
relative_elapsed_in_seconds = nano_seconds_to_seconds(relative_elapsed)
|
363
|
-
previous_elapsed = operation[:elapsed]
|
364
|
-
parsed_operation = {
|
365
|
-
:i => i,
|
366
|
-
:elapsed => operation[:elapsed],
|
367
|
-
:elapsed_in_seconds => nano_seconds_to_seconds(operation[:elapsed]),
|
368
|
-
:relative_elapsed => relative_elapsed,
|
369
|
-
:relative_elapsed_in_seconds => relative_elapsed_in_seconds,
|
370
|
-
:name => operation[:name],
|
371
|
-
:context => operation_context(operation[:name],
|
372
|
-
operation_context_context),
|
373
|
-
:n_records => operation[:n_records],
|
374
|
-
:slow? => slow_operation?(relative_elapsed_in_seconds),
|
375
|
-
}
|
376
|
-
yield parsed_operation
|
377
|
-
end
|
378
|
-
end
|
379
|
-
|
380
|
-
def add_operation(operation)
|
381
|
-
@operations << operation
|
382
|
-
end
|
383
|
-
|
384
|
-
def operations
|
385
|
-
_operations = []
|
386
|
-
each_operation do |operation|
|
387
|
-
_operations << operation
|
388
|
-
end
|
389
|
-
_operations
|
390
|
-
end
|
391
|
-
|
392
|
-
def select_command?
|
393
|
-
command.name == "select"
|
394
|
-
end
|
395
|
-
|
396
|
-
private
|
397
|
-
def nano_seconds_to_seconds(nano_seconds)
|
398
|
-
nano_seconds / 1000.0 / 1000.0 / 1000.0
|
399
|
-
end
|
400
|
-
|
401
|
-
def operation_context(label, context)
|
402
|
-
case label
|
403
|
-
when "filter"
|
404
|
-
if @select_command.query and context[:query_used].nil?
|
405
|
-
context[:query_used] = true
|
406
|
-
"query: #{@select_command.query}"
|
407
|
-
else
|
408
|
-
index = context[:filter_index]
|
409
|
-
context[:filter_index] += 1
|
410
|
-
@select_command.conditions[index]
|
411
|
-
end
|
412
|
-
when "sort"
|
413
|
-
@select_command.sortby
|
414
|
-
when "score"
|
415
|
-
@select_command.scorer
|
416
|
-
when "output"
|
417
|
-
@select_command.output_columns
|
418
|
-
when "drilldown"
|
419
|
-
index = context[:drilldown_index]
|
420
|
-
context[:drilldown_index] += 1
|
421
|
-
@select_command.drilldowns[index]
|
422
|
-
else
|
423
|
-
nil
|
424
|
-
end
|
425
|
-
end
|
426
|
-
|
427
|
-
def ensure_parse_command
|
428
|
-
return unless select_command?
|
429
|
-
@select_command = SelectCommand.parse(@raw_command)
|
430
|
-
end
|
431
|
-
|
432
|
-
def slow_operation?(elapsed)
|
433
|
-
elapsed >= @slow_operation_threshold
|
434
|
-
end
|
435
|
-
end
|
436
|
-
|
437
|
-
class SizedGroupedOperations < Array
|
438
|
-
def initialize
|
439
|
-
@max_size = 10
|
440
|
-
@sorter = create_sorter
|
441
|
-
end
|
442
|
-
|
443
|
-
def apply_options(options)
|
444
|
-
@max_size = options[:n_entries]
|
445
|
-
end
|
446
|
-
|
447
|
-
def each
|
448
|
-
i = 0
|
449
|
-
super do |grouped_operation|
|
450
|
-
break if i >= @max_size
|
451
|
-
i += 1
|
452
|
-
yield(grouped_operation)
|
453
|
-
end
|
454
|
-
end
|
455
|
-
|
456
|
-
def <<(operation)
|
457
|
-
each do |grouped_operation|
|
458
|
-
if grouped_operation[:name] == operation[:name] and
|
459
|
-
grouped_operation[:context] == operation[:context]
|
460
|
-
elapsed = operation[:relative_elapsed_in_seconds]
|
461
|
-
grouped_operation[:total_elapsed] += elapsed
|
462
|
-
grouped_operation[:n_operations] += 1
|
463
|
-
replace(sort_by(&@sorter))
|
464
|
-
return self
|
465
|
-
end
|
466
|
-
end
|
467
|
-
|
468
|
-
grouped_operation = {
|
469
|
-
:name => operation[:name],
|
470
|
-
:context => operation[:context],
|
471
|
-
:n_operations => 1,
|
472
|
-
:total_elapsed => operation[:relative_elapsed_in_seconds],
|
473
|
-
}
|
474
|
-
buffer_size = @max_size * 100
|
475
|
-
if size < buffer_size
|
476
|
-
super(grouped_operation)
|
477
|
-
replace(sort_by(&@sorter))
|
478
|
-
else
|
479
|
-
if @sorter.call(grouped_operation) < @sorter.call(last)
|
480
|
-
super(grouped_operation)
|
481
|
-
sorted_operations = sort_by(&@sorter)
|
482
|
-
sorted_operations.pop
|
483
|
-
replace(sorted_operations)
|
484
|
-
end
|
485
|
-
end
|
486
|
-
self
|
487
|
-
end
|
488
|
-
|
489
|
-
private
|
490
|
-
def create_sorter
|
491
|
-
lambda do |grouped_operation|
|
492
|
-
-grouped_operation[:total_elapsed]
|
493
|
-
end
|
494
|
-
end
|
495
|
-
end
|
496
|
-
|
497
|
-
class SizedStatistics < Array
|
498
|
-
attr_reader :n_responses, :n_slow_responses, :n_slow_operations
|
499
|
-
attr_reader :slow_operations, :total_elapsed
|
500
|
-
attr_reader :start_time, :last_time
|
501
|
-
attr_accessor :slow_operation_threshold, :slow_response_threshold
|
502
|
-
def initialize
|
503
|
-
@max_size = 10
|
504
|
-
self.order = "-elapsed"
|
505
|
-
@slow_operation_threshold = 0.1
|
506
|
-
@slow_response_threshold = 0.2
|
507
|
-
@start_time = nil
|
508
|
-
@last_time = nil
|
509
|
-
@n_responses = 0
|
510
|
-
@n_slow_responses = 0
|
511
|
-
@n_slow_operations = 0
|
512
|
-
@slow_operations = SizedGroupedOperations.new
|
513
|
-
@total_elapsed = 0
|
514
|
-
@collect_slow_statistics = true
|
515
|
-
end
|
516
|
-
|
517
|
-
def order=(new_order)
|
518
|
-
@order = new_order
|
519
|
-
@sorter = create_sorter
|
520
|
-
end
|
521
|
-
|
522
|
-
def apply_options(options)
|
523
|
-
@max_size = options[:n_entries] || @max_size
|
524
|
-
self.order = options[:order] || @order
|
525
|
-
@slow_operation_threshold =
|
526
|
-
options[:slow_operation_threshold] || @slow_operation_threshold
|
527
|
-
@slow_response_threshold =
|
528
|
-
options[:slow_response_threshold] || @slow_response_threshold
|
529
|
-
unless options[:report_summary].nil?
|
530
|
-
@collect_slow_statistics = options[:report_summary]
|
531
|
-
end
|
532
|
-
@slow_operations.apply_options(options)
|
533
|
-
end
|
534
|
-
|
535
|
-
def <<(statistic)
|
536
|
-
update_statistic(statistic)
|
537
|
-
if size < @max_size
|
538
|
-
super(statistic)
|
539
|
-
replace(self)
|
540
|
-
else
|
541
|
-
if @sorter.call(statistic) < @sorter.call(last)
|
542
|
-
super(statistic)
|
543
|
-
replace(self)
|
544
|
-
end
|
545
|
-
end
|
546
|
-
self
|
547
|
-
end
|
548
|
-
|
549
|
-
def replace(other)
|
550
|
-
sorted_other = other.sort_by(&@sorter)
|
551
|
-
if sorted_other.size > @max_size
|
552
|
-
super(sorted_other[0, @max_size])
|
553
|
-
else
|
554
|
-
super(sorted_other)
|
555
|
-
end
|
556
|
-
end
|
557
|
-
|
558
|
-
def responses_per_second
|
559
|
-
_period = period
|
560
|
-
if _period.zero?
|
561
|
-
0
|
562
|
-
else
|
563
|
-
@n_responses.to_f / _period
|
564
|
-
end
|
565
|
-
end
|
566
|
-
|
567
|
-
def slow_response_ratio
|
568
|
-
if @n_responses.zero?
|
569
|
-
0
|
570
|
-
else
|
571
|
-
(@n_slow_responses.to_f / @n_responses) * 100
|
572
|
-
end
|
573
|
-
end
|
574
|
-
|
575
|
-
def period
|
576
|
-
if @start_time and @last_time
|
577
|
-
@last_time - @start_time
|
578
|
-
else
|
579
|
-
0
|
580
|
-
end
|
581
|
-
end
|
582
|
-
|
583
|
-
def each_slow_operation
|
584
|
-
@slow_operations.each do |grouped_operation|
|
585
|
-
total_elapsed = grouped_operation[:total_elapsed]
|
586
|
-
n_operations = grouped_operation[:n_operations]
|
587
|
-
ratios = {
|
588
|
-
:total_elapsed_ratio => total_elapsed / @total_elapsed * 100,
|
589
|
-
:n_operations_ratio => n_operations / @n_slow_operations.to_f * 100,
|
590
|
-
}
|
591
|
-
yield(grouped_operation.merge(ratios))
|
592
|
-
end
|
593
|
-
end
|
594
|
-
|
595
|
-
private
|
596
|
-
def create_sorter
|
597
|
-
case @order
|
598
|
-
when "-elapsed"
|
599
|
-
lambda do |statistic|
|
600
|
-
-statistic.elapsed
|
601
|
-
end
|
602
|
-
when "elapsed"
|
603
|
-
lambda do |statistic|
|
604
|
-
statistic.elapsed
|
605
|
-
end
|
606
|
-
when "-start-time"
|
607
|
-
lambda do |statistic|
|
608
|
-
-statistic.start_time
|
609
|
-
end
|
610
|
-
else
|
611
|
-
lambda do |statistic|
|
612
|
-
statistic.start_time
|
613
|
-
end
|
614
|
-
end
|
615
|
-
end
|
616
|
-
|
617
|
-
def update_statistic(statistic)
|
618
|
-
statistic.slow_response_threshold = @slow_response_threshold
|
619
|
-
statistic.slow_operation_threshold = @slow_operation_threshold
|
620
|
-
@start_time ||= statistic.start_time
|
621
|
-
@start_time = [@start_time, statistic.start_time].min
|
622
|
-
@last_time ||= statistic.last_time
|
623
|
-
@last_time = [@last_time, statistic.last_time].max
|
624
|
-
@n_responses += 1
|
625
|
-
@total_elapsed += statistic.elapsed_in_seconds
|
626
|
-
return unless @collect_slow_statistics
|
627
|
-
if statistic.slow?
|
628
|
-
@n_slow_responses += 1
|
629
|
-
if statistic.select_command?
|
630
|
-
statistic.each_operation do |operation|
|
631
|
-
next unless operation[:slow?]
|
632
|
-
@n_slow_operations += 1
|
633
|
-
@slow_operations << operation
|
634
|
-
end
|
635
|
-
end
|
636
|
-
end
|
637
|
-
end
|
638
|
-
end
|
639
|
-
|
640
|
-
class QueryLogParser
|
641
|
-
def initialize
|
642
|
-
@mutex = Mutex.new
|
643
|
-
end
|
644
|
-
|
645
|
-
def parse(input, &block)
|
646
|
-
current_statistics = {}
|
647
|
-
input.each_line do |line|
|
648
|
-
case line
|
649
|
-
when /\A(\d{4})-(\d\d)-(\d\d) (\d\d):(\d\d):(\d\d)\.(\d+)\|(.+?)\|([>:<])/
|
650
|
-
year, month, day, hour, minutes, seconds, micro_seconds =
|
651
|
-
$1, $2, $3, $4, $5, $6, $7
|
652
|
-
context_id = $8
|
653
|
-
type = $9
|
654
|
-
rest = $POSTMATCH.strip
|
655
|
-
time_stamp = Time.local(year, month, day, hour, minutes, seconds,
|
656
|
-
micro_seconds)
|
657
|
-
parse_line(current_statistics,
|
658
|
-
time_stamp, context_id, type, rest, &block)
|
659
|
-
end
|
660
|
-
end
|
661
|
-
end
|
662
|
-
|
663
|
-
private
|
664
|
-
def parse_line(current_statistics,
|
665
|
-
time_stamp, context_id, type, rest, &block)
|
666
|
-
case type
|
667
|
-
when ">"
|
668
|
-
statistic = Statistic.new(context_id)
|
669
|
-
statistic.start(time_stamp, rest)
|
670
|
-
current_statistics[context_id] = statistic
|
671
|
-
when ":"
|
672
|
-
return unless /\A(\d+) (.+)\((\d+)\)/ =~ rest
|
673
|
-
elapsed = $1
|
674
|
-
name = $2
|
675
|
-
n_records = $3.to_i
|
676
|
-
statistic = current_statistics[context_id]
|
677
|
-
return if statistic.nil?
|
678
|
-
statistic.add_operation(:name => name,
|
679
|
-
:elapsed => elapsed.to_i,
|
680
|
-
:n_records => n_records)
|
681
|
-
when "<"
|
682
|
-
return unless /\A(\d+) rc=(\d+)/ =~ rest
|
683
|
-
elapsed = $1
|
684
|
-
return_code = $2
|
685
|
-
statistic = current_statistics.delete(context_id)
|
686
|
-
return if statistic.nil?
|
687
|
-
statistic.finish(elapsed.to_i, return_code.to_i)
|
688
|
-
block.call(statistic)
|
689
|
-
end
|
690
|
-
end
|
691
|
-
end
|
692
|
-
|
693
|
-
class Streamer
|
694
|
-
def initialize(reporter)
|
695
|
-
@reporter = reporter
|
696
|
-
end
|
697
|
-
|
698
|
-
def start
|
699
|
-
@reporter.start
|
700
|
-
end
|
701
|
-
|
702
|
-
def <<(statistic)
|
703
|
-
@reporter.report_statistic(statistic)
|
704
|
-
end
|
705
|
-
|
706
|
-
def finish
|
707
|
-
@reporter.finish
|
708
|
-
end
|
709
|
-
end
|
710
|
-
|
711
|
-
class QueryLogReporter
|
712
|
-
include Enumerable
|
713
|
-
|
714
|
-
attr_reader :output
|
715
|
-
def initialize(statistics)
|
716
|
-
@statistics = statistics
|
717
|
-
@report_summary = true
|
718
|
-
@output = $stdout
|
719
|
-
end
|
720
|
-
|
721
|
-
def apply_options(options)
|
722
|
-
self.output = options[:output] || @output
|
723
|
-
unless options[:report_summary].nil?
|
724
|
-
@report_summary = options[:report_summary]
|
725
|
-
end
|
726
|
-
end
|
727
|
-
|
728
|
-
def output=(output)
|
729
|
-
@output = output
|
730
|
-
@output = $stdout if @output == "-"
|
731
|
-
end
|
732
|
-
|
733
|
-
def each
|
734
|
-
@statistics.each do |statistic|
|
735
|
-
yield statistic
|
736
|
-
end
|
737
|
-
end
|
738
|
-
|
739
|
-
def report
|
740
|
-
setup do
|
741
|
-
report_summary if @report_summary
|
742
|
-
report_statistics
|
743
|
-
end
|
744
|
-
end
|
745
|
-
|
746
|
-
def report_statistics
|
747
|
-
each do |statistic|
|
748
|
-
report_statistic(statistic)
|
749
|
-
end
|
750
|
-
end
|
751
|
-
|
752
|
-
private
|
753
|
-
def setup
|
754
|
-
setup_output do
|
755
|
-
start
|
756
|
-
yield
|
757
|
-
finish
|
758
|
-
end
|
759
|
-
end
|
760
|
-
|
761
|
-
def setup_output
|
762
|
-
original_output = @output
|
763
|
-
if @output.is_a?(String)
|
764
|
-
File.open(@output, "w") do |output|
|
765
|
-
@output = output
|
766
|
-
yield(@output)
|
767
|
-
end
|
768
|
-
else
|
769
|
-
yield(@output)
|
770
|
-
end
|
771
|
-
ensure
|
772
|
-
@output = original_output
|
773
|
-
end
|
774
|
-
|
775
|
-
def write(*args)
|
776
|
-
@output.write(*args)
|
777
|
-
end
|
778
|
-
|
779
|
-
def format_time(time)
|
780
|
-
if time.nil?
|
781
|
-
"NaN"
|
782
|
-
else
|
783
|
-
time.strftime("%Y-%m-%d %H:%M:%S.%u")
|
784
|
-
end
|
785
|
-
end
|
786
|
-
end
|
787
|
-
|
788
|
-
class ConsoleQueryLogReporter < QueryLogReporter
|
789
|
-
class Color
|
790
|
-
NAMES = ["black", "red", "green", "yellow",
|
791
|
-
"blue", "magenta", "cyan", "white"]
|
792
|
-
|
793
|
-
attr_reader :name
|
794
|
-
def initialize(name, options={})
|
795
|
-
@name = name
|
796
|
-
@foreground = options[:foreground]
|
797
|
-
@foreground = true if @foreground.nil?
|
798
|
-
@intensity = options[:intensity]
|
799
|
-
@bold = options[:bold]
|
800
|
-
@italic = options[:italic]
|
801
|
-
@underline = options[:underline]
|
802
|
-
end
|
803
|
-
|
804
|
-
def foreground?
|
805
|
-
@foreground
|
806
|
-
end
|
807
|
-
|
808
|
-
def intensity?
|
809
|
-
@intensity
|
810
|
-
end
|
811
|
-
|
812
|
-
def bold?
|
813
|
-
@bold
|
814
|
-
end
|
815
|
-
|
816
|
-
def italic?
|
817
|
-
@italic
|
818
|
-
end
|
819
|
-
|
820
|
-
def underline?
|
821
|
-
@underline
|
822
|
-
end
|
823
|
-
|
824
|
-
def ==(other)
|
825
|
-
self.class === other and
|
826
|
-
[name, foreground?, intensity?,
|
827
|
-
bold?, italic?, underline?] ==
|
828
|
-
[other.name, other.foreground?, other.intensity?,
|
829
|
-
other.bold?, other.italic?, other.underline?]
|
830
|
-
end
|
831
|
-
|
832
|
-
def sequence
|
833
|
-
sequence = []
|
834
|
-
if @name == "none"
|
835
|
-
elsif @name == "reset"
|
836
|
-
sequence << "0"
|
837
|
-
else
|
838
|
-
foreground_parameter = foreground? ? 3 : 4
|
839
|
-
foreground_parameter += 6 if intensity?
|
840
|
-
sequence << "#{foreground_parameter}#{NAMES.index(@name)}"
|
841
|
-
end
|
842
|
-
sequence << "1" if bold?
|
843
|
-
sequence << "3" if italic?
|
844
|
-
sequence << "4" if underline?
|
845
|
-
sequence
|
846
|
-
end
|
847
|
-
|
848
|
-
def escape_sequence
|
849
|
-
"\e[#{sequence.join(';')}m"
|
850
|
-
end
|
851
|
-
|
852
|
-
def +(other)
|
853
|
-
MixColor.new([self, other])
|
854
|
-
end
|
855
|
-
end
|
856
|
-
|
857
|
-
class MixColor
|
858
|
-
attr_reader :colors
|
859
|
-
def initialize(colors)
|
860
|
-
@colors = colors
|
861
|
-
end
|
862
|
-
|
863
|
-
def sequence
|
864
|
-
@colors.inject([]) do |result, color|
|
865
|
-
result + color.sequence
|
866
|
-
end
|
867
|
-
end
|
868
|
-
|
869
|
-
def escape_sequence
|
870
|
-
"\e[#{sequence.join(';')}m"
|
871
|
-
end
|
872
|
-
|
873
|
-
def +(other)
|
874
|
-
self.class.new([self, other])
|
875
|
-
end
|
876
|
-
|
877
|
-
def ==(other)
|
878
|
-
self.class === other and colors == other.colors
|
879
|
-
end
|
880
|
-
end
|
881
|
-
|
882
|
-
def initialize(statistics)
|
883
|
-
super
|
884
|
-
@color = :auto
|
885
|
-
@reset_color = Color.new("reset")
|
886
|
-
@color_schema = {
|
887
|
-
:elapsed => {:foreground => :white, :background => :green},
|
888
|
-
:time => {:foreground => :white, :background => :cyan},
|
889
|
-
:slow => {:foreground => :white, :background => :red},
|
890
|
-
}
|
891
|
-
end
|
892
|
-
|
893
|
-
def apply_options(options)
|
894
|
-
super
|
895
|
-
@color = options[:color] || @color
|
896
|
-
end
|
897
|
-
|
898
|
-
def report_statistics
|
899
|
-
write("\n")
|
900
|
-
write("Slow Queries:\n")
|
901
|
-
super
|
902
|
-
end
|
903
|
-
|
904
|
-
def report_statistic(statistic)
|
905
|
-
@index += 1
|
906
|
-
write("%*d) %s" % [@digit, @index, format_heading(statistic)])
|
907
|
-
report_parameters(statistic)
|
908
|
-
report_operations(statistic)
|
909
|
-
end
|
910
|
-
|
911
|
-
def start
|
912
|
-
@index = 0
|
913
|
-
if @statistics.size.zero?
|
914
|
-
@digit = 1
|
915
|
-
else
|
916
|
-
@digit = Math.log10(@statistics.size).truncate + 1
|
917
|
-
end
|
918
|
-
end
|
919
|
-
|
920
|
-
def finish
|
921
|
-
end
|
922
|
-
|
923
|
-
private
|
924
|
-
def setup
|
925
|
-
super do
|
926
|
-
setup_color do
|
927
|
-
yield
|
928
|
-
end
|
929
|
-
end
|
930
|
-
end
|
931
|
-
|
932
|
-
def report_summary
|
933
|
-
write("Summary:\n")
|
934
|
-
write(" Threshold:\n")
|
935
|
-
write(" slow response : #{@statistics.slow_response_threshold}\n")
|
936
|
-
write(" slow operation : #{@statistics.slow_operation_threshold}\n")
|
937
|
-
write(" # of responses : #{@statistics.n_responses}\n")
|
938
|
-
write(" # of slow responses : #{@statistics.n_slow_responses}\n")
|
939
|
-
write(" responses/sec : #{@statistics.responses_per_second}\n")
|
940
|
-
write(" start time : #{format_time(@statistics.start_time)}\n")
|
941
|
-
write(" last time : #{format_time(@statistics.last_time)}\n")
|
942
|
-
write(" period(sec) : #{@statistics.period}\n")
|
943
|
-
slow_response_ratio = @statistics.slow_response_ratio
|
944
|
-
write(" slow response ratio : %5.3f%%\n" % slow_response_ratio)
|
945
|
-
write(" total response time : #{@statistics.total_elapsed}\n")
|
946
|
-
report_slow_operations
|
947
|
-
end
|
948
|
-
|
949
|
-
def report_slow_operations
|
950
|
-
write(" Slow Operations:\n")
|
951
|
-
total_elapsed_digit = nil
|
952
|
-
total_elapsed_decimal_digit = 6
|
953
|
-
n_operations_digit = nil
|
954
|
-
@statistics.each_slow_operation do |grouped_operation|
|
955
|
-
total_elapsed = grouped_operation[:total_elapsed]
|
956
|
-
total_elapsed_digit ||= Math.log10(total_elapsed).truncate + 1
|
957
|
-
n_operations = grouped_operation[:n_operations]
|
958
|
-
n_operations_digit ||= Math.log10(n_operations).truncate + 1
|
959
|
-
parameters = [total_elapsed_digit + 1 + total_elapsed_decimal_digit,
|
960
|
-
total_elapsed_decimal_digit,
|
961
|
-
total_elapsed,
|
962
|
-
grouped_operation[:total_elapsed_ratio],
|
963
|
-
n_operations_digit,
|
964
|
-
n_operations,
|
965
|
-
grouped_operation[:n_operations_ratio],
|
966
|
-
grouped_operation[:name],
|
967
|
-
grouped_operation[:context]]
|
968
|
-
write(" [%*.*f](%5.2f%%) [%*d](%5.2f%%) %9s: %s\n" % parameters)
|
969
|
-
end
|
970
|
-
end
|
971
|
-
|
972
|
-
def report_parameters(statistic)
|
973
|
-
command = statistic.command
|
974
|
-
write(" name: <#{command.name}>\n")
|
975
|
-
write(" parameters:\n")
|
976
|
-
command.parameters.each do |key, value|
|
977
|
-
write(" <#{key}>: <#{value}>\n")
|
978
|
-
end
|
979
|
-
end
|
980
|
-
|
981
|
-
def report_operations(statistic)
|
982
|
-
statistic.each_operation do |operation|
|
983
|
-
relative_elapsed_in_seconds = operation[:relative_elapsed_in_seconds]
|
984
|
-
formatted_elapsed = "%8.8f" % relative_elapsed_in_seconds
|
985
|
-
if operation[:slow?]
|
986
|
-
formatted_elapsed = colorize(formatted_elapsed, :slow)
|
987
|
-
end
|
988
|
-
operation_report = " %2d) %s: %10s" % [operation[:i] + 1,
|
989
|
-
formatted_elapsed,
|
990
|
-
operation[:name]]
|
991
|
-
if operation[:n_records]
|
992
|
-
operation_report << "(%6d)" % operation[:n_records]
|
993
|
-
else
|
994
|
-
operation_report << "(%6s)" % ""
|
995
|
-
end
|
996
|
-
context = operation[:context]
|
997
|
-
if context
|
998
|
-
context = colorize(context, :slow) if operation[:slow?]
|
999
|
-
operation_report << " " << context
|
1000
|
-
end
|
1001
|
-
write("#{operation_report}\n")
|
1002
|
-
end
|
1003
|
-
write("\n")
|
1004
|
-
end
|
1005
|
-
|
1006
|
-
def guess_color_availability(output)
|
1007
|
-
return false unless output.tty?
|
1008
|
-
case ENV["TERM"]
|
1009
|
-
when /term(?:-color)?\z/, "screen"
|
1010
|
-
true
|
1011
|
-
else
|
1012
|
-
return true if ENV["EMACS"] == "t"
|
1013
|
-
false
|
1014
|
-
end
|
1015
|
-
end
|
1016
|
-
|
1017
|
-
def setup_color
|
1018
|
-
color = @color
|
1019
|
-
@color = guess_color_availability(@output) if @color == :auto
|
1020
|
-
yield
|
1021
|
-
ensure
|
1022
|
-
@color = color
|
1023
|
-
end
|
1024
|
-
|
1025
|
-
def format_heading(statistic)
|
1026
|
-
formatted_elapsed = colorize("%8.8f" % statistic.elapsed_in_seconds,
|
1027
|
-
:elapsed)
|
1028
|
-
"[%s-%s (%s)](%d): %s" % [format_time(statistic.start_time),
|
1029
|
-
format_time(statistic.last_time),
|
1030
|
-
formatted_elapsed,
|
1031
|
-
statistic.return_code,
|
1032
|
-
statistic.raw_command]
|
1033
|
-
end
|
1034
|
-
|
1035
|
-
def format_time(time)
|
1036
|
-
colorize(super, :time)
|
1037
|
-
end
|
1038
|
-
|
1039
|
-
def colorize(text, schema_name)
|
1040
|
-
return text unless @color
|
1041
|
-
options = @color_schema[schema_name]
|
1042
|
-
color = Color.new("none")
|
1043
|
-
if options[:foreground]
|
1044
|
-
color += Color.new(options[:foreground].to_s, :bold => true)
|
1045
|
-
end
|
1046
|
-
if options[:background]
|
1047
|
-
color += Color.new(options[:background].to_s, :foreground => false)
|
1048
|
-
end
|
1049
|
-
"%s%s%s" % [color.escape_sequence, text, @reset_color.escape_sequence]
|
1050
|
-
end
|
1051
|
-
end
|
1052
|
-
|
1053
|
-
class JSONQueryLogReporter < QueryLogReporter
|
1054
|
-
def report_statistic(statistic)
|
1055
|
-
write(",") if @index > 0
|
1056
|
-
write("\n")
|
1057
|
-
write(format_statistic(statistic))
|
1058
|
-
@index += 1
|
1059
|
-
end
|
1060
|
-
|
1061
|
-
def start
|
1062
|
-
@index = 0
|
1063
|
-
write("[")
|
1064
|
-
end
|
1065
|
-
|
1066
|
-
def finish
|
1067
|
-
write("\n")
|
1068
|
-
write("]\n")
|
1069
|
-
end
|
1070
|
-
|
1071
|
-
def report_summary
|
1072
|
-
# TODO
|
1073
|
-
end
|
1074
|
-
|
1075
|
-
private
|
1076
|
-
def format_statistic(statistic)
|
1077
|
-
data = {
|
1078
|
-
"start_time" => statistic.start_time.to_i,
|
1079
|
-
"last_time" => statistic.last_time.to_i,
|
1080
|
-
"elapsed" => statistic.elapsed_in_seconds,
|
1081
|
-
"return_code" => statistic.return_code,
|
1082
|
-
}
|
1083
|
-
command = statistic.command
|
1084
|
-
parameters = command.parameters.collect do |key, value|
|
1085
|
-
{"key" => key, "value" => value}
|
1086
|
-
end
|
1087
|
-
data["command"] = {
|
1088
|
-
"raw" => statistic.raw_command,
|
1089
|
-
"name" => command.name,
|
1090
|
-
"parameters" => parameters,
|
1091
|
-
}
|
1092
|
-
operations = []
|
1093
|
-
statistic.each_operation do |operation|
|
1094
|
-
operation_data = {}
|
1095
|
-
operation_data["name"] = operation[:name]
|
1096
|
-
operation_data["relative_elapsed"] = operation[:relative_elapsed_in_seconds]
|
1097
|
-
operation_data["context"] = operation[:context]
|
1098
|
-
operations << operation_data
|
1099
|
-
end
|
1100
|
-
data["operations"] = operations
|
1101
|
-
JSON.generate(data)
|
1102
|
-
end
|
1103
|
-
end
|
1104
|
-
|
1105
|
-
class HTMLQueryLogReporter < QueryLogReporter
|
1106
|
-
include ERB::Util
|
1107
|
-
|
1108
|
-
def report_statistic(statistic)
|
1109
|
-
write(",") if @index > 0
|
1110
|
-
write("\n")
|
1111
|
-
write(format_statistic(statistic))
|
1112
|
-
@index += 1
|
1113
|
-
end
|
1114
|
-
|
1115
|
-
def start
|
1116
|
-
write(header)
|
1117
|
-
end
|
1118
|
-
|
1119
|
-
def finish
|
1120
|
-
write(footer)
|
1121
|
-
end
|
1122
|
-
|
1123
|
-
def report_summary
|
1124
|
-
summary_html = erb(<<-EOH, __LINE__ + 1, binding)
|
1125
|
-
<h2>Summary</h2>
|
1126
|
-
<div class="summary">
|
1127
|
-
<%= analyze_parameters %>
|
1128
|
-
<%= metrics %>
|
1129
|
-
<%= slow_operations %>
|
1130
|
-
</div>
|
1131
|
-
EOH
|
1132
|
-
write(summary_html)
|
1133
|
-
end
|
1134
|
-
|
1135
|
-
def report_statistics
|
1136
|
-
write(statistics_header)
|
1137
|
-
super
|
1138
|
-
write(statistics_footer)
|
1139
|
-
end
|
1140
|
-
|
1141
|
-
def report_statistic(statistic)
|
1142
|
-
command = statistic.command
|
1143
|
-
statistic_html = erb(<<-EOH, __LINE__ + 1, binding)
|
1144
|
-
<div class="statistic-heading">
|
1145
|
-
<h3>Command</h3>
|
1146
|
-
<div class="metrics">
|
1147
|
-
[<%= format_time(statistic.start_time) %>
|
1148
|
-
-
|
1149
|
-
<%= format_time(statistic.last_time) %>
|
1150
|
-
(<%= format_elapsed(statistic.elapsed_in_seconds,
|
1151
|
-
:slow? => statistic.slow?) %>)]
|
1152
|
-
(<%= span({:class => "return-code"}, h(statistic.return_code)) %>)
|
1153
|
-
</div>
|
1154
|
-
<%= div({:class => "raw-command"}, h(statistic.raw_command)) %>
|
1155
|
-
</div>
|
1156
|
-
<div class="statistic-parameters">
|
1157
|
-
<h3>Parameters</h3>
|
1158
|
-
<dl>
|
1159
|
-
<dt>name</dt>
|
1160
|
-
<dd><%= h(command.name) %></dd>
|
1161
|
-
<% command.parameters.each do |key, value| %>
|
1162
|
-
<dt><%= h(key) %></dt>
|
1163
|
-
<dd><%= h(value) %></dd>
|
1164
|
-
<% end %>
|
1165
|
-
</dl>
|
1166
|
-
</div>
|
1167
|
-
<div class="statistic-operations">
|
1168
|
-
<h3>Operations</h3>
|
1169
|
-
<ol>
|
1170
|
-
<% statistic.each_operation do |operation| %>
|
1171
|
-
<li>
|
1172
|
-
<%= format_elapsed(operation[:relative_elapsed_in_seconds],
|
1173
|
-
:slow? => operation[:slow?]) %>:
|
1174
|
-
<%= span({:class => "name"}, h(operation[:name])) %>:
|
1175
|
-
<%= span({:class => "context"}, h(operation[:context])) %>
|
1176
|
-
</li>
|
1177
|
-
<% end %>
|
1178
|
-
</ol>
|
1179
|
-
</div>
|
1180
|
-
EOH
|
1181
|
-
write(statistic_html)
|
1182
|
-
end
|
1183
|
-
|
1184
|
-
private
|
1185
|
-
def erb(content, line, _binding=nil)
|
1186
|
-
_erb = ERB.new(content, nil, "<>")
|
1187
|
-
eval(_erb.src, _binding || binding, __FILE__, line)
|
1188
|
-
end
|
1189
|
-
|
1190
|
-
def header
|
1191
|
-
erb(<<-EOH, __LINE__ + 1)
|
1192
|
-
<html>
|
1193
|
-
<head>
|
1194
|
-
<title>groonga query analyzer</title>
|
1195
|
-
<style>
|
1196
|
-
table,
|
1197
|
-
table tr,
|
1198
|
-
table tr th,
|
1199
|
-
table tr td
|
1200
|
-
{
|
1201
|
-
border: 1px solid black;
|
1202
|
-
}
|
1203
|
-
|
1204
|
-
span.slow
|
1205
|
-
{
|
1206
|
-
color: red;
|
1207
|
-
}
|
1208
|
-
|
1209
|
-
div.parameters
|
1210
|
-
{
|
1211
|
-
float: left;
|
1212
|
-
padding: 2em;
|
1213
|
-
}
|
1214
|
-
|
1215
|
-
div.parameters h3
|
1216
|
-
{
|
1217
|
-
text-align: center;
|
1218
|
-
}
|
1219
|
-
|
1220
|
-
div.parameters table
|
1221
|
-
{
|
1222
|
-
margin-right: auto;
|
1223
|
-
margin-left: auto;
|
1224
|
-
}
|
1225
|
-
|
1226
|
-
div.statistics
|
1227
|
-
{
|
1228
|
-
clear: both;
|
1229
|
-
}
|
1230
|
-
|
1231
|
-
td.elapsed,
|
1232
|
-
td.ratio,
|
1233
|
-
td.n
|
1234
|
-
{
|
1235
|
-
text-align: right;
|
1236
|
-
}
|
1237
|
-
|
1238
|
-
td.name
|
1239
|
-
{
|
1240
|
-
text-align: center;
|
1241
|
-
}
|
1242
|
-
</style>
|
1243
|
-
</head>
|
1244
|
-
<body>
|
1245
|
-
<h1>groonga query analyzer</h1>
|
1246
|
-
EOH
|
1247
|
-
end
|
1248
|
-
|
1249
|
-
def footer
|
1250
|
-
erb(<<-EOH, __LINE__ + 1)
|
1251
|
-
</body>
|
1252
|
-
</html>
|
1253
|
-
EOH
|
1254
|
-
end
|
1255
|
-
|
1256
|
-
def statistics_header
|
1257
|
-
erb(<<-EOH, __LINE__ + 1)
|
1258
|
-
<h2>Slow Queries</h2>
|
1259
|
-
<div>
|
1260
|
-
EOH
|
1261
|
-
end
|
1262
|
-
|
1263
|
-
def statistics_footer
|
1264
|
-
erb(<<-EOH, __LINE__ + 1)
|
1265
|
-
</div>
|
1266
|
-
EOH
|
1267
|
-
end
|
1268
|
-
|
1269
|
-
def analyze_parameters
|
1270
|
-
erb(<<-EOH, __LINE__ + 1)
|
1271
|
-
<div class="parameters">
|
1272
|
-
<h3>Analyze Parameters</h3>
|
1273
|
-
<table>
|
1274
|
-
<tr><th>Name</th><th>Value</th></tr>
|
1275
|
-
<tr>
|
1276
|
-
<th>Slow response threshold</th>
|
1277
|
-
<td><%= h(@statistics.slow_response_threshold) %>sec</td>
|
1278
|
-
</tr>
|
1279
|
-
<tr>
|
1280
|
-
<th>Slow operation threshold</th>
|
1281
|
-
<td><%= h(@statistics.slow_operation_threshold) %>sec</td>
|
1282
|
-
</tr>
|
1283
|
-
</table>
|
1284
|
-
</div>
|
1285
|
-
EOH
|
1286
|
-
end
|
1287
|
-
|
1288
|
-
def metrics
|
1289
|
-
erb(<<-EOH, __LINE__ + 1)
|
1290
|
-
<div class="parameters">
|
1291
|
-
<h3>Metrics</h3>
|
1292
|
-
<table>
|
1293
|
-
<tr><th>Name</th><th>Value</th></tr>
|
1294
|
-
<tr>
|
1295
|
-
<th># of responses</th>
|
1296
|
-
<td><%= h(@statistics.n_responses) %></td>
|
1297
|
-
</tr>
|
1298
|
-
<tr>
|
1299
|
-
<th># of slow responses</th>
|
1300
|
-
<td><%= h(@statistics.n_slow_responses) %></td>
|
1301
|
-
</tr>
|
1302
|
-
<tr>
|
1303
|
-
<th>responses/sec</th>
|
1304
|
-
<td><%= h(@statistics.responses_per_second) %></td>
|
1305
|
-
</tr>
|
1306
|
-
<tr>
|
1307
|
-
<th>start time</th>
|
1308
|
-
<td><%= format_time(@statistics.start_time) %></td>
|
1309
|
-
</tr>
|
1310
|
-
<tr>
|
1311
|
-
<th>last time</th>
|
1312
|
-
<td><%= format_time(@statistics.last_time) %></td>
|
1313
|
-
</tr>
|
1314
|
-
<tr>
|
1315
|
-
<th>period</th>
|
1316
|
-
<td><%= h(@statistics.period) %>sec</td>
|
1317
|
-
</tr>
|
1318
|
-
<tr>
|
1319
|
-
<th>slow response ratio</th>
|
1320
|
-
<td><%= h(@statistics.slow_response_ratio) %>%</td>
|
1321
|
-
</tr>
|
1322
|
-
<tr>
|
1323
|
-
<th>total response time</th>
|
1324
|
-
<td><%= h(@statistics.total_elapsed) %>sec</td>
|
1325
|
-
</tr>
|
1326
|
-
</table>
|
1327
|
-
</div>
|
1328
|
-
EOH
|
1329
|
-
end
|
1330
|
-
|
1331
|
-
def slow_operations
|
1332
|
-
erb(<<-EOH, __LINE__ + 1)
|
1333
|
-
<div class="statistics">
|
1334
|
-
<h3>Slow Operations</h3>
|
1335
|
-
<table class="slow-operations">
|
1336
|
-
<tr>
|
1337
|
-
<th>total elapsed(sec)</th>
|
1338
|
-
<th>total elapsed(%)</th>
|
1339
|
-
<th># of operations</th>
|
1340
|
-
<th># of operations(%)</th>
|
1341
|
-
<th>operation name</th>
|
1342
|
-
<th>context</th>
|
1343
|
-
</tr>
|
1344
|
-
<% @statistics.each_slow_operation do |grouped_operation| %>
|
1345
|
-
<tr>
|
1346
|
-
<td class="elapsed">
|
1347
|
-
<%= format_elapsed(grouped_operation[:total_elapsed]) %>
|
1348
|
-
</td>
|
1349
|
-
<td class="ratio">
|
1350
|
-
<%= format_ratio(grouped_operation[:total_elapsed_ratio]) %>
|
1351
|
-
</td>
|
1352
|
-
<td class="n">
|
1353
|
-
<%= h(grouped_operation[:n_operations]) %>
|
1354
|
-
</td>
|
1355
|
-
<td class="ratio">
|
1356
|
-
<%= format_ratio(grouped_operation[:n_operations_ratio]) %>
|
1357
|
-
</td>
|
1358
|
-
<td class="name"><%= h(grouped_operation[:name]) %></td>
|
1359
|
-
<td class="context">
|
1360
|
-
<%= format_context(grouped_operation[:context]) %>
|
1361
|
-
</td>
|
1362
|
-
</tr>
|
1363
|
-
<% end %>
|
1364
|
-
</table>
|
1365
|
-
</div>
|
1366
|
-
EOH
|
1367
|
-
end
|
1368
|
-
|
1369
|
-
def format_time(time)
|
1370
|
-
span({:class => "time"}, h(super))
|
1371
|
-
end
|
1372
|
-
|
1373
|
-
def format_elapsed(elapsed, options={})
|
1374
|
-
formatted_elapsed = span({:class => "elapsed"}, h("%8.8f" % elapsed))
|
1375
|
-
if options[:slow?]
|
1376
|
-
formatted_elapsed = span({:class => "slow"}, formatted_elapsed)
|
1377
|
-
end
|
1378
|
-
formatted_elapsed
|
1379
|
-
end
|
1380
|
-
|
1381
|
-
def format_ratio(ratio)
|
1382
|
-
h("%5.2f%%" % ratio)
|
1383
|
-
end
|
1384
|
-
|
1385
|
-
def format_context(context)
|
1386
|
-
h(context).gsub(/,/, ",<wbr />")
|
1387
|
-
end
|
1388
|
-
|
1389
|
-
def tag(name, attributes, content)
|
1390
|
-
html = "<#{name}"
|
1391
|
-
html_attributes = attributes.collect do |key, value|
|
1392
|
-
"#{h(key)}=\"#{h(value)}\""
|
1393
|
-
end
|
1394
|
-
html << " #{html_attributes.join(' ')}" unless attributes.empty?
|
1395
|
-
html << ">"
|
1396
|
-
html << content
|
1397
|
-
html << "</#{name}>"
|
1398
|
-
html
|
1399
|
-
end
|
1400
|
-
|
1401
|
-
def span(attributes, content)
|
1402
|
-
tag("span", attributes, content)
|
1403
|
-
end
|
1404
|
-
|
1405
|
-
def div(attributes, content)
|
1406
|
-
tag("div", attributes, content)
|
1407
|
-
end
|
1408
|
-
end
|
1409
|
-
end
|
1410
|
-
|
1411
|
-
if __FILE__ == $0
|
1412
|
-
analyzer = GroongaQueryLogAnalyzer.new
|
1413
|
-
begin
|
1414
|
-
analyzer.run
|
1415
|
-
rescue GroongaQueryLogAnalyzer::Error
|
1416
|
-
$stderr.puts($!.message)
|
1417
|
-
exit(false)
|
1418
|
-
end
|
1419
|
-
end
|