groonga 0.0.7 → 0.9.0
Sign up to get free protection for your applications and to get access to all the features.
- data/NEWS.ja.rdoc +56 -0
- data/NEWS.rdoc +58 -0
- data/Rakefile +2 -3
- data/benchmark/read-write-many-small-items.rb +16 -32
- data/benchmark/write-many-small-items.rb +14 -28
- data/example/bookmark.rb +19 -17
- data/example/index-html.rb +11 -1
- data/example/search/config.ru +14 -9
- data/ext/rb-grn-array.c +6 -6
- data/ext/rb-grn-column.c +348 -18
- data/ext/rb-grn-context.c +8 -4
- data/ext/rb-grn-database.c +6 -7
- data/ext/rb-grn-exception.c +101 -5
- data/ext/rb-grn-expression.c +206 -23
- data/ext/rb-grn-fix-size-column.c +6 -39
- data/ext/rb-grn-hash.c +24 -24
- data/ext/rb-grn-index-column.c +74 -19
- data/ext/rb-grn-logger.c +48 -0
- data/ext/rb-grn-object.c +281 -67
- data/ext/rb-grn-operation.c +1 -1
- data/ext/rb-grn-patricia-trie-cursor.c +10 -1
- data/ext/rb-grn-patricia-trie.c +268 -7
- data/ext/rb-grn-query.c +52 -1
- data/ext/rb-grn-record.c +8 -2
- data/ext/rb-grn-snippet.c +63 -1
- data/ext/rb-grn-table-cursor-key-support.c +15 -1
- data/ext/rb-grn-table-cursor.c +57 -0
- data/ext/rb-grn-table-key-support.c +382 -46
- data/ext/rb-grn-table.c +729 -192
- data/ext/rb-grn-type.c +63 -12
- data/ext/rb-grn-utils.c +156 -158
- data/ext/rb-grn-variable.c +18 -0
- data/ext/rb-grn.h +85 -21
- data/ext/rb-groonga.c +13 -3
- data/extconf.rb +19 -4
- data/html/developer.html +1 -1
- data/html/header.html.erb +1 -1
- data/html/index.html +4 -4
- data/lib/groonga.rb +10 -0
- data/lib/groonga/expression-builder.rb +81 -42
- data/lib/groonga/patricia-trie.rb +13 -0
- data/lib/groonga/record.rb +158 -13
- data/lib/groonga/schema.rb +339 -33
- data/pkg-config.rb +6 -1
- data/test-unit/lib/test/unit.rb +23 -42
- data/test-unit/lib/test/unit/assertionfailederror.rb +11 -0
- data/test-unit/lib/test/unit/assertions.rb +87 -9
- data/test-unit/lib/test/unit/autorunner.rb +20 -11
- data/test-unit/lib/test/unit/collector.rb +1 -8
- data/test-unit/lib/test/unit/collector/load.rb +2 -3
- data/test-unit/lib/test/unit/color-scheme.rb +13 -1
- data/test-unit/lib/test/unit/diff.rb +223 -37
- data/test-unit/lib/test/unit/error.rb +4 -0
- data/test-unit/lib/test/unit/failure.rb +31 -5
- data/test-unit/lib/test/unit/notification.rb +8 -4
- data/test-unit/lib/test/unit/omission.rb +51 -3
- data/test-unit/lib/test/unit/pending.rb +4 -0
- data/test-unit/lib/test/unit/testcase.rb +55 -4
- data/test-unit/lib/test/unit/ui/console/testrunner.rb +190 -4
- data/test-unit/lib/test/unit/ui/emacs/testrunner.rb +14 -0
- data/test-unit/lib/test/unit/ui/testrunner.rb +8 -0
- data/test-unit/lib/test/unit/version.rb +1 -1
- data/test-unit/sample/{tc_adder.rb → test_adder.rb} +3 -1
- data/test-unit/sample/{tc_subtracter.rb → test_subtracter.rb} +3 -1
- data/test-unit/sample/test_user.rb +1 -0
- data/test-unit/test/collector/test-descendant.rb +2 -4
- data/test-unit/test/collector/test_objectspace.rb +7 -5
- data/test-unit/test/run-test.rb +2 -0
- data/test-unit/test/test-color-scheme.rb +7 -0
- data/test-unit/test/test-diff.rb +48 -7
- data/test-unit/test/test-omission.rb +1 -1
- data/test-unit/test/test-testcase.rb +47 -0
- data/test-unit/test/test_assertions.rb +79 -10
- data/test/groonga-test-utils.rb +6 -1
- data/test/test-array.rb +29 -14
- data/test/test-column.rb +107 -55
- data/test/test-context.rb +5 -0
- data/test/test-database.rb +2 -37
- data/test/test-exception.rb +9 -1
- data/test/test-expression-builder.rb +23 -5
- data/test/test-expression.rb +44 -8
- data/test/test-fix-size-column.rb +16 -5
- data/test/test-gqtp.rb +70 -0
- data/test/test-hash.rb +142 -43
- data/test/test-index-column.rb +9 -9
- data/test/test-patricia-trie.rb +79 -20
- data/test/test-procedure.rb +4 -2
- data/test/test-record.rb +32 -20
- data/test/test-remote.rb +3 -2
- data/test/test-schema.rb +226 -92
- data/test/test-table-cursor.rb +103 -1
- data/test/test-table-offset-and-limit.rb +102 -0
- data/test/test-table-select-normalize.rb +4 -4
- data/test/test-table-select.rb +52 -8
- data/test/test-table.rb +235 -116
- data/test/test-type.rb +2 -2
- data/test/test-variable-size-column.rb +21 -5
- data/test/test-vector-column.rb +76 -0
- data/{TUTORIAL.ja.rdoc → text/TUTORIAL.ja.rdoc} +52 -52
- data/text/expression.rdoc +284 -0
- metadata +11 -7
- data/test-unit/sample/ts_examples.rb +0 -7
data/NEWS.ja.rdoc
CHANGED
@@ -1,5 +1,61 @@
|
|
1
1
|
= お知らせ
|
2
2
|
|
3
|
+
== 0.9.0: 2010-02-09
|
4
|
+
|
5
|
+
* groonga 0.1.5対応
|
6
|
+
* APIの追加
|
7
|
+
* Groonga::Object#context
|
8
|
+
* Groonga::Record#n_sub_records
|
9
|
+
* Groonga::Context#send
|
10
|
+
* Groonga::Context#receive
|
11
|
+
* Groonga::PatriciaTrie#prefix_search [Tasuku SUENAGA]
|
12
|
+
* Groonga::Object#path [Ryo Onodera]
|
13
|
+
* Groonga::Object#lock [Tasuku SUENAGA]
|
14
|
+
* Groonga::Object#unlock [Tasuku SUENAGA]
|
15
|
+
* Groonga::Object#locked? [Tasuku SUENAGA]
|
16
|
+
* Groonga::Object#temporary?
|
17
|
+
* Groonga::Object#persistent?
|
18
|
+
* Groonga::ObjectClosed
|
19
|
+
* Groonga::Context.[]
|
20
|
+
* Groonga::Table#column_value
|
21
|
+
* Groonga::Table#set_column_value
|
22
|
+
* APIの変更
|
23
|
+
* Groonga::Table#select, Groonga::Column#select
|
24
|
+
* Groonga::Expressionも受け付けるようになった
|
25
|
+
* grn式のシンタックスを指定する:syntaxオプションの追加
|
26
|
+
* Groonga::Table#open_cursor
|
27
|
+
* 開始位置を指定する:offsetオプションの追加
|
28
|
+
* 最大レコード数を指定する:limitオプションの追加
|
29
|
+
* Groonga::Expression.parseの引数を変更
|
30
|
+
* (nil (default) -> :column) -> (nil (default) -> :query)
|
31
|
+
* :column -> 廃止
|
32
|
+
* :table -> :query
|
33
|
+
* :table_query -> :query
|
34
|
+
* :expression -> :script
|
35
|
+
* :language -> :script
|
36
|
+
* Groonga::Table#define_column, Groonga::Table#define_index_column
|
37
|
+
* 永続テーブルをデフォルトにした
|
38
|
+
* Groonga::Table#[]をGroonga::Table#valueに変更
|
39
|
+
* Groonga::Table#[]=をGroonga::Table#set_valueに変更
|
40
|
+
* Groonga::Table#findをGroonga::Table#[]に変更
|
41
|
+
* Groonga::Table#findは非推奨
|
42
|
+
* Groonga::Table#[]=を削除
|
43
|
+
* Groonga::TableKeySupport#[]=はGroonga::TableKeySupport#addの別名
|
44
|
+
* Groonga::Recordで存在しないカラムにアクセスしたときの例外を
|
45
|
+
Groonga::InvalidArgumentからGroonga::NoSuchColumnに変更
|
46
|
+
* バグ修正
|
47
|
+
* スキーマにコンテキストが伝搬されない問題の修正 [dara]
|
48
|
+
* Groonga::PatriciaTrie#tag_keysが最後のテキストを返さない問題の修正
|
49
|
+
[Ryo Onodera]
|
50
|
+
* extconf.rbにデバッグモードでビルドする--with-debugオプションを追加
|
51
|
+
* Ruby 1.9.1でextconf.rbが失敗する問題の修正
|
52
|
+
|
53
|
+
=== 感謝
|
54
|
+
|
55
|
+
* dara
|
56
|
+
* Ryo Onodera
|
57
|
+
* Tasuku SUENAGA
|
58
|
+
|
3
59
|
== 0.0.7: 2009-10-02
|
4
60
|
|
5
61
|
* groonga 0.1.4対応
|
data/NEWS.rdoc
CHANGED
@@ -1,5 +1,63 @@
|
|
1
1
|
= NEWS
|
2
2
|
|
3
|
+
== 0.9.0: 2010-02-09
|
4
|
+
|
5
|
+
* Supported groonga 0.1.5
|
6
|
+
* Added API
|
7
|
+
* Groonga::Object#context
|
8
|
+
* Groonga::Record#n_sub_records
|
9
|
+
* Groonga::Context#send
|
10
|
+
* Groonga::Context#receive
|
11
|
+
* Groonga::PatriciaTrie#prefix_search [Tasuku SUENAGA]
|
12
|
+
* Groonga::Object#path [Ryo Onodera]
|
13
|
+
* Groonga::Object#lock [Tasuku SUENAGA]
|
14
|
+
* Groonga::Object#unlock [Tasuku SUENAGA]
|
15
|
+
* Groonga::Object#locked? [Tasuku SUENAGA]
|
16
|
+
* Groonga::Object#temporary?
|
17
|
+
* Groonga::Object#persistent?
|
18
|
+
* Groonga::ObjectClosed
|
19
|
+
* Groonga::Context.[]
|
20
|
+
* Groonga::Table#column_value
|
21
|
+
* Groonga::Table#set_column_value
|
22
|
+
* Changed API
|
23
|
+
* Groonga::Table#select, Groonga::Column#select
|
24
|
+
* They also accept Groonga::Expression
|
25
|
+
* Added :syntax option that specifies grn expression syntax
|
26
|
+
* Groonga::Table#open_cursor
|
27
|
+
* Added :offset option that specifies offset.
|
28
|
+
* Added :limit option that specifies max number of records.
|
29
|
+
* Changed Groonga::Expression.parse options:
|
30
|
+
* (nil (default) -> :column) -> (nil (default) -> :query)
|
31
|
+
* :column -> removed
|
32
|
+
* :table -> :query
|
33
|
+
* :table_query -> :query
|
34
|
+
* :expression -> :script
|
35
|
+
* :language -> :script
|
36
|
+
* Groonga::Table#define_column, Groonga::Table#define_index_column
|
37
|
+
* Defined column becomes persistent table by default
|
38
|
+
* Groonga::Table#[] -> Groonga::Table#value
|
39
|
+
* Groonga::Table#[]= -> Groonga::Table#set_value
|
40
|
+
* Groonga::Table#find -> Groonga::Table#[]
|
41
|
+
* Groonga::Table#find -> obsolete
|
42
|
+
* Groonga::Table#[]= -> removed
|
43
|
+
* Groonga::TableKeySupport#[]= is alias of Groonga::TableKeySupport#add
|
44
|
+
* Changed exception class to Groonga::NoSuchColumn from
|
45
|
+
Groonga::InvalidArgument when Groonga::Record accesses nonexistent
|
46
|
+
a column.
|
47
|
+
* Bug fixes
|
48
|
+
* Fixed a bug that context isn't passed to schema [dara]
|
49
|
+
* Fixed a bug that Groonga::PatriciaTrie#tag_keys doesn't return
|
50
|
+
that last text.
|
51
|
+
[Ryo Onodera]
|
52
|
+
* Added --with-debug option to extconf.rb for debug build.
|
53
|
+
* Fixed a bug that Ruby 1.9.1 may fail extconf.rb.
|
54
|
+
|
55
|
+
=== Thanks
|
56
|
+
|
57
|
+
* dara
|
58
|
+
* Ryo Onodera
|
59
|
+
* Tasuku SUENAGA
|
60
|
+
|
3
61
|
== 0.0.7: 2009-10-02
|
4
62
|
|
5
63
|
* Supported groonga 0.1.4
|
data/Rakefile
CHANGED
@@ -51,7 +51,6 @@ manifest_contents = []
|
|
51
51
|
base_dir_included_components = %w(AUTHORS Rakefile
|
52
52
|
README.rdoc README.ja.rdoc
|
53
53
|
NEWS.rdoc NEWS.ja.rdoc
|
54
|
-
TUTORIAL.ja.rdoc
|
55
54
|
extconf.rb pkg-config.rb)
|
56
55
|
excluded_components = %w(.cvsignore .gdb_history CVS depend Makefile pkg
|
57
56
|
.svn .git doc vendor data .test-result)
|
@@ -108,7 +107,7 @@ Hoe.spec('groonga') do |_project|
|
|
108
107
|
project.spec_extras = {
|
109
108
|
:extensions => ['extconf.rb'],
|
110
109
|
:require_paths => ["lib", "ext"],
|
111
|
-
:extra_rdoc_files => Dir.glob("
|
110
|
+
:extra_rdoc_files => Dir.glob("**/*.rdoc"),
|
112
111
|
}
|
113
112
|
project.readme_file = "README.ja.rdoc"
|
114
113
|
|
@@ -145,7 +144,7 @@ ObjectSpace.each_object(Rake::RDocTask) do |rdoc_task|
|
|
145
144
|
|
146
145
|
rdoc_task.rdoc_files = ["ext/rb-groonga.c"] + Dir.glob("ext/rb-grn-*.c")
|
147
146
|
rdoc_task.rdoc_files += Dir.glob("lib/**/*.rb")
|
148
|
-
rdoc_task.rdoc_files += Dir.glob("
|
147
|
+
rdoc_task.rdoc_files += Dir.glob("**/*.rdoc")
|
149
148
|
end
|
150
149
|
|
151
150
|
task :publish_docs => [:prepare_docs_for_publishing]
|
@@ -54,46 +54,30 @@ begin
|
|
54
54
|
$LOAD_PATH.unshift(File.join(base_dir, "lib"))
|
55
55
|
|
56
56
|
require 'groonga'
|
57
|
-
|
58
|
-
|
57
|
+
tmp_dir = "/tmp/groonga"
|
58
|
+
FileUtils.rm_rf(tmp_dir)
|
59
|
+
FileUtils.mkdir(tmp_dir)
|
60
|
+
@database = Groonga::Database.create(:path => "#{tmp_dir}/db")
|
59
61
|
|
60
|
-
item("groonga: Hash: memory") do
|
61
|
-
@hash = Groonga::Hash.create(:key_type => "<shorttext>",
|
62
|
-
:value_type => value_type)
|
63
|
-
values.each do |value|
|
64
|
-
@hash[value] = value
|
65
|
-
@hash[value]
|
66
|
-
end
|
67
|
-
end
|
68
|
-
|
69
|
-
item("groonga: Trie: memory") do
|
70
|
-
@hash = Groonga::PatriciaTrie.create(:key_type => "<shorttext>",
|
71
|
-
:value_type => value_type)
|
72
|
-
values.each do |value|
|
73
|
-
@hash[value] = value
|
74
|
-
@hash[value]
|
75
|
-
end
|
76
|
-
end
|
77
|
-
|
78
|
-
@hash_file = Tempfile.new("groonga-hash")
|
79
62
|
item("groonga: Hash: file") do
|
80
|
-
@hash = Groonga::Hash.create(:
|
81
|
-
:
|
82
|
-
|
63
|
+
@hash = Groonga::Hash.create(:name => "Hash",
|
64
|
+
:key_type => "ShortText")
|
65
|
+
column_name = "value"
|
66
|
+
@column = @hash.define_column(column_name, "ShortText")
|
83
67
|
values.each do |value|
|
84
|
-
@hash
|
85
|
-
@hash
|
68
|
+
@hash.set_column_value(value, column_name, value)
|
69
|
+
@hash.column_value(value, column_name)
|
86
70
|
end
|
87
71
|
end
|
88
72
|
|
89
|
-
trie_file = Tempfile.new("groonga-trie")
|
90
73
|
item("groonga: Trie: file") do
|
91
|
-
@
|
92
|
-
:
|
93
|
-
|
74
|
+
@trie = Groonga::PatriciaTrie.create(:name => "PatriciaTrie",
|
75
|
+
:key_type => "ShortText")
|
76
|
+
column_name = "value"
|
77
|
+
@column = @trie.define_column(column_name, "ShortText")
|
94
78
|
values.each do |value|
|
95
|
-
@
|
96
|
-
@
|
79
|
+
@trie.set_column_value(value, column_name, value)
|
80
|
+
@trie.column_value(value, column_name)
|
97
81
|
end
|
98
82
|
end
|
99
83
|
rescue LoadError
|
@@ -53,42 +53,28 @@ begin
|
|
53
53
|
$LOAD_PATH.unshift(File.join(base_dir, "lib"))
|
54
54
|
|
55
55
|
require 'groonga'
|
56
|
-
|
57
|
-
|
56
|
+
tmp_dir = "/tmp/groonga"
|
57
|
+
FileUtils.rm_rf(tmp_dir)
|
58
|
+
FileUtils.mkdir(tmp_dir)
|
59
|
+
@database = Groonga::Database.create(:path => "#{tmp_dir}/db")
|
58
60
|
|
59
|
-
item("groonga: Hash: memory") do
|
60
|
-
@hash = Groonga::Hash.create(:key_type => "<shorttext>",
|
61
|
-
:value_type => value_type)
|
62
|
-
values.each do |value|
|
63
|
-
@hash[value] = value
|
64
|
-
end
|
65
|
-
end
|
66
|
-
|
67
|
-
item("groonga: Trie: memory") do
|
68
|
-
@hash = Groonga::PatriciaTrie.create(:key_type => "<shorttext>",
|
69
|
-
:value_type => value_type)
|
70
|
-
values.each do |value|
|
71
|
-
@hash[value] = value
|
72
|
-
end
|
73
|
-
end
|
74
|
-
|
75
|
-
@hash_file = Tempfile.new("groonga-hash")
|
76
61
|
item("groonga: Hash: file") do
|
77
|
-
@hash = Groonga::Hash.create(:
|
78
|
-
:
|
79
|
-
|
62
|
+
@hash = Groonga::Hash.create(:name => "Hash",
|
63
|
+
:key_type => "ShortText")
|
64
|
+
column_name = "value"
|
65
|
+
@column = @hash.define_column(column_name, "ShortText")
|
80
66
|
values.each do |value|
|
81
|
-
@hash
|
67
|
+
@hash.set_column_value(value, column_name, value)
|
82
68
|
end
|
83
69
|
end
|
84
70
|
|
85
|
-
trie_file = Tempfile.new("groonga-trie")
|
86
71
|
item("groonga: Trie: file") do
|
87
|
-
@
|
88
|
-
:
|
89
|
-
|
72
|
+
@trie = Groonga::PatriciaTrie.create(:name => "PatriciaTrie",
|
73
|
+
:key_type => "ShortText")
|
74
|
+
column_name = "value"
|
75
|
+
@column = @trie.define_column(column_name, "ShortText")
|
90
76
|
values.each do |value|
|
91
|
-
@
|
77
|
+
@trie.set_column_value(value, column_name, value)
|
92
78
|
end
|
93
79
|
end
|
94
80
|
rescue LoadError
|
data/example/bookmark.rb
CHANGED
@@ -36,46 +36,48 @@ persistent = true
|
|
36
36
|
|
37
37
|
p Groonga::Database.create(:path => path)
|
38
38
|
|
39
|
-
p(items = Groonga::Hash.create(:name => "
|
39
|
+
p(items = Groonga::Hash.create(:name => "Items",
|
40
|
+
:key_type => "ShortText",
|
41
|
+
:persistent => persistent))
|
40
42
|
|
41
43
|
p items.add("http://ja.wikipedia.org/wiki/Ruby")
|
42
44
|
p items.add("http://www.ruby-lang.org/")
|
43
45
|
|
44
|
-
p items.define_column("title", "
|
46
|
+
p items.define_column("title", "Text", :persistent => persistent)
|
45
47
|
|
46
|
-
p(terms = Groonga::Hash.create(:name => "
|
47
|
-
:key_type => "
|
48
|
+
p(terms = Groonga::Hash.create(:name => "Terms",
|
49
|
+
:key_type => "ShortText",
|
48
50
|
:persistent => persistent,
|
49
|
-
:default_tokenizer => "
|
51
|
+
:default_tokenizer => "TokenBigram"))
|
50
52
|
p terms.define_index_column("item_title", items,
|
51
53
|
:persistent => persistent,
|
52
54
|
:with_weight => true,
|
53
55
|
:with_section => true,
|
54
56
|
:with_position => true,
|
55
|
-
:source => "
|
57
|
+
:source => "Items.title")
|
56
58
|
|
57
59
|
p items.find("http://ja.wikipedia.org/wiki/Ruby")["title"] = "Ruby"
|
58
60
|
p items.find("http://www.ruby-lang.org/")["title"] = "オブジェクト指向スクリプト言語Ruby"
|
59
61
|
|
60
|
-
p(users = Groonga::Hash.create(:name => "
|
61
|
-
:key_type => "
|
62
|
+
p(users = Groonga::Hash.create(:name => "Users",
|
63
|
+
:key_type => "ShortText",
|
62
64
|
:persistent => persistent))
|
63
|
-
p users.define_column("name", "
|
65
|
+
p users.define_column("name", "Text",
|
64
66
|
:persistent => persistent)
|
65
67
|
|
66
|
-
p(comments = Groonga::Array.create(:name => "
|
68
|
+
p(comments = Groonga::Array.create(:name => "Comments",
|
67
69
|
:persistent => persistent))
|
68
70
|
p comments.define_column("item", items)
|
69
71
|
p comments.define_column("author", users)
|
70
|
-
p comments.define_column("content", "
|
71
|
-
p comments.define_column("issued", "
|
72
|
+
p comments.define_column("content", "Text")
|
73
|
+
p comments.define_column("issued", "Time")
|
72
74
|
|
73
75
|
p terms.define_index_column("comment_content", comments,
|
74
76
|
:persistent => persistent,
|
75
77
|
:with_weight => true,
|
76
78
|
:with_section => true,
|
77
79
|
:with_position => true,
|
78
|
-
:source => "
|
80
|
+
:source => "Comments.content")
|
79
81
|
|
80
82
|
p users.add("moritan", :name => "モリタン")
|
81
83
|
p users.add("taporobo", :name => "タポロボ")
|
@@ -145,15 +147,15 @@ end
|
|
145
147
|
|
146
148
|
records.group([".item"]).each do |record|
|
147
149
|
item = record.key
|
148
|
-
p [record
|
150
|
+
p [record.n_sub_records,
|
149
151
|
item.key,
|
150
152
|
item[".title"]]
|
151
153
|
end
|
152
154
|
|
153
155
|
p ruby_comments = @comments.select {|record| record["content"] =~ "Ruby"}
|
154
|
-
p ruby_items = @items.select("*W1:50 title
|
156
|
+
p ruby_items = @items.select("*W1:50 title:@Ruby")
|
155
157
|
|
156
158
|
p ruby_items = ruby_comments.group([".item"]).union!(ruby_items)
|
157
|
-
ruby_items.sort([{:key => "
|
158
|
-
p [record["
|
159
|
+
ruby_items.sort([{:key => "._score", :order => "descending"}]).each do |record|
|
160
|
+
p [record["._score"], record[".title"]]
|
159
161
|
end
|
data/example/index-html.rb
CHANGED
@@ -65,9 +65,19 @@ targets.each do |target|
|
|
65
65
|
html_document.css("title").each do |title|
|
66
66
|
values[:title] = title.text
|
67
67
|
end
|
68
|
+
contents = []
|
68
69
|
html_document.css("body").each do |body|
|
69
|
-
|
70
|
+
contents << body.text
|
70
71
|
end
|
72
|
+
html_document.css("img").each do |image|
|
73
|
+
image_content = []
|
74
|
+
title = image['title']
|
75
|
+
alt = image['alt']
|
76
|
+
image_content << title if title and !title.empty?
|
77
|
+
image_content << alt if alt and !alt.empty?
|
78
|
+
contents.concat(image_content) unless image_content.empty?
|
79
|
+
end
|
80
|
+
values[:content] = contents.join("\n")
|
71
81
|
values["last-modified"] = path.mtime
|
72
82
|
|
73
83
|
values.each do |key, value|
|
data/example/search/config.ru
CHANGED
@@ -23,14 +23,20 @@ class Searcher
|
|
23
23
|
def call(env)
|
24
24
|
request = Rack::Request.new(env)
|
25
25
|
response = Rack::Response.new
|
26
|
-
response["Content-Type"] = "text/html"
|
26
|
+
response["Content-Type"] = "text/html; charset=UTF-8"
|
27
|
+
if /\/\z/ !~ request.path_info
|
28
|
+
request.path_info += "/"
|
29
|
+
response.redirect(request.url)
|
30
|
+
return response.to_a
|
31
|
+
end
|
27
32
|
|
28
33
|
response.write(<<-EOH)
|
34
|
+
<?xml version="1.0" encoding="utf-8"?>
|
29
35
|
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
|
30
36
|
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
|
31
37
|
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="ja" lang="ja">
|
32
38
|
<head>
|
33
|
-
<meta http-equiv="content-type" content="text/html;charset=UTF-8" />
|
39
|
+
<meta http-equiv="content-type" content="text/html; charset=UTF-8" />
|
34
40
|
<meta name="robot" content="noindex,nofollow" />
|
35
41
|
<title>groongaで全文検索</title>
|
36
42
|
<link rel="stylesheet" href="css/groonga.css" type="text/css" media="all" />
|
@@ -117,9 +123,9 @@ EOS
|
|
117
123
|
<span class="keyword">#{escape_html(query(request))}</span>の検索結果:
|
118
124
|
<span class="total-entries">#{total_records}</span>件中
|
119
125
|
<span class="display-range">
|
120
|
-
#{total_records.zero? ? 0 : _page + 1}
|
126
|
+
#{total_records.zero? ? 0 : (_page * limit) + 1}
|
121
127
|
-
|
122
|
-
#{_page + records.size}
|
128
|
+
#{(_page * limit) + records.size}
|
123
129
|
</span>
|
124
130
|
件(#{elapsed}秒)
|
125
131
|
</p>
|
@@ -133,7 +139,7 @@ EOS
|
|
133
139
|
end
|
134
140
|
response.write(" </div>\n")
|
135
141
|
|
136
|
-
|
142
|
+
render_pagination(request, response, _page, limit, total_records)
|
137
143
|
end
|
138
144
|
|
139
145
|
def render_record(request, response, record)
|
@@ -168,14 +174,13 @@ EOM
|
|
168
174
|
EOS
|
169
175
|
end
|
170
176
|
|
171
|
-
def render_pagination(request, response, page, limit)
|
177
|
+
def render_pagination(request, response, page, limit, total_records)
|
172
178
|
_query = query(request)
|
173
179
|
return if _query.empty?
|
174
180
|
|
175
|
-
total_records = @documents.size
|
176
181
|
return if total_records < limit
|
177
182
|
|
178
|
-
last_page = total_records / limit
|
183
|
+
last_page = (total_records / limit.to_f).ceil
|
179
184
|
response.write("<div class='pagination'>\n")
|
180
185
|
if page > 0
|
181
186
|
render_pagination_link(request, response, _query, page - 1, "<<")
|
@@ -187,7 +192,7 @@ EOS
|
|
187
192
|
render_pagination_link(request, response, _query, i, i)
|
188
193
|
end
|
189
194
|
end
|
190
|
-
if page < last_page
|
195
|
+
if page < (last_page - 1)
|
191
196
|
render_pagination_link(request, response, _query, page + 1, ">>")
|
192
197
|
end
|
193
198
|
response.write("</div>\n")
|
data/ext/rb-grn-array.c
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
/* -*- c-file-style: "ruby" -*- */
|
2
2
|
/*
|
3
|
-
Copyright (C) 2009 Kouhei Sutou <kou@clear-code.com>
|
3
|
+
Copyright (C) 2009-2010 Kouhei Sutou <kou@clear-code.com>
|
4
4
|
|
5
5
|
This library is free software; you can redistribute it and/or
|
6
6
|
modify it under the terms of the GNU Lesser General Public
|
@@ -70,7 +70,7 @@ VALUE rb_cGrnArray;
|
|
70
70
|
*
|
71
71
|
* [+:sub_records+]
|
72
72
|
* +true+を指定すると#groupでグループ化したときに、
|
73
|
-
*
|
73
|
+
* Groonga::Record#n_sub_recordsでグループに含まれるレコー
|
74
74
|
* ドの件数を取得できる。
|
75
75
|
*
|
76
76
|
* 使用例:
|
@@ -141,7 +141,7 @@ rb_grn_array_s_create (int argc, VALUE *argv, VALUE klass)
|
|
141
141
|
rb_grn_context_check(context, rb_ary_new4(argc, argv));
|
142
142
|
rb_table = GRNOBJECT2RVAL(klass, context, table, RB_GRN_TRUE);
|
143
143
|
rb_grn_context_check(context, rb_table);
|
144
|
-
rb_iv_set(rb_table, "context", rb_context);
|
144
|
+
rb_iv_set(rb_table, "@context", rb_context);
|
145
145
|
|
146
146
|
if (rb_block_given_p())
|
147
147
|
return rb_ensure(rb_yield, rb_table, rb_grn_object_close, rb_table);
|
@@ -163,9 +163,9 @@ rb_grn_array_s_create (int argc, VALUE *argv, VALUE klass)
|
|
163
163
|
*
|
164
164
|
* 使用例では、以下のようなユーザを格納するGroonga::Arrayが
|
165
165
|
* 定義されているものとする。
|
166
|
-
* users = Groonga::Array.create(:name => "
|
167
|
-
* users.define_column("name", "
|
168
|
-
* users.define_column("uri", "
|
166
|
+
* users = Groonga::Array.create(:name => "Users")
|
167
|
+
* users.define_column("name", "ShortText")
|
168
|
+
* users.define_column("uri", "ShortText")
|
169
169
|
*
|
170
170
|
* ユーザを追加する。
|
171
171
|
* user = users.add
|