From null at cozmixng.org Fri Oct 2 00:30:47 2009
From: null at cozmixng.org (null at cozmixng.org)
Date: Fri, 02 Oct 2009 13:30:47 +0900
Subject: [groonga-commit:656] groonga [groonga (trunk) r693] use groonga
0.1.4.
Message-ID: <20091002043047.DECAB1D1C83@mail.cozmixng.org>
retro 2009-10-02 13:30:47 +0900 (Fri, 02 Oct 2009)
New Revision: 693
Log:
use groonga 0.1.4.
Modified files:
groonga/trunk/README.ja.rdoc
groonga/trunk/README.rdoc
groonga/trunk/extconf.rb
Modified: groonga/trunk/README.ja.rdoc (+1 -1)
===================================================================
--- groonga/trunk/README.ja.rdoc 2009-10-01 10:03:28 +09:00 (rev 692)
+++ groonga/trunk/README.ja.rdoc 2009-10-02 13:30:47 +09:00 (rev 693)
@@ -32,7 +32,7 @@
== ????????
* Ruby >= 1.8 ?1.9.1???
-* groonga >= 0.1.1
+* groonga >= 0.1.4
== ??????
Modified: groonga/trunk/README.rdoc (+1 -1)
===================================================================
--- groonga/trunk/README.rdoc 2009-10-01 10:03:28 +09:00 (rev 692)
+++ groonga/trunk/README.rdoc 2009-10-02 13:30:47 +09:00 (rev 693)
@@ -33,7 +33,7 @@
== Dependencies
* Ruby >= 1.8 (including 1.9.1)
-* groonga >= 0.1.1
+* groonga >= 0.1.4
== Install
Modified: groonga/trunk/extconf.rb (+1 -1)
===================================================================
--- groonga/trunk/extconf.rb 2009-10-01 10:03:28 +09:00 (rev 692)
+++ groonga/trunk/extconf.rb 2009-10-02 13:30:47 +09:00 (rev 693)
@@ -36,7 +36,7 @@
module_name = "groonga"
ext_dir_name = "ext"
src_dir = File.join(File.expand_path(File.dirname(__FILE__)), ext_dir_name)
-major, minor, micro = 0, 1, 3
+major, minor, micro = 0, 1, 4
def local_groonga_base_dir
File.join(File.dirname(__FILE__), "vendor")
From null at cozmixng.org Fri Oct 2 00:45:32 2009
From: null at cozmixng.org (null at cozmixng.org)
Date: Fri, 02 Oct 2009 13:45:32 +0900
Subject: [groonga-commit:657] groonga [groonga (trunk) r694] * Cotnext#recv
-> Context#receive.
Message-ID: <20091002044532.3AB211D1CBF@mail.cozmixng.org>
retro 2009-10-02 13:45:31 +0900 (Fri, 02 Oct 2009)
New Revision: 694
Log:
* Cotnext#recv -> Context#receive.
Modified files:
groonga/trunk/ext/rb-grn-context.c
Modified: groonga/trunk/ext/rb-grn-context.c (+22 -18)
===================================================================
--- groonga/trunk/ext/rb-grn-context.c 2009-10-02 13:27:55 +09:00 (rev 693)
+++ groonga/trunk/ext/rb-grn-context.c 2009-10-02 13:45:31 +09:00 (rev 694)
@@ -382,48 +382,52 @@
/*
* call-seq:
- * context.send(str) -> ID
+ * context.send(string) -> ID
*
* groonga????????????????
+ *
+ * ???: API?????????????
*/
static VALUE
-rb_grn_context_send (VALUE self, VALUE rb_str)
+rb_grn_context_send (VALUE self, VALUE rb_string)
{
grn_ctx *context;
- char *str;
- unsigned str_size;
+ char *string;
+ unsigned int string_size;
int flags = 0;
- unsigned qid;
+ unsigned int query_id;
context = SELF(self);
- str = StringValuePtr(rb_str);
- str_size = RSTRING_LEN(rb_str);
- qid = grn_ctx_send(context, str, str_size, flags);
+ string = StringValuePtr(rb_string);
+ string_size = RSTRING_LEN(rb_string);
+ query_id = grn_ctx_send(context, string, string_size, flags);
rb_grn_context_check(context, self);
- return UINT2NUM(qid);
+ return UINT2NUM(query_id);
}
/*
* call-seq:
- * context.recv -> [ID, String]
+ * context.receive -> [ID, String]
*
* groonga?????????????????????
+ *
+ * ???: API?????????????
*/
static VALUE
-rb_grn_context_recv (VALUE self)
+rb_grn_context_receive (VALUE self)
{
grn_ctx *context;
- char *str;
- unsigned str_size;
+ char *string;
+ unsigned string_size;
int flags = 0;
- unsigned qid;
+ unsigned int query_id;
context = SELF(self);
- qid = grn_ctx_recv(context, &str, &str_size, &flags);
+ query_id = grn_ctx_recv(context, &string, &string_size, &flags);
rb_grn_context_check(context, self);
- return rb_ary_new3(2, UINT2NUM(qid), rb_str_new(str, str_size));
+ return rb_ary_new3(2, UINT2NUM(query_id), rb_str_new(string, string_size));
}
static const char *
@@ -583,10 +587,10 @@
rb_define_method(cGrnContext, "database", rb_grn_context_get_database, 0);
rb_define_method(cGrnContext, "[]", rb_grn_context_array_reference, 1);
-
+
rb_define_method(cGrnContext, "pop", rb_grn_context_pop, 0);
rb_define_method(cGrnContext, "connect", rb_grn_context_connect, 2);
rb_define_method(cGrnContext, "send", rb_grn_context_send, 1);
- rb_define_method(cGrnContext, "recv", rb_grn_context_recv, 0);
+ rb_define_method(cGrnContext, "receive", rb_grn_context_receive, 0);
}
From null at cozmixng.org Fri Oct 2 00:45:33 2009
From: null at cozmixng.org (null at cozmixng.org)
Date: Fri, 02 Oct 2009 13:45:33 +0900
Subject: [groonga-commit:658] groonga [groonga (trunk) r695] *
Cotnext#connect supports default host and port.
Message-ID: <20091002044533.EA5851D1CCB@mail.cozmixng.org>
retro 2009-10-02 13:45:33 +0900 (Fri, 02 Oct 2009)
New Revision: 695
Log:
* Cotnext#connect supports default host and port.
Modified files:
groonga/trunk/ext/rb-grn-context.c
Modified: groonga/trunk/ext/rb-grn-context.c (+33 -6)
===================================================================
--- groonga/trunk/ext/rb-grn-context.c 2009-10-02 13:31:53 +09:00 (rev 694)
+++ groonga/trunk/ext/rb-grn-context.c 2009-10-02 13:45:33 +09:00 (rev 695)
@@ -357,22 +357,49 @@
/*
* call-seq:
- * context.connect(host, port)
+ * context.connect(options=nil)
*
- * groonga?????????
+ * groonga?????????_options_????????????
+ * ??
+ *
+ * [+:host+]
+ * groonga????????????IP??????????
+ * "localhost"??????
+ *
+ * [+:port+]
+ * groonga???????????????10041??????
+ * ????
*/
static VALUE
-rb_grn_context_connect (VALUE self, VALUE rb_host, VALUE rb_port)
+rb_grn_context_connect (int argc, VALUE *argv, VALUE self)
{
grn_ctx *context;
char *host;
int port;
int flags = 0;
grn_rc rc;
+ VALUE options, rb_host, rb_port;
+ rb_scan_args(argc, argv, "01", &options);
+ rb_grn_scan_options(options,
+ "host", &rb_host,
+ "port", &rb_port,
+ NULL);
+
context = SELF(self);
- host = StringValueCStr(rb_host);
- port = NUM2INT(rb_port);
+
+ if (NIL_P(rb_host)) {
+ host = "localhost";
+ } else {
+ host = StringValueCStr(rb_host);
+ }
+
+ if (NIL_P(rb_port)) {
+ port = 10041;
+ } else {
+ port = NUM2INT(rb_port);
+ }
+
rc = grn_ctx_connect(context, host, port, flags);
rb_grn_context_check(context, self);
rb_grn_rc_check(rc, self);
@@ -590,7 +617,7 @@
rb_define_method(cGrnContext, "pop", rb_grn_context_pop, 0);
- rb_define_method(cGrnContext, "connect", rb_grn_context_connect, 2);
+ rb_define_method(cGrnContext, "connect", rb_grn_context_connect, -1);
rb_define_method(cGrnContext, "send", rb_grn_context_send, 1);
rb_define_method(cGrnContext, "receive", rb_grn_context_receive, 0);
}
From null at cozmixng.org Fri Oct 2 01:15:28 2009
From: null at cozmixng.org (null at cozmixng.org)
Date: Fri, 02 Oct 2009 14:15:28 +0900
Subject: [groonga-commit:659] groonga [groonga (trunk) r696] * add a test
for remote groonga server connection.
Message-ID: <20091002051528.AA0FF1D1C9C@mail.cozmixng.org>
retro 2009-10-02 14:15:28 +0900 (Fri, 02 Oct 2009)
New Revision: 696
Log:
* add a test for remote groonga server connection.
Added files:
groonga/trunk/test/test-remote.rb
Modified files:
groonga/trunk/test/groonga-test-utils.rb
groonga/trunk/test/run-test.rb
Modified: groonga/trunk/test/groonga-test-utils.rb (+2 -0)
===================================================================
--- groonga/trunk/test/groonga-test-utils.rb 2009-10-02 13:42:59 +09:00 (rev 695)
+++ groonga/trunk/test/groonga-test-utils.rb 2009-10-02 14:15:28 +09:00 (rev 696)
@@ -16,6 +16,8 @@
require 'fileutils'
require 'pathname'
require 'time'
+require 'json'
+require 'pkg-config'
require 'groonga'
Added: groonga/trunk/test/test-remote.rb (+52 -0)
===================================================================
--- groonga/trunk/test/test-remote.rb 2009-10-02 13:42:59 +09:00 (rev 695)
+++ groonga/trunk/test/test-remote.rb 2009-10-02 14:15:28 +09:00 (rev 696)
@@ -0,0 +1,52 @@
+# Copyright (C) 2009 Kouhei Sutou
+#
+# This library is free software; you can redistribute it and/or
+# modify it under the terms of the GNU Lesser General Public
+# License version 2.1 as published by the Free Software Foundation.
+#
+# This library is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+# Lesser General Public License for more details.
+#
+# You should have received a copy of the GNU Lesser General Public
+# License along with this library; if not, write to the Free Software
+# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+
+class RemoteTest < Test::Unit::TestCase
+ include GroongaTestUtils
+
+ setup :before => :append
+ def setup_remote_connection
+ @process_id = nil
+
+ package_config = PKGConfig.package_config("groonga")
+ groonga = package_config.variable("groonga")
+
+ @host = "127.0.0.1"
+ @port = 12345
+ @remote_database_path = @tmp_dir + "remote-database"
+ @process_id = Process.fork do
+ exec(groonga,
+ "-i", @host,
+ "-p", @port.to_s,
+ "-s", "-n", @remote_database_path.to_s)
+ end
+ sleep(1)
+ end
+
+ teardown
+ def teardown_remote_connection
+ Process.kill(:TERM, @process_id) if @process_id
+ end
+
+ def test_send
+ _context = Groonga::Context.new
+ _context.connect(:host => @host, :port => @port)
+ assert_equal(0, _context.send("status"))
+ id, result = _context.receive
+ assert_equal(0, id)
+ assert_equal(["alloc_count", "starttime", "uptime"],
+ JSON.load(result).keys.sort)
+ end
+end
Modified: groonga/trunk/test/run-test.rb (+4 -0)
===================================================================
--- groonga/trunk/test/run-test.rb 2009-10-02 13:42:59 +09:00 (rev 695)
+++ groonga/trunk/test/run-test.rb 2009-10-02 14:15:28 +09:00 (rev 696)
@@ -43,10 +43,14 @@
$LOAD_PATH.unshift(ext_dir)
$LOAD_PATH.unshift(lib_dir)
+$LOAD_PATH.unshift(base_dir)
$LOAD_PATH.unshift(test_dir)
require 'groonga-test-utils'
+pkg_config = File.join(base_dir, "vendor", "local", "lib", "pkgconfig")
+PackageConfig.prepend_default_path(pkg_config)
+
Dir.glob("#{base_dir}/test/**/test{_,-}*.rb") do |file|
require file.sub(/\.rb$/, '')
end
From null at cozmixng.org Fri Oct 2 02:00:36 2009
From: null at cozmixng.org (null at cozmixng.org)
Date: Fri, 02 Oct 2009 15:00:36 +0900
Subject: [groonga-commit:660] groonga [groonga (trunk) r697] * add documents
for Groonga::Expression#snippet and Groonga::Table#select.
Message-ID: <20091002060036.E93A21D1CB7@mail.cozmixng.org>
retro 2009-10-02 15:00:36 +0900 (Fri, 02 Oct 2009)
New Revision: 697
Log:
* add documents for Groonga::Expression#snippet and Groonga::Table#select.
Modified files:
groonga/trunk/ext/rb-grn-expression.c
groonga/trunk/ext/rb-grn-table.c
Modified: groonga/trunk/ext/rb-grn-table.c (+74 -0)
===================================================================
--- groonga/trunk/ext/rb-grn-table.c 2009-10-02 14:06:53 +09:00 (rev 696)
+++ groonga/trunk/ext/rb-grn-table.c 2009-10-02 15:00:36 +09:00 (rev 697)
@@ -1244,6 +1244,80 @@
return CBOOL2RVAL(grn_obj_is_locked(context, table));
}
+/*
+ * call-seq:
+ * table.select(options) {|record| ...} -> Groonga::Hash
+ * table.select(query, options) -> Groonga::Hash
+ *
+ * _table_?????????????????????????
+ * ??????????????????+expression+????
+ * ?????????????????????
+ * Groonga::Expression???????
+ * Groonga::Expression#snippet???????????????
+ * ?????????????????
+ *
+ * results = table.select do |record|
+ * result["description"] =~ "groonga"
+ * end
+ * snippet = results.expression.snippet([["", ""]])
+ * results.each do |record|
+ * puts "#{record['name']}????????groonga????????"
+ * snippet.execute(record["description"].each do |snippet|
+ * puts "---"
+ * puts "#{snippet}..."
+ * puts "---"
+ * end
+ * end
+ *
+ * ???
+ * Ruby/groonga????????groonga????????
+ * ---
+ * Ruby/groonga?groonga?????DB-API???...
+ * ---
+ *
+ * _query_???[????]:[???][?]??????????
+ * ???????????????
+ *
+ * ??: [????] == [?]
+ * +!+: [????] != [?]
+ * +<+: [????] < [?]
+ * +>+: [????] > [?]
+ * +<=+: [????] <= [?]
+ * +>=+: [????] >= [?]
+ * + at +: [????]?[?]??????????
+ *
+ * ?:
+ * "name:daijiro" # "name"??????"daijiro"?????????
+ * "description:@groonga" # "description"????
+ * # "groonga"??????????????
+ *
+ * ???????????????Groonga::ExpressionBuilder
+ * ????
+ *
+ * _options_??????????????
+ *
+ * [+:operator+]
+ * ???????????????????????????
+ * ????????????Groonga::Operation::OR?
+ *
+ * [Groonga::Operation::OR]
+ * ?????????????????????????
+ * ????????????
+ * [Groonga::Operation::AND]
+ * ?????????????????????????
+ * ????????
+ * [Groonga::Operation::BUT]
+ * ?????????????
+ * [Groonga::Operation::ADJUST]
+ * ?????????????????
+ *
+ * [+:result+]
+ * ???????????????????????????
+ * ???????????????????????????
+ *
+ * [+:name+]
+ * ?????????????????????
+ */
static VALUE
rb_grn_table_select (int argc, VALUE *argv, VALUE self)
{
Modified: groonga/trunk/ext/rb-grn-expression.c (+45 -1)
===================================================================
--- groonga/trunk/ext/rb-grn-expression.c 2009-10-02 14:06:53 +09:00 (rev 696)
+++ groonga/trunk/ext/rb-grn-expression.c 2009-10-02 15:00:36 +09:00 (rev 697)
@@ -371,6 +371,51 @@
return rb_inspected;
}
+/*
+ * call-seq:
+ * expression.snippet(tags, options) -> Groonga::Snippet
+ *
+ * _expression_??Groonga::Snippet??????_tags_????
+ * ????????????????????????????
+ * ???
+ *
+ * [
+ * ["??????????????1", "??????????????1"],
+ * ["??????????????2", "??????????????2"],
+ * ...,
+ * ]
+ *
+ * ???1??????????_tags_????????????
+ * ????????????????????????????
+ * ?????????????
+ *
+ * expression.parse("Ruby groonga ??")
+ * tags = [["", ""], ["", ""]]
+ * snippet = expression.snippet(tags)
+ * p snippet.execute("Ruby?groonga?????????????")
+ * # => ["Ruby?groonga"
+ * # "?????????????"]
+ *
+ * _options_??????????????
+ *
+ * [+:normalize+]
+ * ???????????????????????????
+ * ??????????+false+????????
+ *
+ * [+:skip_leading_spaces+]
+ * ??????????????????????+false+??
+ * ?????
+ *
+ * [+:width+]
+ * ???????????????????100???
+ *
+ * [+:max_results+]
+ * ?????????????????????3?
+ *
+ * [+:html_escape+]
+ * ???????+<+, +>+, +&+, +"+?HTML????????
+ * ???????????+false+??HTML?????????
+ */
static VALUE
rb_grn_expression_snippet (int argc, VALUE *argv, VALUE self)
{
@@ -400,7 +445,6 @@
rb_scan_args(argc, argv, "11", &rb_tags, &options);
rb_grn_scan_options(options,
- "context", &rb_context,
"normalize", &rb_normalize,
"skip_leading_spaces", &rb_skip_leading_spaces,
"width", &rb_width,
From null at cozmixng.org Fri Oct 2 02:15:25 2009
From: null at cozmixng.org (null at cozmixng.org)
Date: Fri, 02 Oct 2009 15:15:25 +0900
Subject: [groonga-commit:661] groonga [groonga (trunk) r698] * fix RDoc
format.
Message-ID: <20091002061525.8F9111D1C85@mail.cozmixng.org>
retro 2009-10-02 15:15:25 +0900 (Fri, 02 Oct 2009)
New Revision: 698
Log:
* fix RDoc format.
Modified files:
groonga/trunk/ext/rb-grn-table.c
Modified: groonga/trunk/ext/rb-grn-table.c (+24 -17)
===================================================================
--- groonga/trunk/ext/rb-grn-table.c 2009-10-02 14:58:43 +09:00 (rev 697)
+++ groonga/trunk/ext/rb-grn-table.c 2009-10-02 15:15:25 +09:00 (rev 698)
@@ -1278,13 +1278,20 @@
* _query_???[????]:[???][?]??????????
* ???????????????
*
- * ??: [????] == [?]
- * +!+: [????] != [?]
- * +<+: [????] < [?]
- * +>+: [????] > [?]
- * +<=+: [????] <= [?]
- * +>=+: [????] >= [?]
- * + at +: [????]?[?]??????????
+ * [??]
+ * [????] == [?]
+ * [+!+]
+ * [????] != [?]
+ * [+<+]
+ * [????] < [?]
+ * [+>+]
+ * [????] > [?]
+ * [+<=+]
+ * [????] <= [?]
+ * [+>=+]
+ * [????] >= [?]
+ * [+ at +]
+ * [????]?[?]??????????
*
* ?:
* "name:daijiro" # "name"??????"daijiro"?????????
@@ -1300,16 +1307,16 @@
* ???????????????????????????
* ????????????Groonga::Operation::OR?
*
- * [Groonga::Operation::OR]
- * ?????????????????????????
- * ????????????
- * [Groonga::Operation::AND]
- * ?????????????????????????
- * ????????
- * [Groonga::Operation::BUT]
- * ?????????????
- * [Groonga::Operation::ADJUST]
- * ?????????????????
+ * [Groonga::Operation::OR]
+ * ?????????????????????????
+ * ????????????
+ * [Groonga::Operation::AND]
+ * ?????????????????????????
+ * ????????
+ * [Groonga::Operation::BUT]
+ * ?????????????
+ * [Groonga::Operation::ADJUST]
+ * ?????????????????
*
* [+:result+]
* ???????????????????????????
From null at cozmixng.org Fri Oct 2 02:15:26 2009
From: null at cozmixng.org (null at cozmixng.org)
Date: Fri, 02 Oct 2009 15:15:26 +0900
Subject: [groonga-commit:662] groonga [groonga (trunk) r699] * remove an
unused variable.
Message-ID: <20091002061526.E54851D1CB7@mail.cozmixng.org>
retro 2009-10-02 15:15:26 +0900 (Fri, 02 Oct 2009)
New Revision: 699
Log:
* remove an unused variable.
Modified files:
groonga/trunk/ext/rb-grn-expression.c
Modified: groonga/trunk/ext/rb-grn-expression.c (+1 -1)
===================================================================
--- groonga/trunk/ext/rb-grn-expression.c 2009-10-02 15:09:54 +09:00 (rev 698)
+++ groonga/trunk/ext/rb-grn-expression.c 2009-10-02 15:15:26 +09:00 (rev 699)
@@ -423,7 +423,7 @@
grn_obj *expression;
grn_snip *snippet;
VALUE options;
- VALUE rb_context, rb_normalize, rb_skip_leading_spaces;
+ VALUE rb_normalize, rb_skip_leading_spaces;
VALUE rb_width, rb_max_results, rb_tags;
VALUE rb_html_escape;
VALUE *rb_tag_values;
From null at cozmixng.org Fri Oct 2 02:45:27 2009
From: null at cozmixng.org (null at cozmixng.org)
Date: Fri, 02 Oct 2009 15:45:27 +0900
Subject: [groonga-commit:663] groonga [groonga (trunk) r700] * remove
needless comma.
Message-ID: <20091002064527.5B3301D1C9C@mail.cozmixng.org>
retro 2009-10-02 15:45:26 +0900 (Fri, 02 Oct 2009)
New Revision: 700
Log:
* remove needless comma.
Modified files:
groonga/trunk/ext/rb-grn-expression.c
Modified: groonga/trunk/ext/rb-grn-expression.c (+2 -2)
===================================================================
--- groonga/trunk/ext/rb-grn-expression.c 2009-10-02 15:12:38 +09:00 (rev 699)
+++ groonga/trunk/ext/rb-grn-expression.c 2009-10-02 15:45:26 +09:00 (rev 700)
@@ -455,7 +455,7 @@
if (TYPE(rb_tags) != T_ARRAY) {
rb_raise(rb_eArgError,
"tags should be "
- "[\"open_tag\", \"close_tag\"] or",
+ "[\"open_tag\", \"close_tag\"] or"
"[[\"open_tag1\", \"close_tag1\"], ...]: %s",
rb_grn_inspect(rb_tags));
}
@@ -477,7 +477,7 @@
RARRAY_LEN(rb_tag_values[i]) != 2) {
rb_raise(rb_eArgError,
"tags should be "
- "[\"open_tag\", \"close_tag\"] or",
+ "[\"open_tag\", \"close_tag\"] or"
"[[\"open_tag1\", \"close_tag1\"], ...]: %s",
rb_grn_inspect(rb_tags));
}
From null at cozmixng.org Fri Oct 2 03:00:40 2009
From: null at cozmixng.org (null at cozmixng.org)
Date: Fri, 02 Oct 2009 16:00:40 +0900
Subject: [groonga-commit:664] groonga [groonga (trunk) r701] * remove
needless character class.
Message-ID: <20091002070040.0DA161D1C83@mail.cozmixng.org>
retro 2009-10-02 16:00:39 +0900 (Fri, 02 Oct 2009)
New Revision: 701
Log:
* remove needless character class.
Modified files:
groonga/trunk/pkg-config.rb
Modified: groonga/trunk/pkg-config.rb (+1 -1)
===================================================================
--- groonga/trunk/pkg-config.rb 2009-10-02 15:40:49 +09:00 (rev 700)
+++ groonga/trunk/pkg-config.rb 2009-10-02 16:00:39 +09:00 (rev 701)
@@ -146,7 +146,7 @@
[path_flags, other_flags]
end
- IDENTIFIER_RE = /[\w\d_.]+/
+ IDENTIFIER_RE = /[\w.]+/
def parse_pc
raise ".pc for #{@name} doesn't exist." unless exist?
@variables = {}
From null at cozmixng.org Fri Oct 2 03:00:41 2009
From: null at cozmixng.org (null at cozmixng.org)
Date: Fri, 02 Oct 2009 16:00:41 +0900
Subject: [groonga-commit:665] groonga [groonga (trunk) r702] *
Groonga::PatriciaTrie#scan supports Ruby encoding.
Message-ID: <20091002070041.A31B01D1CBF@mail.cozmixng.org>
retro 2009-10-02 16:00:41 +0900 (Fri, 02 Oct 2009)
New Revision: 702
Log:
* Groonga::PatriciaTrie#scan supports Ruby encoding.
Modified files:
groonga/trunk/ext/rb-grn-encoding.c
groonga/trunk/ext/rb-grn-patricia-trie.c
groonga/trunk/ext/rb-grn-snippet.c
groonga/trunk/ext/rb-grn.h
Modified: groonga/trunk/ext/rb-grn-patricia-trie.c (+6 -0)
===================================================================
--- groonga/trunk/ext/rb-grn-patricia-trie.c 2009-10-02 15:45:38 +09:00 (rev 701)
+++ groonga/trunk/ext/rb-grn-patricia-trie.c 2009-10-02 16:00:41 +09:00 (rev 702)
@@ -188,8 +188,14 @@
continue;
record = rb_grn_record_new(self, hits[i].id, Qnil);
+#ifdef HAVE_RUBY_ENCODING_H
+ term = rb_enc_str_new(string + hits[i].offset,
+ hits[i].length,
+ GRNENCODING2RBENCODING(context->encoding));
+#else
term = rb_str_new(string + hits[i].offset,
hits[i].length);
+#endif
matched_info = rb_ary_new3(4,
record,
term,
Modified: groonga/trunk/ext/rb-grn.h (+9 -0)
===================================================================
--- groonga/trunk/ext/rb-grn.h 2009-10-02 15:45:38 +09:00 (rev 701)
+++ groonga/trunk/ext/rb-grn.h 2009-10-02 16:00:41 +09:00 (rev 702)
@@ -21,6 +21,10 @@
#include
+#ifdef HAVE_RUBY_ENCODING_H
+# include
+#endif
+
#include
#if defined(__cplusplus)
@@ -401,6 +405,8 @@
#define RVAL2GRNENCODING(object, context) \
(rb_grn_encoding_from_ruby_object(object, context))
#define GRNENCODING2RVAL(encoding) (rb_grn_encoding_to_ruby_object(encoding))
+#define GRNENCODING2RBENCODING(encoding) \
+ (rb_grn_encoding_to_ruby_encoding(encoding))
#define RVAL2GRNCONTEXT(object) (rb_grn_context_from_ruby_object(object))
#define GRNCONTEXT2RVAL(context) (rb_grn_context_to_ruby_object(context))
@@ -485,6 +491,9 @@
grn_encoding rb_grn_encoding_from_ruby_object (VALUE object,
grn_ctx *context);
VALUE rb_grn_encoding_to_ruby_object (grn_encoding encoding);
+#ifdef HAVE_RUBY_ENCODING_H
+rb_encoding *rb_grn_encoding_to_ruby_encoding (grn_encoding encoding);
+#endif
grn_ctx *rb_grn_context_from_ruby_object (VALUE object);
VALUE rb_grn_context_to_ruby_object (grn_ctx *context);
Modified: groonga/trunk/ext/rb-grn-snippet.c (+0 -4)
===================================================================
--- groonga/trunk/ext/rb-grn-snippet.c 2009-10-02 15:45:38 +09:00 (rev 701)
+++ groonga/trunk/ext/rb-grn-snippet.c 2009-10-02 16:00:41 +09:00 (rev 702)
@@ -18,10 +18,6 @@
#include "rb-grn.h"
-#ifdef HAVE_RUBY_ENCODING_H
-# include
-#endif
-
#define SELF(object) (rb_rb_grn_snippet_from_ruby_object(object))
typedef struct _RbGrnSnippet RbGrnSnippet;
Modified: groonga/trunk/ext/rb-grn-encoding.c (+37 -0)
===================================================================
--- groonga/trunk/ext/rb-grn-encoding.c 2009-10-02 15:45:38 +09:00 (rev 701)
+++ groonga/trunk/ext/rb-grn-encoding.c 2009-10-02 16:00:41 +09:00 (rev 702)
@@ -148,6 +148,43 @@
return rb_encoding;
}
+#ifdef HAVE_RUBY_ENCODING_H
+rb_encoding *
+rb_grn_encoding_to_ruby_encoding (grn_encoding encoding)
+{
+ rb_encoding *rb_encoding;
+
+ if (encoding == GRN_ENC_DEFAULT)
+ encoding = grn_get_default_encoding();
+
+ switch (encoding) {
+ case GRN_ENC_NONE:
+ rb_encoding = rb_ascii8bit_encoding();
+ break;
+ case GRN_ENC_EUC_JP:
+ rb_encoding = rb_enc_find("euc-jp");
+ break;
+ case GRN_ENC_UTF8:
+ rb_encoding = rb_utf8_encoding();
+ break;
+ case GRN_ENC_SJIS:
+ rb_encoding = rb_enc_find("CP932");
+ break;
+ case GRN_ENC_LATIN1:
+ rb_encoding = rb_enc_find("ISO-8859-1");
+ break;
+ case GRN_ENC_KOI8R:
+ rb_encoding = rb_enc_find("KOI8-R");
+ break;
+ default:
+ rb_raise(rb_eArgError, "unknown encoding: %d", encoding);
+ break;
+ }
+
+ return rb_encoding;
+}
+#endif
+
/*
* call-seq:
* Groonga::Encoding.default -> ????????
From null at cozmixng.org Fri Oct 2 03:45:34 2009
From: null at cozmixng.org (null at cozmixng.org)
Date: Fri, 02 Oct 2009 16:45:34 +0900
Subject: [groonga-commit:666] groonga [groonga (trunk) r703] * support Ruby
encoding.
Message-ID: <20091002074534.470CB1D1C83@mail.cozmixng.org>
retro 2009-10-02 16:45:33 +0900 (Fri, 02 Oct 2009)
New Revision: 703
Log:
* support Ruby encoding.
Modified files:
groonga/trunk/ext/rb-grn-context.c
groonga/trunk/ext/rb-grn-patricia-trie.c
groonga/trunk/ext/rb-grn-snippet.c
groonga/trunk/ext/rb-grn-utils.c
groonga/trunk/ext/rb-grn.h
groonga/trunk/lib/groonga/patricia-trie.rb
Modified: groonga/trunk/ext/rb-grn-patricia-trie.c (+3 -8)
===================================================================
--- groonga/trunk/ext/rb-grn-patricia-trie.c 2009-10-02 15:58:58 +09:00 (rev 702)
+++ groonga/trunk/ext/rb-grn-patricia-trie.c 2009-10-02 16:45:33 +09:00 (rev 703)
@@ -188,14 +188,9 @@
continue;
record = rb_grn_record_new(self, hits[i].id, Qnil);
-#ifdef HAVE_RUBY_ENCODING_H
- term = rb_enc_str_new(string + hits[i].offset,
- hits[i].length,
- GRNENCODING2RBENCODING(context->encoding));
-#else
- term = rb_str_new(string + hits[i].offset,
- hits[i].length);
-#endif
+ term = rb_grn_context_rb_string_new(context,
+ string + hits[i].offset,
+ hits[i].length);
matched_info = rb_ary_new3(4,
record,
term,
Modified: groonga/trunk/ext/rb-grn-context.c (+28 -0)
===================================================================
--- groonga/trunk/ext/rb-grn-context.c 2009-10-02 15:58:58 +09:00 (rev 702)
+++ groonga/trunk/ext/rb-grn-context.c 2009-10-02 16:45:33 +09:00 (rev 703)
@@ -148,6 +148,34 @@
return SELF(*context);
}
+VALUE
+rb_grn_context_rb_string_new (grn_ctx *context, const char *string, long length)
+{
+ if (length < 0)
+ length = strlen(string);
+#ifdef HAVE_RUBY_ENCODING_H
+ return rb_enc_str_new(string, length,
+ rb_grn_encoding_to_ruby_encoding(context->encoding));
+#else
+ return rb_str_new(string, length);
+#endif
+}
+
+VALUE
+rb_grn_context_rb_string_encode (grn_ctx *context, VALUE rb_string)
+{
+#ifdef HAVE_RUBY_ENCODING_H
+ rb_encoding *encoding, *to_encode;
+
+ encoding = rb_enc_get(rb_string);
+ to_encode = rb_grn_encoding_to_ruby_encoding(context->encoding);
+ if (rb_enc_to_index(encoding) != rb_enc_to_index(to_encode))
+ rb_string = rb_str_encode(rb_string, rb_enc_from_encoding(to_encode),
+ 0, Qnil);
+#endif
+ return rb_string;
+}
+
/*
* call-seq:
* Groonga::Context.default -> Groonga::Context
Modified: groonga/trunk/ext/rb-grn-utils.c (+6 -2)
===================================================================
--- groonga/trunk/ext/rb-grn-utils.c 2009-10-02 15:58:58 +09:00 (rev 702)
+++ groonga/trunk/ext/rb-grn-utils.c 2009-10-02 16:45:33 +09:00 (rev 703)
@@ -124,7 +124,9 @@
case GRN_DB_SHORT_TEXT:
case GRN_DB_TEXT:
case GRN_DB_LONG_TEXT:
- *rb_value = rb_str_new(GRN_TEXT_VALUE(bulk), GRN_TEXT_LEN(bulk));
+ *rb_value = rb_grn_context_rb_string_new(context,
+ GRN_TEXT_VALUE(bulk),
+ GRN_TEXT_LEN(bulk));
break;
default:
success = RB_GRN_FALSE;
@@ -190,7 +192,9 @@
related_object, &rb_value))
return rb_value;
- return rb_str_new(GRN_BULK_HEAD(bulk), GRN_BULK_VSIZE(bulk));
+ return rb_grn_context_rb_string_new(context,
+ GRN_BULK_HEAD(bulk),
+ GRN_BULK_VSIZE(bulk));
}
grn_obj *
Modified: groonga/trunk/ext/rb-grn.h (+5 -2)
===================================================================
--- groonga/trunk/ext/rb-grn.h 2009-10-02 15:58:58 +09:00 (rev 702)
+++ groonga/trunk/ext/rb-grn.h 2009-10-02 16:45:33 +09:00 (rev 703)
@@ -405,8 +405,6 @@
#define RVAL2GRNENCODING(object, context) \
(rb_grn_encoding_from_ruby_object(object, context))
#define GRNENCODING2RVAL(encoding) (rb_grn_encoding_to_ruby_object(encoding))
-#define GRNENCODING2RBENCODING(encoding) \
- (rb_grn_encoding_to_ruby_encoding(encoding))
#define RVAL2GRNCONTEXT(object) (rb_grn_context_from_ruby_object(object))
#define GRNCONTEXT2RVAL(context) (rb_grn_context_to_ruby_object(context))
@@ -497,6 +495,11 @@
grn_ctx *rb_grn_context_from_ruby_object (VALUE object);
VALUE rb_grn_context_to_ruby_object (grn_ctx *context);
+VALUE rb_grn_context_rb_string_new (grn_ctx *context,
+ const char *string,
+ long length);
+VALUE rb_grn_context_rb_string_encode (grn_ctx *context,
+ VALUE rb_string);
grn_obj *rb_grn_object_from_ruby_object (VALUE object,
grn_ctx **context);
Modified: groonga/trunk/ext/rb-grn-snippet.c (+4 -11)
===================================================================
--- groonga/trunk/ext/rb-grn-snippet.c 2009-10-02 15:58:58 +09:00 (rev 702)
+++ groonga/trunk/ext/rb-grn-snippet.c 2009-10-02 16:45:33 +09:00 (rev 703)
@@ -221,19 +221,16 @@
unsigned int i, n_results, max_tagged_length;
VALUE rb_results;
char *result;
-#ifdef HAVE_RUBY_ENCODING_H
- rb_encoding *encoding;
-#endif
rb_grn_snippet = SELF(self);
context = rb_grn_snippet->context;
snippet = rb_grn_snippet->snippet;
- string = StringValuePtr(rb_string);
- string_length = RSTRING_LEN(rb_string);
#ifdef HAVE_RUBY_ENCODING_H
- encoding = rb_enc_get(rb_string);
+ rb_string = rb_grn_context_rb_string_encode(context, rb_string);
#endif
+ string = StringValuePtr(rb_string);
+ string_length = RSTRING_LEN(rb_string);
rc = grn_snip_exec(context, snippet, string, string_length,
&n_results, &max_tagged_length);
@@ -247,11 +244,7 @@
rc = grn_snip_get_result(context, snippet, i, result, &result_length);
rb_grn_rc_check(rc, self);
-#ifdef HAVE_RUBY_ENCODING_H
- rb_result = rb_enc_str_new(result, result_length, encoding);
-#else
- rb_result = rb_str_new(result, result_length);
-#endif
+ rb_result = rb_grn_context_rb_string_new(context, result, result_length);
rb_ary_push(rb_results, rb_result);
}
Modified: groonga/trunk/lib/groonga/patricia-trie.rb (+10 -1)
===================================================================
--- groonga/trunk/lib/groonga/patricia-trie.rb 2009-10-02 15:58:58 +09:00 (rev 702)
+++ groonga/trunk/lib/groonga/patricia-trie.rb 2009-10-02 16:45:33 +09:00 (rev 703)
@@ -20,8 +20,17 @@
def tag_keys(text)
position = 0
result = ''
+ if text.respond_to?(:encoding)
+ encoding = text.encoding
+ bytes = text.dup.force_encoding("ascii-8bit")
+ else
+ encoding = nil
+ bytes = text
+ end
scan(text) do |record, word, start, length|
- result << text[position...start]
+ previous_text = bytes[position...start]
+ previous_text.force_encoding(encoding) if encoding
+ result << previous_text
result << yield(record, word)
position = start + length
end
From null at cozmixng.org Fri Oct 2 04:00:36 2009
From: null at cozmixng.org (null at cozmixng.org)
Date: Fri, 02 Oct 2009 17:00:36 +0900
Subject: [groonga-commit:667] groonga [groonga (trunk) r704] * add authors.
Message-ID: <20091002080036.1BCF61D1CBF@mail.cozmixng.org>
retro 2009-10-02 17:00:35 +0900 (Fri, 02 Oct 2009)
New Revision: 704
Log:
* add authors.
Modified files:
groonga/trunk/README.ja.rdoc
groonga/trunk/README.rdoc
Modified: groonga/trunk/README.ja.rdoc (+5 -1)
===================================================================
--- groonga/trunk/README.ja.rdoc 2009-10-02 16:45:18 +09:00 (rev 703)
+++ groonga/trunk/README.ja.rdoc 2009-10-02 17:00:35 +09:00 (rev 704)
@@ -20,7 +20,11 @@
== ??
-Kouhei Sutou:
+Kouhei Sutou::
+Tasuku SUENAGA::
+daijiro::
+Yuto HAYAMIZU::
+SHIDARA Yoji::
== ?????
Modified: groonga/trunk/README.rdoc (+6 -2)
===================================================================
--- groonga/trunk/README.rdoc 2009-10-02 16:45:18 +09:00 (rev 703)
+++ groonga/trunk/README.rdoc 2009-10-02 17:00:35 +09:00 (rev 704)
@@ -18,9 +18,13 @@
* groonga: http://groonga.org/
-== Author
+== Authors
-Kouhei Sutou:
+Kouhei Sutou::
+Tasuku SUENAGA::
+daijiro::
+Yuto HAYAMIZU::
+SHIDARA Yoji::
== License
From null at cozmixng.org Fri Oct 2 04:00:37 2009
From: null at cozmixng.org (null at cozmixng.org)
Date: Fri, 02 Oct 2009 17:00:37 +0900
Subject: [groonga-commit:668] groonga [groonga (trunk) r705] * add 1.0.7
entry.
Message-ID: <20091002080037.75C771D1CCB@mail.cozmixng.org>
retro 2009-10-02 17:00:37 +0900 (Fri, 02 Oct 2009)
New Revision: 705
Log:
* add 1.0.7 entry.
Modified files:
groonga/trunk/NEWS.ja.rdoc
groonga/trunk/NEWS.rdoc
groonga/trunk/html/index.html
Modified: groonga/trunk/NEWS.rdoc (+10 -0)
===================================================================
--- groonga/trunk/NEWS.rdoc 2009-10-02 16:48:41 +09:00 (rev 704)
+++ groonga/trunk/NEWS.rdoc 2009-10-02 17:00:37 +09:00 (rev 705)
@@ -1,5 +1,15 @@
= NEWS
+== 0.0.7: 2009-10-02
+
+* Supported groonga 0.1.4
+* Added API
+ * Groonga::PatriciaTrie#scan
+ * Groonga::PatriciaTrie#tag_keys
+ * Groonga::Expression#snippet
+ * Groonga::Object#append
+ * Groonga::Object#prepend
+
== 0.0.6: 2009-07-31
* Supported groonga 0.1.1.
Modified: groonga/trunk/NEWS.ja.rdoc (+10 -0)
===================================================================
--- groonga/trunk/NEWS.ja.rdoc 2009-10-02 16:48:41 +09:00 (rev 704)
+++ groonga/trunk/NEWS.ja.rdoc 2009-10-02 17:00:37 +09:00 (rev 705)
@@ -1,5 +1,15 @@
= ????
+== 0.0.7: 2009-10-02
+
+* groonga 0.1.4??
+* API???
+ * Groonga::PatriciaTrie#scan
+ * Groonga::PatriciaTrie#tag_keys
+ * Groonga::Expression#snippet
+ * Groonga::Object#append
+ * Groonga::Object#prepend
+
== 0.0.6: 2009-07-31
* groonga 0.1.1??
Modified: groonga/trunk/html/index.html (+2 -2)
===================================================================
--- groonga/trunk/html/index.html 2009-10-02 16:48:41 +09:00 (rev 704)
+++ groonga/trunk/html/index.html 2009-10-02 17:00:37 +09:00 (rev 705)
@@ -42,7 +42,7 @@
Ruby/groonga???????
- 2009-07-31????????0.0.6??????
+ 2009-10-02????????0.0.7??????
Ruby/groonga???????
@@ -79,7 +79,7 @@
ActiveGroonga???????
- 2009-07-31????????0.0.6??????
+ 2009-10-02????????0.0.7??????
ActiveGroonga???????
From null at cozmixng.org Fri Oct 2 04:45:52 2009
From: null at cozmixng.org (null at cozmixng.org)
Date: Fri, 02 Oct 2009 17:45:52 +0900
Subject: [groonga-commit:669] groonga [groonga (trunk) r707] * update
authors.
Message-ID: <20091002084552.BD3321D1CBF@mail.cozmixng.org>
retro 2009-10-02 17:45:51 +0900 (Fri, 02 Oct 2009)
New Revision: 707
Log:
* update authors.
Modified files:
groonga/trunk/AUTHORS
Modified: groonga/trunk/AUTHORS (+4 -0)
===================================================================
--- groonga/trunk/AUTHORS 2009-10-02 17:33:34 +09:00 (rev 706)
+++ groonga/trunk/AUTHORS 2009-10-02 17:45:51 +09:00 (rev 707)
@@ -1 +1,5 @@
Kouhei Sutou
+Tasuku SUENAGA
+daijiro
+Yuto HAYAMIZU
+SHIDARA Yoji
From null at cozmixng.org Fri Oct 2 04:45:50 2009
From: null at cozmixng.org (null at cozmixng.org)
Date: Fri, 02 Oct 2009 17:45:50 +0900
Subject: [groonga-commit:670] groonga [groonga (trunk) r706] * use
Groonga::Expression#snippet and Groonga::Expression#parse.
Message-ID: <20091002084550.53DBC1D1CB7@mail.cozmixng.org>
retro 2009-10-02 17:45:49 +0900 (Fri, 02 Oct 2009)
New Revision: 706
Log:
* use Groonga::Expression#snippet and Groonga::Expression#parse.
Modified files:
groonga/trunk/example/search/config.ru
Modified: groonga/trunk/example/search/config.ru (+52 -28)
===================================================================
--- groonga/trunk/example/search/config.ru 2009-10-02 16:48:56 +09:00 (rev 705)
+++ groonga/trunk/example/search/config.ru 2009-10-02 17:45:49 +09:00 (rev 706)
@@ -71,8 +71,8 @@
request['query'] || ''
end
- def words(request)
- query(request).split
+ def page(request)
+ (request['page'] || 0).to_i
end
def render_search_box(request, response)
@@ -88,8 +88,10 @@
end
def render_search_result(request, response)
- _words = words(request)
- if _words.empty?
+ _query = query(request)
+ _page = page(request)
+ limit = 20
+ if _query.empty?
records = []
response.write(<<-EOS)
@@ -97,25 +99,16 @@
EOS
else
- offset = 0
options = {}
before = Time.now
records = @documents.select do |record|
- expression = nil
- _words.each do |word|
- sub_expression = record["content"] =~ word
- if expression.nil?
- expression = sub_expression
- else
- expression &= sub_expression
- end
- end
- expression
+ record["content"].match(_query)
end
total_records = records.size
records = records.sort([[".:score", "descending"],
[".last-modified", "descending"]],
- :limit => 20)
+ :offset => _page * limit,
+ :limit => limit)
elapsed = Time.now - before
response.write(<<-EOS)
@@ -124,9 +117,9 @@
#{escape_html(query(request))}?????:
#{total_records}??
- #{total_records.zero? ? 0 : offset + 1}
+ #{total_records.zero? ? 0 : _page + 1}
-
- #{offset + records.size}
+ #{_page + records.size}
??#{elapsed}??
@@ -139,6 +132,8 @@
render_record(request, response, record)
end
response.write(" \n")
+
+ # render_pagination(request, response, _page, limit)
end
def render_record(request, response, record)
@@ -160,16 +155,11 @@
end
def render_snippet(request, response, record)
- open_tag = ""
- close_tag = ""
- snippet = Groonga::Snippet.new(:width => 100,
- :default_open_tag => open_tag,
- :default_close_tag => close_tag,
- :html_escape => true,
- :normalize => true)
- words(request).each do |word|
- snippet.add_keyword(word)
- end
+ expression = record.table.expression
+ snippet = expression.snippet([["", ""]],
+ :width => 100,
+ :html_escape => true,
+ :normalize => true)
separator = "\n...\n"
response.write(<<-EOS)
@@ -177,6 +167,40 @@
EOS
end
+
+ def render_pagination(request, response, page, limit)
+ _query = query(request)
+ return if _query.empty?
+
+ total_records = @documents.size
+ return if total_records < limit
+
+ last_page = total_records / limit
+ response.write("\n")
+ end
+
+ def render_pagination_link(request, response, query, page, label)
+ href = "./?query=#{escape_html(query)};page=#{escape_html(page)}"
+ response.write(pagination_span("#{label}"))
+ end
+
+ def pagination_span(content)
+ "\n"
+ end
end
run Searcher.new
From null at cozmixng.org Fri Oct 2 05:00:40 2009
From: null at cozmixng.org (null at cozmixng.org)
Date: Fri, 02 Oct 2009 18:00:40 +0900
Subject: [groonga-commit:671] groonga [groonga (0.0.7) r708] release 0.0.7!!!
Message-ID: <20091002090040.1512B1D1C83@mail.cozmixng.org>
retro 2009-10-02 18:00:39 +0900 (Fri, 02 Oct 2009)
New Revision: 708
Log:
release 0.0.7!!!
Copied directories:
groonga/tags/0.0.7/ (from rev 707, groonga/trunk/)
Copied: groonga/tags/0.0.7/
(from rev 707, groonga/trunk/)
From null at cozmixng.org Fri Oct 2 05:00:41 2009
From: null at cozmixng.org (null at cozmixng.org)
Date: Fri, 02 Oct 2009 18:00:41 +0900
Subject: [groonga-commit:672] groonga [activegroonga (trunk) r709] * add
0.0.7 entry.
Message-ID: <20091002090041.B59241D1CCB@mail.cozmixng.org>
retro 2009-10-02 18:00:41 +0900 (Fri, 02 Oct 2009)
New Revision: 709
Log:
* add 0.0.7 entry.
Modified files:
activegroonga/trunk/NEWS.ja.rdoc
activegroonga/trunk/NEWS.rdoc
Modified: activegroonga/trunk/NEWS.rdoc (+4 -0)
===================================================================
--- activegroonga/trunk/NEWS.rdoc 2009-10-02 17:46:11 +09:00 (rev 708)
+++ activegroonga/trunk/NEWS.rdoc 2009-10-02 18:00:41 +09:00 (rev 709)
@@ -1,5 +1,9 @@
= NEWS
+== 0.0.7: 2009-10-02
+
+* Support Ruby/groonga 0.0.7.
+
== 0.0.6: 2009-07-31
* Support Ruby/groonga 0.0.6.
Modified: activegroonga/trunk/NEWS.ja.rdoc (+4 -0)
===================================================================
--- activegroonga/trunk/NEWS.ja.rdoc 2009-10-02 17:46:11 +09:00 (rev 708)
+++ activegroonga/trunk/NEWS.ja.rdoc 2009-10-02 18:00:41 +09:00 (rev 709)
@@ -1,5 +1,9 @@
= ????
+== 0.0.7: 2009-10-02
+
+* Ruby/groonga 0.0.7??
+
== 0.0.6: 2009-07-31
* Ruby/groonga 0.0.6??
From null at cozmixng.org Fri Oct 2 05:00:47 2009
From: null at cozmixng.org (null at cozmixng.org)
Date: Fri, 02 Oct 2009 18:00:47 +0900
Subject: [groonga-commit:673] groonga [activegroonga (trunk) r712] * 0.0.7
-> 0.0.8.
Message-ID: <20091002090047.2AE3F1D1CD2@mail.cozmixng.org>
retro 2009-10-02 18:00:46 +0900 (Fri, 02 Oct 2009)
New Revision: 712
Log:
* 0.0.7 -> 0.0.8.
Modified files:
activegroonga/trunk/lib/active_groonga/version.rb
Modified: activegroonga/trunk/lib/active_groonga/version.rb (+1 -1)
===================================================================
--- activegroonga/trunk/lib/active_groonga/version.rb 2009-10-02 17:49:43 +09:00 (rev 711)
+++ activegroonga/trunk/lib/active_groonga/version.rb 2009-10-02 18:00:46 +09:00 (rev 712)
@@ -17,7 +17,7 @@
module VERSION
MAJOR = 0
MINOR = 0
- TINY = 7
+ TINY = 8
STRING = [MAJOR, MINOR, TINY].join(".")
end
From null at cozmixng.org Fri Oct 2 05:00:43 2009
From: null at cozmixng.org (null at cozmixng.org)
Date: Fri, 02 Oct 2009 18:00:43 +0900
Subject: [groonga-commit:674] groonga [activegroonga (0.0.7) r710] release
0.0.7!!!
Message-ID: <20091002090043.7427C1D1CCE@mail.cozmixng.org>
retro 2009-10-02 18:00:42 +0900 (Fri, 02 Oct 2009)
New Revision: 710
Log:
release 0.0.7!!!
Copied directories:
activegroonga/tags/0.0.7/ (from rev 709, activegroonga/trunk/)
Copied: activegroonga/tags/0.0.7/
(from rev 709, activegroonga/trunk/)
From null at cozmixng.org Fri Oct 2 05:00:45 2009
From: null at cozmixng.org (null at cozmixng.org)
Date: Fri, 02 Oct 2009 18:00:45 +0900
Subject: [groonga-commit:675] groonga [groonga (trunk) r711] * 0.0.7 ->
0.0.8.
Message-ID: <20091002090045.9B4131D1CD0@mail.cozmixng.org>
retro 2009-10-02 18:00:45 +0900 (Fri, 02 Oct 2009)
New Revision: 711
Log:
* 0.0.7 -> 0.0.8.
Modified files:
groonga/trunk/ext/rb-grn.h
Modified: groonga/trunk/ext/rb-grn.h (+1 -1)
===================================================================
--- groonga/trunk/ext/rb-grn.h 2009-10-02 17:48:08 +09:00 (rev 710)
+++ groonga/trunk/ext/rb-grn.h 2009-10-02 18:00:45 +09:00 (rev 711)
@@ -69,7 +69,7 @@
#define RB_GRN_MAJOR_VERSION 0
#define RB_GRN_MINOR_VERSION 0
-#define RB_GRN_MICRO_VERSION 7
+#define RB_GRN_MICRO_VERSION 8
typedef int rb_grn_boolean;
#define RB_GRN_FALSE (0)
From null at cozmixng.org Fri Oct 2 13:00:34 2009
From: null at cozmixng.org (null at cozmixng.org)
Date: Sat, 03 Oct 2009 02:00:34 +0900
Subject: [groonga-commit:676] groonga [groonga (trunk) r713] add a test for
index creation specifing context explicitly
Message-ID: <20091002170034.59BEE1D1CBF@mail.cozmixng.org>
retro 2009-10-03 02:00:33 +0900 (Sat, 03 Oct 2009)
New Revision: 713
Log:
add a test for index creation specifing context explicitly
Modified files:
groonga/trunk/test/test-schema.rb
Modified: groonga/trunk/test/test-schema.rb (+20 -0)
===================================================================
--- groonga/trunk/test/test-schema.rb 2009-10-02 17:49:55 +09:00 (rev 712)
+++ groonga/trunk/test/test-schema.rb 2009-10-03 02:00:33 -15:00 (rev 713)
@@ -279,4 +279,24 @@
end
EOS
end
+
+ priority :never # the following test case will not pass at this time
+ def test_explicit_context_create_table
+ context = Groonga::Context.default
+ Groonga::Context.default = nil
+
+ Groonga::Schema.define(:context => context) do |schema|
+ schema.create_table('items', :type => :hash) do |table|
+ table.text("text")
+ end
+ assert_nothing_raised do
+ schema.create_table("terms_text",
+ :type => :patricia_trie,
+ :key_normalize => true,
+ :default_tokenizer => "TokenBigram") do |table|
+ table.index('items.text')
+ end
+ end
+ end
+ end
end
From null at cozmixng.org Sun Oct 4 06:15:42 2009
From: null at cozmixng.org (null at cozmixng.org)
Date: Sun, 04 Oct 2009 19:15:42 +0900
Subject: [groonga-commit:677] groonga [groonga (trunk) r714] * export
object's context reader to Ruby layer.
Message-ID: <20091004101542.AC7341D1CB7@mail.cozmixng.org>
retro 2009-10-04 19:15:41 +0900 (Sun, 04 Oct 2009)
New Revision: 714
Log:
* export object's context reader to Ruby layer.
Modified files:
groonga/trunk/ext/rb-grn-array.c
groonga/trunk/ext/rb-grn-database.c
groonga/trunk/ext/rb-grn-object.c
groonga/trunk/ext/rb-grn-query.c
groonga/trunk/ext/rb-grn-snippet.c
Modified: groonga/trunk/ext/rb-grn-object.c (+4 -2)
===================================================================
--- groonga/trunk/ext/rb-grn-object.c 2009-10-03 01:48:51 -15:00 (rev 713)
+++ groonga/trunk/ext/rb-grn-object.c 2009-10-04 19:15:41 +09:00 (rev 714)
@@ -257,7 +257,7 @@
grn_ctx *context, grn_obj *object)
{
DATA_PTR(self) = rb_grn_object;
- rb_iv_set(self, "context", rb_context);
+ rb_iv_set(self, "@context", rb_context);
rb_grn_object->self = self;
rb_grn_object->need_close = RB_GRN_TRUE;
@@ -1089,7 +1089,7 @@
rc = grn_obj_remove(context, rb_grn_object->object);
rb_grn_rc_check(rc, self);
- rb_iv_set(self, "context", Qnil);
+ rb_iv_set(self, "@context", Qnil);
return Qnil;
}
@@ -1100,6 +1100,8 @@
rb_cGrnObject = rb_define_class_under(mGrn, "Object", rb_cObject);
rb_define_alloc_func(rb_cGrnObject, rb_grn_object_alloc);
+ rb_define_attr(rb_cGrnObject, "context", RB_GRN_TRUE, RB_GRN_FALSE);
+
rb_define_method(rb_cGrnObject, "inspect", rb_grn_object_inspect, 0);
rb_define_method(rb_cGrnObject, "id", rb_grn_object_get_id, 0);
Modified: groonga/trunk/ext/rb-grn-query.c (+1 -1)
===================================================================
--- groonga/trunk/ext/rb-grn-query.c 2009-10-03 01:48:51 -15:00 (rev 713)
+++ groonga/trunk/ext/rb-grn-query.c 2009-10-04 19:15:41 +09:00 (rev 714)
@@ -160,7 +160,7 @@
rb_grn_query->query = query;
rb_grn_query->owner = RB_GRN_TRUE;
- rb_iv_set(self, "context", rb_context);
+ rb_iv_set(self, "@context", rb_context);
return Qnil;
}
Modified: groonga/trunk/ext/rb-grn-array.c (+1 -1)
===================================================================
--- groonga/trunk/ext/rb-grn-array.c 2009-10-03 01:48:51 -15:00 (rev 713)
+++ groonga/trunk/ext/rb-grn-array.c 2009-10-04 19:15:41 +09:00 (rev 714)
@@ -141,7 +141,7 @@
rb_grn_context_check(context, rb_ary_new4(argc, argv));
rb_table = GRNOBJECT2RVAL(klass, context, table, RB_GRN_TRUE);
rb_grn_context_check(context, rb_table);
- rb_iv_set(rb_table, "context", rb_context);
+ rb_iv_set(rb_table, "@context", rb_context);
if (rb_block_given_p())
return rb_ensure(rb_yield, rb_table, rb_grn_object_close, rb_table);
Modified: groonga/trunk/ext/rb-grn-snippet.c (+1 -1)
===================================================================
--- groonga/trunk/ext/rb-grn-snippet.c 2009-10-03 01:48:51 -15:00 (rev 713)
+++ groonga/trunk/ext/rb-grn-snippet.c 2009-10-04 19:15:41 +09:00 (rev 714)
@@ -162,7 +162,7 @@
rb_grn_snippet->snippet = snippet;
rb_grn_snippet->owner = RB_GRN_TRUE;
- rb_iv_set(self, "context", rb_context);
+ rb_iv_set(self, "@context", rb_context);
return Qnil;
}
Modified: groonga/trunk/ext/rb-grn-database.c (+3 -3)
===================================================================
--- groonga/trunk/ext/rb-grn-database.c 2009-10-03 01:48:51 -15:00 (rev 713)
+++ groonga/trunk/ext/rb-grn-database.c 2009-10-04 19:15:41 +09:00 (rev 714)
@@ -78,7 +78,7 @@
{
VALUE rb_context;
- rb_context = rb_iv_get(self, "context");
+ rb_context = rb_iv_get(self, "@context");
if (!NIL_P(rb_context))
rb_iv_set(rb_context, "database", Qnil);
@@ -142,7 +142,7 @@
rb_grn_context_check(context, rb_ary_new4(argc, argv));
rb_database = rb_grn_object_alloc(klass);
rb_grn_object_assign(Qnil, rb_database, rb_context, context, database);
- rb_iv_set(rb_database, "context", rb_context);
+ rb_iv_set(rb_database, "@context", rb_context);
if (!NIL_P(rb_context))
rb_iv_set(rb_context, "database", rb_database);
rb_grn_context_check(context, rb_ary_new4(argc, argv));
@@ -194,7 +194,7 @@
rb_grn_object_assign(Qnil, self, rb_context, context, database);
rb_grn_context_check(context, self);
- rb_iv_set(self, "context", rb_context);
+ rb_iv_set(self, "@context", rb_context);
if (!NIL_P(rb_context))
rb_iv_set(rb_context, "database", self);
From null at cozmixng.org Sun Oct 4 06:15:44 2009
From: null at cozmixng.org (null at cozmixng.org)
Date: Sun, 04 Oct 2009 19:15:44 +0900
Subject: [groonga-commit:678] groonga [groonga (trunk) r715] * fix a problem
that explicit context isn't passed to index
Message-ID: <20091004101544.2BFA41D1CC9@mail.cozmixng.org>
retro 2009-10-04 19:15:43 +0900 (Sun, 04 Oct 2009)
New Revision: 715
Log:
* fix a problem that explicit context isn't passed to index
column.
Reported by dara. Thanks!!!
Modified files:
groonga/trunk/lib/groonga/schema.rb
groonga/trunk/test/test-schema.rb
Modified: groonga/trunk/test/test-schema.rb (+8 -8)
===================================================================
--- groonga/trunk/test/test-schema.rb 2009-10-04 19:06:11 +09:00 (rev 714)
+++ groonga/trunk/test/test-schema.rb 2009-10-04 19:15:43 +09:00 (rev 715)
@@ -280,7 +280,6 @@
EOS
end
- priority :never # the following test case will not pass at this time
def test_explicit_context_create_table
context = Groonga::Context.default
Groonga::Context.default = nil
@@ -289,14 +288,15 @@
schema.create_table('items', :type => :hash) do |table|
table.text("text")
end
- assert_nothing_raised do
- schema.create_table("terms_text",
- :type => :patricia_trie,
- :key_normalize => true,
- :default_tokenizer => "TokenBigram") do |table|
- table.index('items.text')
- end
+ schema.create_table("terms_text",
+ :type => :patricia_trie,
+ :key_normalize => true,
+ :default_tokenizer => "TokenBigram") do |table|
+ table.index('items.text')
end
end
+
+ assert_not_nil(context["items.text"])
+ assert_not_nil(context["terms_text.items_text"])
end
end
Modified: groonga/trunk/lib/groonga/schema.rb (+1 -6)
===================================================================
--- groonga/trunk/lib/groonga/schema.rb 2009-10-04 19:06:11 +09:00 (rev 714)
+++ groonga/trunk/lib/groonga/schema.rb 2009-10-04 19:15:43 +09:00 (rev 715)
@@ -513,7 +513,7 @@
def define(table)
target = @target
- target = context[target] unless target.is_a?(Groonga::Object)
+ target = table.context[target] unless target.is_a?(Groonga::Object)
if target.nil?
raise ArgumentError, "Unknown index target: #{@target.inspect}"
end
@@ -523,11 +523,6 @@
index.source = target
index
end
-
- private
- def context
- @options[:context] || Groonga::Context.default
- end
end
class Dumper
From null at cozmixng.org Tue Oct 13 20:35:23 2009
From: null at cozmixng.org (null at cozmixng.org)
Date: Wed, 14 Oct 2009 09:35:23 +0900
Subject: [groonga-commit:679] groonga [groonga (trunk) r716]
PatriciaTrie#tag_keys did't return last part of tagged text
Message-ID: <20091014003523.26D261D1C4B@mail.cozmixng.org>
retro 2009-10-14 09:35:22 +0900 (Wed, 14 Oct 2009)
New Revision: 716
Log:
PatriciaTrie#tag_keys did't return last part of tagged text
Modified files:
groonga/trunk/lib/groonga/patricia-trie.rb
groonga/trunk/test/test-patricia-trie.rb
Modified: groonga/trunk/test/test-patricia-trie.rb (+18 -2)
===================================================================
--- groonga/trunk/test/test-patricia-trie.rb 2009-10-04 19:07:03 +09:00 (rev 715)
+++ groonga/trunk/test/test-patricia-trie.rb 2009-10-14 09:35:22 +09:00 (rev 716)
@@ -116,7 +116,7 @@
words.add('???')
words.add('??????')
- text = 'muTEki ?????? ?????? ????? ??'
+ text = 'muTEki ?????? ?????? ????? ?? ???'
actual = words.tag_keys(text) do |record, word|
"<#{word}(#{record.key})>"
end
@@ -124,7 +124,23 @@
"?????(??????)> " +
"?????? " +
"????(?????)> " +
- "?(??)>",
+ "?(??)> " +
+ "???",
actual)
end
+
+ def test_tag_keys_with_no_match
+ Groonga::Context.default_options = {:encoding => "utf-8"}
+ words = Groonga::PatriciaTrie.create(:key_type => "ShortText",
+ :key_normalize => true)
+
+ words.add('??')
+ words.add('??????')
+
+ text = 'muTEki ?????? ?????? ????? ?? ???'
+ actual = words.tag_keys(text) do |record, word|
+ "<#{word}(#{record.key})>"
+ end
+ assert_equal(text, actual)
+ end
end
Modified: groonga/trunk/lib/groonga/patricia-trie.rb (+1 -0)
===================================================================
--- groonga/trunk/lib/groonga/patricia-trie.rb 2009-10-04 19:07:03 +09:00 (rev 715)
+++ groonga/trunk/lib/groonga/patricia-trie.rb 2009-10-14 09:35:22 +09:00 (rev 716)
@@ -34,6 +34,7 @@
result << yield(record, word)
position = start + length
end
+ result << bytes[position..-1]
result
end
end
From null at cozmixng.org Tue Oct 13 20:50:22 2009
From: null at cozmixng.org (null at cozmixng.org)
Date: Wed, 14 Oct 2009 09:50:22 +0900
Subject: [groonga-commit:680] groonga [groonga (trunk) r717] * work with
Ruby 1.9.
Message-ID: <20091014005022.5FC851D1C58@mail.cozmixng.org>
retro 2009-10-14 09:50:22 +0900 (Wed, 14 Oct 2009)
New Revision: 717
Log:
* work with Ruby 1.9.
Modified files:
groonga/trunk/lib/groonga/patricia-trie.rb
Modified: groonga/trunk/lib/groonga/patricia-trie.rb (+5 -1)
===================================================================
--- groonga/trunk/lib/groonga/patricia-trie.rb 2009-10-14 09:31:40 +09:00 (rev 716)
+++ groonga/trunk/lib/groonga/patricia-trie.rb 2009-10-14 09:50:22 +09:00 (rev 717)
@@ -34,7 +34,11 @@
result << yield(record, word)
position = start + length
end
- result << bytes[position..-1]
+ last_text = bytes[position..-1]
+ unless last_text.empty?
+ last_text.force_encoding(encoding) if encoding
+ result << last_text
+ end
result
end
end
From null at cozmixng.org Tue Oct 13 20:50:23 2009
From: null at cozmixng.org (null at cozmixng.org)
Date: Wed, 14 Oct 2009 09:50:23 +0900
Subject: [groonga-commit:681] groonga [groonga (trunk) r718] * re-add a test
for the last word is matched.
Message-ID: <20091014005023.A05EF1D1C59@mail.cozmixng.org>
retro 2009-10-14 09:50:23 +0900 (Wed, 14 Oct 2009)
New Revision: 718
Log:
* re-add a test for the last word is matched.
Modified files:
groonga/trunk/test/test-patricia-trie.rb
Modified: groonga/trunk/test/test-patricia-trie.rb (+17 -0)
===================================================================
--- groonga/trunk/test/test-patricia-trie.rb 2009-10-14 09:48:18 +09:00 (rev 717)
+++ groonga/trunk/test/test-patricia-trie.rb 2009-10-14 09:50:23 +09:00 (rev 718)
@@ -129,6 +129,23 @@
actual)
end
+ def test_tag_keys_with_last_match
+ Groonga::Context.default_options = {:encoding => "utf-8"}
+ words = Groonga::PatriciaTrie.create(:key_type => "ShortText",
+ :key_normalize => true)
+ words.add('???')
+ words.add('??????')
+
+ text = 'muTEki ?????? ??'
+ actual = words.tag_keys(text) do |record, word|
+ "<#{word}(#{record.key})>"
+ end
+ assert_equal(" " +
+ "?????? " +
+ "?(??)>",
+ actual)
+ end
+
def test_tag_keys_with_no_match
Groonga::Context.default_options = {:encoding => "utf-8"}
words = Groonga::PatriciaTrie.create(:key_type => "ShortText",
From null at cozmixng.org Tue Oct 13 21:05:40 2009
From: null at cozmixng.org (null at cozmixng.org)
Date: Wed, 14 Oct 2009 10:05:40 +0900
Subject: [groonga-commit:682] groonga [groonga (trunk) r719] * remove
needless words.
Message-ID: <20091014010540.4C9141D1C4B@mail.cozmixng.org>
retro 2009-10-14 10:05:39 +0900 (Wed, 14 Oct 2009)
New Revision: 719
Log:
* remove needless words.
Modified files:
groonga/trunk/test/test-patricia-trie.rb
Modified: groonga/trunk/test/test-patricia-trie.rb (+1 -1)
===================================================================
--- groonga/trunk/test/test-patricia-trie.rb 2009-10-14 09:50:06 +09:00 (rev 718)
+++ groonga/trunk/test/test-patricia-trie.rb 2009-10-14 10:05:39 +09:00 (rev 719)
@@ -154,7 +154,7 @@
words.add('??')
words.add('??????')
- text = 'muTEki ?????? ?????? ????? ?? ???'
+ text = 'muTEki ??????'
actual = words.tag_keys(text) do |record, word|
"<#{word}(#{record.key})>"
end
From null at cozmixng.org Wed Oct 14 00:10:23 2009
From: null at cozmixng.org (null at cozmixng.org)
Date: Wed, 14 Oct 2009 13:10:23 +0900
Subject: [groonga-commit:683] groonga [groonga (trunk) r720] add a test for
Expression#snippet with an empty array
Message-ID: <20091014041023.356C51D1C4B@mail.cozmixng.org>
retro 2009-10-14 13:10:22 +0900 (Wed, 14 Oct 2009)
New Revision: 720
Log:
add a test for Expression#snippet with an empty array
Modified files:
groonga/trunk/test/test-expression.rb
Modified: groonga/trunk/test/test-expression.rb (+21 -0)
===================================================================
--- groonga/trunk/test/test-expression.rb 2009-10-14 09:50:34 +09:00 (rev 719)
+++ groonga/trunk/test/test-expression.rb 2009-10-14 13:10:22 +09:00 (rev 720)
@@ -94,4 +94,25 @@
"Ruby???????????????????" +
"????????"))
end
+
+ def test_snippet_without_tags
+ users = Groonga::Array.create(:name => "users")
+ name = users.define_column("name", "ShortText")
+ terms = Groonga::Hash.create(:name => "terms",
+ :key_type => "ShortText",
+ :default_tokenizer => "TokenBigram")
+ users.define_index_column("user_name", users,
+ :source => "users.name",
+ :with_position => true)
+
+ expression = Groonga::Expression.new
+ variable = expression.define_variable(:domain => users)
+ expression.append_object(variable)
+ expression.parse("????", :default_column => name)
+ expression.compile
+
+ snippet = expression.snippet([], :width => 30)
+ assert_equal(["??????????"],
+ snippet.execute("????????????????????"))
+ end
end
From null at cozmixng.org Tue Oct 20 04:50:26 2009
From: null at cozmixng.org (null at cozmixng.org)
Date: Tue, 20 Oct 2009 17:50:26 +0900
Subject: [groonga-commit:684] groonga [groonga (trunk) r721] * use stderr
for debugging.
Message-ID: <20091020085026.C40661D1C85@mail.cozmixng.org>
retro 2009-10-20 17:50:26 +0900 (Tue, 20 Oct 2009)
New Revision: 721
Log:
* use stderr for debugging.
Modified files:
groonga/trunk/ext/rb-grn.h
Modified: groonga/trunk/ext/rb-grn.h (+1 -1)
===================================================================
--- groonga/trunk/ext/rb-grn.h 2009-10-14 13:00:16 +09:00 (rev 720)
+++ groonga/trunk/ext/rb-grn.h 2009-10-20 17:50:26 +09:00 (rev 721)
@@ -62,7 +62,7 @@
#endif
#ifdef RB_GRN_DEBUG
-# define debug(...) printf(__VA_ARGS__)
+# define debug(...) fprintf(stderr, __VA_ARGS__)
#else
# define debug(...)
#endif
From null at cozmixng.org Tue Oct 20 05:20:25 2009
From: null at cozmixng.org (null at cozmixng.org)
Date: Tue, 20 Oct 2009 18:20:25 +0900
Subject: [groonga-commit:685] groonga [groonga (trunk) r722] * use
ObjectSpace.define_finalizer instead of
Message-ID: <20091020092025.6B45E1D1C7F@mail.cozmixng.org>
retro 2009-10-20 18:20:25 +0900 (Tue, 20 Oct 2009)
New Revision: 722
Log:
* use ObjectSpace.define_finalizer instead of
rb_set_end_proc() to work with mod_ruby. mod_ruby calls
hooks defined by rb_set_end_proc() for each request end. :<
Modified files:
groonga/trunk/ext/rb-groonga.c
Modified: groonga/trunk/ext/rb-groonga.c (+13 -3)
===================================================================
--- groonga/trunk/ext/rb-groonga.c 2009-10-20 17:44:30 +09:00 (rev 721)
+++ groonga/trunk/ext/rb-groonga.c 2009-10-20 18:20:25 +09:00 (rev 722)
@@ -21,8 +21,8 @@
rb_grn_boolean rb_grn_exited = RB_GRN_FALSE;
extern grn_ctx grn_gctx;
-static void
-finish_groonga (VALUE data)
+static VALUE
+finish_groonga (VALUE self, VALUE object_id)
{
grn_ctx *context = grn_gctx.next;
@@ -34,6 +34,8 @@
grn_fin();
debug("finish: done\n");
rb_grn_exited = RB_GRN_TRUE;
+
+ return Qnil;
}
void
@@ -41,9 +43,18 @@
{
VALUE mGrn;
VALUE cGrnBuildVersion, cGrnBindingsVersion;
+ VALUE groonga_finalizer, groonga_finalizer_keeper;
mGrn = rb_define_module("Groonga");
+ groonga_finalizer = rb_funcall(rb_cObject, rb_intern("new"), 0);
+ rb_define_singleton_method(groonga_finalizer, "call", finish_groonga, 1);
+ groonga_finalizer_keeper = rb_funcall(rb_cObject, rb_intern("new"), 0);
+ rb_funcall(rb_const_get(rb_cObject, rb_intern("ObjectSpace")),
+ rb_intern("define_finalizer"),
+ 2, groonga_finalizer_keeper, groonga_finalizer);
+ rb_iv_set(mGrn, "finalizer", groonga_finalizer_keeper);
+
cGrnBuildVersion = rb_ary_new3(3,
INT2NUM(GRN_MAJOR_VERSION),
INT2NUM(GRN_MINOR_VERSION),
@@ -78,7 +89,6 @@
rb_grn_init_exception(mGrn);
rb_grn_rc_check(grn_init(), Qnil);
- rb_set_end_proc(finish_groonga, Qnil);
rb_grn_init_utils(mGrn);
rb_grn_init_encoding(mGrn);
From null at cozmixng.org Wed Oct 21 20:35:25 2009
From: null at cozmixng.org (null at cozmixng.org)
Date: Thu, 22 Oct 2009 09:35:25 +0900
Subject: [groonga-commit:686] groonga [groonga (trunk) r723] follow API
change introduced at 63c2090
Message-ID: <20091022003525.E90941D1CB7@mail.cozmixng.org>
retro 2009-10-22 09:35:25 +0900 (Thu, 22 Oct 2009)
New Revision: 723
Log:
follow API change introduced at 63c2090
Modified files:
groonga/trunk/ext/rb-grn-operation.c
Modified: groonga/trunk/ext/rb-grn-operation.c (+1 -1)
===================================================================
--- groonga/trunk/ext/rb-grn-operation.c 2009-10-20 18:10:21 +09:00 (rev 722)
+++ groonga/trunk/ext/rb-grn-operation.c 2009-10-22 09:35:25 +09:00 (rev 723)
@@ -60,7 +60,7 @@
rb_define_const(rb_mGrnOperation, "SHIFTL_ASSIGN",
UINT2NUM(GRN_OP_SHIFTL_ASSIGN));
rb_define_const(rb_mGrnOperation, "SHIRTR_ASSIGN",
- UINT2NUM(GRN_OP_SHIRTR_ASSIGN));
+ UINT2NUM(GRN_OP_SHIFTR_ASSIGN));
rb_define_const(rb_mGrnOperation, "SHIFTRR_ASSIGN",
UINT2NUM(GRN_OP_SHIFTRR_ASSIGN));
rb_define_const(rb_mGrnOperation, "AND_ASSIGN",
From null at cozmixng.org Wed Oct 21 20:35:27 2009
From: null at cozmixng.org (null at cozmixng.org)
Date: Thu, 22 Oct 2009 09:35:27 +0900
Subject: [groonga-commit:687] groonga [groonga (trunk) r724] follow API
change introduced at 3403e07
Message-ID: <20091022003527.A52071D1CAB@mail.cozmixng.org>
retro 2009-10-22 09:35:27 +0900 (Thu, 22 Oct 2009)
New Revision: 724
Log:
follow API change introduced at 3403e07
Modified files:
groonga/trunk/test/test-database.rb
Modified: groonga/trunk/test/test-database.rb (+3 -0)
===================================================================
--- groonga/trunk/test/test-database.rb 2009-10-22 09:21:26 +09:00 (rev 723)
+++ groonga/trunk/test/test-database.rb 2009-10-22 09:35:27 +09:00 (rev 724)
@@ -85,11 +85,14 @@
"UInt64",
"UInt8",
"WGS84GeoPoint",
+ "clearlock",
"column_create",
"column_list",
"define_selector",
"expr_missing",
"load",
+ "log_level",
+ "log_put",
"now",
"quit",
"rand",
From null at cozmixng.org Wed Oct 21 21:05:33 2009
From: null at cozmixng.org (null at cozmixng.org)
Date: Thu, 22 Oct 2009 10:05:33 +0900
Subject: [groonga-commit:687] groonga [groonga (trunk) r725] * just check
"Bool" is available.
Message-ID: <20091022010533.B87E81D1CAA@mail.cozmixng.org>
retro 2009-10-22 10:05:33 +0900 (Thu, 22 Oct 2009)
New Revision: 725
Log:
* just check "Bool" is available.
Modified files:
groonga/trunk/test/test-database.rb
Modified: groonga/trunk/test/test-database.rb (+2 -40)
===================================================================
--- groonga/trunk/test/test-database.rb 2009-10-22 09:28:44 +09:00 (rev 724)
+++ groonga/trunk/test/test-database.rb 2009-10-22 10:05:33 +09:00 (rev 725)
@@ -63,46 +63,8 @@
def test_each
db_path = @tmp_dir + "db"
database = Groonga::Database.create(:path => db_path.to_s)
- assert_equal(["Bool",
- "Float",
- "Int16",
- "Int32",
- "Int64",
- "Int8",
- "LongText",
- "Object",
- "ShortText",
- "Text",
- "Time",
- "TokenBigram",
- "TokenDelimit",
- "TokenMecab",
- "TokenTrigram",
- "TokenUnigram",
- "TokyoGeoPoint",
- "UInt16",
- "UInt32",
- "UInt64",
- "UInt8",
- "WGS84GeoPoint",
- "clearlock",
- "column_create",
- "column_list",
- "define_selector",
- "expr_missing",
- "load",
- "log_level",
- "log_put",
- "now",
- "quit",
- "rand",
- "select",
- "shutdown",
- "status",
- "table_create",
- "table_list",
- "view_add"],
- database.collect {|object| object.name}.sort)
+ default_object_names = database.collect {|object| object.name}.sort
+ assert_send([default_object_names, :include?, "Bool"])
end
def test_encoding
From null at cozmixng.org Wed Oct 21 21:20:30 2009
From: null at cozmixng.org (null at cozmixng.org)
Date: Thu, 22 Oct 2009 10:20:30 +0900
Subject: [groonga-commit:688] groonga [groonga (trunk) r726] fix a tiny bug
in rb_grn_patricia_trie_search() and make the omitted
Message-ID: <20091022012030.DCC131D1C8D@mail.cozmixng.org>
retro 2009-10-22 10:20:30 +0900 (Thu, 22 Oct 2009)
New Revision: 726
Log:
fix a tiny bug in rb_grn_patricia_trie_search() and make the omitted
PatriciaTrieTest#test_search a normal test
Modified files:
groonga/trunk/ext/rb-grn-patricia-trie.c
groonga/trunk/test/test-patricia-trie.rb
Modified: groonga/trunk/ext/rb-grn-patricia-trie.c (+1 -1)
===================================================================
--- groonga/trunk/ext/rb-grn-patricia-trie.c 2009-10-22 09:56:00 +09:00 (rev 725)
+++ groonga/trunk/ext/rb-grn-patricia-trie.c 2009-10-22 10:20:30 +09:00 (rev 726)
@@ -113,7 +113,7 @@
grn_obj *key, *domain, *result;
grn_operator operator;
grn_search_optarg search_options;
- rb_grn_boolean search_options_is_set = RB_GRN_TRUE;
+ rb_grn_boolean search_options_is_set = RB_GRN_FALSE;
VALUE rb_key, options, rb_result, rb_operator, rb_type;
rb_grn_table_key_support_deconstruct(SELF(self), &table, &context,
Modified: groonga/trunk/test/test-patricia-trie.rb (+0 -2)
===================================================================
--- groonga/trunk/test/test-patricia-trie.rb 2009-10-22 09:56:00 +09:00 (rev 725)
+++ groonga/trunk/test/test-patricia-trie.rb 2009-10-22 10:20:30 +09:00 (rev 726)
@@ -33,8 +33,6 @@
end
def test_search
- omit("creating entry is broken.")
-
users = Groonga::Array.create(:name => "")
user_name = users.define_column("name", "")
From null at cozmixng.org Wed Oct 21 22:20:31 2009
From: null at cozmixng.org (null at cozmixng.org)
Date: Thu, 22 Oct 2009 11:20:31 +0900
Subject: [groonga-commit:689] groonga [groonga (trunk) r727] make
Column#select return Table with |expression| method like Table#select does
Message-ID: <20091022022032.00A751D1CB3@mail.cozmixng.org>
retro 2009-10-22 11:20:31 +0900 (Thu, 22 Oct 2009)
New Revision: 727
Log:
make Column#select return Table with |expression| method like Table#select does
Modified files:
groonga/trunk/ext/rb-grn-column.c
groonga/trunk/test/test-column.rb
Modified: groonga/trunk/ext/rb-grn-column.c (+5 -0)
===================================================================
--- groonga/trunk/ext/rb-grn-column.c 2009-10-22 10:06:15 +09:00 (rev 726)
+++ groonga/trunk/ext/rb-grn-column.c 2009-10-22 11:20:31 +09:00 (rev 727)
@@ -220,6 +220,11 @@
grn_table_select(context, table, expression, result, operator);
rb_grn_context_check(context, self);
+ rb_attr(rb_singleton_class(rb_result),
+ rb_intern("expression"),
+ RB_GRN_TRUE, RB_GRN_FALSE, RB_GRN_FALSE);
+ rb_iv_set(rb_result, "@expression", rb_expression);
+
return rb_result;
}
Modified: groonga/trunk/test/test-column.rb (+4 -0)
===================================================================
--- groonga/trunk/test/test-column.rb 2009-10-22 10:06:15 +09:00 (rev 726)
+++ groonga/trunk/test/test-column.rb 2009-10-22 11:20:31 +09:00 (rev 727)
@@ -194,6 +194,8 @@
result.records.collect do |record|
record["body"]
end)
+ assert_equal("#", result.expression.inspect)
end
def test_select_with_block
@@ -218,6 +220,8 @@
result.records.collect do |record|
record["body"]
end)
+ assert_equal("#", result.expression.inspect)
end
def test_set_time
From null at cozmixng.org Thu Oct 22 00:35:31 2009
From: null at cozmixng.org (null at cozmixng.org)
Date: Thu, 22 Oct 2009 13:35:31 +0900
Subject: [groonga-commit:690] groonga [groonga (trunk) r728] make it
possible to pass Expression to Table#select and Column#select
Message-ID: <20091022043531.A1BD21D1CAB@mail.cozmixng.org>
retro 2009-10-22 13:35:31 +0900 (Thu, 22 Oct 2009)
New Revision: 728
Log:
make it possible to pass Expression to Table#select and Column#select
Modified files:
groonga/trunk/ext/rb-grn-column.c
groonga/trunk/ext/rb-grn-table.c
groonga/trunk/test/test-column.rb
groonga/trunk/test/test-table-select.rb
Modified: groonga/trunk/ext/rb-grn-table.c (+20 -11)
===================================================================
--- groonga/trunk/ext/rb-grn-table.c 2009-10-22 11:10:28 +09:00 (rev 727)
+++ groonga/trunk/ext/rb-grn-table.c 2009-10-22 13:35:31 +09:00 (rev 728)
@@ -1248,6 +1248,7 @@
* call-seq:
* table.select(options) {|record| ...} -> Groonga::Hash
* table.select(query, options) -> Groonga::Hash
+ * table.select(expression, options) -> Groonga::Hash
*
* _table_?????????????????????????
* ??????????????????+expression+????
@@ -1298,6 +1299,8 @@
* "description:@groonga" # "description"????
* # "groonga"??????????????
*
+ * _expression_?????????Groonga::Expression???
+ *
* ???????????????Groonga::ExpressionBuilder
* ????
*
@@ -1331,25 +1334,29 @@
grn_ctx *context;
grn_obj *table, *result, *expression;
grn_operator operator = GRN_OP_OR;
- VALUE rb_query = Qnil, query_or_options, options;
+ VALUE rb_query = Qnil, condition_or_options, options;
VALUE rb_name, rb_operator, rb_result;
- VALUE rb_expression, builder;
+ VALUE rb_expression = Qnil, builder;
- rb_scan_args(argc, argv, "02", &query_or_options, &options);
+ rb_scan_args(argc, argv, "02", &condition_or_options, &options);
rb_grn_table_deconstruct(SELF(self), &table, &context,
NULL, NULL,
NULL, NULL, NULL);
- if (RVAL2CBOOL(rb_obj_is_kind_of(query_or_options, rb_cString))) {
- rb_query = query_or_options;
+ if (RVAL2CBOOL(rb_obj_is_kind_of(condition_or_options, rb_cString))) {
+ rb_query = condition_or_options;
+ } else if (RVAL2CBOOL(rb_obj_is_kind_of(condition_or_options,
+ rb_cGrnExpression))) {
+ rb_expression = condition_or_options;
} else {
if (!NIL_P(options))
rb_raise(rb_eArgError,
- "should be [query_string, option_hash] "
+ "should be [query_string, option_hash], "
+ "[expression, opion_hash] "
"or [option_hash]: %s",
rb_grn_inspect(rb_ary_new4(argc, argv)));
- options = query_or_options;
+ options = condition_or_options;
}
rb_grn_scan_options(options,
@@ -1371,11 +1378,13 @@
result = RVAL2GRNTABLE(rb_result, &context);
}
- builder = rb_grn_record_expression_builder_new(self, rb_name);
- if (!NIL_P(rb_query)) {
- rb_funcall(builder, rb_intern("query="), 1, rb_query);
+ if (NIL_P(rb_expression)) {
+ builder = rb_grn_record_expression_builder_new(self, rb_name);
+ if (!NIL_P(rb_query)) {
+ rb_funcall(builder, rb_intern("query="), 1, rb_query);
+ }
+ rb_expression = rb_grn_record_expression_builder_build(builder);
}
- rb_expression = rb_grn_record_expression_builder_build(builder);
rb_grn_object_deconstruct(RB_GRN_OBJECT(DATA_PTR(rb_expression)),
&expression, NULL,
NULL, NULL, NULL, NULL);
Modified: groonga/trunk/test/test-table-select.rb (+11 -0)
===================================================================
--- groonga/trunk/test/test-table-select.rb 2009-10-22 11:10:28 +09:00 (rev 727)
+++ groonga/trunk/test/test-table-select.rb 2009-10-22 13:35:31 +09:00 (rev 728)
@@ -53,6 +53,17 @@
assert_equal_select_result([@comment1, @comment2], result)
end
+ def test_select_expression
+ expression = Groonga::Expression.new
+ variable = expression.define_variable(:domain => @comments)
+ expression.append_object(variable)
+ expression.parse("content:%Hello", :parser => :table)
+ expression.compile
+ result = @comments.select(expression)
+ assert_equal(expression, result.expression)
+ assert_equal_select_result([@comment1, @comment2], result)
+ end
+
def test_select_query_with_block
result = @comments.select("content:%Hello") do |record|
record["created_at"] < Time.parse("2009-08-01")
Modified: groonga/trunk/ext/rb-grn-column.c (+15 -9)
===================================================================
--- groonga/trunk/ext/rb-grn-column.c 2009-10-22 11:10:28 +09:00 (rev 727)
+++ groonga/trunk/ext/rb-grn-column.c 2009-10-22 13:35:31 +09:00 (rev 728)
@@ -168,28 +168,32 @@
grn_obj *table, *column, *result, *expression;
grn_operator operator = GRN_OP_OR;
VALUE options;
- VALUE rb_query, rb_query_or_options, rb_name, rb_operator, rb_result;
+ VALUE rb_query, condition_or_options, rb_name, rb_operator, rb_result;
VALUE builder;
- VALUE rb_expression;
+ VALUE rb_expression = Qnil;
rb_query = Qnil;
- rb_scan_args(argc, argv, "02", &rb_query_or_options, &options);
+ rb_scan_args(argc, argv, "02", &condition_or_options, &options);
rb_grn_column_deconstruct(SELF(self), &column, &context,
NULL, NULL,
NULL, NULL, NULL);
table = grn_column_table(context, column);
- if (RVAL2CBOOL(rb_obj_is_kind_of(rb_query_or_options, rb_cString))) {
- rb_query = rb_query_or_options;
+ if (RVAL2CBOOL(rb_obj_is_kind_of(condition_or_options, rb_cString))) {
+ rb_query = condition_or_options;
+ } else if (RVAL2CBOOL(rb_obj_is_kind_of(condition_or_options,
+ rb_cGrnExpression))) {
+ rb_expression = condition_or_options;
} else {
if (!NIL_P(options))
rb_raise(rb_eArgError,
- "should be [query_string, option_hash] "
+ "should be [query_string, option_hash], "
+ "[expression, opion_hash] "
"or [option_hash]: %s",
rb_grn_inspect(rb_ary_new4(argc, argv)));
- options = rb_query_or_options;
+ options = condition_or_options;
}
rb_grn_scan_options(options,
@@ -211,8 +215,10 @@
result = RVAL2GRNTABLE(rb_result, &context);
}
- builder = rb_grn_column_expression_builder_new(self, rb_name, rb_query);
- rb_expression = rb_grn_column_expression_builder_build(builder);
+ if (NIL_P(rb_expression)) {
+ builder = rb_grn_column_expression_builder_new(self, rb_name, rb_query);
+ rb_expression = rb_grn_column_expression_builder_build(builder);
+ }
rb_grn_object_deconstruct(RB_GRN_OBJECT(DATA_PTR(rb_expression)),
&expression, NULL,
NULL, NULL, NULL, NULL);
Modified: groonga/trunk/test/test-column.rb (+37 -28)
===================================================================
--- groonga/trunk/test/test-column.rb 2009-10-22 11:10:28 +09:00 (rev 727)
+++ groonga/trunk/test/test-column.rb 2009-10-22 13:35:31 +09:00 (rev 728)
@@ -175,21 +175,9 @@
end
def test_select
- posts = Groonga::Hash.create(:name => "", :key_type => "")
- body = posts.define_column("body", "")
-
- index = Groonga::PatriciaTrie.create(:name => "",
- :key_type => "",
- :key_normalize => true)
- index.default_tokenizer = ""
- body_index = index.define_index_column("body_index", posts,
- :with_position => true,
- :source => body)
-
- first_post = posts.add("Hello!", :body => "World")
- hobby = posts.add("My Hobby", :body => "Drive and Eat")
+ populate_table_for_select
- result = body.select("drive")
+ result = @body.select("drive")
assert_equal(["Drive and Eat"],
result.records.collect do |record|
record["body"]
@@ -198,22 +186,27 @@
"{body GET_VALUE \"drive\" MATCH}>", result.expression.inspect)
end
+ def test_select_expression
+ populate_table_for_select
+
+ expression = Groonga::Expression.new
+ variable = expression.define_variable(:domain => @posts)
+ expression.append_object(variable)
+ expression.parse("body:%drive", :parser => :table)
+ expression.compile
+ result = @body.select(expression)
+ assert_equal(["Drive and Eat"],
+ result.records.collect do |record|
+ record["body"]
+ end)
+ assert_equal("#", result.expression.inspect)
+ end
+
def test_select_with_block
- posts = Groonga::Hash.create(:name => "", :key_type => "")
- body = posts.define_column("body", "")
+ populate_table_for_select
- index = Groonga::PatriciaTrie.create(:name => "",
- :key_type => "",
- :key_normalize => true)
- index.default_tokenizer = ""
- body_index = index.define_index_column("body_index", posts,
- :with_position => true,
- :source => body)
-
- first_post = posts.add("Hello!", :body => "World")
- hobby = posts.add("My Hobby", :body => "Drive and Eat")
-
- result = body.select do |column|
+ result = @body.select do |column|
column =~ "drive"
end
assert_equal(["Drive and Eat"],
@@ -247,4 +240,20 @@
end
assert_equal(expected_contents, actual_contents)
end
+
+ def populate_table_for_select
+ @posts = Groonga::Hash.create(:name => "", :key_type => "")
+ @body = @posts.define_column("body", "")
+
+ index = Groonga::PatriciaTrie.create(:name => "",
+ :key_type => "",
+ :key_normalize => true)
+ index.default_tokenizer = ""
+ body_index = index.define_index_column("body_index", @posts,
+ :with_position => true,
+ :source => @body)
+
+ first_post = @posts.add("Hello!", :body => "World")
+ hobby = @posts.add("My Hobby", :body => "Drive and Eat")
+ end
end
From null at cozmixng.org Thu Oct 22 06:05:38 2009
From: null at cozmixng.org (null at cozmixng.org)
Date: Thu, 22 Oct 2009 19:05:38 +0900
Subject: [groonga-commit:691] groonga [groonga (trunk) r729] make
Table#select and Column#select accept the :parser option of Expression
Message-ID: <20091022100538.98F841D1CA5@mail.cozmixng.org>
retro 2009-10-22 19:05:38 +0900 (Thu, 22 Oct 2009)
New Revision: 729
Log:
make Table#select and Column#select accept the :parser option of Expression
Modified files:
groonga/trunk/ext/rb-grn-column.c
groonga/trunk/ext/rb-grn-table.c
groonga/trunk/lib/groonga/expression-builder.rb
groonga/trunk/test/test-column.rb
groonga/trunk/test/test-table-select.rb
Modified: groonga/trunk/ext/rb-grn-table.c (+8 -4)
===================================================================
--- groonga/trunk/ext/rb-grn-table.c 2009-10-22 13:30:36 +09:00 (rev 728)
+++ groonga/trunk/ext/rb-grn-table.c 2009-10-22 19:05:38 +09:00 (rev 729)
@@ -1327,6 +1327,10 @@
*
* [+:name+]
* ?????????????????????
+ *
+ * [+:parser+]
+ * _query_????????????????????????
+ * _:table_
*/
static VALUE
rb_grn_table_select (int argc, VALUE *argv, VALUE self)
@@ -1335,7 +1339,7 @@
grn_obj *table, *result, *expression;
grn_operator operator = GRN_OP_OR;
VALUE rb_query = Qnil, condition_or_options, options;
- VALUE rb_name, rb_operator, rb_result;
+ VALUE rb_name, rb_operator, rb_result, rb_parser = Qnil;
VALUE rb_expression = Qnil, builder;
rb_scan_args(argc, argv, "02", &condition_or_options, &options);
@@ -1363,6 +1367,7 @@
"operator", &rb_operator,
"result", &rb_result,
"name", &rb_name,
+ "parser", &rb_parser,
NULL);
if (!NIL_P(rb_operator))
@@ -1380,9 +1385,8 @@
if (NIL_P(rb_expression)) {
builder = rb_grn_record_expression_builder_new(self, rb_name);
- if (!NIL_P(rb_query)) {
- rb_funcall(builder, rb_intern("query="), 1, rb_query);
- }
+ rb_funcall(builder, rb_intern("query="), 1, rb_query);
+ rb_funcall(builder, rb_intern("parser="), 1, rb_parser);
rb_expression = rb_grn_record_expression_builder_build(builder);
}
rb_grn_object_deconstruct(RB_GRN_OBJECT(DATA_PTR(rb_expression)),
Modified: groonga/trunk/test/test-table-select.rb (+5 -0)
===================================================================
--- groonga/trunk/test/test-table-select.rb 2009-10-22 13:30:36 +09:00 (rev 728)
+++ groonga/trunk/test/test-table-select.rb 2009-10-22 19:05:38 +09:00 (rev 729)
@@ -53,6 +53,11 @@
assert_equal_select_result([@comment1, @comment2], result)
end
+ def test_select_query_with_parser
+ result = @comments.select("content @ \"Hello\"", :parser => :expression)
+ assert_equal_select_result([@comment1, @comment2], result)
+ end
+
def test_select_expression
expression = Groonga::Expression.new
variable = expression.define_variable(:domain => @comments)
Modified: groonga/trunk/ext/rb-grn-column.c (+4 -1)
===================================================================
--- groonga/trunk/ext/rb-grn-column.c 2009-10-22 13:30:36 +09:00 (rev 728)
+++ groonga/trunk/ext/rb-grn-column.c 2009-10-22 19:05:38 +09:00 (rev 729)
@@ -168,7 +168,8 @@
grn_obj *table, *column, *result, *expression;
grn_operator operator = GRN_OP_OR;
VALUE options;
- VALUE rb_query, condition_or_options, rb_name, rb_operator, rb_result;
+ VALUE rb_query, condition_or_options;
+ VALUE rb_name, rb_operator, rb_result, rb_parser = Qnil;
VALUE builder;
VALUE rb_expression = Qnil;
@@ -200,6 +201,7 @@
"operator", &rb_operator,
"result", &rb_result,
"name", &rb_name,
+ "parser", &rb_parser,
NULL);
if (!NIL_P(rb_operator))
@@ -217,6 +219,7 @@
if (NIL_P(rb_expression)) {
builder = rb_grn_column_expression_builder_new(self, rb_name, rb_query);
+ rb_funcall(builder, rb_intern("parser="), 1, rb_parser);
rb_expression = rb_grn_column_expression_builder_build(builder);
}
rb_grn_object_deconstruct(RB_GRN_OBJECT(DATA_PTR(rb_expression)),
Modified: groonga/trunk/lib/groonga/expression-builder.rb (+9 -6)
===================================================================
--- groonga/trunk/lib/groonga/expression-builder.rb 2009-10-22 13:30:36 +09:00 (rev 728)
+++ groonga/trunk/lib/groonga/expression-builder.rb 2009-10-22 19:05:38 +09:00 (rev 729)
@@ -19,11 +19,13 @@
module ExpressionBuildable
attr_reader :table
attr_accessor :query
+ attr_accessor :parser
def initialize(*args)
@table = nil
@name = nil
@query = nil
+ @parser = nil
@default_column = nil
end
@@ -32,7 +34,7 @@
variable = expression.define_variable(:domain => @table)
builder = nil
- builder = match(@query) if @query
+ builder = match(@query, :parser => @parser) if @query
if block_given?
if builder
builder &= yield(self)
@@ -185,8 +187,9 @@
else
options = options_or_default_column
end
- default_options = {:parser => :table}
- SubExpressionBuilder.new(query, default_options.merge(options))
+ options = options.dup
+ options[:parser] ||= :table
+ SubExpressionBuilder.new(query, options)
end
end
@@ -228,9 +231,9 @@
end
def match(query, options={})
- default_options = {:parser => :table}
- ensure_options = {:default_column => @default_column}
- options = default_options.merge(options).merge(ensure_options)
+ options = options.dup
+ options[:parser] ||= :table
+ options[:default_column] = @default_column
SubExpressionBuilder.new(query, options)
end
Modified: groonga/trunk/test/test-column.rb (+13 -1)
===================================================================
--- groonga/trunk/test/test-column.rb 2009-10-22 13:30:36 +09:00 (rev 728)
+++ groonga/trunk/test/test-column.rb 2009-10-22 19:05:38 +09:00 (rev 729)
@@ -174,7 +174,7 @@
assert_equal("title", title.local_name)
end
- def test_select
+ def test_select_query
populate_table_for_select
result = @body.select("drive")
@@ -186,6 +186,18 @@
"{body GET_VALUE \"drive\" MATCH}>", result.expression.inspect)
end
+ def test_select_query_with_parser
+ populate_table_for_select
+
+ result = @body.select("body @ \"drive\"", :parser => :expression)
+ assert_equal(["Drive and Eat"],
+ result.records.collect do |record|
+ record["body"]
+ end)
+ assert_equal("#", result.expression.inspect)
+ end
+
def test_select_expression
populate_table_for_select
From null at cozmixng.org Mon Oct 26 00:35:27 2009
From: null at cozmixng.org (null at cozmixng.org)
Date: Mon, 26 Oct 2009 13:35:27 +0900
Subject: [groonga-commit:692] groonga [groonga (trunk) r730] add tests for
sorting with/without limit and/or offset
Message-ID: <20091026043527.1BFDC1D1C49@mail.cozmixng.org>
retro 2009-10-26 13:35:26 +0900 (Mon, 26 Oct 2009)
New Revision: 730
Log:
add tests for sorting with/without limit and/or offset
Modified files:
groonga/trunk/test/test-table.rb
Modified: groonga/trunk/test/test-table.rb (+55 -25)
===================================================================
--- groonga/trunk/test/test-table.rb 2009-10-22 19:03:54 +09:00 (rev 729)
+++ groonga/trunk/test/test-table.rb 2009-10-26 13:35:26 +09:00 (rev 730)
@@ -325,12 +325,8 @@
end
def test_sort
- bookmarks = Groonga::Array.create(:name => "")
- id_column = bookmarks.define_column("id", "")
- 100.times do |i|
- bookmark = bookmarks.add
- bookmark["id"] = i + 100
- end
+ bookmarks = create_bookmarks
+ add_shuffled_ids(bookmarks)
results = bookmarks.sort([
{
@@ -344,12 +340,8 @@
end
def test_sort_simple
- bookmarks = Groonga::Array.create(:name => "")
- id_column = bookmarks.define_column("id", "")
- 100.times do |i|
- bookmark = bookmarks.add
- bookmark["id"] = i + 100
- end
+ bookmarks = create_bookmarks
+ add_shuffled_ids(bookmarks)
results = bookmarks.sort(["id"], :limit => 20)
assert_equal((100..119).to_a,
@@ -357,31 +349,53 @@
end
def test_sort_by_array
- bookmarks = Groonga::Array.create(:name => "")
- id_column = bookmarks.define_column("id", "")
- 100.times do |i|
- bookmark = bookmarks.add
- bookmark["id"] = i + 100
- end
+ bookmarks = create_bookmarks
+ add_shuffled_ids(bookmarks)
results = bookmarks.sort([["id", "descending"]], :limit => 20)
assert_equal((180..199).to_a.reverse,
results.collect {|record| record["id"]})
end
- def test_sort_without_limit
- bookmarks = Groonga::Array.create(:name => "")
- id_column = bookmarks.define_column("id", "")
- 100.times do |i|
- bookmark = bookmarks.add
- bookmark["id"] = i + 100
- end
+ def test_sort_without_limit_and_offset
+ bookmarks = create_bookmarks
+ add_shuffled_ids(bookmarks)
results = bookmarks.sort([{:key => "id", :order => :descending}])
assert_equal((100..199).to_a.reverse,
results.collect {|record| record["id"]})
end
+ def test_sort_with_limit
+ bookmarks = create_bookmarks
+ add_shuffled_ids(bookmarks)
+
+ results = bookmarks.sort([{:key => "id", :order => :descending}],
+ :limit => 20)
+ assert_equal((180..199).to_a.reverse,
+ results.collect {|record| record["id"]})
+ end
+
+ def test_sort_with_offset
+ bookmarks = create_bookmarks
+ add_shuffled_ids(bookmarks)
+
+ results = bookmarks.sort([{:key => "id", :order => :descending}],
+ :offset => 20)
+ assert_equal((100..179).to_a.reverse,
+ results.collect {|record| record["id"]})
+ end
+
+ def test_sort_with_limit_and_offset
+ bookmarks = create_bookmarks
+ add_shuffled_ids(bookmarks)
+
+ results = bookmarks.sort([{:key => "id", :order => :descending}],
+ :limit => 20, :offset => 20)
+ assert_equal((160..179).to_a.reverse,
+ results.collect {|record| record["id"]})
+ end
+
def test_group
bookmarks = Groonga::Hash.create(:name => "")
bookmarks.define_column("title", "")
@@ -520,4 +534,20 @@
bookmarks.clear_lock
assert_not_predicate(bookmarks, :locked?)
end
+
+ private
+ def create_bookmarks
+ bookmarks = Groonga::Array.create(:name => "")
+ bookmarks.define_column("id", "")
+ bookmarks
+ end
+
+ def add_shuffled_ids(bookmarks)
+ srand(Time.now.to_i)
+ (0...100).to_a.shuffle.each do |i|
+ bookmark = bookmarks.add
+ bookmark["id"] = i + 100
+ end
+ bookmarks
+ end
end
From null at cozmixng.org Mon Oct 26 02:20:23 2009
From: null at cozmixng.org (null at cozmixng.org)
Date: Mon, 26 Oct 2009 15:20:23 +0900
Subject: [groonga-commit:693] groonga [groonga (trunk) r731] make
Table#open_cursor accept :offset and :limit options
Message-ID: <20091026062023.8F6CA1D1C8D@mail.cozmixng.org>
retro 2009-10-26 15:20:23 +0900 (Mon, 26 Oct 2009)
New Revision: 731
Log:
make Table#open_cursor accept :offset and :limit options
Modified files:
groonga/trunk/ext/rb-grn-table.c
groonga/trunk/test/test-table-cursor.rb
Modified: groonga/trunk/ext/rb-grn-table.c (+9 -2)
===================================================================
--- groonga/trunk/ext/rb-grn-table.c 2009-10-26 13:30:54 +09:00 (rev 730)
+++ groonga/trunk/ext/rb-grn-table.c 2009-10-26 15:20:23 +09:00 (rev 731)
@@ -644,8 +644,10 @@
grn_table_cursor *cursor;
void *min_key = NULL, *max_key = NULL;
unsigned min_key_size = 0, max_key_size = 0;
+ unsigned offset = 0, limit = 0;
int flags = 0;
VALUE options, rb_min, rb_max, rb_order, rb_greater_than, rb_less_than;
+ VALUE rb_offset, rb_limit;
rb_grn_table_deconstruct(SELF(self), &table, context,
NULL, NULL,
@@ -656,6 +658,8 @@
rb_grn_scan_options(options,
"min", &rb_min,
"max", &rb_max,
+ "offset", &rb_offset,
+ "limit", &rb_limit,
"order", &rb_order,
"greater_than", &rb_greater_than,
"less_than", &rb_less_than,
@@ -669,6 +673,10 @@
max_key = StringValuePtr(rb_max);
max_key_size = RSTRING_LEN(rb_max);
}
+ if (!NIL_P(rb_offset))
+ offset = NUM2INT(rb_offset);
+ if (!NIL_P(rb_limit))
+ limit = NUM2INT(rb_limit);
if (NIL_P(rb_order)) {
} else if (rb_grn_equal_option(rb_order, "asc") ||
@@ -689,11 +697,10 @@
if (RVAL2CBOOL(rb_less_than))
flags |= GRN_CURSOR_LT;
- /* FIXME: should support offset and limit */
cursor = grn_table_cursor_open(*context, table,
min_key, min_key_size,
max_key, max_key_size,
- 0, 0, flags);
+ offset, limit, flags);
rb_grn_context_check(*context, self);
return cursor;
Modified: groonga/trunk/test/test-table-cursor.rb (+67 -0)
===================================================================
--- groonga/trunk/test/test-table-cursor.rb 2009-10-26 13:30:54 +09:00 (rev 730)
+++ groonga/trunk/test/test-table-cursor.rb 2009-10-26 15:20:23 +09:00 (rev 731)
@@ -48,4 +48,71 @@
[@groonga_bookmark, "groonga"]],
record_and_key_list)
end
+
+ def test_without_limit_and_offset
+ bookmarks = create_bookmarks
+ add_ids(bookmarks)
+ results = []
+ bookmarks.open_cursor do |cursor|
+ while record = cursor.next
+ results << record["id"]
+ end
+ end
+
+ assert_equal((100..199).to_a, results)
+ end
+
+ def test_with_limit
+ bookmarks = create_bookmarks
+ add_ids(bookmarks)
+ results = []
+ bookmarks.open_cursor(:limit => 20) do |cursor|
+ while record = cursor.next
+ results << record["id"]
+ end
+ end
+
+ assert_equal((100...120).to_a, results)
+ end
+
+ def test_with_offset
+ bookmarks = create_bookmarks
+ add_ids(bookmarks)
+ results = []
+ bookmarks.open_cursor(:offset => 20) do |cursor|
+ while record = cursor.next
+ results << record["id"]
+ end
+ end
+
+ assert_equal((120...200).to_a, results)
+ end
+
+ def test_with_limit_and_offset
+ bookmarks = create_bookmarks
+ add_ids(bookmarks)
+ results = []
+ bookmarks.open_cursor(:limit => 20, :offset => 20) do |cursor|
+ while record = cursor.next
+ results << record["id"]
+ end
+ end
+
+ assert_equal((120...140).to_a, results)
+ end
+
+ private
+ def create_bookmarks
+ bookmarks = Groonga::Array.create(:name => "")
+ bookmarks.define_column("id", "")
+ bookmarks
+ end
+
+ def add_ids(bookmarks)
+ (0...100).to_a.each do |i|
+ bookmark = bookmarks.add
+ bookmark["id"] = i + 100
+ end
+ bookmarks
+ end
end
From null at cozmixng.org Mon Oct 26 02:35:43 2009
From: null at cozmixng.org (null at cozmixng.org)
Date: Mon, 26 Oct 2009 15:35:43 +0900
Subject: [groonga-commit:694] groonga [groonga (trunk) r732] * use each
instead of while and next.
Message-ID: <20091026063543.398FD1D1C83@mail.cozmixng.org>
retro 2009-10-26 15:35:42 +0900 (Mon, 26 Oct 2009)
New Revision: 732
Log:
* use each instead of while and next.
Modified files:
groonga/trunk/test/test-table-cursor.rb
Modified: groonga/trunk/test/test-table-cursor.rb (+4 -4)
===================================================================
--- groonga/trunk/test/test-table-cursor.rb 2009-10-26 15:09:35 +09:00 (rev 731)
+++ groonga/trunk/test/test-table-cursor.rb 2009-10-26 15:35:42 +09:00 (rev 732)
@@ -54,7 +54,7 @@
add_ids(bookmarks)
results = []
bookmarks.open_cursor do |cursor|
- while record = cursor.next
+ cursor.each do |record|
results << record["id"]
end
end
@@ -67,7 +67,7 @@
add_ids(bookmarks)
results = []
bookmarks.open_cursor(:limit => 20) do |cursor|
- while record = cursor.next
+ cursor.each do |record|
results << record["id"]
end
end
@@ -80,7 +80,7 @@
add_ids(bookmarks)
results = []
bookmarks.open_cursor(:offset => 20) do |cursor|
- while record = cursor.next
+ cursor.each do |record|
results << record["id"]
end
end
@@ -93,7 +93,7 @@
add_ids(bookmarks)
results = []
bookmarks.open_cursor(:limit => 20, :offset => 20) do |cursor|
- while record = cursor.next
+ cursor.each do |record|
results << record["id"]
end
end