rroonga 2.0.8 → 2.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/README.textile +2 -2
- data/bin/groonga-index-dump +47 -0
- data/doc/text/news.textile +733 -0
- data/doc/text/tutorial.textile +535 -0
- data/example/bookmark.rb +1 -1
- data/ext/groonga/rb-grn-database.c +21 -24
- data/ext/groonga/rb-grn-double-array-trie.c +50 -58
- data/ext/groonga/rb-grn-exception.c +18 -1
- data/ext/groonga/rb-grn-hash.c +18 -3
- data/ext/groonga/rb-grn-index-column.c +50 -2
- data/ext/groonga/rb-grn-normalizer.c +83 -0
- data/ext/groonga/rb-grn-object.c +18 -14
- data/ext/groonga/rb-grn-patricia-trie.c +17 -2
- data/ext/groonga/rb-grn-query-logger.c +263 -0
- data/ext/groonga/rb-grn-snippet.c +6 -0
- data/ext/groonga/rb-grn-table-key-support.c +204 -13
- data/ext/groonga/rb-grn-table.c +124 -46
- data/ext/groonga/rb-grn.h +14 -3
- data/ext/groonga/rb-groonga.c +2 -0
- data/lib/groonga/database.rb +7 -0
- data/lib/groonga/dumper.rb +21 -2
- data/lib/groonga/index-column.rb +170 -0
- data/lib/groonga/query-logger.rb +129 -0
- data/lib/groonga/record.rb +32 -8
- data/lib/groonga/schema.rb +231 -288
- data/lib/groonga.rb +2 -1
- data/rroonga-build.rb +2 -2
- data/rroonga.gemspec +11 -7
- data/test/groonga-test-utils.rb +18 -6
- data/test/test-hash.rb +49 -20
- data/test/test-index-cursor.rb +4 -4
- data/{Gemfile → test/test-normalizer.rb} +9 -5
- data/test/test-pagination.rb +1 -1
- data/test/test-patricia-trie.rb +8 -0
- data/test/test-schema.rb +16 -13
- data/test/test-snippet.rb +5 -0
- data/test/test-table.rb +24 -12
- data/test/test-view.rb +0 -1
- metadata +154 -136
- data/AUTHORS +0 -5
- data/Rakefile +0 -203
- data/bin/groonga-query-log-extract +0 -117
@@ -1,117 +0,0 @@
|
|
1
|
-
#!/usr/bin/env ruby
|
2
|
-
# -*- coding: utf-8 -*-
|
3
|
-
#
|
4
|
-
# Copyright (C) 2011 Kouhei Sutou <kou@clear-code.com>
|
5
|
-
#
|
6
|
-
# This library is free software; you can redistribute it and/or
|
7
|
-
# modify it under the terms of the GNU Lesser General Public
|
8
|
-
# License version 2.1 as published by the Free Software Foundation.
|
9
|
-
#
|
10
|
-
# This library is distributed in the hope that it will be useful,
|
11
|
-
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
12
|
-
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
13
|
-
# Lesser General Public License for more details.
|
14
|
-
#
|
15
|
-
# You should have received a copy of the GNU Lesser General Public
|
16
|
-
# License along with this library; if not, write to the Free Software
|
17
|
-
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
18
|
-
|
19
|
-
require 'ostruct'
|
20
|
-
require 'optparse'
|
21
|
-
require 'pathname'
|
22
|
-
|
23
|
-
require 'groonga/query-log'
|
24
|
-
|
25
|
-
options = OpenStruct.new
|
26
|
-
options.unify_format = nil
|
27
|
-
options.commands = []
|
28
|
-
options.exclude_commands = []
|
29
|
-
options.output_path = nil
|
30
|
-
option_parser = OptionParser.new do |parser|
|
31
|
-
parser.banner += " QUERY_LOG1 ..."
|
32
|
-
|
33
|
-
available_formats = ["uri", "command"]
|
34
|
-
parser.on("--unify-format=FORMAT",
|
35
|
-
available_formats,
|
36
|
-
"Unify command format to FORMAT.",
|
37
|
-
"(#{available_formats.join(', ')})",
|
38
|
-
"[not unify]") do |format|
|
39
|
-
options.unify_format = format
|
40
|
-
end
|
41
|
-
|
42
|
-
parser.on("--command=COMMAND",
|
43
|
-
"Extract only COMMAND.",
|
44
|
-
"To extract one or more commands,",
|
45
|
-
"specify this command a number of times.",
|
46
|
-
"Use /.../ as COMMAND to match command with regular expression.",
|
47
|
-
"[all commands]") do |command|
|
48
|
-
case command
|
49
|
-
when /\A\/(.*)\/(i)?\z/
|
50
|
-
options.commands << Regexp.new($1, $2 == "i")
|
51
|
-
when
|
52
|
-
options.commands << command
|
53
|
-
end
|
54
|
-
end
|
55
|
-
|
56
|
-
parser.on("--exclude-command=COMMAND",
|
57
|
-
"Don't extract COMMAND.",
|
58
|
-
"To ignore one or more commands,",
|
59
|
-
"specify this command a number of times.",
|
60
|
-
"Use /.../ as COMMAND to match command with regular expression.",
|
61
|
-
"[no commands]") do |command|
|
62
|
-
case command
|
63
|
-
when /\A\/(.*)\/(i)?\z/
|
64
|
-
options.exclude_commands << Regexp.new($1, $2 == "i")
|
65
|
-
when
|
66
|
-
options.exclude_commands << command
|
67
|
-
end
|
68
|
-
end
|
69
|
-
|
70
|
-
parser.on("--output=PATH",
|
71
|
-
"Output to PATH.",
|
72
|
-
"[standard output]") do |path|
|
73
|
-
options.output_path = path
|
74
|
-
end
|
75
|
-
end
|
76
|
-
args = option_parser.parse!(ARGV)
|
77
|
-
|
78
|
-
if args.empty?
|
79
|
-
puts(option_parser)
|
80
|
-
exit(false)
|
81
|
-
end
|
82
|
-
|
83
|
-
def target?(command, options)
|
84
|
-
name = command.name
|
85
|
-
if options.commands.any? {|target_command| target_command === name}
|
86
|
-
true
|
87
|
-
elsif options.exclude_commands.any? {|exclude_command| exclude_command == name}
|
88
|
-
false
|
89
|
-
else
|
90
|
-
true
|
91
|
-
end
|
92
|
-
end
|
93
|
-
|
94
|
-
def extract(output, options)
|
95
|
-
parser = Groonga::QueryLog::Parser.new
|
96
|
-
parser.parse(ARGF) do |statistic|
|
97
|
-
command = statistic.command
|
98
|
-
next unless target?(command, options)
|
99
|
-
command_text = nil
|
100
|
-
case options.unify_format
|
101
|
-
when "uri"
|
102
|
-
command_text = command.to_uri_format unless command.uri_format?
|
103
|
-
when "command"
|
104
|
-
command_text = command.to_command_format unless command.command_format?
|
105
|
-
end
|
106
|
-
command_text ||= statistic.raw_command
|
107
|
-
output.puts(command_text)
|
108
|
-
end
|
109
|
-
end
|
110
|
-
|
111
|
-
if options.output_path
|
112
|
-
File.open(options.output_path, "w") do |output|
|
113
|
-
extract(output, options)
|
114
|
-
end
|
115
|
-
else
|
116
|
-
extract($stdout, options)
|
117
|
-
end
|