rroonga 1.0.1-x86-mingw32 → 1.1.0-x86-mingw32
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/NEWS.ja.rdoc +146 -0
- data/NEWS.rdoc +146 -0
- data/README.ja.rdoc +7 -5
- data/README.rdoc +6 -5
- data/Rakefile +170 -18
- data/benchmark/create-wikipedia-database.rb +212 -0
- data/benchmark/read-write-many-small-items.rb +0 -0
- data/benchmark/repeat-load.rb +213 -0
- data/benchmark/select.rb +1052 -0
- data/benchmark/write-many-small-items.rb +0 -0
- data/example/bookmark.rb +94 -91
- data/example/index-html.rb +0 -0
- data/ext/groonga/extconf.rb +6 -6
- data/ext/groonga/rb-grn-accessor.c +1 -1
- data/ext/groonga/rb-grn-array.c +1 -1
- data/ext/groonga/rb-grn-column.c +201 -10
- data/ext/groonga/rb-grn-context.c +119 -20
- data/ext/groonga/rb-grn-database.c +27 -4
- data/ext/groonga/rb-grn-exception.c +15 -0
- data/ext/groonga/rb-grn-expression.c +14 -10
- data/ext/groonga/rb-grn-hash.c +4 -4
- data/ext/groonga/rb-grn-index-column.c +10 -6
- data/ext/groonga/rb-grn-logger.c +2 -2
- data/ext/groonga/rb-grn-object.c +33 -29
- data/ext/groonga/{rb-grn-operation.c → rb-grn-operator.c} +89 -87
- data/ext/groonga/rb-grn-patricia-trie.c +12 -12
- data/ext/groonga/rb-grn-plugin.c +134 -0
- data/ext/groonga/rb-grn-procedure.c +1 -1
- data/ext/groonga/rb-grn-query.c +7 -7
- data/ext/groonga/rb-grn-snippet.c +4 -3
- data/ext/groonga/rb-grn-table-cursor.c +1 -1
- data/ext/groonga/rb-grn-table-key-support.c +27 -24
- data/ext/groonga/rb-grn-table.c +119 -58
- data/ext/groonga/rb-grn-type.c +1 -1
- data/ext/groonga/rb-grn-utils.c +20 -19
- data/ext/groonga/rb-grn-variable.c +1 -1
- data/ext/groonga/rb-grn-view-accessor.c +1 -1
- data/ext/groonga/rb-grn-view.c +1 -1
- data/ext/groonga/rb-grn.h +26 -20
- data/ext/groonga/rb-groonga.c +6 -4
- data/extconf.rb +10 -4
- data/html/developer.html +8 -2
- data/html/favicon.ico +0 -0
- data/html/favicon.svg +591 -0
- data/html/index.html +78 -12
- data/html/logo.svg +612 -0
- data/html/ranguba.css +92 -7
- data/html/readme.svg +256 -0
- data/lib/groonga.so +0 -0
- data/lib/groonga/context.rb +52 -1
- data/lib/groonga/expression-builder.rb +42 -6
- data/lib/groonga/record.rb +84 -15
- data/lib/groonga/schema.rb +524 -122
- data/pkg/rroonga-1.1.0-x86-mingw32/NEWS.ja.rdoc +326 -0
- data/pkg/rroonga-1.1.0-x86-mingw32/NEWS.rdoc +328 -0
- data/pkg/rroonga-1.1.0-x86-mingw32/README.ja.rdoc +68 -0
- data/pkg/rroonga-1.1.0-x86-mingw32/README.rdoc +68 -0
- data/pkg/rroonga-1.1.0-x86-mingw32/text/expression.rdoc +285 -0
- data/{text/TUTORIAL.ja.rdoc → pkg/rroonga-1.1.0-x86-mingw32/text/tutorial.ja.rdoc} +165 -126
- data/pkg/rroonga-1.1.0/NEWS.ja.rdoc +326 -0
- data/pkg/rroonga-1.1.0/NEWS.rdoc +328 -0
- data/pkg/rroonga-1.1.0/README.ja.rdoc +68 -0
- data/pkg/rroonga-1.1.0/README.rdoc +68 -0
- data/pkg/rroonga-1.1.0/text/expression.rdoc +285 -0
- data/pkg/rroonga-1.1.0/text/tutorial.ja.rdoc +433 -0
- data/rroonga-build.rb +3 -3
- data/test/run-test.rb +1 -1
- data/test/test-array.rb +4 -0
- data/test/test-column.rb +31 -1
- data/test/test-context-select.rb +45 -14
- data/test/test-context.rb +44 -0
- data/test/test-database.rb +21 -1
- data/test/test-expression-builder.rb +46 -5
- data/test/test-fix-size-column.rb +12 -0
- data/test/test-hash.rb +10 -4
- data/test/test-index-column.rb +33 -0
- data/test/test-patricia-trie.rb +6 -0
- data/test/test-plugin.rb +29 -0
- data/test/test-record.rb +84 -1
- data/test/test-remote.rb +3 -2
- data/test/test-schema-create-table.rb +32 -2
- data/test/test-schema-type.rb +167 -0
- data/test/test-schema.rb +159 -12
- data/test/test-table-select-weight.rb +20 -1
- data/test/test-table-select.rb +12 -0
- data/test/test-table.rb +65 -0
- data/test/test-variable-size-column.rb +12 -0
- data/text/tutorial.ja.rdoc +433 -0
- data/vendor/local/bin/grntest.exe +0 -0
- data/vendor/local/bin/groonga.exe +0 -0
- data/vendor/local/bin/libgroonga-0.dll +0 -0
- data/vendor/local/etc/groonga/init.d/redhat/groonga +1 -9
- data/vendor/local/include/groonga/groonga.h +156 -6
- data/vendor/local/include/groonga/groonga/plugin.h +44 -0
- 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/{modules → plugins}/suggest/suggest.la +2 -2
- data/vendor/local/lib/libgroonga.a +0 -0
- data/vendor/local/lib/libgroonga.dll.a +0 -0
- data/vendor/local/lib/libgroonga.la +1 -1
- data/vendor/local/lib/pkgconfig/groonga.pc +3 -2
- data/vendor/local/share/groonga/examples/dictionary/edict/edict_import.sh +14 -3
- data/vendor/local/share/groonga/examples/dictionary/eijiro/eijiro_import.sh +3 -1
- data/vendor/local/share/groonga/examples/dictionary/gene95/gene_import.sh +19 -3
- data/vendor/local/share/groonga/munin/plugins/groonga_cpu_load +0 -0
- data/vendor/local/share/groonga/munin/plugins/groonga_cpu_time +0 -0
- data/vendor/local/share/groonga/munin/plugins/groonga_disk +0 -0
- data/vendor/local/share/groonga/munin/plugins/groonga_memory +0 -0
- data/vendor/local/share/groonga/munin/plugins/groonga_n_records +0 -0
- data/vendor/local/share/groonga/munin/plugins/groonga_query_performance +0 -0
- data/vendor/local/share/groonga/munin/plugins/groonga_status +0 -0
- metadata +91 -341
- data/html/favicon.xcf +0 -0
- data/html/logo.xcf +0 -0
- data/lib/1.8/groonga.so +0 -0
- data/lib/1.9/groonga.so +0 -0
- data/license/GPL +0 -340
- data/license/RUBY +0 -59
- data/vendor/local/lib/groonga/modules/suggest/suggest.a +0 -0
- data/vendor/local/lib/groonga/modules/suggest/suggest.dll +0 -0
- data/vendor/local/lib/groonga/modules/suggest/suggest.dll.a +0 -0
- data/vendor/local/share/groonga/doc/ja/html/.buildinfo +0 -4
- data/vendor/local/share/groonga/doc/ja/html/_sources/characteristic.txt +0 -56
- data/vendor/local/share/groonga/doc/ja/html/_sources/commands.txt +0 -10
- data/vendor/local/share/groonga/doc/ja/html/_sources/commands/cache_limit.txt +0 -52
- data/vendor/local/share/groonga/doc/ja/html/_sources/commands/check.txt +0 -164
- data/vendor/local/share/groonga/doc/ja/html/_sources/commands/clearlock.txt +0 -61
- data/vendor/local/share/groonga/doc/ja/html/_sources/commands/column_create.txt +0 -93
- data/vendor/local/share/groonga/doc/ja/html/_sources/commands/column_list.txt +0 -97
- data/vendor/local/share/groonga/doc/ja/html/_sources/commands/column_remove.txt +0 -58
- data/vendor/local/share/groonga/doc/ja/html/_sources/commands/define_selector.txt +0 -114
- data/vendor/local/share/groonga/doc/ja/html/_sources/commands/defrag.txt +0 -57
- data/vendor/local/share/groonga/doc/ja/html/_sources/commands/delete.txt +0 -68
- data/vendor/local/share/groonga/doc/ja/html/_sources/commands/dump.txt +0 -62
- data/vendor/local/share/groonga/doc/ja/html/_sources/commands/load.txt +0 -98
- data/vendor/local/share/groonga/doc/ja/html/_sources/commands/log_level.txt +0 -65
- data/vendor/local/share/groonga/doc/ja/html/_sources/commands/log_put.txt +0 -69
- data/vendor/local/share/groonga/doc/ja/html/_sources/commands/log_reopen.txt +0 -66
- data/vendor/local/share/groonga/doc/ja/html/_sources/commands/quit.txt +0 -38
- data/vendor/local/share/groonga/doc/ja/html/_sources/commands/select.txt +0 -247
- data/vendor/local/share/groonga/doc/ja/html/_sources/commands/shutdown.txt +0 -38
- data/vendor/local/share/groonga/doc/ja/html/_sources/commands/status.txt +0 -59
- data/vendor/local/share/groonga/doc/ja/html/_sources/commands/suggest.txt +0 -79
- data/vendor/local/share/groonga/doc/ja/html/_sources/commands/table_create.txt +0 -111
- data/vendor/local/share/groonga/doc/ja/html/_sources/commands/table_list.txt +0 -87
- data/vendor/local/share/groonga/doc/ja/html/_sources/commands/table_remove.txt +0 -50
- data/vendor/local/share/groonga/doc/ja/html/_sources/commands/view_add.txt +0 -53
- data/vendor/local/share/groonga/doc/ja/html/_sources/commands_not_implemented/add.txt +0 -102
- data/vendor/local/share/groonga/doc/ja/html/_sources/commands_not_implemented/get.txt +0 -78
- data/vendor/local/share/groonga/doc/ja/html/_sources/commands_not_implemented/set.txt +0 -103
- data/vendor/local/share/groonga/doc/ja/html/_sources/developer.txt +0 -10
- data/vendor/local/share/groonga/doc/ja/html/_sources/developer/com.txt +0 -18
- data/vendor/local/share/groonga/doc/ja/html/_sources/developer/document.txt +0 -38
- data/vendor/local/share/groonga/doc/ja/html/_sources/developer/query.txt +0 -212
- data/vendor/local/share/groonga/doc/ja/html/_sources/developer/test.txt +0 -114
- data/vendor/local/share/groonga/doc/ja/html/_sources/execfile.txt +0 -226
- data/vendor/local/share/groonga/doc/ja/html/_sources/expr.txt +0 -43
- data/vendor/local/share/groonga/doc/ja/html/_sources/functions.txt +0 -10
- data/vendor/local/share/groonga/doc/ja/html/_sources/functions/edit_distance.txt +0 -48
- data/vendor/local/share/groonga/doc/ja/html/_sources/functions/geo_distance.txt +0 -51
- data/vendor/local/share/groonga/doc/ja/html/_sources/functions/geo_in_circle.txt +0 -54
- data/vendor/local/share/groonga/doc/ja/html/_sources/functions/geo_in_rectangle.txt +0 -55
- data/vendor/local/share/groonga/doc/ja/html/_sources/functions/now.txt +0 -34
- data/vendor/local/share/groonga/doc/ja/html/_sources/functions/rand.txt +0 -41
- data/vendor/local/share/groonga/doc/ja/html/_sources/grnslap.txt +0 -64
- data/vendor/local/share/groonga/doc/ja/html/_sources/grntest.txt +0 -259
- data/vendor/local/share/groonga/doc/ja/html/_sources/http.txt +0 -52
- data/vendor/local/share/groonga/doc/ja/html/_sources/index.txt +0 -21
- data/vendor/local/share/groonga/doc/ja/html/_sources/install.txt +0 -114
- data/vendor/local/share/groonga/doc/ja/html/_sources/news.txt +0 -199
- data/vendor/local/share/groonga/doc/ja/html/_sources/process.txt +0 -12
- data/vendor/local/share/groonga/doc/ja/html/_sources/pseudo_column.txt +0 -38
- data/vendor/local/share/groonga/doc/ja/html/_sources/reference.txt +0 -14
- data/vendor/local/share/groonga/doc/ja/html/_sources/tutorial.txt +0 -10
- data/vendor/local/share/groonga/doc/ja/html/_sources/tutorial/tutorial01.txt +0 -293
- data/vendor/local/share/groonga/doc/ja/html/_sources/tutorial/tutorial02.txt +0 -100
- data/vendor/local/share/groonga/doc/ja/html/_sources/tutorial/tutorial03.txt +0 -72
- data/vendor/local/share/groonga/doc/ja/html/_sources/tutorial/tutorial04.txt +0 -111
- data/vendor/local/share/groonga/doc/ja/html/_sources/tutorial/tutorial05.txt +0 -65
- data/vendor/local/share/groonga/doc/ja/html/_sources/tutorial/tutorial06.txt +0 -91
- data/vendor/local/share/groonga/doc/ja/html/_sources/tutorial/tutorial07.txt +0 -92
- data/vendor/local/share/groonga/doc/ja/html/_sources/tutorial/tutorial08.txt +0 -53
- data/vendor/local/share/groonga/doc/ja/html/_sources/tutorial/tutorial09.txt +0 -9
- data/vendor/local/share/groonga/doc/ja/html/_sources/tutorial/tutorial10.txt +0 -486
- data/vendor/local/share/groonga/doc/ja/html/_sources/type.txt +0 -118
- data/vendor/local/share/groonga/doc/ja/html/_static/basic.css +0 -509
- data/vendor/local/share/groonga/doc/ja/html/_static/default.css +0 -277
- data/vendor/local/share/groonga/doc/ja/html/_static/doctools.js +0 -247
- data/vendor/local/share/groonga/doc/ja/html/_static/file.png +0 -0
- data/vendor/local/share/groonga/doc/ja/html/_static/jquery.js +0 -6240
- data/vendor/local/share/groonga/doc/ja/html/_static/minus.png +0 -0
- data/vendor/local/share/groonga/doc/ja/html/_static/plus.png +0 -0
- data/vendor/local/share/groonga/doc/ja/html/_static/pygments.css +0 -61
- data/vendor/local/share/groonga/doc/ja/html/_static/searchtools.js +0 -518
- data/vendor/local/share/groonga/doc/ja/html/_static/sidebar.js +0 -147
- data/vendor/local/share/groonga/doc/ja/html/_static/underscore.js +0 -16
- data/vendor/local/share/groonga/doc/ja/html/characteristic.html +0 -162
- data/vendor/local/share/groonga/doc/ja/html/commands.html +0 -139
- data/vendor/local/share/groonga/doc/ja/html/commands/cache_limit.html +0 -173
- data/vendor/local/share/groonga/doc/ja/html/commands/check.html +0 -285
- data/vendor/local/share/groonga/doc/ja/html/commands/clearlock.html +0 -180
- data/vendor/local/share/groonga/doc/ja/html/commands/column_create.html +0 -210
- data/vendor/local/share/groonga/doc/ja/html/commands/column_list.html +0 -220
- data/vendor/local/share/groonga/doc/ja/html/commands/column_remove.html +0 -183
- data/vendor/local/share/groonga/doc/ja/html/commands/define_selector.html +0 -221
- data/vendor/local/share/groonga/doc/ja/html/commands/defrag.html +0 -177
- data/vendor/local/share/groonga/doc/ja/html/commands/delete.html +0 -182
- data/vendor/local/share/groonga/doc/ja/html/commands/dump.html +0 -177
- data/vendor/local/share/groonga/doc/ja/html/commands/load.html +0 -208
- data/vendor/local/share/groonga/doc/ja/html/commands/log_level.html +0 -187
- data/vendor/local/share/groonga/doc/ja/html/commands/log_put.html +0 -190
- data/vendor/local/share/groonga/doc/ja/html/commands/log_reopen.html +0 -188
- data/vendor/local/share/groonga/doc/ja/html/commands/quit.html +0 -156
- data/vendor/local/share/groonga/doc/ja/html/commands/select.html +0 -331
- data/vendor/local/share/groonga/doc/ja/html/commands/shutdown.html +0 -156
- data/vendor/local/share/groonga/doc/ja/html/commands/status.html +0 -179
- data/vendor/local/share/groonga/doc/ja/html/commands/suggest.html +0 -191
- data/vendor/local/share/groonga/doc/ja/html/commands/table_create.html +0 -222
- data/vendor/local/share/groonga/doc/ja/html/commands/table_list.html +0 -202
- data/vendor/local/share/groonga/doc/ja/html/commands/table_remove.html +0 -173
- data/vendor/local/share/groonga/doc/ja/html/commands/view_add.html +0 -175
- data/vendor/local/share/groonga/doc/ja/html/commands_not_implemented/add.html +0 -180
- data/vendor/local/share/groonga/doc/ja/html/commands_not_implemented/get.html +0 -161
- data/vendor/local/share/groonga/doc/ja/html/commands_not_implemented/set.html +0 -182
- data/vendor/local/share/groonga/doc/ja/html/developer.html +0 -118
- data/vendor/local/share/groonga/doc/ja/html/developer/com.html +0 -136
- data/vendor/local/share/groonga/doc/ja/html/developer/document.html +0 -159
- data/vendor/local/share/groonga/doc/ja/html/developer/query.html +0 -336
- data/vendor/local/share/groonga/doc/ja/html/developer/test.html +0 -220
- data/vendor/local/share/groonga/doc/ja/html/execfile.html +0 -370
- data/vendor/local/share/groonga/doc/ja/html/expr.html +0 -157
- data/vendor/local/share/groonga/doc/ja/html/functions.html +0 -122
- data/vendor/local/share/groonga/doc/ja/html/functions/edit_distance.html +0 -162
- data/vendor/local/share/groonga/doc/ja/html/functions/geo_distance.html +0 -170
- data/vendor/local/share/groonga/doc/ja/html/functions/geo_in_circle.html +0 -173
- data/vendor/local/share/groonga/doc/ja/html/functions/geo_in_rectangle.html +0 -172
- data/vendor/local/share/groonga/doc/ja/html/functions/now.html +0 -152
- data/vendor/local/share/groonga/doc/ja/html/functions/rand.html +0 -159
- data/vendor/local/share/groonga/doc/ja/html/genindex.html +0 -227
- data/vendor/local/share/groonga/doc/ja/html/grnslap.html +0 -183
- data/vendor/local/share/groonga/doc/ja/html/grntest.html +0 -368
- data/vendor/local/share/groonga/doc/ja/html/http.html +0 -163
- data/vendor/local/share/groonga/doc/ja/html/index.html +0 -291
- data/vendor/local/share/groonga/doc/ja/html/install.html +0 -228
- data/vendor/local/share/groonga/doc/ja/html/news.html +0 -310
- data/vendor/local/share/groonga/doc/ja/html/objects.inv +0 -0
- data/vendor/local/share/groonga/doc/ja/html/process.html +0 -120
- data/vendor/local/share/groonga/doc/ja/html/pseudo_column.html +0 -147
- data/vendor/local/share/groonga/doc/ja/html/reference.html +0 -174
- data/vendor/local/share/groonga/doc/ja/html/search.html +0 -96
- data/vendor/local/share/groonga/doc/ja/html/searchindex.js +0 -1
- data/vendor/local/share/groonga/doc/ja/html/tutorial.html +0 -172
- data/vendor/local/share/groonga/doc/ja/html/tutorial/tutorial01.html +0 -388
- data/vendor/local/share/groonga/doc/ja/html/tutorial/tutorial02.html +0 -214
- data/vendor/local/share/groonga/doc/ja/html/tutorial/tutorial03.html +0 -183
- data/vendor/local/share/groonga/doc/ja/html/tutorial/tutorial04.html +0 -212
- data/vendor/local/share/groonga/doc/ja/html/tutorial/tutorial05.html +0 -169
- data/vendor/local/share/groonga/doc/ja/html/tutorial/tutorial06.html +0 -209
- data/vendor/local/share/groonga/doc/ja/html/tutorial/tutorial07.html +0 -212
- data/vendor/local/share/groonga/doc/ja/html/tutorial/tutorial08.html +0 -139
- data/vendor/local/share/groonga/doc/ja/html/tutorial/tutorial09.html +0 -114
- data/vendor/local/share/groonga/doc/ja/html/tutorial/tutorial10.html +0 -458
- data/vendor/local/share/groonga/doc/ja/html/type.html +0 -217
- data/vendor/local/share/groonga/doc/ja/source/__init__.py +0 -0
- data/vendor/local/share/groonga/doc/ja/source/characteristic.txt +0 -56
- data/vendor/local/share/groonga/doc/ja/source/commands.txt +0 -10
- data/vendor/local/share/groonga/doc/ja/source/commands/cache_limit.txt +0 -52
- data/vendor/local/share/groonga/doc/ja/source/commands/check.txt +0 -164
- data/vendor/local/share/groonga/doc/ja/source/commands/clearlock.txt +0 -61
- data/vendor/local/share/groonga/doc/ja/source/commands/column_create.txt +0 -93
- data/vendor/local/share/groonga/doc/ja/source/commands/column_list.txt +0 -97
- data/vendor/local/share/groonga/doc/ja/source/commands/column_remove.txt +0 -58
- data/vendor/local/share/groonga/doc/ja/source/commands/define_selector.txt +0 -114
- data/vendor/local/share/groonga/doc/ja/source/commands/defrag.txt +0 -57
- data/vendor/local/share/groonga/doc/ja/source/commands/delete.txt +0 -68
- data/vendor/local/share/groonga/doc/ja/source/commands/dump.txt +0 -62
- data/vendor/local/share/groonga/doc/ja/source/commands/load.txt +0 -98
- data/vendor/local/share/groonga/doc/ja/source/commands/log_level.txt +0 -65
- data/vendor/local/share/groonga/doc/ja/source/commands/log_put.txt +0 -69
- data/vendor/local/share/groonga/doc/ja/source/commands/log_reopen.txt +0 -66
- data/vendor/local/share/groonga/doc/ja/source/commands/quit.txt +0 -38
- data/vendor/local/share/groonga/doc/ja/source/commands/select.txt +0 -247
- data/vendor/local/share/groonga/doc/ja/source/commands/shutdown.txt +0 -38
- data/vendor/local/share/groonga/doc/ja/source/commands/status.txt +0 -59
- data/vendor/local/share/groonga/doc/ja/source/commands/table_create.txt +0 -111
- data/vendor/local/share/groonga/doc/ja/source/commands/table_list.txt +0 -87
- data/vendor/local/share/groonga/doc/ja/source/commands/table_remove.txt +0 -50
- data/vendor/local/share/groonga/doc/ja/source/commands/view_add.txt +0 -53
- data/vendor/local/share/groonga/doc/ja/source/commands_not_implemented/add.txt +0 -102
- data/vendor/local/share/groonga/doc/ja/source/commands_not_implemented/get.txt +0 -78
- data/vendor/local/share/groonga/doc/ja/source/commands_not_implemented/set.txt +0 -103
- data/vendor/local/share/groonga/doc/ja/source/conf.py +0 -265
- data/vendor/local/share/groonga/doc/ja/source/developer.txt +0 -10
- data/vendor/local/share/groonga/doc/ja/source/developer/com.txt +0 -18
- data/vendor/local/share/groonga/doc/ja/source/developer/document.txt +0 -38
- data/vendor/local/share/groonga/doc/ja/source/developer/query.txt +0 -212
- data/vendor/local/share/groonga/doc/ja/source/developer/test.txt +0 -114
- data/vendor/local/share/groonga/doc/ja/source/example/tutorial01-1.log +0 -6
- data/vendor/local/share/groonga/doc/ja/source/example/tutorial01-10.log +0 -5
- data/vendor/local/share/groonga/doc/ja/source/example/tutorial01-11.log +0 -5
- data/vendor/local/share/groonga/doc/ja/source/example/tutorial01-12.log +0 -5
- data/vendor/local/share/groonga/doc/ja/source/example/tutorial01-13.log +0 -5
- data/vendor/local/share/groonga/doc/ja/source/example/tutorial01-14.log +0 -9
- data/vendor/local/share/groonga/doc/ja/source/example/tutorial01-15.log +0 -5
- data/vendor/local/share/groonga/doc/ja/source/example/tutorial01-16.log +0 -5
- data/vendor/local/share/groonga/doc/ja/source/example/tutorial01-17.log +0 -5
- data/vendor/local/share/groonga/doc/ja/source/example/tutorial01-2.log +0 -5
- data/vendor/local/share/groonga/doc/ja/source/example/tutorial01-3.log +0 -5
- data/vendor/local/share/groonga/doc/ja/source/example/tutorial01-4.log +0 -7
- data/vendor/local/share/groonga/doc/ja/source/example/tutorial01-5.log +0 -5
- data/vendor/local/share/groonga/doc/ja/source/example/tutorial01-6.log +0 -5
- data/vendor/local/share/groonga/doc/ja/source/example/tutorial01-7.log +0 -16
- data/vendor/local/share/groonga/doc/ja/source/example/tutorial01-8.log +0 -5
- data/vendor/local/share/groonga/doc/ja/source/example/tutorial01-9.log +0 -5
- data/vendor/local/share/groonga/doc/ja/source/example/tutorial02-1.log +0 -8
- data/vendor/local/share/groonga/doc/ja/source/example/tutorial02-2.log +0 -6
- data/vendor/local/share/groonga/doc/ja/source/example/tutorial02-3.log +0 -12
- data/vendor/local/share/groonga/doc/ja/source/example/tutorial03-1.log +0 -18
- data/vendor/local/share/groonga/doc/ja/source/example/tutorial03-2.log +0 -10
- data/vendor/local/share/groonga/doc/ja/source/example/tutorial03-3.log +0 -10
- data/vendor/local/share/groonga/doc/ja/source/example/tutorial04-1.log +0 -5
- data/vendor/local/share/groonga/doc/ja/source/example/tutorial04-2.log +0 -7
- data/vendor/local/share/groonga/doc/ja/source/example/tutorial04-3.log +0 -7
- data/vendor/local/share/groonga/doc/ja/source/example/tutorial04-4.log +0 -13
- data/vendor/local/share/groonga/doc/ja/source/example/tutorial04-5.log +0 -5
- data/vendor/local/share/groonga/doc/ja/source/example/tutorial04-6.log +0 -5
- data/vendor/local/share/groonga/doc/ja/source/example/tutorial04-7.log +0 -5
- data/vendor/local/share/groonga/doc/ja/source/example/tutorial05-1.log +0 -24
- data/vendor/local/share/groonga/doc/ja/source/example/tutorial05-2.log +0 -5
- data/vendor/local/share/groonga/doc/ja/source/example/tutorial05-3.log +0 -5
- data/vendor/local/share/groonga/doc/ja/source/example/tutorial05-4.log +0 -5
- data/vendor/local/share/groonga/doc/ja/source/example/tutorial05-5.log +0 -5
- data/vendor/local/share/groonga/doc/ja/source/example/tutorial05-6.log +0 -5
- data/vendor/local/share/groonga/doc/ja/source/example/tutorial06-1.log +0 -25
- data/vendor/local/share/groonga/doc/ja/source/example/tutorial06-2.log +0 -9
- data/vendor/local/share/groonga/doc/ja/source/example/tutorial06-3.log +0 -21
- data/vendor/local/share/groonga/doc/ja/source/example/tutorial06-4.log +0 -7
- data/vendor/local/share/groonga/doc/ja/source/example/tutorial06-5.log +0 -5
- data/vendor/local/share/groonga/doc/ja/source/example/tutorial07-1.log +0 -22
- data/vendor/local/share/groonga/doc/ja/source/example/tutorial07-2.log +0 -9
- data/vendor/local/share/groonga/doc/ja/source/example/tutorial07-3.log +0 -20
- data/vendor/local/share/groonga/doc/ja/source/example/tutorial07-4.log +0 -9
- data/vendor/local/share/groonga/doc/ja/source/example/tutorial08-1.log +0 -14
- data/vendor/local/share/groonga/doc/ja/source/example/tutorial10-1.log +0 -5
- data/vendor/local/share/groonga/doc/ja/source/example/tutorial10-10.log +0 -5
- data/vendor/local/share/groonga/doc/ja/source/example/tutorial10-2.log +0 -5
- data/vendor/local/share/groonga/doc/ja/source/example/tutorial10-3.log +0 -5
- data/vendor/local/share/groonga/doc/ja/source/example/tutorial10-4.log +0 -5
- data/vendor/local/share/groonga/doc/ja/source/example/tutorial10-5.log +0 -5
- data/vendor/local/share/groonga/doc/ja/source/example/tutorial10-6.log +0 -5
- data/vendor/local/share/groonga/doc/ja/source/example/tutorial10-7.log +0 -5
- data/vendor/local/share/groonga/doc/ja/source/example/tutorial10-8.log +0 -5
- data/vendor/local/share/groonga/doc/ja/source/example/tutorial10-9.log +0 -5
- data/vendor/local/share/groonga/doc/ja/source/execfile.txt +0 -226
- data/vendor/local/share/groonga/doc/ja/source/expr.txt +0 -43
- data/vendor/local/share/groonga/doc/ja/source/functions.txt +0 -10
- data/vendor/local/share/groonga/doc/ja/source/functions/edit_distance.txt +0 -48
- data/vendor/local/share/groonga/doc/ja/source/functions/geo_distance.txt +0 -51
- data/vendor/local/share/groonga/doc/ja/source/functions/geo_in_circle.txt +0 -54
- data/vendor/local/share/groonga/doc/ja/source/functions/geo_in_rectangle.txt +0 -55
- data/vendor/local/share/groonga/doc/ja/source/functions/now.txt +0 -34
- data/vendor/local/share/groonga/doc/ja/source/functions/rand.txt +0 -41
- data/vendor/local/share/groonga/doc/ja/source/grnslap.txt +0 -64
- data/vendor/local/share/groonga/doc/ja/source/grntest.txt +0 -259
- data/vendor/local/share/groonga/doc/ja/source/http.txt +0 -52
- data/vendor/local/share/groonga/doc/ja/source/index.txt +0 -21
- data/vendor/local/share/groonga/doc/ja/source/install.txt +0 -114
- data/vendor/local/share/groonga/doc/ja/source/news.txt +0 -199
- data/vendor/local/share/groonga/doc/ja/source/process.txt +0 -12
- data/vendor/local/share/groonga/doc/ja/source/pseudo_column.txt +0 -38
- data/vendor/local/share/groonga/doc/ja/source/rdoc.py +0 -762
- data/vendor/local/share/groonga/doc/ja/source/reference.txt +0 -14
- data/vendor/local/share/groonga/doc/ja/source/tutorial.txt +0 -10
- data/vendor/local/share/groonga/doc/ja/source/tutorial/tutorial01.txt +0 -293
- data/vendor/local/share/groonga/doc/ja/source/tutorial/tutorial02.txt +0 -100
- data/vendor/local/share/groonga/doc/ja/source/tutorial/tutorial03.txt +0 -72
- data/vendor/local/share/groonga/doc/ja/source/tutorial/tutorial04.txt +0 -111
- data/vendor/local/share/groonga/doc/ja/source/tutorial/tutorial05.txt +0 -65
- data/vendor/local/share/groonga/doc/ja/source/tutorial/tutorial06.txt +0 -91
- data/vendor/local/share/groonga/doc/ja/source/tutorial/tutorial07.txt +0 -92
- data/vendor/local/share/groonga/doc/ja/source/tutorial/tutorial08.txt +0 -53
- data/vendor/local/share/groonga/doc/ja/source/tutorial/tutorial09.txt +0 -9
- data/vendor/local/share/groonga/doc/ja/source/tutorial/tutorial10.txt +0 -486
- data/vendor/local/share/groonga/doc/ja/source/type.txt +0 -118
- data/vendor/local/share/groonga/doc/ja/source/update_execution_example.py +0 -113
- data/vendor/local/share/man/man1/groonga.1 +0 -5498
@@ -1,6 +1,6 @@
|
|
1
1
|
# -*- coding: utf-8 -*-
|
2
2
|
#
|
3
|
-
# Copyright (C) 2009-
|
3
|
+
# Copyright (C) 2009-2011 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
|
@@ -39,7 +39,7 @@ module Groonga
|
|
39
39
|
end
|
40
40
|
|
41
41
|
def build(&block)
|
42
|
-
expression = Expression.new(:name => @name)
|
42
|
+
expression = Expression.new(:name => @name, :context => @table.context)
|
43
43
|
variable = expression.define_variable(:domain => @table)
|
44
44
|
build_expression(expression, variable, &block)
|
45
45
|
end
|
@@ -212,13 +212,25 @@ module Groonga
|
|
212
212
|
SubExpressionBuilder.new(query, options)
|
213
213
|
end
|
214
214
|
|
215
|
+
def prefix_search(other)
|
216
|
+
PrefixSearchExpressionBuilder.new(self, normalize(other))
|
217
|
+
end
|
218
|
+
|
219
|
+
def suffix_search(other)
|
220
|
+
SuffixSearchExpressionBuilder.new(self, normalize(other))
|
221
|
+
end
|
222
|
+
|
215
223
|
private
|
216
224
|
def normalize(other)
|
217
|
-
if @range.is_a?(Groonga::Table)
|
218
|
-
|
219
|
-
|
220
|
-
|
225
|
+
if @range.is_a?(Groonga::Table)
|
226
|
+
if other.respond_to?(:record_id)
|
227
|
+
id = other.record_id
|
228
|
+
else
|
229
|
+
id = other
|
230
|
+
end
|
231
|
+
return Groonga::Record.new(@range, id) if id.is_a?(Integer)
|
221
232
|
end
|
233
|
+
other
|
222
234
|
end
|
223
235
|
|
224
236
|
def method_missing(name, *args, &block)
|
@@ -359,6 +371,18 @@ module Groonga
|
|
359
371
|
expression.parse(@query, @options)
|
360
372
|
end
|
361
373
|
end
|
374
|
+
|
375
|
+
class PrefixSearchExpressionBuilder < BinaryExpressionBuilder # :nodoc:
|
376
|
+
def initialize(column_value_builder, value)
|
377
|
+
super(Groonga::Operation::PREFIX, column_value_builder, value)
|
378
|
+
end
|
379
|
+
end
|
380
|
+
|
381
|
+
class SuffixSearchExpressionBuilder < BinaryExpressionBuilder # :nodoc:
|
382
|
+
def initialize(column_value_builder, value)
|
383
|
+
super(Groonga::Operation::SUFFIX, column_value_builder, value)
|
384
|
+
end
|
385
|
+
end
|
362
386
|
end
|
363
387
|
|
364
388
|
class RecordExpressionBuilder # :nodoc:
|
@@ -414,6 +438,18 @@ module Groonga
|
|
414
438
|
MatchTargetExpressionBuilder.new(build_match_target(&block))
|
415
439
|
end
|
416
440
|
|
441
|
+
def index(name)
|
442
|
+
object = @table.context[name]
|
443
|
+
if object.nil?
|
444
|
+
raise ArgumentError, "unknown index column: <#{name}>"
|
445
|
+
end
|
446
|
+
if object.range != @table
|
447
|
+
raise ArgumentError,
|
448
|
+
"differenct index column: <#{name}>: #{object.inspect}"
|
449
|
+
end
|
450
|
+
column_expression_builder(object, name)
|
451
|
+
end
|
452
|
+
|
417
453
|
private
|
418
454
|
def build_match_target(&block)
|
419
455
|
sub_builder = MatchTargetRecordExpressionBuilder.new(@table, nil)
|
data/lib/groonga/record.rb
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
# -*- coding: utf-8 -*-
|
2
2
|
#
|
3
|
-
# Copyright (C) 2009-
|
3
|
+
# Copyright (C) 2009-2011 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
|
@@ -21,8 +21,6 @@ module Groonga
|
|
21
21
|
class Record
|
22
22
|
# レコードが所属するテーブル
|
23
23
|
attr_reader :table
|
24
|
-
# レコードのID
|
25
|
-
attr_reader :id
|
26
24
|
# _table_の_id_に対応するレコードを作成する。_values_には各
|
27
25
|
# カラムに設定する値を以下のような形式で指定する。
|
28
26
|
#
|
@@ -104,15 +102,22 @@ module Groonga
|
|
104
102
|
column(column_name).prepend(@id, value)
|
105
103
|
end
|
106
104
|
|
105
|
+
# call-seq:
|
106
|
+
# record.support_key? -> true/false
|
107
|
+
#
|
108
|
+
# _record_が所属するテーブルで主キーを使える場合は+true+
|
109
|
+
# を返し、使えない場合は+false+を返す。
|
110
|
+
def support_key?
|
111
|
+
@table.support_key?
|
112
|
+
end
|
113
|
+
|
107
114
|
# call-seq:
|
108
115
|
# record.have_column?(name) -> true/false
|
109
116
|
#
|
110
117
|
# 名前が_name_のカラムがレコードの所属するテーブルで定義され
|
111
118
|
# ているなら+true+を返す。
|
112
119
|
def have_column?(name)
|
113
|
-
column(name).
|
114
|
-
rescue Groonga::NoSuchColumn
|
115
|
-
false
|
120
|
+
not @table.column(normalize_column_name(name)).nil?
|
116
121
|
end
|
117
122
|
|
118
123
|
# call-seq:
|
@@ -120,7 +125,36 @@ module Groonga
|
|
120
125
|
#
|
121
126
|
# 名前が_name_のカラムが参照カラムであるなら+true+を返す。
|
122
127
|
def reference_column?(name)
|
123
|
-
column(name).
|
128
|
+
column(name).reference?
|
129
|
+
end
|
130
|
+
|
131
|
+
# call-seq:
|
132
|
+
# record.index_column?(name) -> true/false
|
133
|
+
#
|
134
|
+
# 名前が_name_のカラムが索引カラム
|
135
|
+
# (Groonga::IndexColumn)であるなら+true+を返す。
|
136
|
+
def index_column?(name)
|
137
|
+
column(name).index?
|
138
|
+
end
|
139
|
+
|
140
|
+
# call-seq:
|
141
|
+
# record.vector_column?(name) -> true/false
|
142
|
+
#
|
143
|
+
# 名前が_name_のカラムの値がベクターであるなら+true+を返す。
|
144
|
+
#
|
145
|
+
# @since: 1.0.5
|
146
|
+
def vector_column?(name)
|
147
|
+
column(name).vector?
|
148
|
+
end
|
149
|
+
|
150
|
+
# call-seq:
|
151
|
+
# record.scalar_column?(name) -> true/false
|
152
|
+
#
|
153
|
+
# 名前が_name_のカラムの値がスカラーであるなら+true+を返す。
|
154
|
+
#
|
155
|
+
# @since: 1.0.5
|
156
|
+
def scalar_column?(name)
|
157
|
+
column(name).scalar?
|
124
158
|
end
|
125
159
|
|
126
160
|
# call-seq:
|
@@ -141,20 +175,44 @@ module Groonga
|
|
141
175
|
# _record_が所属するテーブルがGroonga:::Arrayの場合は常
|
142
176
|
# に+nil+を返す。
|
143
177
|
def key
|
144
|
-
if
|
178
|
+
if support_key?
|
179
|
+
@key ||= @table.key(@id)
|
180
|
+
else
|
145
181
|
nil
|
182
|
+
end
|
183
|
+
end
|
184
|
+
|
185
|
+
# call-seq:
|
186
|
+
# record.record_id -> IDまたは主キー
|
187
|
+
#
|
188
|
+
# レコードを一意に識別するための情報を返す。
|
189
|
+
#
|
190
|
+
# _record_が所属するテーブルがGroonga:::Arrayの場合はID
|
191
|
+
# を返し、それ以外の場合は主キーを返す。
|
192
|
+
def record_id
|
193
|
+
if support_key?
|
194
|
+
key
|
146
195
|
else
|
147
|
-
|
196
|
+
id
|
148
197
|
end
|
149
198
|
end
|
150
199
|
|
200
|
+
# call-seq:
|
201
|
+
# record.record_raw_id -> ID
|
202
|
+
#
|
203
|
+
# レコードのIDを返す。
|
204
|
+
def record_raw_id
|
205
|
+
@id
|
206
|
+
end
|
207
|
+
alias_method :id, :record_raw_id
|
208
|
+
|
151
209
|
# call-seq:
|
152
210
|
# record.score -> スコア値
|
153
211
|
#
|
154
212
|
# レコードのスコア値を返す。検索結果として生成されたテーブル
|
155
213
|
# のみに定義される。
|
156
214
|
def score
|
157
|
-
self["
|
215
|
+
self["_score"]
|
158
216
|
end
|
159
217
|
|
160
218
|
# call-seq:
|
@@ -163,10 +221,10 @@ module Groonga
|
|
163
221
|
# 主キーの値が同一であったレコードの件数を返す。検索結果とし
|
164
222
|
# て生成されたテーブルのみに定義される。
|
165
223
|
#
|
166
|
-
# Groonga::Record#support_sub_records
|
224
|
+
# Groonga::Record#support_sub_records?でこの値を利用でき
|
167
225
|
# るかがわかる。
|
168
226
|
def n_sub_records
|
169
|
-
self["
|
227
|
+
self["_nsubrecs"]
|
170
228
|
end
|
171
229
|
|
172
230
|
# call-seq:
|
@@ -228,8 +286,7 @@ module Groonga
|
|
228
286
|
# たこのレコードのカラムの値のハッシュを返す。
|
229
287
|
def attributes
|
230
288
|
attributes = {"id" => id}
|
231
|
-
|
232
|
-
attributes["key"] = _key if _key
|
289
|
+
attributes["key"] = key if support_key?
|
233
290
|
table_name = @table.name
|
234
291
|
columns.each do |column|
|
235
292
|
next if column.is_a?(Groonga::IndexColumn)
|
@@ -298,6 +355,14 @@ module Groonga
|
|
298
355
|
@table.locked?(options.merge(:id => @id))
|
299
356
|
end
|
300
357
|
|
358
|
+
# call-seq:
|
359
|
+
# record.valid_id? -> true/false
|
360
|
+
#
|
361
|
+
# レコードが持つIDが有効なIDであれば+true+を返す。
|
362
|
+
def valid_id?
|
363
|
+
@table.exist?(@id)
|
364
|
+
end
|
365
|
+
|
301
366
|
def methods(include_inherited=true) # :nodoc:
|
302
367
|
_methods = super
|
303
368
|
return _methods unless include_inherited
|
@@ -314,8 +379,12 @@ module Groonga
|
|
314
379
|
end
|
315
380
|
|
316
381
|
private
|
382
|
+
def normalize_column_name(name)
|
383
|
+
name.to_s
|
384
|
+
end
|
385
|
+
|
317
386
|
def column(name) # :nodoc:
|
318
|
-
_column = @table.column(name
|
387
|
+
_column = @table.column(normalize_column_name(name))
|
319
388
|
raise NoSuchColumn, "column(#{name.inspect}) is nil" if _column.nil?
|
320
389
|
_column
|
321
390
|
end
|
data/lib/groonga/schema.rb
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
# -*- coding: utf-8 -*-
|
2
2
|
#
|
3
|
-
# Copyright (C) 2009-
|
3
|
+
# Copyright (C) 2009-2011 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
|
@@ -15,6 +15,7 @@
|
|
15
15
|
# License along with this library; if not, write to the Free Software
|
16
16
|
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
17
17
|
|
18
|
+
require 'fileutils'
|
18
19
|
|
19
20
|
module Groonga
|
20
21
|
|
@@ -80,12 +81,22 @@ module Groonga
|
|
80
81
|
end
|
81
82
|
end
|
82
83
|
|
84
|
+
# 未知のインデックス対象テーブルを指定したときに発生する。
|
85
|
+
class UnknownIndexTargetTable < Error
|
86
|
+
attr_reader :table
|
87
|
+
def initialize(table)
|
88
|
+
@table = table
|
89
|
+
super("unknown index target table: <#{@table.inspect}>")
|
90
|
+
end
|
91
|
+
end
|
92
|
+
|
83
93
|
# 未知のインデックス対象を指定したときに発生する。
|
84
94
|
class UnknownIndexTarget < Error
|
85
|
-
attr_reader :
|
86
|
-
def initialize(
|
87
|
-
@
|
88
|
-
|
95
|
+
attr_reader :table, :targets
|
96
|
+
def initialize(table, targets)
|
97
|
+
@table = table
|
98
|
+
@targets = targets
|
99
|
+
super("unknown index target: <#{@table.inspect}>: <#{@targets.inspect}>")
|
89
100
|
end
|
90
101
|
end
|
91
102
|
|
@@ -96,7 +107,7 @@ module Groonga
|
|
96
107
|
@options = options
|
97
108
|
@unknown_keys = unknown_keys
|
98
109
|
@available_keys = available_keys
|
99
|
-
message = "unknown keys are specified: #{
|
110
|
+
message = "unknown keys are specified: #{@unknown_keys.inspect}"
|
100
111
|
message << ": available keys: #{@available_keys.inspect}"
|
101
112
|
message << ": options: #{@options.inspect}"
|
102
113
|
super(message)
|
@@ -114,6 +125,18 @@ module Groonga
|
|
114
125
|
end
|
115
126
|
end
|
116
127
|
|
128
|
+
# 参照先のテーブルを推測できないときに発生する。
|
129
|
+
class UnguessableReferenceTable < Error
|
130
|
+
attr_reader :name, :tried_table_names
|
131
|
+
def initialize(name, tried_table_names)
|
132
|
+
@name = name
|
133
|
+
@tried_table_names = tried_table_names
|
134
|
+
super("failed to guess referenced table name " +
|
135
|
+
"for reference column: #{@name.inspect}: " +
|
136
|
+
"tried table names: #{@tried_table_names.inspect}")
|
137
|
+
end
|
138
|
+
end
|
139
|
+
|
117
140
|
class << self
|
118
141
|
|
119
142
|
# call-seq:
|
@@ -349,6 +372,20 @@ module Groonga
|
|
349
372
|
end
|
350
373
|
end
|
351
374
|
|
375
|
+
# call-seq:
|
376
|
+
# Groonga::Schema.remove_column(table_name, column_name)
|
377
|
+
#
|
378
|
+
# 以下と同様:
|
379
|
+
#
|
380
|
+
# Groonga::Schema.change_table(table_name) do |table|
|
381
|
+
# table.remove_column(column_name)
|
382
|
+
# end
|
383
|
+
def remove_column(table_name, column_name)
|
384
|
+
change_table(table_name) do |table|
|
385
|
+
table.remove_column(column_name)
|
386
|
+
end
|
387
|
+
end
|
388
|
+
|
352
389
|
# スキーマの内容を文字列で返す。返された値は
|
353
390
|
# Groonga::Schema.restoreすることによりスキーマ内に組
|
354
391
|
# み込むことができる。
|
@@ -369,39 +406,78 @@ module Groonga
|
|
369
406
|
# スキーマ定義時に使用するGroonga::Contextを指定する。
|
370
407
|
# 省略した場合はGroonga::Context.defaultを使用する。
|
371
408
|
def dump(options={})
|
372
|
-
|
409
|
+
options = options.dup
|
410
|
+
schema = new(:context => options.delete(:context))
|
411
|
+
schema.dump
|
373
412
|
end
|
374
413
|
|
375
414
|
# Groonga::Schema.dumpで文字列化したスキーマを組み込む。
|
376
415
|
def restore(dumped_text, options={})
|
377
416
|
define(options) do |schema|
|
378
|
-
schema.
|
417
|
+
schema.restore(dumped_text)
|
379
418
|
end
|
380
419
|
end
|
381
420
|
|
421
|
+
NORMALIZE_TYPE_TABLE = {
|
422
|
+
"short_text" => "ShortText",
|
423
|
+
"string" => "ShortText",
|
424
|
+
"text" => "Text",
|
425
|
+
"binary" => "LongText",
|
426
|
+
"long_text" => "LongText",
|
427
|
+
"int" => "Int32",
|
428
|
+
"integer" => "Int32",
|
429
|
+
"int32" => "Int32",
|
430
|
+
"integer32" => "Int32",
|
431
|
+
"decimal" => "Int64",
|
432
|
+
"int64" => "Int64",
|
433
|
+
"integer64" => "Int64",
|
434
|
+
"uint" => "UInt32",
|
435
|
+
"unsigned_integer" => "UInt32",
|
436
|
+
"uint32" => "UInt32",
|
437
|
+
"unsigned_integer32" => "UInt32",
|
438
|
+
"uint64" => "UInt64",
|
439
|
+
"unsigned_integer64" => "UInt64",
|
440
|
+
"float" => "Float",
|
441
|
+
"datetime" => "Time",
|
442
|
+
"timestamp" => "Time",
|
443
|
+
"time" => "Time",
|
444
|
+
"date" => "Time",
|
445
|
+
"boolean" => "Bool",
|
446
|
+
"unigram" => "TokenUnigram",
|
447
|
+
"token_unigram" => "TokenUnigram",
|
448
|
+
"bigram" => "TokenBigram",
|
449
|
+
"token_bigram" => "TokenBigram",
|
450
|
+
"bigram_split_symbol" => "TokenBigramSplitSymbol",
|
451
|
+
"token_bigram_split_symbol" => "TokenBigramSplitSymbol",
|
452
|
+
"bigram_split_symbol_alpha" => "TokenBigramSplitSymbolAlpha",
|
453
|
+
"token_bigram_split_symbol_alpha" => "TokenBigramSplitSymbolAlpha",
|
454
|
+
"bigram_split_symbol_alpha_digit" => "TokenBigramSplitSymbolAlphaDigit",
|
455
|
+
"token_bigram_split_symbol_alpha_digit" =>
|
456
|
+
"TokenBigramSplitSymbolAlphaDigit",
|
457
|
+
"bigram_ignore_blank" => "TokenBigramIgnoreBlank",
|
458
|
+
"token_bigram_ignore_blank" => "TokenBigramIgnoreBlank",
|
459
|
+
"bigram_ignore_blank_split_symbol" =>
|
460
|
+
"TokenBigramIgnoreBlankSplitSymbol",
|
461
|
+
"token_bigram_ignore_blank_split_symbol" =>
|
462
|
+
"TokenBigramIgnoreBlankSplitSymbol",
|
463
|
+
"bigram_ignore_blank_split_symbol_alpha" =>
|
464
|
+
"TokenBigramIgnoreBlankSplitSymbolAlpha",
|
465
|
+
"token_bigram_ignore_blank_split_symbol_alpha" =>
|
466
|
+
"TokenBigramIgnoreBlankSplitSymbolAlpha",
|
467
|
+
"bigram_ignore_blank_split_symbol_alpha_digit" =>
|
468
|
+
"TokenBigramIgnoreBlankSplitSymbolAlphaDigit",
|
469
|
+
"token_bigram_ignore_blank_split_symbol_alpha_digit" =>
|
470
|
+
"TokenBigramIgnoreBlankSplitSymbolAlphaDigit",
|
471
|
+
"trigram" => "TokenTrigram",
|
472
|
+
"token_trigram" => "TokenTrigram",
|
473
|
+
"mecab" => "TokenMecab",
|
474
|
+
"token_mecab"=> "TokenMecab",
|
475
|
+
}
|
382
476
|
def normalize_type(type) # :nodoc:
|
383
477
|
return type if type.nil?
|
384
478
|
return type if type.is_a?(Groonga::Object)
|
385
|
-
|
386
|
-
|
387
|
-
"ShortText"
|
388
|
-
when "text"
|
389
|
-
"Text"
|
390
|
-
when "int", "integer"
|
391
|
-
"Int32"
|
392
|
-
when "float"
|
393
|
-
"Float"
|
394
|
-
when "decimal"
|
395
|
-
"Int64"
|
396
|
-
when "datetime", "timestamp", "time", "date"
|
397
|
-
"Time"
|
398
|
-
when "binary"
|
399
|
-
"LongText"
|
400
|
-
when "boolean"
|
401
|
-
"Bool"
|
402
|
-
else
|
403
|
-
type
|
404
|
-
end
|
479
|
+
type = type.to_s if type.is_a?(Symbol)
|
480
|
+
NORMALIZE_TYPE_TABLE[type] || type
|
405
481
|
end
|
406
482
|
end
|
407
483
|
|
@@ -414,6 +490,7 @@ module Groonga
|
|
414
490
|
# 省略した場合はGroonga::Context.defaultを使用する。
|
415
491
|
def initialize(options={})
|
416
492
|
@options = (options || {}).dup
|
493
|
+
@options[:context] ||= Groonga::Context.default
|
417
494
|
@definitions = []
|
418
495
|
end
|
419
496
|
|
@@ -424,13 +501,23 @@ module Groonga
|
|
424
501
|
end
|
425
502
|
end
|
426
503
|
|
427
|
-
# Groonga::Schema
|
504
|
+
# Groonga::Schema#dumpで返されたスキーマの内容を読み込む。
|
428
505
|
#
|
429
506
|
# 読み込まれた内容は#defineを呼び出すまでは実行されない
|
430
507
|
# ことに注意すること。
|
431
|
-
def
|
508
|
+
def restore(dumped_text)
|
432
509
|
instance_eval(dumped_text)
|
433
510
|
end
|
511
|
+
# for backward compatibility.
|
512
|
+
# TODO: remove this at the next major release.
|
513
|
+
alias_method :load, :restore
|
514
|
+
|
515
|
+
# スキーマの内容を文字列で返す。返された値は
|
516
|
+
# Groonga::Schema#restoreすることによりスキーマ内に組み込むことができる。
|
517
|
+
def dump
|
518
|
+
dumper = Dumper.new(:context => @options[:context])
|
519
|
+
dumper.dump
|
520
|
+
end
|
434
521
|
|
435
522
|
# call-seq:
|
436
523
|
# schema.create_table(name, options={}) {|table| ...}
|
@@ -516,7 +603,7 @@ module Groonga
|
|
516
603
|
# 登録される。
|
517
604
|
def create_table(name, options={})
|
518
605
|
definition = TableDefinition.new(name, @options.merge(options || {}))
|
519
|
-
yield(definition)
|
606
|
+
yield(definition) if block_given?
|
520
607
|
@definitions << definition
|
521
608
|
end
|
522
609
|
|
@@ -624,10 +711,47 @@ module Groonga
|
|
624
711
|
@definitions << definition
|
625
712
|
end
|
626
713
|
|
714
|
+
# call-seq:
|
715
|
+
# schema.remove_column(table_name, column_name)
|
716
|
+
#
|
717
|
+
# 以下と同様:
|
718
|
+
#
|
719
|
+
# schema.change_table(table_name) do |table|
|
720
|
+
# table.remove_column(column_name)
|
721
|
+
# end
|
722
|
+
def remove_column(table_name, column_name)
|
723
|
+
change_table(table_name) do |table|
|
724
|
+
table.remove_column(column_name)
|
725
|
+
end
|
726
|
+
end
|
727
|
+
|
728
|
+
def context # :nodoc:
|
729
|
+
@options[:context] || Groonga::Context.default
|
730
|
+
end
|
731
|
+
|
732
|
+
module Path # :nodoc:
|
733
|
+
def tables_directory_path(database)
|
734
|
+
"#{database.path}.tables"
|
735
|
+
end
|
736
|
+
|
737
|
+
def columns_directory_path(table)
|
738
|
+
"#{table.path}.columns"
|
739
|
+
end
|
740
|
+
|
741
|
+
def rmdir_if_dir_exists(dir)
|
742
|
+
begin
|
743
|
+
Dir.rmdir(dir)
|
744
|
+
rescue Errno::ENOENT
|
745
|
+
end
|
746
|
+
end
|
747
|
+
end
|
748
|
+
|
627
749
|
# スキーマ定義時にGroonga::Schema.create_tableや
|
628
750
|
# Groonga::Schema#create_tableからブロックに渡されてくる
|
629
751
|
# オブジェクト
|
630
752
|
class TableDefinition
|
753
|
+
include Path
|
754
|
+
|
631
755
|
# テーブルの名前
|
632
756
|
attr_reader :name
|
633
757
|
|
@@ -708,9 +832,9 @@ module Groonga
|
|
708
832
|
self
|
709
833
|
end
|
710
834
|
|
711
|
-
# 名前が_name_
|
835
|
+
# 名前が_name_のカラムを削除します。
|
712
836
|
#
|
713
|
-
# _options_
|
837
|
+
# _options_に指定可能な値はありません(TODO _options_は不要?)。
|
714
838
|
#
|
715
839
|
def remove_column(name, options={})
|
716
840
|
definition = self[name, ColumnRemoveDefinition]
|
@@ -725,9 +849,11 @@ module Groonga
|
|
725
849
|
# call-seq:
|
726
850
|
# table.index(target_column_full_name, options={})
|
727
851
|
# table.index(target_table, target_column, options={})
|
852
|
+
# table.index(target_table, target_column1, target_column2, ..., options={})
|
728
853
|
#
|
729
|
-
# _target_table_の_target_column_
|
730
|
-
#
|
854
|
+
# _target_table_の_target_column_を対象とするインデック
|
855
|
+
# スカラムを作成します。複数のカラムを指定することもで
|
856
|
+
# きます。
|
731
857
|
#
|
732
858
|
# _target_column_full_name_で指定するときはテーブル名
|
733
859
|
# とカラム名を"."でつなげます。例えば、「Users」テーブ
|
@@ -753,31 +879,71 @@ module Groonga
|
|
753
879
|
# した場合は自動的にパスが付加される。
|
754
880
|
#
|
755
881
|
# [+:with_section+]
|
756
|
-
#
|
882
|
+
# +true+を指定すると転置索引にsection(段落情報)を合
|
883
|
+
# わせて格納する。未指定または+nil+を指定した場合、
|
884
|
+
# 複数のカラムを指定すると自動的に有効になる。
|
757
885
|
#
|
758
886
|
# [+:with_weight+]
|
759
|
-
#
|
887
|
+
# +true+を指定すると転置索引にweight情報を合わせて格
|
888
|
+
# 納する。
|
760
889
|
#
|
761
890
|
# [+:with_position+]
|
762
|
-
#
|
891
|
+
# +true+を指定すると転置索引に出現位置情報を合わせて
|
892
|
+
# 格納する。未指定または+nil+を指定した場合、テーブ
|
893
|
+
# ルがN-gram系のトークナイザーを利用している場合は自
|
894
|
+
# 動的に有効になる。
|
763
895
|
def index(target_table_or_target_column_full_name, *args)
|
764
|
-
|
765
|
-
|
766
|
-
|
896
|
+
key, target_table, target_columns, options =
|
897
|
+
parse_index_argument(target_table_or_target_column_full_name, *args)
|
898
|
+
|
899
|
+
name = options.delete(:name)
|
900
|
+
definition = self[key, IndexColumnDefinition]
|
901
|
+
if definition.nil?
|
902
|
+
definition = IndexColumnDefinition.new(name, options)
|
903
|
+
update_definition(key, IndexColumnDefinition, definition)
|
767
904
|
end
|
768
|
-
|
769
|
-
|
770
|
-
|
771
|
-
|
772
|
-
|
773
|
-
|
774
|
-
|
775
|
-
|
776
|
-
|
777
|
-
|
778
|
-
|
905
|
+
definition.target_table = target_table
|
906
|
+
definition.target_columns = target_columns
|
907
|
+
definition.options.merge!(column_options.merge(options))
|
908
|
+
self
|
909
|
+
end
|
910
|
+
|
911
|
+
# call-seq:
|
912
|
+
# table.remove_index(target_column_full_name, options={})
|
913
|
+
# table.remove_index(target_table, target_column, options={})
|
914
|
+
# table.remove_index(target_table, target_column1, target_column2, ..., options={})
|
915
|
+
#
|
916
|
+
# _target_table_の_target_column_を対象とするインデッ
|
917
|
+
# クスカラムを削除します。
|
918
|
+
#
|
919
|
+
# _target_column_full_name_で指定するときはテーブル名
|
920
|
+
# とカラム名を"."でつなげます。例えば、「Users」テーブ
|
921
|
+
# ルの「name」カラムのインデックスカラムを削除する場合
|
922
|
+
# はこうなります。
|
923
|
+
#
|
924
|
+
# table.remove_index("Users.name")
|
925
|
+
#
|
926
|
+
# _options_に指定可能な値は以下の通り。
|
927
|
+
#
|
928
|
+
# [+:name+]
|
929
|
+
# インデックスカラムのカラム名を任意に指定する。
|
930
|
+
def remove_index(target_table_or_target_column_full_name, *args)
|
931
|
+
key, target_table, target_columns, options =
|
932
|
+
parse_index_argument(target_table_or_target_column_full_name, *args)
|
933
|
+
|
934
|
+
name = options.delete(:name)
|
935
|
+
name ||= lambda do |context|
|
936
|
+
IndexColumnDefinition.column_name(context,
|
937
|
+
target_table,
|
938
|
+
target_columns)
|
939
|
+
end
|
940
|
+
definition = self[key, ColumnRemoveDefinition]
|
941
|
+
if definition.nil?
|
942
|
+
definition = ColumnRemoveDefinition.new(name, options)
|
943
|
+
update_definition(key, ColumnRemoveDefinition, definition)
|
779
944
|
end
|
780
|
-
|
945
|
+
definition.options.merge!(options)
|
946
|
+
self
|
781
947
|
end
|
782
948
|
|
783
949
|
# 名前が_name_の32bit符号付き整数のカラムを作成する。
|
@@ -836,6 +1002,14 @@ module Groonga
|
|
836
1002
|
column(name, "Time", options)
|
837
1003
|
end
|
838
1004
|
|
1005
|
+
# 以下と同様:
|
1006
|
+
# table.time("updated_at")
|
1007
|
+
# table.time("created_at")
|
1008
|
+
def timestamps(options={})
|
1009
|
+
time("created_at", options)
|
1010
|
+
time("updated_at", options)
|
1011
|
+
end
|
1012
|
+
|
839
1013
|
# 名前が_name_の4Kbyte以下の文字列を格納できるカラムを
|
840
1014
|
# 作成する。
|
841
1015
|
#
|
@@ -867,9 +1041,13 @@ module Groonga
|
|
867
1041
|
# 名前が_name_で_table_のレコードIDを格納する参照カラ
|
868
1042
|
# ムを作成する。
|
869
1043
|
#
|
1044
|
+
# _table_が省略された場合は_name_の複数形が使われる。
|
1045
|
+
# 例えば、_name_が"user"な場合は_table_は"users"になる。
|
1046
|
+
#
|
870
1047
|
# _options_に指定可能な値は
|
871
1048
|
# Groonga::Schema::TableDefinition#columnを参照。
|
872
|
-
def reference(name, table, options={})
|
1049
|
+
def reference(name, table=nil, options={})
|
1050
|
+
table ||= lambda {|context| guess_table_name(context, name)}
|
873
1051
|
column(name, table, options)
|
874
1052
|
end
|
875
1053
|
|
@@ -894,8 +1072,8 @@ module Groonga
|
|
894
1072
|
end
|
895
1073
|
|
896
1074
|
private
|
897
|
-
def update_definition(
|
898
|
-
old_definition = self[
|
1075
|
+
def update_definition(key, definition_class, definition) # :nodoc:
|
1076
|
+
old_definition = self[key, definition_class]
|
899
1077
|
if old_definition
|
900
1078
|
index = @definitions.index(old_definition)
|
901
1079
|
@definitions[index] = definition
|
@@ -934,14 +1112,14 @@ module Groonga
|
|
934
1112
|
def create_options # :nodoc:
|
935
1113
|
common = {
|
936
1114
|
:name => @name,
|
937
|
-
:path =>
|
1115
|
+
:path => path,
|
938
1116
|
:persistent => persistent?,
|
939
1117
|
:value_type => @options[:value_type],
|
940
1118
|
:context => context,
|
941
1119
|
:sub_records => @options[:sub_records],
|
942
1120
|
}
|
943
1121
|
key_support_table_common = {
|
944
|
-
:key_type =>
|
1122
|
+
:key_type => normalize_key_type(@options[:key_type] || "ShortText"),
|
945
1123
|
:key_normalize => @options[:key_normalize],
|
946
1124
|
:default_tokenizer => @options[:default_tokenizer],
|
947
1125
|
}
|
@@ -958,6 +1136,14 @@ module Groonga
|
|
958
1136
|
end
|
959
1137
|
end
|
960
1138
|
|
1139
|
+
def path
|
1140
|
+
user_path = @options[:path]
|
1141
|
+
return user_path if user_path
|
1142
|
+
tables_dir = tables_directory_path(context.database)
|
1143
|
+
FileUtils.mkdir_p(tables_dir)
|
1144
|
+
File.join(tables_dir, @name)
|
1145
|
+
end
|
1146
|
+
|
961
1147
|
def column_options # :nodoc:
|
962
1148
|
{:persistent => persistent?}
|
963
1149
|
end
|
@@ -966,19 +1152,26 @@ module Groonga
|
|
966
1152
|
@options[:persistent].nil? ? true : @options[:persistent]
|
967
1153
|
end
|
968
1154
|
|
969
|
-
def
|
970
|
-
|
971
|
-
|
972
|
-
|
973
|
-
|
974
|
-
|
975
|
-
|
976
|
-
|
1155
|
+
def parse_index_argument(target_table_or_target_column_full_name, *args)
|
1156
|
+
options = nil
|
1157
|
+
options = args.pop if args.last.is_a?(::Hash)
|
1158
|
+
if args.empty?
|
1159
|
+
target_column_full_name = target_table_or_target_column_full_name
|
1160
|
+
if target_column_full_name.is_a?(Groonga::Column)
|
1161
|
+
target_column_full_name = target_column_full_name.name
|
1162
|
+
end
|
1163
|
+
target_table, target_column = target_column_full_name.split(/\./, 2)
|
1164
|
+
target_columns = [target_column]
|
1165
|
+
key = [target_table, target_columns]
|
1166
|
+
else
|
1167
|
+
target_table_name = target_table_or_target_column_full_name
|
1168
|
+
target_table = lambda do |context|
|
1169
|
+
guess_table_name(context, target_table_name)
|
1170
|
+
end
|
1171
|
+
target_columns = args
|
1172
|
+
key = [target_table_name, target_columns]
|
977
1173
|
end
|
978
|
-
|
979
|
-
definition.target_column = target_column
|
980
|
-
definition.options.merge!(column_options.merge(options))
|
981
|
-
self
|
1174
|
+
[key, target_table, target_columns, options || {}]
|
982
1175
|
end
|
983
1176
|
|
984
1177
|
def same_table?(table, options)
|
@@ -987,12 +1180,15 @@ module Groonga
|
|
987
1180
|
sub_records = options[:sub_records]
|
988
1181
|
sub_records = false if sub_records.nil?
|
989
1182
|
return false unless table.support_sub_records? == sub_records
|
1183
|
+
path = options[:path]
|
1184
|
+
return false if path and table.path != path
|
990
1185
|
|
991
1186
|
case table
|
992
1187
|
when Groonga::Array
|
993
1188
|
true
|
994
1189
|
when Groonga::Hash, Groonga::PatriciaTrie
|
995
|
-
|
1190
|
+
key_type = normalize_key_type(options[:key_type])
|
1191
|
+
return false unless table.domain == resolve_name(key_type)
|
996
1192
|
default_tokenizer = resolve_name(options[:default_tokenizer])
|
997
1193
|
return false unless table.default_tokenizer == default_tokenizer
|
998
1194
|
key_normalize = options[:key_normalize]
|
@@ -1009,26 +1205,57 @@ module Groonga
|
|
1009
1205
|
end
|
1010
1206
|
end
|
1011
1207
|
|
1208
|
+
def normalize_key_type(key_type)
|
1209
|
+
Schema.normalize_type(key_type || "ShortText")
|
1210
|
+
end
|
1211
|
+
|
1012
1212
|
def resolve_name(type)
|
1013
|
-
if type.
|
1014
|
-
nil
|
1015
|
-
elsif type.is_a?(String)
|
1213
|
+
if type.is_a?(String)
|
1016
1214
|
context[type]
|
1017
1215
|
else
|
1018
1216
|
type
|
1019
1217
|
end
|
1020
1218
|
end
|
1219
|
+
|
1220
|
+
def guess_table_name(context, name)
|
1221
|
+
original_name = name
|
1222
|
+
name = name.to_s
|
1223
|
+
candidate_names = [name]
|
1224
|
+
if name.respond_to?(:pluralize)
|
1225
|
+
pluralized_name = name.pluralize
|
1226
|
+
else
|
1227
|
+
pluralized_name = "#{name}s"
|
1228
|
+
end
|
1229
|
+
candidate_names << pluralized_name
|
1230
|
+
if pluralized_name.respond_to?(:camelize)
|
1231
|
+
candidate_names << pluralized_name.camelize
|
1232
|
+
else
|
1233
|
+
candidate_names << pluralized_name.split(/_/).collect do |word|
|
1234
|
+
word.capitalize
|
1235
|
+
end.join
|
1236
|
+
end
|
1237
|
+
candidate_names.each do |table_name|
|
1238
|
+
return table_name if context[table_name]
|
1239
|
+
end
|
1240
|
+
raise UnguessableReferenceTable.new(original_name, candidate_names)
|
1241
|
+
end
|
1021
1242
|
end
|
1022
1243
|
|
1023
1244
|
class TableRemoveDefinition # :nodoc:
|
1245
|
+
include Path
|
1246
|
+
|
1024
1247
|
def initialize(name, options={})
|
1025
1248
|
@name = name
|
1026
1249
|
@options = options
|
1027
1250
|
end
|
1028
1251
|
|
1029
1252
|
def define
|
1030
|
-
context = @options[:context]
|
1031
|
-
context[@name]
|
1253
|
+
context = @options[:context]
|
1254
|
+
table = context[@name]
|
1255
|
+
dir = columns_directory_path(table)
|
1256
|
+
result = table.remove
|
1257
|
+
rmdir_if_dir_exists(dir)
|
1258
|
+
result
|
1032
1259
|
end
|
1033
1260
|
end
|
1034
1261
|
|
@@ -1119,6 +1346,8 @@ module Groonga
|
|
1119
1346
|
end
|
1120
1347
|
|
1121
1348
|
class ColumnDefinition # :nodoc:
|
1349
|
+
include Path
|
1350
|
+
|
1122
1351
|
attr_accessor :name, :type
|
1123
1352
|
attr_reader :options
|
1124
1353
|
|
@@ -1130,26 +1359,51 @@ module Groonga
|
|
1130
1359
|
end
|
1131
1360
|
|
1132
1361
|
def define(table_definition, table)
|
1362
|
+
context = table_definition.context
|
1133
1363
|
column = table.column(@name)
|
1364
|
+
options = define_options(context, table)
|
1134
1365
|
if column
|
1135
|
-
return column if same_column?(
|
1136
|
-
if @options
|
1366
|
+
return column if same_column?(context, column)
|
1367
|
+
if @options[:force]
|
1137
1368
|
column.remove
|
1138
1369
|
else
|
1139
|
-
options = @options.merge(:type => @type)
|
1140
1370
|
raise ColumnCreationWithDifferentOptions.new(column, options)
|
1141
1371
|
end
|
1142
1372
|
end
|
1143
1373
|
table.define_column(@name,
|
1144
|
-
|
1145
|
-
|
1374
|
+
normalize_type(context),
|
1375
|
+
options)
|
1146
1376
|
end
|
1147
1377
|
|
1148
1378
|
private
|
1149
|
-
def
|
1150
|
-
|
1379
|
+
def normalize_type(context)
|
1380
|
+
if @type.respond_to?(:call)
|
1381
|
+
resolved_type = @type.call(context)
|
1382
|
+
else
|
1383
|
+
resolved_type = @type
|
1384
|
+
end
|
1385
|
+
Schema.normalize_type(resolved_type)
|
1386
|
+
end
|
1387
|
+
|
1388
|
+
def same_column?(context, column)
|
1151
1389
|
# TODO: should check column type and other options.
|
1152
|
-
column.range == context[
|
1390
|
+
column.range == context[normalize_type(context)]
|
1391
|
+
end
|
1392
|
+
|
1393
|
+
def define_options(context, table)
|
1394
|
+
{
|
1395
|
+
:path => path(context, table),
|
1396
|
+
:type => @options[:type],
|
1397
|
+
:compress => @options[:compress],
|
1398
|
+
}
|
1399
|
+
end
|
1400
|
+
|
1401
|
+
def path(context, table)
|
1402
|
+
user_path = @options[:path]
|
1403
|
+
return user_path if user_path
|
1404
|
+
columns_dir = columns_directory_path(table)
|
1405
|
+
FileUtils.mkdir_p(columns_dir)
|
1406
|
+
File.join(columns_dir, @name)
|
1153
1407
|
end
|
1154
1408
|
end
|
1155
1409
|
|
@@ -1164,12 +1418,35 @@ module Groonga
|
|
1164
1418
|
end
|
1165
1419
|
|
1166
1420
|
def define(table_definition, table)
|
1167
|
-
|
1421
|
+
if @name.respond_to?(:call)
|
1422
|
+
name = @name.call(table_definition.context)
|
1423
|
+
else
|
1424
|
+
name = @name
|
1425
|
+
end
|
1426
|
+
table.column(name).remove
|
1168
1427
|
end
|
1169
1428
|
end
|
1170
1429
|
|
1171
1430
|
class IndexColumnDefinition # :nodoc:
|
1172
|
-
|
1431
|
+
include Path
|
1432
|
+
|
1433
|
+
class << self
|
1434
|
+
def column_name(context, target_table, target_columns)
|
1435
|
+
target_table = resolve(context, target_table)
|
1436
|
+
"#{target_table.name}_#{target_columns.join('_')}"
|
1437
|
+
end
|
1438
|
+
|
1439
|
+
def resolve(context, object)
|
1440
|
+
return object if object.is_a?(Groonga::Object)
|
1441
|
+
if object.respond_to?(:call)
|
1442
|
+
object = object.call(context)
|
1443
|
+
end
|
1444
|
+
return nil if object.nil?
|
1445
|
+
context[object]
|
1446
|
+
end
|
1447
|
+
end
|
1448
|
+
|
1449
|
+
attr_accessor :name, :target_table, :target_columns
|
1173
1450
|
attr_reader :options
|
1174
1451
|
|
1175
1452
|
def initialize(name, options={})
|
@@ -1177,48 +1454,83 @@ module Groonga
|
|
1177
1454
|
@name = @name.to_s if @name.is_a?(Symbol)
|
1178
1455
|
@options = (options || {}).dup
|
1179
1456
|
@target_table = nil
|
1180
|
-
@
|
1457
|
+
@target_columns = nil
|
1181
1458
|
end
|
1182
1459
|
|
1183
1460
|
def define(table_definition, table)
|
1184
|
-
|
1185
|
-
target_table =
|
1186
|
-
if target_table.nil?
|
1187
|
-
|
1188
|
-
|
1189
|
-
|
1461
|
+
context = table_definition.context
|
1462
|
+
target_table = resolve_target_table(context)
|
1463
|
+
if target_table.nil?
|
1464
|
+
raise UnknownIndexTargetTable.new(@target_table)
|
1465
|
+
end
|
1466
|
+
nonexistent_columns = nonexistent_columns(target_table)
|
1467
|
+
unless nonexistent_columns.empty?
|
1468
|
+
raise UnknownIndexTarget.new(target_table, nonexistent_columns)
|
1190
1469
|
end
|
1191
|
-
|
1470
|
+
name = @name || self.class.column_name(context,
|
1471
|
+
target_table,
|
1472
|
+
@target_columns)
|
1473
|
+
index = table.column(name)
|
1192
1474
|
if index
|
1193
|
-
return index if same_index?(
|
1194
|
-
if @options
|
1475
|
+
return index if same_index?(context, index, target_table)
|
1476
|
+
if @options[:force]
|
1195
1477
|
index.remove
|
1196
1478
|
else
|
1197
1479
|
options = @options.merge(:type => :index,
|
1198
|
-
:
|
1480
|
+
:target_table => target_table,
|
1481
|
+
:target_columns => @target_columns)
|
1199
1482
|
raise ColumnCreationWithDifferentOptions.new(index, options)
|
1200
1483
|
end
|
1201
1484
|
end
|
1202
|
-
index = table.define_index_column(
|
1203
|
-
|
1204
|
-
|
1205
|
-
index.
|
1485
|
+
index = table.define_index_column(name,
|
1486
|
+
target_table,
|
1487
|
+
define_options(context, table, name))
|
1488
|
+
index.sources = @target_columns.collect do |column|
|
1489
|
+
target_table.column(column)
|
1490
|
+
end
|
1206
1491
|
index
|
1207
1492
|
end
|
1208
1493
|
|
1209
1494
|
private
|
1210
|
-
def same_index?(
|
1211
|
-
context = table_definition.context
|
1495
|
+
def same_index?(context, index, target_table)
|
1212
1496
|
# TODO: should check column type and other options.
|
1213
|
-
|
1497
|
+
range = index.range
|
1498
|
+
return false if range != target_table
|
1214
1499
|
source_names = index.sources.collect do |source|
|
1215
|
-
if source ==
|
1216
|
-
"
|
1500
|
+
if source == range
|
1501
|
+
"_key"
|
1217
1502
|
else
|
1218
|
-
source.
|
1503
|
+
source.local_name
|
1219
1504
|
end
|
1220
1505
|
end
|
1221
|
-
source_names ==
|
1506
|
+
source_names.sort == @target_columns.sort
|
1507
|
+
end
|
1508
|
+
|
1509
|
+
def nonexistent_columns(target_table)
|
1510
|
+
@target_columns.reject do |column|
|
1511
|
+
column == "_key" or target_table.have_column?(column)
|
1512
|
+
end
|
1513
|
+
end
|
1514
|
+
|
1515
|
+
def resolve_target_table(context)
|
1516
|
+
self.class.resolve(context, @target_table)
|
1517
|
+
end
|
1518
|
+
|
1519
|
+
def define_options(context, table, name)
|
1520
|
+
{
|
1521
|
+
:path => path(context, table, name),
|
1522
|
+
:with_section => @options[:with_section],
|
1523
|
+
:with_weight => @options[:with_weight],
|
1524
|
+
:with_position => @options[:with_position],
|
1525
|
+
}
|
1526
|
+
end
|
1527
|
+
|
1528
|
+
def path(context, table, name)
|
1529
|
+
user_path = @options[:path]
|
1530
|
+
return user_path if user_path
|
1531
|
+
columns_dir = "#{table.path}.columns"
|
1532
|
+
FileUtils.mkdir_p(columns_dir)
|
1533
|
+
File.join(columns_dir, name)
|
1222
1534
|
end
|
1223
1535
|
end
|
1224
1536
|
|
@@ -1232,35 +1544,51 @@ module Groonga
|
|
1232
1544
|
database = context.database
|
1233
1545
|
return nil if database.nil?
|
1234
1546
|
|
1547
|
+
header + dump_schema(database) + footer
|
1548
|
+
end
|
1549
|
+
|
1550
|
+
def dump_schema(database)
|
1551
|
+
index_columns = []
|
1235
1552
|
reference_columns = []
|
1236
1553
|
definitions = []
|
1237
1554
|
database.each do |object|
|
1238
1555
|
next unless object.is_a?(Groonga::Table)
|
1239
|
-
|
1240
|
-
|
1241
|
-
|
1242
|
-
|
1556
|
+
table = object
|
1557
|
+
schema = create_table_header(table)
|
1558
|
+
table.columns.sort_by {|column| column.local_name}.each do |column|
|
1559
|
+
if column.is_a?(Groonga::IndexColumn)
|
1560
|
+
index_columns << column
|
1243
1561
|
else
|
1244
|
-
|
1245
|
-
|
1246
|
-
|
1562
|
+
if column.range.is_a?(Groonga::Table)
|
1563
|
+
reference_columns << column
|
1564
|
+
else
|
1565
|
+
schema << define_column(table, column)
|
1566
|
+
end
|
1247
1567
|
end
|
1248
1568
|
end
|
1249
|
-
schema <<
|
1569
|
+
schema << create_table_footer(table)
|
1250
1570
|
definitions << schema
|
1251
1571
|
end
|
1252
1572
|
|
1253
1573
|
reference_columns.group_by do |column|
|
1254
1574
|
column.table
|
1255
1575
|
end.each do |table, columns|
|
1256
|
-
schema =
|
1576
|
+
schema = change_table_header(table)
|
1257
1577
|
columns.each do |column|
|
1258
|
-
|
1259
|
-
reference = column.range
|
1260
|
-
schema << " table.reference(#{name.inspect}, " +
|
1261
|
-
"#{reference.name.inspect})\n"
|
1578
|
+
schema << define_reference_column(table, column)
|
1262
1579
|
end
|
1263
|
-
schema <<
|
1580
|
+
schema << change_table_footer(table)
|
1581
|
+
definitions << schema
|
1582
|
+
end
|
1583
|
+
|
1584
|
+
index_columns.group_by do |column|
|
1585
|
+
column.table
|
1586
|
+
end.each do |table, columns|
|
1587
|
+
schema = change_table_header(table)
|
1588
|
+
columns.each do |column|
|
1589
|
+
schema << define_index_column(table, column)
|
1590
|
+
end
|
1591
|
+
schema << change_table_footer(table)
|
1264
1592
|
definitions << schema
|
1265
1593
|
end
|
1266
1594
|
|
@@ -1272,6 +1600,80 @@ module Groonga
|
|
1272
1600
|
end
|
1273
1601
|
|
1274
1602
|
private
|
1603
|
+
def header
|
1604
|
+
""
|
1605
|
+
end
|
1606
|
+
|
1607
|
+
def footer
|
1608
|
+
""
|
1609
|
+
end
|
1610
|
+
|
1611
|
+
def create_table_header(table)
|
1612
|
+
parameters = []
|
1613
|
+
unless table.is_a?(Groonga::Array)
|
1614
|
+
case table
|
1615
|
+
when Groonga::Hash
|
1616
|
+
parameters << ":type => :hash"
|
1617
|
+
when Groonga::PatriciaTrie
|
1618
|
+
parameters << ":type => :patricia_trie"
|
1619
|
+
end
|
1620
|
+
if table.domain
|
1621
|
+
parameters << ":key_type => #{table.domain.name.dump}"
|
1622
|
+
if table.normalize_key?
|
1623
|
+
parameters << ":key_normalize => true"
|
1624
|
+
end
|
1625
|
+
end
|
1626
|
+
default_tokenizer = table.default_tokenizer
|
1627
|
+
if default_tokenizer
|
1628
|
+
parameters << ":default_tokenizer => #{default_tokenizer.name.dump}"
|
1629
|
+
end
|
1630
|
+
end
|
1631
|
+
parameters << ":force => true"
|
1632
|
+
parameters.unshift("")
|
1633
|
+
parameters = parameters.join(",\n ")
|
1634
|
+
"create_table(#{table.name.dump}#{parameters}) do |table|\n"
|
1635
|
+
end
|
1636
|
+
|
1637
|
+
def create_table_footer(table)
|
1638
|
+
"end"
|
1639
|
+
end
|
1640
|
+
|
1641
|
+
def change_table_header(table)
|
1642
|
+
"change_table(#{table.name.inspect}) do |table|\n"
|
1643
|
+
end
|
1644
|
+
|
1645
|
+
def change_table_footer(table)
|
1646
|
+
"end"
|
1647
|
+
end
|
1648
|
+
|
1649
|
+
def define_column(table, column)
|
1650
|
+
type = column_method(column)
|
1651
|
+
name = column.local_name
|
1652
|
+
" table.#{type}(#{name.inspect})\n"
|
1653
|
+
end
|
1654
|
+
|
1655
|
+
def define_reference_column(table, column)
|
1656
|
+
name = column.local_name
|
1657
|
+
reference = column.range
|
1658
|
+
" table.reference(#{name.dump}, #{reference.name.dump})\n"
|
1659
|
+
end
|
1660
|
+
|
1661
|
+
def define_index_column(table, column)
|
1662
|
+
target_table_name = column.range.name
|
1663
|
+
sources = column.sources
|
1664
|
+
source_names = sources.collect do |source|
|
1665
|
+
if source.is_a?(table.class)
|
1666
|
+
"_key".dump
|
1667
|
+
else
|
1668
|
+
source.local_name.dump
|
1669
|
+
end
|
1670
|
+
end.join(", ")
|
1671
|
+
arguments = [target_table_name.dump,
|
1672
|
+
sources.size == 1 ? source_names : "[#{source_names}]",
|
1673
|
+
":name => #{column.local_name.dump}"]
|
1674
|
+
" table.index(#{arguments.join(', ')})\n"
|
1675
|
+
end
|
1676
|
+
|
1275
1677
|
def column_method(column)
|
1276
1678
|
range = column.range
|
1277
1679
|
case range.name
|