From null at cozmixng.org Sat Sep 5 11:05:39 2009 From: null at cozmixng.org (null at cozmixng.org) Date: Sun, 06 Sep 2009 00:05:39 +0900 Subject: [groonga-commit:617] groonga [groonga (trunk) r653] fixed the rounding error of the test of time conversion. Message-ID: <20090905150540.06B3B1D1CAF@mail.cozmixng.org> retro 2009-09-06 00:05:39 +0900 (Sun, 06 Sep 2009) New Revision: 653 Log: fixed the rounding error of the test of time conversion. Modified files: groonga/trunk/test/test-column.rb Modified: groonga/trunk/test/test-column.rb (+1 -1) =================================================================== --- groonga/trunk/test/test-column.rb 2009-08-28 15:20:20 +09:00 (rev 652) +++ groonga/trunk/test/test-column.rb 2009-09-06 00:05:39 -15:00 (rev 653) @@ -229,7 +229,7 @@ post = posts.add("groonga", :issued => 1251380635) assert_equal(Time.parse("2009-08-27 22:43:55"), post[".issued"]) post = posts.add("mroonga", :issued => 1251380635.1234567) - assert_in_delta(Time.at(1251380635.1234567).usec, post[".issued"].usec, 1) + assert_in_delta(Time.at(1251380635.1234567).usec, post[".issued"].usec, 10) end private From null at cozmixng.org Sat Sep 5 11:05:41 2009 From: null at cozmixng.org (null at cozmixng.org) Date: Sun, 06 Sep 2009 00:05:41 +0900 Subject: [groonga-commit:618] groonga [groonga (trunk) r654] follow the changes of object types(db.c) and proc procs(proc.c) of groonga Message-ID: <20090905150541.AF71F1D1CB7@mail.cozmixng.org> retro 2009-09-06 00:05:41 +0900 (Sun, 06 Sep 2009) New Revision: 654 Log: follow the changes of object types(db.c) and proc procs(proc.c) of groonga Modified files: groonga/trunk/test/test-database.rb Modified: groonga/trunk/test/test-database.rb (+4 -1) =================================================================== --- groonga/trunk/test/test-database.rb 2009-09-05 23:59:17 +09:00 (rev 653) +++ groonga/trunk/test/test-database.rb 2009-09-06 00:05:41 -15:00 (rev 654) @@ -79,10 +79,12 @@ "TokenMecab", "TokenTrigram", "TokenUnigram", + "TokyoGeoPoint", "UInt16", "UInt32", "UInt64", "UInt8", + "WGS84GeoPoint", "column_create", "column_list", "define_selector", @@ -93,7 +95,8 @@ "select", "status", "table_create", - "table_list"], + "table_list", + "view_add"], database.collect {|object| object.name}.sort) end From null at cozmixng.org Mon Sep 7 09:05:43 2009 From: null at cozmixng.org (null at cozmixng.org) Date: Mon, 07 Sep 2009 22:05:43 +0900 Subject: [groonga-commit:619] groonga [groonga (trunk) r655] * support uint64 key. Message-ID: <20090907130543.827D21D1C83@mail.cozmixng.org> retro 2009-09-07 22:05:43 +0900 (Mon, 07 Sep 2009) New Revision: 655 Log: * support uint64 key. Patch by dara. Thanks!!! Modified files: groonga/trunk/README.ja.rdoc groonga/trunk/README.rdoc groonga/trunk/ext/rb-grn-utils.c groonga/trunk/test/test-hash.rb Modified: groonga/trunk/README.ja.rdoc (+3 -1) =================================================================== --- groonga/trunk/README.ja.rdoc 2009-09-06 00:01:03 -15:00 (rev 654) +++ groonga/trunk/README.ja.rdoc 2009-09-07 22:05:43 +09:00 (rev 655) @@ -53,5 +53,7 @@ * ???: ??groonga???????????? * ??????: ?????????????? * ????: ?????????????? -* dara??: ????????????? +* dara??: + * ????????????? + * ???????????? * id:mat_aki??: ???????????????????? Modified: groonga/trunk/README.rdoc (+3 -1) =================================================================== --- groonga/trunk/README.rdoc 2009-09-06 00:01:03 -15:00 (rev 654) +++ groonga/trunk/README.rdoc 2009-09-07 22:05:43 +09:00 (rev 655) @@ -54,5 +54,7 @@ * mori: sent patches to support the latest groonga. * Tasuku SUENAGA: sent bug reports. * niku: sent bug reports. -* dara: wrote tests. +* dara: + * wrote tests. + * fixed bugs. * id:mat_aki: sent bug reports. Modified: groonga/trunk/ext/rb-grn-utils.c (+10 -1) =================================================================== --- groonga/trunk/ext/rb-grn-utils.c 2009-09-06 00:01:03 -15:00 (rev 654) +++ groonga/trunk/ext/rb-grn-utils.c 2009-09-07 22:05:43 +09:00 (rev 655) @@ -105,6 +105,9 @@ case GRN_DB_INT64: *rb_value = LL2NUM(*((long long *)GRN_BULK_HEAD(bulk))); break; + case GRN_DB_UINT64: + *rb_value = ULL2NUM(GRN_UINT64_VALUE(bulk)); + break; case GRN_DB_FLOAT: *rb_value = rb_float_new(*((double *)GRN_BULK_HEAD(bulk))); break; @@ -204,7 +207,7 @@ return rb_grn_bulk_from_ruby_object_with_type( object, context, bulk, bulk->header.domain, grn_ctx_at(context, bulk->header.domain)); - + switch (TYPE(object)) { case T_NIL: string = NULL; @@ -284,6 +287,7 @@ int32_t int32_value; uint32_t uint32_value; int64_t int64_value; + uint64_t uint64_value; int64_t time_value; double double_value; grn_id range; @@ -306,6 +310,11 @@ string = (const char *)&int64_value; size = sizeof(int64_value); break; + case GRN_DB_UINT64: + uint64_value = NUM2ULL(object); + string = (const char *)&uint64_value; + size = sizeof(uint64_value); + break; case GRN_DB_FLOAT: double_value = NUM2DBL(object); string = (const char *)&double_value; Modified: groonga/trunk/test/test-hash.rb (+7 -0) =================================================================== --- groonga/trunk/test/test-hash.rb 2009-09-06 00:01:03 -15:00 (rev 654) +++ groonga/trunk/test/test-hash.rb 2009-09-07 22:05:43 +09:00 (rev 655) @@ -203,4 +203,11 @@ users.add("morita") assert_true(users.has_key?("morita")) end + + def test_big_key + hash = Groonga::Hash.create(:key_type => "UInt64") + assert_nothing_raised do + hash.add(1 << 63) + end + end end From null at cozmixng.org Mon Sep 7 09:20:31 2009 From: null at cozmixng.org (null at cozmixng.org) Date: Mon, 07 Sep 2009 22:20:31 +0900 Subject: [groonga-commit:620] groonga [groonga (trunk) r656] * use groonga's macros. Message-ID: <20090907132031.6C59C1D1C83@mail.cozmixng.org> retro 2009-09-07 22:20:31 +0900 (Mon, 07 Sep 2009) New Revision: 656 Log: * use groonga's macros. Modified files: groonga/trunk/ext/rb-grn-utils.c groonga/trunk/ext/rb-grn.h Modified: groonga/trunk/ext/rb-grn-utils.c (+17 -14) =================================================================== --- groonga/trunk/ext/rb-grn-utils.c 2009-09-07 22:01:45 +09:00 (rev 655) +++ groonga/trunk/ext/rb-grn-utils.c 2009-09-07 22:20:31 +09:00 (rev 656) @@ -94,35 +94,37 @@ switch (range_id) { case GRN_DB_VOID: - *rb_value = rb_str_new(GRN_BULK_HEAD(bulk), GRN_BULK_VSIZE(bulk)); + *rb_value = rb_str_new(GRN_TEXT_VALUE(bulk), GRN_TEXT_LEN(bulk)); break; case GRN_DB_INT32: - *rb_value = INT2NUM(*((int *)GRN_BULK_HEAD(bulk))); + *rb_value = INT2NUM(GRN_INT32_VALUE(bulk)); break; case GRN_DB_UINT32: - *rb_value = UINT2NUM(*((int *)GRN_BULK_HEAD(bulk))); + *rb_value = UINT2NUM(GRN_UINT32_VALUE(bulk)); break; case GRN_DB_INT64: - *rb_value = LL2NUM(*((long long *)GRN_BULK_HEAD(bulk))); + *rb_value = LL2NUM(GRN_INT64_VALUE(bulk)); break; case GRN_DB_UINT64: *rb_value = ULL2NUM(GRN_UINT64_VALUE(bulk)); break; case GRN_DB_FLOAT: - *rb_value = rb_float_new(*((double *)GRN_BULK_HEAD(bulk))); + *rb_value = rb_float_new(GRN_FLOAT_VALUE(bulk)); break; case GRN_DB_TIME: { - int64_t time_value = GRN_TIME_VALUE(bulk); + int64_t time_value, sec, usec; + + time_value = GRN_TIME_VALUE(bulk); + GRN_TIME_UNPACK(time_value, sec, usec); *rb_value = rb_funcall(rb_cTime, rb_intern("at"), 2, - LL2NUM(time_value / RB_GRN_USEC_PER_SEC), - LL2NUM(time_value % RB_GRN_USEC_PER_SEC)); + LL2NUM(sec), LL2NUM(usec)); } break; case GRN_DB_SHORT_TEXT: case GRN_DB_TEXT: case GRN_DB_LONG_TEXT: - *rb_value = rb_str_new(GRN_BULK_HEAD(bulk), GRN_BULK_VSIZE(bulk)); + *rb_value = rb_str_new(GRN_TEXT_VALUE(bulk), GRN_TEXT_LEN(bulk)); break; default: success = RB_GRN_FALSE; @@ -245,7 +247,7 @@ sec = rb_funcall(object, rb_intern("to_i"), 0); usec = rb_funcall(object, rb_intern("usec"), 0); - time_value = NUM2LL(sec) * RB_GRN_USEC_PER_SEC + NUM2LL(usec); + time_value = GRN_TIME_PACK(NUM2LL(sec), NUM2LL(usec)); string = (const char *)&time_value; size = sizeof(time_value); } else if (RVAL2CBOOL(rb_obj_is_kind_of(object, rb_cGrnObject))) { @@ -334,7 +336,8 @@ break; case T_FLOAT: rb_sec = rb_funcall(object, rb_intern("to_i"), 0); - rb_usec = rb_funcall(object, rb_intern("remainder"), 1, INT2NUM(1)); + rb_usec = rb_funcall(object, rb_intern("remainder"), 1, + INT2NUM(1)); sec = NUM2LL(rb_sec); usec = (int32_t)(NUM2DBL(rb_usec) * 1000000); @@ -344,8 +347,8 @@ usec = NUM2INT(rb_funcall(object, rb_intern("usec"), 0)); break; } - - time_value = sec * RB_GRN_USEC_PER_SEC + usec; + + time_value = GRN_TIME_PACK(sec, usec); } string = (const char *)&time_value; size = sizeof(time_value); @@ -655,7 +658,7 @@ sec = rb_funcall(rb_object, rb_intern("to_i"), 0); usec = rb_funcall(rb_object, rb_intern("usec"), 0); - time_value = NUM2LL(sec) * RB_GRN_USEC_PER_SEC + NUM2LL(usec); + time_value = GRN_TIME_PACK(NUM2LL(sec), NUM2LL(usec)); grn_obj_reinit(context, obj, GRN_DB_TIME, 0); GRN_TIME_SET(context, obj, time_value); } else if (RVAL2CBOOL(rb_obj_is_kind_of(rb_object, rb_cGrnObject))) { Modified: groonga/trunk/ext/rb-grn.h (+0 -2) =================================================================== --- groonga/trunk/ext/rb-grn.h 2009-09-07 22:01:45 +09:00 (rev 655) +++ groonga/trunk/ext/rb-grn.h 2009-09-07 22:20:31 +09:00 (rev 656) @@ -75,8 +75,6 @@ #include -#define RB_GRN_USEC_PER_SEC 1000000 - #define RB_GRN_OBJECT(object) ((RbGrnObject *)(object)) #define RB_GRN_TABLE(object) ((RbGrnTable *)(object)) #define RB_GRN_TABLE_KEY_SUPPORT(object) ((RbGrnTableKeySupport *)(object)) From null at cozmixng.org Thu Sep 10 18:35:38 2009 From: null at cozmixng.org (null at cozmixng.org) Date: Fri, 11 Sep 2009 07:35:38 +0900 Subject: [groonga-commit:621] groonga [groonga (trunk) r657] * extconf.rb: ensure $INSTALLFILES is array for Ruby 1.8.6. Message-ID: <20090910223538.0B7491D1C83@mail.cozmixng.org> retro 2009-09-11 07:35:37 +0900 (Fri, 11 Sep 2009) New Revision: 657 Log: * extconf.rb: ensure $INSTALLFILES is array for Ruby 1.8.6. Modified files: groonga/trunk/extconf.rb Modified: groonga/trunk/extconf.rb (+1 -0) =================================================================== --- groonga/trunk/extconf.rb 2009-09-07 22:07:54 +09:00 (rev 656) +++ groonga/trunk/extconf.rb 2009-09-11 07:35:37 -15:00 (rev 657) @@ -143,6 +143,7 @@ have_func("rb_errinfo", "ruby.h") have_type("enum ruby_value_type", "ruby.h") +$INSTALLFILES ||= [] $INSTALLFILES << ["../lib/**/*.rb", "$(RUBYLIBDIR)", "../lib"] create_makefile(module_name, src_dir) From null at cozmixng.org Thu Sep 10 19:50:26 2009 From: null at cozmixng.org (null at cozmixng.org) Date: Fri, 11 Sep 2009 08:50:26 +0900 Subject: [groonga-commit:622] groonga [groonga (trunk) r658] * rb-grn-operation.c: follow changes on operators in groonga.h Message-ID: <20090910235026.DA9CC1D1C82@mail.cozmixng.org> retro 2009-09-11 08:50:26 +0900 (Fri, 11 Sep 2009) New Revision: 658 Log: * rb-grn-operation.c: follow changes on operators in groonga.h Modified files: groonga/trunk/ext/rb-grn-operation.c Modified: groonga/trunk/ext/rb-grn-operation.c (+4 -2) =================================================================== --- groonga/trunk/ext/rb-grn-operation.c 2009-09-11 07:20:33 -15:00 (rev 657) +++ groonga/trunk/ext/rb-grn-operation.c 2009-09-11 08:50:26 -15:00 (rev 658) @@ -69,8 +69,10 @@ UINT2NUM(GRN_OP_XOR_ASSIGN)); rb_define_const(rb_mGrnOperation, "OR_ASSIGN", UINT2NUM(GRN_OP_OR_ASSIGN)); - rb_define_const(rb_mGrnOperation, "TERNARY", - UINT2NUM(GRN_OP_TERNARY)); + rb_define_const(rb_mGrnOperation, "JUMP", + UINT2NUM(GRN_OP_JUMP)); + rb_define_const(rb_mGrnOperation, "CJUMP", + UINT2NUM(GRN_OP_CJUMP)); rb_define_const(rb_mGrnOperation, "COMMA", UINT2NUM(GRN_OP_COMMA)); rb_define_const(rb_mGrnOperation, "BITWISE_OR", From null at cozmixng.org Sun Sep 13 04:05:29 2009 From: null at cozmixng.org (null at cozmixng.org) Date: Sun, 13 Sep 2009 17:05:29 +0900 Subject: [groonga-commit:623] groonga [groonga (trunk) r659] * fix a typo. Message-ID: <20090913080529.7D0311D1C74@mail.cozmixng.org> retro 2009-09-13 17:05:29 +0900 (Sun, 13 Sep 2009) New Revision: 659 Log: * fix a typo. Modified files: groonga/trunk/ext/rb-grn-variable-size-column.c Modified: groonga/trunk/ext/rb-grn-variable-size-column.c (+1 -1) =================================================================== --- groonga/trunk/ext/rb-grn-variable-size-column.c 2009-09-11 08:38:17 -15:00 (rev 658) +++ groonga/trunk/ext/rb-grn-variable-size-column.c 2009-09-13 17:05:29 +09:00 (rev 659) @@ -23,7 +23,7 @@ VALUE rb_cGrnVariableSizeColumn; /* - * Document-class: Groonga::FixSizeColumn < Groonga::Column + * Document-class: Groonga::VariableSizeColumn < Groonga::Column * * ???????????? */ From null at cozmixng.org Sun Sep 13 04:21:11 2009 From: null at cozmixng.org (null at cozmixng.org) Date: Sun, 13 Sep 2009 17:21:11 +0900 Subject: [groonga-commit:624] groonga [groonga (trunk) r660] * add missing :default_tokenizer argument. Message-ID: <20090913082111.D1DD61D1C80@mail.cozmixng.org> retro 2009-09-13 17:21:10 +0900 (Sun, 13 Sep 2009) New Revision: 660 Log: * add missing :default_tokenizer argument. Modified files: groonga/trunk/test/test-table-select.rb Modified: groonga/trunk/test/test-table-select.rb (+2 -1) =================================================================== --- groonga/trunk/test/test-table-select.rb 2009-09-13 16:54:46 +09:00 (rev 659) +++ groonga/trunk/test/test-table-select.rb 2009-09-13 17:21:10 +09:00 (rev 660) @@ -23,7 +23,8 @@ @comments = Groonga::Array.create(:name => "comments") @comments.define_column("content", "Text") @comments.define_column("created_at", "Time") - terms = Groonga::PatriciaTrie.create(:name => "terms") + terms = Groonga::PatriciaTrie.create(:name => "terms", + :default_tokenizer => "TokenBigram") terms.define_index_column("comment_content", @comments, :with_section => true, :source => "comments.content") From null at cozmixng.org Sun Sep 13 04:21:14 2009 From: null at cozmixng.org (null at cozmixng.org) Date: Sun, 13 Sep 2009 17:21:14 +0900 Subject: [groonga-commit:625] groonga [groonga (trunk) r661] * follow the recent groonga changes. Message-ID: <20090913082114.B964A1D1C82@mail.cozmixng.org> retro 2009-09-13 17:21:13 +0900 (Sun, 13 Sep 2009) New Revision: 661 Log: * follow the recent groonga changes. 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-09-13 17:12:11 +09:00 (rev 660) +++ groonga/trunk/ext/rb-grn-expression.c 2009-09-13 17:21:13 +09:00 (rev 661) @@ -238,7 +238,7 @@ if (!NIL_P(rb_default_operator)) default_operator = RVAL2GRNOPERATOR(rb_default_operator); if (RVAL2CBOOL(rb_use_pragma)) - parse_level = 2; + parse_level = 4; rc = grn_expr_parse(context, expression, query, query_size, default_column, default_mode, default_operator, parse_level); From null at cozmixng.org Sun Sep 13 04:35:39 2009 From: null at cozmixng.org (null at cozmixng.org) Date: Sun, 13 Sep 2009 17:35:39 +0900 Subject: [groonga-commit:626] groonga [groonga (trunk) r662] * follow the recent groonga changes. Message-ID: <20090913083539.7C1081D1C80@mail.cozmixng.org> retro 2009-09-13 17:35:39 +0900 (Sun, 13 Sep 2009) New Revision: 662 Log: * follow the recent groonga changes. Modified files: groonga/trunk/test/test-schema.rb Modified: groonga/trunk/test/test-schema.rb (+1 -1) =================================================================== --- groonga/trunk/test/test-schema.rb 2009-09-13 17:12:29 +09:00 (rev 661) +++ groonga/trunk/test/test-schema.rb 2009-09-13 17:35:39 +09:00 (rev 662) @@ -125,7 +125,7 @@ "id: <#{table.id}>, " + "name: <>, " + "path: <#{path}>, " + - "domain: , " + + "domain: <#{type.inspect}>, " + "range: <#{type.inspect}>, " + "flags: <>, " + "size: <0>>", From null at cozmixng.org Sun Sep 13 05:35:33 2009 From: null at cozmixng.org (null at cozmixng.org) Date: Sun, 13 Sep 2009 18:35:33 +0900 Subject: [groonga-commit:627] groonga [groonga (trunk) r663] * add tests for Japanese query. Message-ID: <20090913093533.5960E1D1C74@mail.cozmixng.org> retro 2009-09-13 18:35:32 +0900 (Sun, 13 Sep 2009) New Revision: 663 Log: * add tests for Japanese query. Patch by dara. Thanks!!! Added files: groonga/trunk/test/test-table-select-normalize.rb Modified files: groonga/trunk/test/test-table-select.rb Modified: groonga/trunk/test/test-table-select.rb (+11 -3) =================================================================== --- groonga/trunk/test/test-table-select.rb 2009-09-13 17:24:18 +09:00 (rev 662) +++ groonga/trunk/test/test-table-select.rb 2009-09-13 18:35:32 +09:00 (rev 663) @@ -1,3 +1,4 @@ +# -*- coding: utf-8 -*- # Copyright (C) 2009 Kouhei Sutou # # This library is free software; you can redistribute it and/or @@ -34,6 +35,9 @@ :created_at => Time.parse("2009-07-09")) @comment3 = @comments.add(:content => "test", :created_at => Time.parse("2009-06-09")) + @japanese_comment = + @comments.add(:content => "?????TV???????", + :created_at => Time.parse("2009-06-09")) end def test_select_sub_expression @@ -49,8 +53,7 @@ result = @comments.select("content:%Hello") assert_equal([@comment1, @comment2], result.collect {|record| record.key}) end - - priority :must + def test_select_query_with_block result = @comments.select("content:%Hello") do |record| record["created_at"] < Time.parse("2009-08-01") @@ -66,7 +69,12 @@ end def test_select_without_block - assert_equal([@comment1, @comment2, @comment3], + assert_equal([@comment1, @comment2, @comment3, @japanese_comment], @comments.select.collect {|record| record.key}) end + + def test_select_query_japanese + result = @comments.select("content:%??TV") + assert_equal([@japanese_comment], result.collect {|record| record.key}) + end end Added: groonga/trunk/test/test-table-select-normalize.rb (+43 -0) =================================================================== --- groonga/trunk/test/test-table-select-normalize.rb 2009-09-13 17:24:18 +09:00 (rev 662) +++ groonga/trunk/test/test-table-select-normalize.rb 2009-09-13 18:35:32 +09:00 (rev 663) @@ -0,0 +1,43 @@ +# -*- coding: utf-8 -*- +# Copyright (C) 2009 Kouhei Sutou +# Copyright (C) 2009 SHIDARA Yoji +# +# 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 TableTestSelectNormalize < Test::Unit::TestCase + include GroongaTestUtils + + setup :setup_database + + setup + def setup_comments + @comments = Groonga::Array.create(:name => "comments") + @comments.define_column("content", "Text") + @comments.define_column("created_at", "Time") + terms = Groonga::PatriciaTrie.create(:name => "terms", + :default_tokenizer => "TokenBigram", + :key_normalize => true) + terms.define_index_column("comment_content", @comments, + :with_section => true, + :source => "comments.content") + @japanese_comment = + @comments.add(:content => "?????TV???????", + :created_at => Time.parse("2009-06-09")) + end + + def test_select_query_with_japanese + result = @comments.select("content:%??TV") + assert_equal([@japanese_comment], result.collect {|record| record.key}) + end +end From null at cozmixng.org Mon Sep 14 05:35:53 2009 From: null at cozmixng.org (null at cozmixng.org) Date: Mon, 14 Sep 2009 18:35:53 +0900 Subject: [groonga-commit:628] groonga [groonga (trunk) r664] globbing with absolute path: Message-ID: <20090914093553.BF2F61D1C74@mail.cozmixng.org> retro 2009-09-14 18:35:53 +0900 (Mon, 14 Sep 2009) New Revision: 664 Log: globbing with absolute path: globbing fails if there's no make command and current directory is not base_dir Modified files: groonga/trunk/test/run-test.rb Modified: groonga/trunk/test/run-test.rb (+1 -1) =================================================================== --- groonga/trunk/test/run-test.rb 2009-09-13 18:32:50 +09:00 (rev 663) +++ groonga/trunk/test/run-test.rb 2009-09-14 18:35:53 +09:00 (rev 664) @@ -47,7 +47,7 @@ $LOAD_PATH.unshift(test_dir) require 'groonga-test-utils' -Dir.glob("test/**/test{_,-}*.rb") do |file| +Dir.glob("#{base_dir}/test/**/test{_,-}*.rb") do |file| require file.sub(/\.rb$/, '') end From null at cozmixng.org Mon Sep 14 20:20:29 2009 From: null at cozmixng.org (null at cozmixng.org) Date: Tue, 15 Sep 2009 09:20:29 +0900 Subject: [groonga-commit:629] groonga [groonga (trunk) r665] * add a test for select query in Japanese. Message-ID: <20090915002029.78F481D1C74@mail.cozmixng.org> retro 2009-09-15 09:20:29 +0900 (Tue, 15 Sep 2009) New Revision: 665 Log: * add a test for select query in Japanese. Patch by dara. Thanks!!! Modified files: groonga/trunk/test/test-table-select-normalize.rb Modified: groonga/trunk/test/test-table-select-normalize.rb (+5 -0) =================================================================== --- groonga/trunk/test/test-table-select-normalize.rb 2009-09-14 18:32:47 +09:00 (rev 664) +++ groonga/trunk/test/test-table-select-normalize.rb 2009-09-15 09:20:29 +09:00 (rev 665) @@ -40,4 +40,9 @@ result = @comments.select("content:%??TV") assert_equal([@japanese_comment], result.collect {|record| record.key}) end + + def test_select_query_only_in_japanese + result = @comments.select("content:%???") + assert_equal([@japanese_comment], result.collect {|record| record.key}) + end end From null at cozmixng.org Tue Sep 15 04:05:43 2009 From: null at cozmixng.org (null at cozmixng.org) Date: Tue, 15 Sep 2009 17:05:43 +0900 Subject: [groonga-commit:630] groonga [groonga (trunk) r666] * fix a memory leak. Message-ID: <20090915080543.33ECD1D1C74@mail.cozmixng.org> retro 2009-09-15 17:05:42 +0900 (Tue, 15 Sep 2009) New Revision: 666 Log: * fix a memory leak. Patch by mori. Thanks!!! Modified files: groonga/trunk/ext/rb-grn-expression.c Modified: groonga/trunk/ext/rb-grn-expression.c (+1 -0) =================================================================== --- groonga/trunk/ext/rb-grn-expression.c 2009-09-15 09:08:07 +09:00 (rev 665) +++ groonga/trunk/ext/rb-grn-expression.c 2009-09-15 17:05:42 +09:00 (rev 666) @@ -245,6 +245,7 @@ if (rc != GRN_SUCCESS) rb_grn_context_check(context, rb_ary_new3(2, self, rb_ary_new4(argc, argv))); + grn_obj_close(context, default_column); return Qnil; } From null at cozmixng.org Tue Sep 15 04:05:44 2009 From: null at cozmixng.org (null at cozmixng.org) Date: Tue, 15 Sep 2009 17:05:44 +0900 Subject: [groonga-commit:631] groonga [groonga (trunk) r667] * fix a SEGV bug. Message-ID: <20090915080544.91FA41D1C82@mail.cozmixng.org> retro 2009-09-15 17:05:44 +0900 (Tue, 15 Sep 2009) New Revision: 667 Log: * fix a SEGV bug. Patch by mori. Thanks!!! Modified files: groonga/trunk/ext/rb-grn-context.c groonga/trunk/ext/rb-grn-object.c groonga/trunk/ext/rb-grn.h Modified: groonga/trunk/ext/rb-grn-object.c (+1 -1) =================================================================== --- groonga/trunk/ext/rb-grn-object.c 2009-09-15 17:00:40 +09:00 (rev 666) +++ groonga/trunk/ext/rb-grn-object.c 2009-09-15 17:05:44 +09:00 (rev 667) @@ -155,7 +155,7 @@ rb_grn_object->object = NULL; debug("type: %x\n", grn_object->header.type); if (rb_grn_object->need_close) { - grn_obj_close(context, grn_object); + grn_obj_unlink(context, grn_object); } } xfree(rb_grn_object); Modified: groonga/trunk/ext/rb-grn-context.c (+3 -7) =================================================================== --- groonga/trunk/ext/rb-grn-context.c 2009-09-15 17:00:40 +09:00 (rev 666) +++ groonga/trunk/ext/rb-grn-context.c 2009-09-15 17:05:44 +09:00 (rev 667) @@ -53,7 +53,7 @@ Data_Get_Struct(object, RbGrnContext, rb_grn_context); if (!rb_grn_context) rb_raise(rb_eGrnError, "groonga context is NULL"); - return &(rb_grn_context->context); + return rb_grn_context->context; } static void @@ -62,7 +62,7 @@ RbGrnContext *rb_grn_context = pointer; grn_ctx *context; - context = &(rb_grn_context->context); + context = rb_grn_context->context; debug("context-free: %p\n", context); if (context->stat != GRN_CTX_FIN) { grn_obj *database; @@ -76,8 +76,6 @@ } debug("context-free: %p: done\n", context); xfree(rb_grn_context); - - GRN_CTX_USER_DATA(context)->ptr = NULL; } static VALUE @@ -233,7 +231,6 @@ RbGrnContext *rb_grn_context; grn_ctx *context; int flags = 0; - grn_rc rc; VALUE options, default_options; VALUE rb_encoding; @@ -252,8 +249,7 @@ rb_grn_context = ALLOC(RbGrnContext); DATA_PTR(self) = rb_grn_context; - context = &(rb_grn_context->context); - rc = grn_ctx_init(context, flags); + context = rb_grn_context->context = grn_ctx_open(flags); rb_grn_context_check(context, self); GRN_CTX_USER_DATA(context)->ptr = rb_grn_context; Modified: groonga/trunk/ext/rb-grn.h (+1 -1) =================================================================== --- groonga/trunk/ext/rb-grn.h 2009-09-15 17:00:40 +09:00 (rev 666) +++ groonga/trunk/ext/rb-grn.h 2009-09-15 17:05:44 +09:00 (rev 667) @@ -89,7 +89,7 @@ typedef struct _RbGrnContext RbGrnContext; struct _RbGrnContext { - grn_ctx context; + grn_ctx *context; }; typedef struct _RbGrnObject RbGrnObject; From null at cozmixng.org Tue Sep 15 10:05:31 2009 From: null at cozmixng.org (null at cozmixng.org) Date: Tue, 15 Sep 2009 23:05:31 +0900 Subject: [groonga-commit:632] groonga [groonga (trunk) r668] * add a test for 'not' query Message-ID: <20090915140531.E1D331D1C74@mail.cozmixng.org> retro 2009-09-15 23:05:31 +0900 (Tue, 15 Sep 2009) New Revision: 668 Log: * add a test for 'not' query Modified files: groonga/trunk/test/test-table-select.rb Modified: groonga/trunk/test/test-table-select.rb (+7 -0) =================================================================== --- groonga/trunk/test/test-table-select.rb 2009-09-15 17:05:21 +09:00 (rev 667) +++ groonga/trunk/test/test-table-select.rb 2009-09-15 23:05:31 +09:00 (rev 668) @@ -77,4 +77,11 @@ result = @comments.select("content:%??TV") assert_equal([@japanese_comment], result.collect {|record| record.key}) end + + def test_select_not_query + result = @comments.select do |record| + record["content"].match "Hello -World" + end + assert_equal([@comment1], result.collect {|record| record.key}) + end end From null at cozmixng.org Wed Sep 23 19:58:54 2009 From: null at cozmixng.org (null at cozmixng.org) Date: Thu, 24 Sep 2009 08:58:54 +0900 Subject: [groonga-commit:633] groonga [groonga (trunk) r669] * fix MeCab related finalization problem. Message-ID: <20090923235854.DF5111D1C83@mail.cozmixng.org> retro 2009-09-24 08:58:53 +0900 (Thu, 24 Sep 2009) New Revision: 669 Log: * fix MeCab related finalization problem. Reported by dara. Thanks!!! Modified files: groonga/trunk/ext/rb-grn-context.c groonga/trunk/ext/rb-grn-object.c groonga/trunk/ext/rb-grn.h groonga/trunk/ext/rb-groonga.c Modified: groonga/trunk/ext/rb-grn-object.c (+4 -1) =================================================================== --- groonga/trunk/ext/rb-grn-object.c 2009-09-15 22:57:05 +09:00 (rev 668) +++ groonga/trunk/ext/rb-grn-object.c 2009-09-24 08:58:53 -15:00 (rev 669) @@ -85,6 +85,9 @@ RbGrnObject *rb_grn_object; grn_obj *grn_object = *grn_objects; + if (rb_grn_exited) + return NULL; + rb_grn_object = user_data->ptr; grn_obj_user_data(context, grn_object)->ptr = NULL; @@ -150,7 +153,7 @@ context = rb_grn_object->context; grn_object = rb_grn_object->object; debug("rb-free: %p:%p:%p\n", context, grn_object, rb_grn_object); - if (context && grn_object) { + if (!rb_grn_exited && context && grn_object) { rb_grn_object->context = NULL; rb_grn_object->object = NULL; debug("type: %x\n", grn_object->header.type); Modified: groonga/trunk/ext/rb-grn-context.c (+18 -10) =================================================================== --- groonga/trunk/ext/rb-grn-context.c 2009-09-15 22:57:05 +09:00 (rev 668) +++ groonga/trunk/ext/rb-grn-context.c 2009-09-24 08:58:53 -15:00 (rev 669) @@ -56,6 +56,22 @@ return rb_grn_context->context; } +void +rb_grn_context_fin (grn_ctx *context) +{ + grn_obj *database; + + if (context->stat == GRN_CTX_FIN) + return; + + database = grn_ctx_db(context); + debug("context:database: %p:%p\n", context, database); + if (database && database->header.type == GRN_DB) { + grn_obj_close(context, database); + } + grn_ctx_fin(context); +} + static void rb_grn_context_free (void *pointer) { @@ -64,16 +80,8 @@ context = rb_grn_context->context; debug("context-free: %p\n", context); - if (context->stat != GRN_CTX_FIN) { - grn_obj *database; - - database = grn_ctx_db(context); - debug("context:database: %p:%p\n", context, database); - if (database && database->header.type == GRN_DB) { - grn_obj_close(context, database); - } - grn_ctx_fin(context); - } + if (!rb_grn_exited) + rb_grn_context_fin(context); debug("context-free: %p: done\n", context); xfree(rb_grn_context); } Modified: groonga/trunk/ext/rb-grn.h (+3 -0) =================================================================== --- groonga/trunk/ext/rb-grn.h 2009-09-15 22:57:05 +09:00 (rev 668) +++ groonga/trunk/ext/rb-grn.h 2009-09-24 08:58:53 -15:00 (rev 669) @@ -154,6 +154,8 @@ grn_obj *value; }; +RB_GRN_VAR rb_grn_boolean rb_grn_exited; + RB_GRN_VAR VALUE rb_eGrnError; RB_GRN_VAR VALUE rb_cGrnObject; RB_GRN_VAR VALUE rb_mGrnEncodingSupport; @@ -223,6 +225,7 @@ void rb_grn_rc_check (grn_rc rc, VALUE related_object); +void rb_grn_context_fin (grn_ctx *context); grn_ctx *rb_grn_context_ensure (VALUE *context); VALUE rb_grn_context_get_default (void); VALUE rb_grn_context_to_exception (grn_ctx *context, Modified: groonga/trunk/ext/rb-groonga.c (+12 -2) =================================================================== --- groonga/trunk/ext/rb-groonga.c 2009-09-15 22:57:05 +09:00 (rev 668) +++ groonga/trunk/ext/rb-groonga.c 2009-09-24 08:58:53 -15:00 (rev 669) @@ -18,12 +18,22 @@ #include "rb-grn.h" +rb_grn_boolean rb_grn_exited = RB_GRN_FALSE; extern grn_ctx grn_gctx; static void -finish_groonga (void) +finish_groonga (VALUE data) { + grn_ctx *context = grn_gctx.next; + + debug("finish\n"); + while (context && context != &grn_gctx) { + rb_grn_context_fin(context); + context = context->next; + } grn_fin(); + debug("finish: done\n"); + rb_grn_exited = RB_GRN_TRUE; } void @@ -68,7 +78,7 @@ rb_grn_init_exception(mGrn); rb_grn_rc_check(grn_init(), Qnil); - atexit(finish_groonga); + rb_set_end_proc(finish_groonga, Qnil); rb_grn_init_utils(mGrn); rb_grn_init_encoding(mGrn); From null at cozmixng.org Wed Sep 23 19:58:57 2009 From: null at cozmixng.org (null at cozmixng.org) Date: Thu, 24 Sep 2009 08:58:57 +0900 Subject: [groonga-commit:634] groonga [groonga (trunk) r670] * use parse_level == 0 for column#match and Message-ID: <20090923235857.88DCD1D1CD7@mail.cozmixng.org> retro 2009-09-24 08:58:56 +0900 (Thu, 24 Sep 2009) New Revision: 670 Log: * use parse_level == 0 for column#match and parse_level == 2 for table#match by default. Modified files: groonga/trunk/ext/rb-grn-expression.c groonga/trunk/lib/groonga/expression-builder.rb Modified: groonga/trunk/ext/rb-grn-expression.c (+22 -4) =================================================================== --- groonga/trunk/ext/rb-grn-expression.c 2009-09-22 18:06:02 +09:00 (rev 669) +++ groonga/trunk/ext/rb-grn-expression.c 2009-09-24 08:58:56 -15:00 (rev 670) @@ -215,14 +215,14 @@ unsigned query_size = 0; int parse_level = 0; VALUE options, rb_query, rb_default_column, rb_default_operator; - VALUE rb_default_mode, rb_use_pragma; + VALUE rb_default_mode, rb_parser; rb_scan_args(argc, argv, "11", &rb_query, &options); rb_grn_scan_options(options, "default_column", &rb_default_column, "default_operator", &rb_default_operator, "default_mode", &rb_default_mode, - "use_pragma", &rb_use_pragma, + "parser", &rb_parser, NULL); query = StringValuePtr(rb_query); @@ -237,8 +237,26 @@ default_mode = RVAL2GRNOPERATOR(rb_default_mode); if (!NIL_P(rb_default_operator)) default_operator = RVAL2GRNOPERATOR(rb_default_operator); - if (RVAL2CBOOL(rb_use_pragma)) + if (NIL_P(rb_parser) || + rb_grn_equal_option(rb_parser, "column") || + rb_grn_equal_option(rb_parser, "column-query") || + rb_grn_equal_option(rb_parser, "column_query")) { + parse_level = 0; + } else if (rb_grn_equal_option(rb_parser, "table") || + rb_grn_equal_option(rb_parser, "table-query") || + rb_grn_equal_option(rb_parser, "table_query")) { + parse_level = 2; + } else if (rb_grn_equal_option(rb_parser, "expression") || + rb_grn_equal_option(rb_parser, "language")) { parse_level = 4; + } else { + rb_raise(rb_eArgError, + "parser should be one of " + "[nil, :column, :column_query, :table, :table_query, " + ":expression, :language]: %s", + rb_grn_inspect(rb_parser)); + } + rc = grn_expr_parse(context, expression, query, query_size, default_column, default_mode, default_operator, parse_level); @@ -264,7 +282,7 @@ rc = grn_expr_exec(context, expression, 0); rb_grn_context_check(context, self); rb_grn_rc_check(rc, self); - + return Qnil; } Modified: groonga/trunk/lib/groonga/expression-builder.rb (+7 -3) =================================================================== --- groonga/trunk/lib/groonga/expression-builder.rb 2009-09-22 18:06:02 +09:00 (rev 669) +++ groonga/trunk/lib/groonga/expression-builder.rb 2009-09-24 08:58:56 -15:00 (rev 670) @@ -185,7 +185,8 @@ else options = options_or_default_column end - SubExpressionBuilder.new(query, options) + default_options = {:parser => :table} + SubExpressionBuilder.new(query, default_options.merge(options)) end end @@ -226,8 +227,11 @@ GreaterEqualExpressionBuilder.new(@default_column, normalize(other)) end - def match(query) - SubExpressionBuilder.new(query, :default_column => @default_column) + def match(query, options={}) + default_options = {:parser => :table} + ensure_options = {:default_column => @default_column} + options = default_options.merge(options).merge(ensure_options) + SubExpressionBuilder.new(query, options) end private From null at cozmixng.org Wed Sep 23 19:59:00 2009 From: null at cozmixng.org (null at cozmixng.org) Date: Thu, 24 Sep 2009 08:59:00 +0900 Subject: [groonga-commit:634] groonga [groonga (trunk) r671] * attach an expression to result table as singleton table. Message-ID: <20090923235901.0FA5C1D1CD9@mail.cozmixng.org> retro 2009-09-24 08:58:59 +0900 (Thu, 24 Sep 2009) New Revision: 671 Log: * attach an expression to result table as singleton table. Modified files: groonga/trunk/ext/rb-grn-table.c Modified: groonga/trunk/ext/rb-grn-table.c (+6 -1) =================================================================== --- groonga/trunk/ext/rb-grn-table.c 2009-09-22 19:20:52 +09:00 (rev 670) +++ groonga/trunk/ext/rb-grn-table.c 2009-09-24 08:58:59 -15:00 (rev 671) @@ -1297,11 +1297,16 @@ 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); + NULL, NULL, NULL, NULL); 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; } From null at cozmixng.org Wed Sep 23 19:59:06 2009 From: null at cozmixng.org (null at cozmixng.org) Date: Thu, 24 Sep 2009 08:59:06 +0900 Subject: [groonga-commit:635] groonga [groonga (trunk) r672] * implement Groonga::Object#append and Groonga::Object#prepend. Message-ID: <20090923235906.B03031D1CD7@mail.cozmixng.org> retro 2009-09-24 08:59:05 +0900 (Thu, 24 Sep 2009) New Revision: 672 Log: * implement Groonga::Object#append and Groonga::Object#prepend. Modified files: groonga/trunk/ext/rb-grn-object.c groonga/trunk/ext/rb-grn-utils.c groonga/trunk/lib/groonga/record.rb groonga/trunk/test/test-variable-size-column.rb Modified: groonga/trunk/ext/rb-grn-object.c (+16 -1) =================================================================== --- groonga/trunk/ext/rb-grn-object.c 2009-09-22 19:31:32 +09:00 (rev 671) +++ groonga/trunk/ext/rb-grn-object.c 2009-09-24 08:59:05 -15:00 (rev 672) @@ -1052,7 +1052,7 @@ * call-seq: * object.append(id, value) * - * _object_?_id_???????_value_?????? + * _object_?_id_??????????_value_?????? */ static VALUE rb_grn_object_append_value (VALUE self, VALUE rb_id, VALUE rb_value) @@ -1060,7 +1060,21 @@ return rb_grn_object_set(self, rb_id, rb_value, GRN_OBJ_APPEND); } +/* + * Document-method: prepend + * + * call-seq: + * object.prepend(id, value) + * + * _object_?_id_??????????_value_?????? + */ static VALUE +rb_grn_object_prepend_value (VALUE self, VALUE rb_id, VALUE rb_value) +{ + return rb_grn_object_set(self, rb_id, rb_value, GRN_OBJ_PREPEND); +} + +static VALUE rb_grn_object_remove (VALUE self) { RbGrnObject *rb_grn_object; @@ -1101,6 +1115,7 @@ rb_define_method(rb_cGrnObject, "[]", rb_grn_object_array_reference, 1); rb_define_method(rb_cGrnObject, "[]=", rb_grn_object_array_set, 2); rb_define_method(rb_cGrnObject, "append", rb_grn_object_append_value, 2); + rb_define_method(rb_cGrnObject, "prepend", rb_grn_object_prepend_value, 2); rb_define_method(rb_cGrnObject, "remove", rb_grn_object_remove, 0); } Modified: groonga/trunk/test/test-variable-size-column.rb (+28 -0) =================================================================== --- groonga/trunk/test/test-variable-size-column.rb 2009-09-22 19:31:32 +09:00 (rev 671) +++ groonga/trunk/test/test-variable-size-column.rb 2009-09-24 08:59:05 -15:00 (rev 672) @@ -20,6 +20,7 @@ setup_database setup_users_table + setup_users end def setup_users_table @@ -30,8 +31,19 @@ @users_name_column_path = @columns_dir + "name" @name = @users.define_column("name", "", :path => @users_name_column_path.to_s) + + @users_friends_column_path = @columns_dir + "friends" + @friends = @users.define_column("friends", @users, + :type => :vector, + :path => @users_friends_column_path.to_s) end + def setup_users + @morita = @users.add(:name => "mori daijiro") + @gunyara_kun = @users.add(:name => "Tasuku SUENAGA") + @yu = @users.add(:name => "Yutaro Shimamura") + end + def test_inspect assert_equal("#, " + @@ -51,4 +63,20 @@ def test_table assert_equal(@users, @name.table) end + + def test_vector_append + assert_equal([], @morita["friends"]) + @morita.append("friends", @yu) + assert_equal([@yu], @morita["friends"]) + @morita.append("friends", @gunyara_kun) + assert_equal([@yu, @gunyara_kun], @morita["friends"]) + end + + def test_vector_prepend + assert_equal([], @morita["friends"]) + @morita.prepend("friends", @yu) + assert_equal([@yu], @morita["friends"]) + @morita.prepend("friends", @gunyara_kun) + assert_equal([@gunyara_kun, @yu], @morita["friends"]) + end end Modified: groonga/trunk/lib/groonga/record.rb (+5 -1) =================================================================== --- groonga/trunk/lib/groonga/record.rb 2009-09-22 19:31:32 +09:00 (rev 671) +++ groonga/trunk/lib/groonga/record.rb 2009-09-24 08:59:05 -15:00 (rev 672) @@ -45,6 +45,10 @@ column(column_name).append(@id, value) end + def prepend(column_name, value) + column(column_name).prepend(@id, value) + end + def have_column?(name) column(name).is_a?(Groonga::Column) rescue Groonga::InvalidArgument @@ -92,7 +96,7 @@ table_name = @table.name columns.each do |column| next if column.is_a?(Groonga::IndexColumn) - attributes[column.name[(table_name.size + 1)..-1]] = column[@id] + attributes[column.local_name] = column[@id] end attributes end Modified: groonga/trunk/ext/rb-grn-utils.c (+19 -0) =================================================================== --- groonga/trunk/ext/rb-grn-utils.c 2009-09-22 19:31:32 +09:00 (rev 671) +++ groonga/trunk/ext/rb-grn-utils.c 2009-09-24 08:59:05 -15:00 (rev 672) @@ -521,6 +521,25 @@ value->header.domain = grn_obj_id(context, range); return GRNBULK2RVAL(context, value, related_object); break; + case GRN_UVECTOR: + { + VALUE rb_value, rb_range = Qnil; + grn_id *uvector, *uvector_end; + + rb_value = rb_ary_new(); + if (range) + rb_range = GRNTABLE2RVAL(context, range, RB_GRN_FALSE); + uvector = (grn_id *)GRN_BULK_HEAD(value); + uvector_end = (grn_id *)GRN_BULK_CURR(value); + for (; uvector < uvector_end; uvector++) { + VALUE record = Qnil; + if (*uvector != GRN_ID_NIL) + record = rb_grn_record_new(rb_range, *uvector, Qnil); + rb_ary_push(rb_value, record); + } + return rb_value; + } + break; default: rb_raise(rb_eGrnError, "unsupported value type: 0x%0x: %s", From null at cozmixng.org Wed Sep 23 19:59:11 2009 From: null at cozmixng.org (null at cozmixng.org) Date: Thu, 24 Sep 2009 08:59:11 +0900 Subject: [groonga-commit:636] groonga [groonga (trunk) r673] give a better name for the test case Message-ID: <20090923235911.548641D1D08@mail.cozmixng.org> retro 2009-09-24 08:59:09 +0900 (Thu, 24 Sep 2009) New Revision: 673 Log: give a better name for the test case Modified files: groonga/trunk/test/test-table-select.rb Modified: groonga/trunk/test/test-table-select.rb (+1 -1) =================================================================== --- groonga/trunk/test/test-table-select.rb 2009-09-23 15:16:05 +09:00 (rev 672) +++ groonga/trunk/test/test-table-select.rb 2009-09-24 08:59:09 -15:00 (rev 673) @@ -78,7 +78,7 @@ assert_equal([@japanese_comment], result.collect {|record| record.key}) end - def test_select_not_query + def test_select_but_query result = @comments.select do |record| record["content"].match "Hello -World" end From null at cozmixng.org Wed Sep 23 19:59:16 2009 From: null at cozmixng.org (null at cozmixng.org) Date: Thu, 24 Sep 2009 08:59:16 +0900 Subject: [groonga-commit:637] groonga [groonga (trunk) r674] add a test case for a query including a dot in the third term Message-ID: <20090923235916.A26A21D1D0A@mail.cozmixng.org> retro 2009-09-24 08:59:14 +0900 (Thu, 24 Sep 2009) New Revision: 674 Log: add a test case for a query including a dot in the third term Modified files: groonga/trunk/test/test-table-select.rb Modified: groonga/trunk/test/test-table-select.rb (+7 -0) =================================================================== --- groonga/trunk/test/test-table-select.rb 2009-09-23 20:16:14 +09:00 (rev 673) +++ groonga/trunk/test/test-table-select.rb 2009-09-24 08:59:14 -15:00 (rev 674) @@ -84,4 +84,11 @@ end assert_equal([@comment1], result.collect {|record| record.key}) end + + def test_select_query_with_dot + result = @comments.select do |record| + record["content"].match "Hello World a.b" + end + assert_equal([], result.collect {|record| record.key}) + end end From null at cozmixng.org Wed Sep 23 19:59:20 2009 From: null at cozmixng.org (null at cozmixng.org) Date: Thu, 24 Sep 2009 08:59:20 +0900 Subject: [groonga-commit:638] groonga [groonga (trunk) r675] make the test more general Message-ID: <20090923235920.DEA6F1D1C74@mail.cozmixng.org> retro 2009-09-24 08:59:19 +0900 (Thu, 24 Sep 2009) New Revision: 675 Log: make the test more general Modified files: groonga/trunk/test/test-table-select.rb Modified: groonga/trunk/test/test-table-select.rb (+2 -2) =================================================================== --- groonga/trunk/test/test-table-select.rb 2009-09-23 20:22:24 +09:00 (rev 674) +++ groonga/trunk/test/test-table-select.rb 2009-09-24 08:59:19 -15:00 (rev 675) @@ -85,9 +85,9 @@ assert_equal([@comment1], result.collect {|record| record.key}) end - def test_select_query_with_dot + def test_select_query_with_three_terms result = @comments.select do |record| - record["content"].match "Hello World a.b" + record["content"].match "Say Hello World" end assert_equal([], result.collect {|record| record.key}) end From null at cozmixng.org Wed Sep 23 23:25:29 2009 From: null at cozmixng.org (null at cozmixng.org) Date: Thu, 24 Sep 2009 12:25:29 +0900 Subject: [groonga-commit:639] groonga [groonga (trunk) r676] * show inspected Groonga::Expression on failure. Message-ID: <20090924032529.8020B1D1CB7@mail.cozmixng.org> retro 2009-09-24 12:25:29 +0900 (Thu, 24 Sep 2009) New Revision: 676 Log: * show inspected Groonga::Expression on failure. Modified files: groonga/trunk/test/groonga-test-utils.rb groonga/trunk/test/test-table-select-normalize.rb groonga/trunk/test/test-table-select.rb Modified: groonga/trunk/test/groonga-test-utils.rb (+7 -0) =================================================================== --- groonga/trunk/test/groonga-test-utils.rb 2009-09-23 23:37:51 +09:00 (rev 675) +++ groonga/trunk/test/groonga-test-utils.rb 2009-09-24 12:25:29 +09:00 (rev 676) @@ -89,4 +89,11 @@ def teardown_tmp_directory FileUtils.rm_rf(@tmp_dir.to_s) end + + private + def assert_equal_select_result(expected, actual) + assert_equal(expected, + actual.collect {|record| record.key}, + actual.expression.inspect) + end end Modified: groonga/trunk/test/test-table-select.rb (+10 -10) =================================================================== --- groonga/trunk/test/test-table-select.rb 2009-09-23 23:37:51 +09:00 (rev 675) +++ groonga/trunk/test/test-table-select.rb 2009-09-24 12:25:29 +09:00 (rev 676) @@ -45,50 +45,50 @@ record.match("Hello", "content") & (record["created_at"] < Time.parse("2009-08-01")) end - assert_equal([@comment2], - result.collect {|record| record.key}) + assert_equal_select_result([@comment2], result) end def test_select_query result = @comments.select("content:%Hello") - assert_equal([@comment1, @comment2], result.collect {|record| record.key}) + 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") end - assert_equal([@comment2], result.collect {|record| record.key}) + assert_equal_select_result([@comment2], result) end def test_select_query_with_block_match result = @comments.select("content:%Hello") do |record| record.match("World", "content") end - assert_equal([@comment2], result.collect {|record| record.key}) + assert_equal_select_result([@comment2], result) end def test_select_without_block - assert_equal([@comment1, @comment2, @comment3, @japanese_comment], - @comments.select.collect {|record| record.key}) + assert_equal_select_result([@comment1, @comment2, + @comment3, @japanese_comment], + @comments.select) end def test_select_query_japanese result = @comments.select("content:%??TV") - assert_equal([@japanese_comment], result.collect {|record| record.key}) + assert_equal_select_result([@japanese_comment], result) end def test_select_but_query result = @comments.select do |record| record["content"].match "Hello -World" end - assert_equal([@comment1], result.collect {|record| record.key}) + assert_equal_select_result([@comment1], result) end def test_select_query_with_three_terms result = @comments.select do |record| record["content"].match "Say Hello World" end - assert_equal([], result.collect {|record| record.key}) + assert_equal_select_result([], result) end end Modified: groonga/trunk/test/test-table-select-normalize.rb (+2 -2) =================================================================== --- groonga/trunk/test/test-table-select-normalize.rb 2009-09-23 23:37:51 +09:00 (rev 675) +++ groonga/trunk/test/test-table-select-normalize.rb 2009-09-24 12:25:29 +09:00 (rev 676) @@ -38,11 +38,11 @@ def test_select_query_with_japanese result = @comments.select("content:%??TV") - assert_equal([@japanese_comment], result.collect {|record| record.key}) + assert_equal_select_result([@japanese_comment], result) end def test_select_query_only_in_japanese result = @comments.select("content:%???") - assert_equal([@japanese_comment], result.collect {|record| record.key}) + assert_equal_select_result([@japanese_comment], result) end end From null at cozmixng.org Thu Sep 24 00:55:29 2009 From: null at cozmixng.org (null at cozmixng.org) Date: Thu, 24 Sep 2009 13:55:29 +0900 Subject: [groonga-commit:640] groonga [groonga (trunk) r677] * require groonga 0.1.4. (note: 0.1.4 isn't released yet. :-p) Message-ID: <20090924045529.B5EAE1D1CBF@mail.cozmixng.org> retro 2009-09-24 13:55:29 +0900 (Thu, 24 Sep 2009) New Revision: 677 Log: * require groonga 0.1.4. (note: 0.1.4 isn't released yet. :-p) Modified files: groonga/trunk/extconf.rb Modified: groonga/trunk/extconf.rb (+1 -1) =================================================================== --- groonga/trunk/extconf.rb 2009-09-24 12:21:43 +09:00 (rev 676) +++ groonga/trunk/extconf.rb 2009-09-24 13:55:29 +09:00 (rev 677) @@ -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, 1 +major, minor, micro = 0, 1, 4 def local_groonga_base_dir File.join(File.dirname(__FILE__), "vendor") From null at cozmixng.org Thu Sep 24 01:40:28 2009 From: null at cozmixng.org (null at cozmixng.org) Date: Thu, 24 Sep 2009 14:40:28 +0900 Subject: [groonga-commit:641] groonga [groonga (trunk) r678] * add PatriciaTrie#tag_keys as a utility method for creating Message-ID: <20090924054028.997AF1D1C85@mail.cozmixng.org> retro 2009-09-24 14:40:28 +0900 (Thu, 24 Sep 2009) New Revision: 678 Log: * add PatriciaTrie#tag_keys as a utility method for creating links of keyword. Added files: groonga/trunk/lib/groonga/patricia-trie.rb Modified files: groonga/trunk/ext/rb-grn-patricia-trie.c groonga/trunk/lib/groonga.rb groonga/trunk/test/test-patricia-trie.rb Modified: groonga/trunk/lib/groonga.rb (+1 -0) =================================================================== --- groonga/trunk/lib/groonga.rb 2009-09-24 13:54:08 +09:00 (rev 677) +++ groonga/trunk/lib/groonga.rb 2009-09-24 14:40:28 +09:00 (rev 678) @@ -69,4 +69,5 @@ end end +require 'groonga/patricia-trie' require 'groonga/schema' Modified: groonga/trunk/ext/rb-grn-patricia-trie.c (+1 -1) =================================================================== --- groonga/trunk/ext/rb-grn-patricia-trie.c 2009-09-24 13:54:08 +09:00 (rev 677) +++ groonga/trunk/ext/rb-grn-patricia-trie.c 2009-09-24 14:40:28 +09:00 (rev 678) @@ -191,8 +191,8 @@ term = rb_str_new(string + hits[i].offset, hits[i].length); matched_info = rb_ary_new3(4, + record, term, - record, UINT2NUM(hits[i].offset), UINT2NUM(hits[i].length)); if (block_given) { Modified: groonga/trunk/test/test-patricia-trie.rb (+24 -3) =================================================================== --- groonga/trunk/test/test-patricia-trie.rb 2009-09-24 13:54:08 +09:00 (rev 677) +++ groonga/trunk/test/test-patricia-trie.rb 2009-09-24 14:40:28 +09:00 (rev 678) @@ -99,9 +99,30 @@ words.add('??') gaxtu = words.add('???') muteki = words.add('??????') - assert_equal([["muTEki", muteki, 0, 6], - ["??????", adventure_of_link, 7, 18], - ["??", gaxtu, 42, 6]], + assert_equal([[muteki, "muTEki", 0, 6], + [adventure_of_link, "??????", 7, 18], + [gaxtu, "??", 42, 6]], words.scan('muTEki ?????? ????? ??')) end + + def test_tag_keys + Groonga::Context.default_options = {:encoding => "utf-8"} + words = Groonga::PatriciaTrie.create(:key_type => "ShortText", + :key_normalize => true) + words.add("???") + words.add('??????') + words.add('??') + words.add('???') + words.add('??????') + + text = 'muTEki ?????? ????? ??' + actual = words.tag_keys(text) do |record, word| + "<#{word}(#{record.key})>" + end + assert_equal(" " + + " " + + "????? " + + "", + actual) + end end Added: groonga/trunk/lib/groonga/patricia-trie.rb (+31 -0) =================================================================== --- groonga/trunk/lib/groonga/patricia-trie.rb 2009-09-24 13:54:08 +09:00 (rev 677) +++ groonga/trunk/lib/groonga/patricia-trie.rb 2009-09-24 14:40:28 +09:00 (rev 678) @@ -0,0 +1,31 @@ +# -*- coding: utf-8 -*- +# +# 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 + +module Groonga + class PatriciaTrie + def tag_keys(text) + position = 0 + result = '' + scan(text) do |record, word, start, length| + result << text[position...start] + result << yield(record, word) + position = start + length + end + result + end + end +end From null at cozmixng.org Thu Sep 24 01:55:27 2009 From: null at cozmixng.org (null at cozmixng.org) Date: Thu, 24 Sep 2009 14:55:27 +0900 Subject: [groonga-commit:642] groonga [groonga (trunk) r679] * still use 0.1.3. :< Message-ID: <20090924055527.926C71D1CB7@mail.cozmixng.org> retro 2009-09-24 14:55:27 +0900 (Thu, 24 Sep 2009) New Revision: 679 Log: * still use 0.1.3. :< Modified files: groonga/trunk/extconf.rb Modified: groonga/trunk/extconf.rb (+1 -1) =================================================================== --- groonga/trunk/extconf.rb 2009-09-24 14:27:00 +09:00 (rev 678) +++ groonga/trunk/extconf.rb 2009-09-24 14:55:27 +09:00 (rev 679) @@ -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, 4 +major, minor, micro = 0, 1, 3 def local_groonga_base_dir File.join(File.dirname(__FILE__), "vendor") From null at cozmixng.org Thu Sep 24 01:55:29 2009 From: null at cozmixng.org (null at cozmixng.org) Date: Thu, 24 Sep 2009 14:55:29 +0900 Subject: [groonga-commit:643] groonga [groonga (trunk) r680] * ignore example/search/data/. Message-ID: <20090924055529.088D91D1CBF@mail.cozmixng.org> retro 2009-09-24 14:55:28 +0900 (Thu, 24 Sep 2009) New Revision: 680 Log: * ignore example/search/data/. Modified files: groonga/trunk/Rakefile Modified: groonga/trunk/Rakefile (+1 -1) =================================================================== --- groonga/trunk/Rakefile 2009-09-24 14:43:22 +09:00 (rev 679) +++ groonga/trunk/Rakefile 2009-09-24 14:55:28 +09:00 (rev 680) @@ -54,7 +54,7 @@ TUTORIAL.ja.rdoc extconf.rb pkg-config.rb) excluded_components = %w(.cvsignore .gdb_history CVS depend Makefile pkg - .svn .git doc vendor .test-result) + .svn .git doc vendor data .test-result) excluded_suffixes = %w(.png .ps .pdf .o .so .a .txt .~) Find.find(base_dir) do |target| target = truncate_base_dir[target] From null at cozmixng.org Thu Sep 24 02:10:30 2009 From: null at cozmixng.org (null at cozmixng.org) Date: Thu, 24 Sep 2009 15:10:30 +0900 Subject: [groonga-commit:644] groonga [activegroonga (trunk) r681] * require ActiveRecord 2.3.4. Message-ID: <20090924061030.254281D1C74@mail.cozmixng.org> retro 2009-09-24 15:10:29 +0900 (Thu, 24 Sep 2009) New Revision: 681 Log: * require ActiveRecord 2.3.4. Modified files: activegroonga/trunk/Rakefile Modified: activegroonga/trunk/Rakefile (+2 -1) =================================================================== --- activegroonga/trunk/Rakefile 2009-09-24 14:45:30 +09:00 (rev 680) +++ activegroonga/trunk/Rakefile 2009-09-24 15:10:29 +09:00 (rev 681) @@ -106,7 +106,8 @@ :extra_rdoc_files => Dir.glob("*.rdoc"), } project.readme_file = "README.ja.rdoc" - project.extra_deps = [["groonga", "=#{version}"], ["activerecord", "=2.3.2"]] + project.extra_deps = [["groonga", "=#{version}"], + ["activerecord", "=2.3.4"]] news_of_current_release = File.read("NEWS.rdoc").split(/^==\s.*$/)[1] project.changes = cleanup_white_space(news_of_current_release) From null at cozmixng.org Thu Sep 24 02:40:36 2009 From: null at cozmixng.org (null at cozmixng.org) Date: Thu, 24 Sep 2009 15:40:36 +0900 Subject: [groonga-commit:645] groonga [activegroonga (trunk) r682] * fix remove_column doesn't work. Message-ID: <20090924064036.44FD51D1C83@mail.cozmixng.org> retro 2009-09-24 15:40:35 +0900 (Thu, 24 Sep 2009) New Revision: 682 Log: * fix remove_column doesn't work. Modified files: activegroonga/trunk/lib/active_groonga/schema.rb activegroonga/trunk/test/test-schema.rb Modified: activegroonga/trunk/test/test-schema.rb (+12 -0) =================================================================== --- activegroonga/trunk/test/test-schema.rb 2009-09-24 14:56:36 +09:00 (rev 681) +++ activegroonga/trunk/test/test-schema.rb 2009-09-24 15:40:35 +09:00 (rev 682) @@ -62,4 +62,16 @@ assert_predicate(index_file, :exist?) end + + def test_remove_column + column_file = @tables_dir + "posts" + "columns" + "title.groonga" + assert_not_predicate(column_file, :exist?) + ActiveGroonga::Schema.create_table(:posts) do |table| + table.string :title + end + assert_predicate(column_file, :exist?) + + ActiveGroonga::Schema.remove_column(:posts, :title) + assert_not_predicate(column_file, :exist?) + end end Modified: activegroonga/trunk/lib/active_groonga/schema.rb (+5 -0) =================================================================== --- activegroonga/trunk/lib/active_groonga/schema.rb 2009-09-24 14:56:36 +09:00 (rev 681) +++ activegroonga/trunk/lib/active_groonga/schema.rb 2009-09-24 15:40:35 +09:00 (rev 682) @@ -83,6 +83,11 @@ end def remove_column(table_name, *column_names) + if column_names.last.is_a?(Hash) + options = columns.pop + else + options = {} + end options_with_context = options.merge(:context => Base.context) Groonga::Schema.change_table(table_name, options_with_context) do |table| column_names.each do |column_name| From null at cozmixng.org Thu Sep 24 02:55:27 2009 From: null at cozmixng.org (null at cozmixng.org) Date: Thu, 24 Sep 2009 15:55:27 +0900 Subject: [groonga-commit:646] groonga [activegroonga (trunk) r683] * support callback. Message-ID: <20090924065527.9B4E01D1C83@mail.cozmixng.org> retro 2009-09-24 15:55:27 +0900 (Thu, 24 Sep 2009) New Revision: 683 Log: * support callback. Added files: activegroonga/trunk/lib/active_groonga/callbacks.rb activegroonga/trunk/test/test-callbacks.rb Modified files: activegroonga/trunk/lib/active_groonga/base.rb Modified: activegroonga/trunk/lib/active_groonga/base.rb (+1 -0) =================================================================== --- activegroonga/trunk/lib/active_groonga/base.rb 2009-09-24 15:34:17 +09:00 (rev 682) +++ activegroonga/trunk/lib/active_groonga/base.rb 2009-09-24 15:55:27 +09:00 (rev 683) @@ -1600,6 +1600,7 @@ end include Validations + include Callbacks include AttributeMethods include Dirty include Timestamp Added: activegroonga/trunk/test/test-callbacks.rb (+30 -0) =================================================================== --- activegroonga/trunk/test/test-callbacks.rb 2009-09-24 15:34:17 +09:00 (rev 682) +++ activegroonga/trunk/test/test-callbacks.rb 2009-09-24 15:55:27 +09:00 (rev 683) @@ -0,0 +1,30 @@ +# 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 as published by the Free Software Foundation; either +# version 2.1 of the License. +# +# 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 TestCallbacks < Test::Unit::TestCase + include ActiveGroongaTestUtils + + def test_before_save + bookmark = Bookmark.new + def bookmark.before_save + @called = true + end + bookmark.instance_variable_set("@called", false) + assert_equal(false, bookmark.instance_variable_get("@called")) + bookmark.save + assert_equal(true, bookmark.instance_variable_get("@called")) + end +end Added: activegroonga/trunk/lib/active_groonga/callbacks.rb (+26 -0) =================================================================== --- activegroonga/trunk/lib/active_groonga/callbacks.rb 2009-09-24 15:34:17 +09:00 (rev 682) +++ activegroonga/trunk/lib/active_groonga/callbacks.rb 2009-09-24 15:55:27 +09:00 (rev 683) @@ -0,0 +1,26 @@ +# 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 + +module ActiveGroonga + module Callbacks + class << self + def included(base) + base.class_eval do + include ActiveRecord::Callbacks + end + end + end + end +end From null at cozmixng.org Thu Sep 24 08:40:28 2009 From: null at cozmixng.org (null at cozmixng.org) Date: Thu, 24 Sep 2009 21:40:28 +0900 Subject: [groonga-commit:647] groonga [groonga (trunk) r684] added test for a query with brackets Message-ID: <20090924124028.3A38B1D1CCB@mail.cozmixng.org> retro 2009-09-24 21:40:27 +0900 (Thu, 24 Sep 2009) New Revision: 684 Log: added test for a query with brackets Modified files: groonga/trunk/test/test-table-select.rb Modified: groonga/trunk/test/test-table-select.rb (+7 -0) =================================================================== --- groonga/trunk/test/test-table-select.rb 2009-09-24 15:51:51 +09:00 (rev 683) +++ groonga/trunk/test/test-table-select.rb 2009-09-24 21:40:27 +09:00 (rev 684) @@ -91,4 +91,11 @@ end assert_equal_select_result([], result) end + + def test_select_query_with_brackets + result = @comments.select do |record| + record["content"].match "Say (Hello World)" + end + assert_equal_select_result([], result) + end end From null at cozmixng.org Fri Sep 25 04:25:29 2009 From: null at cozmixng.org (null at cozmixng.org) Date: Fri, 25 Sep 2009 17:25:29 +0900 Subject: [groonga-commit:648] groonga [activegroonga (trunk) r686] * add observer. Message-ID: <20090925082529.E8C501D1CCE@mail.cozmixng.org> retro 2009-09-25 17:25:29 +0900 (Fri, 25 Sep 2009) New Revision: 686 Log: * add observer. Added files: activegroonga/trunk/lib/active_groonga/observer.rb Modified files: activegroonga/trunk/lib/active_groonga/base.rb Modified: activegroonga/trunk/lib/active_groonga/base.rb (+1 -2) =================================================================== --- activegroonga/trunk/lib/active_groonga/base.rb 2009-09-25 17:18:07 +09:00 (rev 685) +++ activegroonga/trunk/lib/active_groonga/base.rb 2009-09-25 17:25:29 +09:00 (rev 686) @@ -1600,10 +1600,9 @@ end include Validations - include Callbacks include AttributeMethods include Dirty - include Timestamp + include Callbacks, Observing, Timestamp include Associations include Aggregations, Reflection end Added: activegroonga/trunk/lib/active_groonga/observer.rb (+29 -0) =================================================================== --- activegroonga/trunk/lib/active_groonga/observer.rb 2009-09-25 17:18:07 +09:00 (rev 685) +++ activegroonga/trunk/lib/active_groonga/observer.rb 2009-09-25 17:25:29 +09:00 (rev 686) @@ -0,0 +1,29 @@ +# 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 + +module ActiveGroonga + module Observing + class << self + def included(base) + base.class_eval do + include ActiveRecord::Observing + end + end + end + end + + class Observer < ActiveRecord::Observer + end +end From null at cozmixng.org Fri Sep 25 04:25:28 2009 From: null at cozmixng.org (null at cozmixng.org) Date: Fri, 25 Sep 2009 17:25:28 +0900 Subject: [groonga-commit:649] groonga [activegroonga (trunk) r685] * migration version is not column but key. Message-ID: <20090925082528.8C9231D1CCB@mail.cozmixng.org> retro 2009-09-25 17:25:27 +0900 (Fri, 25 Sep 2009) New Revision: 685 Log: * migration version is not column but key. Modified files: activegroonga/trunk/lib/active_groonga/schema.rb Modified: activegroonga/trunk/lib/active_groonga/schema.rb (+1 -2) =================================================================== --- activegroonga/trunk/lib/active_groonga/schema.rb 2009-09-24 21:29:54 +09:00 (rev 684) +++ activegroonga/trunk/lib/active_groonga/schema.rb 2009-09-25 17:25:27 +09:00 (rev 685) @@ -46,8 +46,7 @@ if inserted.include?(v) raise "Duplicate migration #{v}. Please renumber your migrations to resolve the conflict." elsif v < version - migration = migrations_table.add - migration["version"] = v.to_s + migration = migrations_table.add(v.to_s) inserted << v end end From null at cozmixng.org Fri Sep 25 04:56:26 2009 From: null at cozmixng.org (null at cozmixng.org) Date: Fri, 25 Sep 2009 17:56:26 +0900 Subject: [groonga-commit:650] groonga [activegroonga (trunk) r687] * add ID column. Message-ID: <20090925085626.49E791D1CB7@mail.cozmixng.org> retro 2009-09-25 17:56:25 +0900 (Fri, 25 Sep 2009) New Revision: 687 Log: * add ID column. Modified files: activegroonga/trunk/lib/active_groonga.rb activegroonga/trunk/lib/active_groonga/base.rb activegroonga/trunk/lib/active_groonga/column.rb activegroonga/trunk/lib/active_groonga/schema_dumper.rb Modified: activegroonga/trunk/lib/active_groonga/base.rb (+9 -3) =================================================================== --- activegroonga/trunk/lib/active_groonga/base.rb 2009-09-25 17:24:41 +09:00 (rev 686) +++ activegroonga/trunk/lib/active_groonga/base.rb 2009-09-25 17:56:25 +09:00 (rev 687) @@ -375,7 +375,7 @@ # Returns an array of column objects for the table associated with this class. def columns - @columns ||= table.columns.collect do |column| + @columns ||= [IdColumn.new(table)] + table.columns.collect do |column| Column.new(column) end end @@ -428,7 +428,13 @@ elsif abstract_class? "#{super}(abstract)" elsif table_exists? - attr_list = columns.map { |c| "#{c.name}: #{c.type}" } * ', ' + attr_list = columns.collect do |column| + if column.id? + nil + else + "#{column.name}: #{column.type}" + end + end.compact.join(', ') "#{super}(#{attr_list})" else "#{super}(Table doesn't exist)" @@ -1571,7 +1577,7 @@ quoted = {} attribute_names.each do |name| column = column_for_attribute(name) - next if column.nil? + next if column.nil? or column.id? value = read_attribute(name) # We need explicit to_yaml because quote() does not properly convert Time/Date fields to YAML. Modified: activegroonga/trunk/lib/active_groonga/schema_dumper.rb (+1 -0) =================================================================== --- activegroonga/trunk/lib/active_groonga/schema_dumper.rb 2009-09-25 17:24:41 +09:00 (rev 686) +++ activegroonga/trunk/lib/active_groonga/schema_dumper.rb 2009-09-25 17:56:25 +09:00 (rev 687) @@ -74,6 +74,7 @@ table_schema.puts " create_table #{name.inspect}, #{options.join(', ')} do |t|" column_specs = [] columns(name).each do |column| + next if column.id? if column.reference_type? @references << [name, column] next Modified: activegroonga/trunk/lib/active_groonga/column.rb (+22 -1) =================================================================== --- activegroonga/trunk/lib/active_groonga/column.rb 2009-09-25 17:24:41 +09:00 (rev 686) +++ activegroonga/trunk/lib/active_groonga/column.rb 2009-09-25 17:56:25 +09:00 (rev 687) @@ -24,6 +24,10 @@ @type = detect_type end + def id? + false + end + def type_cast(value) return nil if value.nil? case type @@ -65,7 +69,11 @@ end def index_sources - @column.sources + if @column + @column.sources + else + [] + end end def reference_type? @@ -113,4 +121,17 @@ end end end + + class IdColumn < Column + def initialize(table) + @column = nil + @table = table + @name = "id" + @type = :unsigned_integer + end + + def id? + true + end + end end Modified: activegroonga/trunk/lib/active_groonga.rb (+2 -1) =================================================================== --- activegroonga/trunk/lib/active_groonga.rb 2009-09-25 17:24:41 +09:00 (rev 686) +++ activegroonga/trunk/lib/active_groonga.rb 2009-09-25 17:56:25 +09:00 (rev 687) @@ -28,7 +28,7 @@ module ActiveGroonga def self.load_all! - [Base] + [Base, Column] end autoload :VERSION, 'active_groonga/version' @@ -45,6 +45,7 @@ autoload :Calculations, 'active_groonga/calculations' autoload :Callbacks, 'active_groonga/callbacks' autoload :Column, 'active_groonga/column' + autoload :IdColumn, 'active_groonga/column' autoload :Dirty, 'active_groonga/dirty' autoload :DynamicRecordExpressionBuilder, 'active_groonga/dynamic_record_expression_builder' From null at cozmixng.org Mon Sep 28 03:30:38 2009 From: null at cozmixng.org (null at cozmixng.org) Date: Mon, 28 Sep 2009 16:30:38 +0900 Subject: [groonga-commit:651] groonga [groonga (trunk) r688] Fixed test_tag_keys for current implementation. Message-ID: <20090928073038.37A8C1D1CBF@mail.cozmixng.org> retro 2009-09-28 16:30:37 +0900 (Mon, 28 Sep 2009) New Revision: 688 Log: Fixed test_tag_keys for current implementation. Modified files: groonga/trunk/test/test-patricia-trie.rb Modified: groonga/trunk/test/test-patricia-trie.rb (+5 -4) =================================================================== --- groonga/trunk/test/test-patricia-trie.rb 2009-09-25 17:52:59 +09:00 (rev 687) +++ groonga/trunk/test/test-patricia-trie.rb 2009-09-28 16:30:37 +09:00 (rev 688) @@ -112,6 +112,7 @@ words.add("???") words.add('??????') words.add('??') + words.add('?') words.add('???') words.add('??????') @@ -119,10 +120,10 @@ actual = words.tag_keys(text) do |record, word| "<#{word}(#{record.key})>" end - assert_equal(" " + - " " + - "????? " + - "", + assert_equal(" " + + " " + + " " + + "", actual) end end From null at cozmixng.org Mon Sep 28 04:01:57 2009 From: null at cozmixng.org (null at cozmixng.org) Date: Mon, 28 Sep 2009 17:01:57 +0900 Subject: [groonga-commit:652] groonga [groonga (trunk) r689] * add no keyword terms. Message-ID: <20090928080157.925281D1CB7@mail.cozmixng.org> retro 2009-09-28 17:01:57 +0900 (Mon, 28 Sep 2009) New Revision: 689 Log: * add no keyword terms. Modified files: groonga/trunk/test/test-patricia-trie.rb Modified: groonga/trunk/test/test-patricia-trie.rb (+2 -1) =================================================================== --- groonga/trunk/test/test-patricia-trie.rb 2009-09-28 16:29:23 +09:00 (rev 688) +++ groonga/trunk/test/test-patricia-trie.rb 2009-09-28 17:01:57 +09:00 (rev 689) @@ -116,12 +116,13 @@ words.add('???') words.add('??????') - text = 'muTEki ?????? ????? ??' + text = 'muTEki ?????? ?????? ????? ??' actual = words.tag_keys(text) do |record, word| "<#{word}(#{record.key})>" end assert_equal(" " + " " + + "?????? " + " " + "", actual) From null at cozmixng.org Tue Sep 29 09:44:09 2009 From: null at cozmixng.org (null at cozmixng.org) Date: Tue, 29 Sep 2009 22:44:09 +0900 Subject: [groonga-commit:653] groonga [groonga (trunk) r690] bind Groonga::Expression#snippet. Message-ID: <20090929134409.89C731D1C83@mail.cozmixng.org> retro 2009-09-29 22:44:09 +0900 (Tue, 29 Sep 2009) New Revision: 690 Log: bind Groonga::Expression#snippet. Modified files: groonga/trunk/ext/rb-grn-expression.c groonga/trunk/ext/rb-grn-snippet.c groonga/trunk/ext/rb-grn.h groonga/trunk/test/test-expression.rb Modified: groonga/trunk/ext/rb-grn-expression.c (+111 -3) =================================================================== --- groonga/trunk/ext/rb-grn-expression.c 2009-09-28 16:49:28 +09:00 (rev 689) +++ groonga/trunk/ext/rb-grn-expression.c 2009-09-29 22:44:09 +09:00 (rev 690) @@ -216,6 +216,7 @@ int parse_level = 0; VALUE options, rb_query, rb_default_column, rb_default_operator; VALUE rb_default_mode, rb_parser; + VALUE exception = Qnil; rb_scan_args(argc, argv, "11", &rb_query, &options); rb_grn_scan_options(options, @@ -260,11 +261,17 @@ rc = grn_expr_parse(context, expression, query, query_size, default_column, default_mode, default_operator, parse_level); - if (rc != GRN_SUCCESS) - rb_grn_context_check(context, - rb_ary_new3(2, self, rb_ary_new4(argc, argv))); + if (rc != GRN_SUCCESS) { + VALUE related_object; + + related_object = rb_ary_new3(2, self, rb_ary_new4(argc, argv)); + exception = rb_grn_context_to_exception(context, related_object); + } grn_obj_close(context, default_column); + if (!NIL_P(exception)) + rb_exc_raise(exception); + return Qnil; } @@ -364,6 +371,104 @@ return rb_inspected; } +static VALUE +rb_grn_expression_snippet (int argc, VALUE *argv, VALUE self) +{ + grn_ctx *context = NULL; + grn_obj *expression; + grn_snip *snippet; + VALUE options; + VALUE rb_context, rb_normalize, rb_skip_leading_spaces; + VALUE rb_width, rb_max_results, rb_tags; + VALUE rb_html_escape; + VALUE *rb_tag_values; + unsigned int i; + int flags = GRN_SNIP_COPY_TAG; + unsigned int width = 100; + unsigned int max_results = 3; + unsigned int n_tags = 0; + char **open_tags = NULL; + unsigned int *open_tag_lengths = NULL; + char **close_tags = NULL; + unsigned int *close_tag_lengths = NULL; + grn_snip_mapping *mapping = NULL; + + rb_grn_expression_deconstruct(SELF(self), &expression, &context, + NULL, NULL, + NULL, NULL, NULL); + + 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, + "max_results", &rb_max_results, + "html_escape", &rb_html_escape, + NULL); + + if (TYPE(rb_tags) != T_ARRAY) { + rb_raise(rb_eArgError, + "tags should be " + "[\"open_tag\", \"close_tag\"] or", + "[[\"open_tag1\", \"close_tag1\"], ...]: %s", + rb_grn_inspect(rb_tags)); + } + + if (TYPE(RARRAY_PTR(rb_tags)[0]) == T_STRING) { + rb_tags = rb_ary_new3(1, rb_tags); + } + + rb_tag_values = RARRAY_PTR(rb_tags); + n_tags = RARRAY_LEN(rb_tags); + open_tags = ALLOCA_N(char *, n_tags); + open_tag_lengths = ALLOCA_N(unsigned int, n_tags); + close_tags = ALLOCA_N(char *, n_tags); + close_tag_lengths = ALLOCA_N(unsigned int, n_tags); + for (i = 0; i < n_tags; i++) { + VALUE *tag_pair; + + if (TYPE(rb_tag_values[i]) != T_ARRAY || + RARRAY_LEN(rb_tag_values[i]) != 2) { + rb_raise(rb_eArgError, + "tags should be " + "[\"open_tag\", \"close_tag\"] or", + "[[\"open_tag1\", \"close_tag1\"], ...]: %s", + rb_grn_inspect(rb_tags)); + } + tag_pair = RARRAY_PTR(rb_tag_values[i]); + open_tags[i] = StringValuePtr(tag_pair[0]); + open_tag_lengths[i] = RSTRING_LEN(tag_pair[0]); + close_tags[i] = StringValuePtr(tag_pair[1]); + close_tag_lengths[i] = RSTRING_LEN(tag_pair[1]); + } + + if (RVAL2CBOOL(rb_normalize)) + flags |= GRN_SNIP_NORMALIZE; + if (RVAL2CBOOL(rb_skip_leading_spaces)) + flags |= GRN_SNIP_SKIP_LEADING_SPACES; + + if (!NIL_P(rb_width)) + width = NUM2UINT(rb_width); + + if (!NIL_P(rb_max_results)) + max_results = NUM2UINT(rb_max_results); + + if (RVAL2CBOOL(rb_html_escape)) + mapping = (grn_snip_mapping *)-1; + + snippet = grn_expr_snip(context, expression, flags, width, max_results, + n_tags, + (const char **)open_tags, open_tag_lengths, + (const char **)close_tags, close_tag_lengths, + mapping); + rb_grn_context_check(context, + rb_ary_new3(2, self, rb_ary_new4(argc, argv))); + + return GRNSNIPPET2RVAL(context, snippet, RB_GRN_TRUE); +} + void rb_grn_init_expression (VALUE mGrn) { @@ -392,6 +497,9 @@ rb_define_method(rb_cGrnExpression, "[]", rb_grn_expression_array_reference, 1); + rb_define_method(rb_cGrnExpression, "snippet", + rb_grn_expression_snippet, -1); + rb_define_method(rb_cGrnExpression, "inspect", rb_grn_expression_inspect, 0); } Modified: groonga/trunk/test/test-expression.rb (+30 -0) =================================================================== --- groonga/trunk/test/test-expression.rb 2009-09-28 16:49:28 +09:00 (rev 689) +++ groonga/trunk/test/test-expression.rb 2009-09-29 22:44:09 +09:00 (rev 690) @@ -1,3 +1,4 @@ +# -*- coding: utf-8 -*- # Copyright (C) 2009 Kouhei Sutou # # This library is free software; you can redistribute it and/or @@ -64,4 +65,33 @@ assert_equal("#", expression.inspect) end + + def test_snippet + 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("???? OR Ruby OR groonga", :default_column => name) + expression.compile + + snippet = expression.snippet([["[[", "]]"], ["<", ">"]], + :width => 30) + assert_equal(["[[????]]??????", + "?[[groonga]]?????", + "?[[groonga]]?????"], + snippet.execute("????????????????????" + + "??????????????????groonga" + + "????Ruby???????????????" + + "?????????????groonga????" + + "Ruby???????????????????" + + "????????")) + end end Modified: groonga/trunk/ext/rb-grn.h (+10 -0) =================================================================== --- groonga/trunk/ext/rb-grn.h 2009-09-28 16:49:28 +09:00 (rev 689) +++ groonga/trunk/ext/rb-grn.h 2009-09-29 22:44:09 +09:00 (rev 690) @@ -476,7 +476,12 @@ #define RVAL2GRNVARIABLE(object, context) \ (rb_grn_variable_from_ruby_object(object, context)) +#define GRNSNIPPET2RVAL(context, snippet, owner) \ + (rb_grn_snippet_to_ruby_object(context, snippet, owner)) +#define RVAL2GRNSNIPPET(snippet) \ + (rb_grn_snippet_from_ruby_object(snippet)) + grn_encoding rb_grn_encoding_from_ruby_object (VALUE object, grn_ctx *context); VALUE rb_grn_encoding_to_ruby_object (grn_encoding encoding); @@ -593,6 +598,11 @@ grn_obj *obj, VALUE related_object); +grn_snip *rb_grn_snippet_from_ruby_object (VALUE rb_snippet); +VALUE rb_grn_snippet_to_ruby_object (grn_ctx *context, + grn_snip *snippet, + rb_grn_boolean owner); + RB_GRN_END_DECLS #endif Modified: groonga/trunk/ext/rb-grn-snippet.c (+3 -2) =================================================================== --- groonga/trunk/ext/rb-grn-snippet.c 2009-09-28 16:49:28 +09:00 (rev 689) +++ groonga/trunk/ext/rb-grn-snippet.c 2009-09-29 22:44:09 +09:00 (rev 690) @@ -73,7 +73,8 @@ } VALUE -rb_grn_snippet_to_ruby_object (grn_ctx *context, grn_snip *snippet) +rb_grn_snippet_to_ruby_object (grn_ctx *context, grn_snip *snippet, + rb_grn_boolean owner) { RbGrnSnippet *rb_grn_snippet; @@ -83,7 +84,7 @@ rb_grn_snippet = ALLOC(RbGrnSnippet); rb_grn_snippet->context = context; rb_grn_snippet->snippet = snippet; - rb_grn_snippet->owner = RB_GRN_FALSE; + rb_grn_snippet->owner = owner; return Data_Wrap_Struct(rb_cGrnSnippet, NULL, rb_rb_grn_snippet_free, rb_grn_snippet); From null at cozmixng.org Wed Sep 30 08:30:32 2009 From: null at cozmixng.org (null at cozmixng.org) Date: Wed, 30 Sep 2009 21:30:32 +0900 Subject: [groonga-commit:654] groonga [groonga (trunk) r691] Added 'quit' and 'shutdown' to test-database.rb. Message-ID: <20090930123032.AF0551D1C74@mail.cozmixng.org> retro 2009-09-30 21:30:32 +0900 (Wed, 30 Sep 2009) New Revision: 691 Log: Added 'quit' and 'shutdown' to test-database.rb. Modified files: groonga/trunk/test/test-database.rb Modified: groonga/trunk/test/test-database.rb (+2 -0) =================================================================== --- groonga/trunk/test/test-database.rb 2009-09-29 22:36:26 +09:00 (rev 690) +++ groonga/trunk/test/test-database.rb 2009-09-30 21:30:32 +09:00 (rev 691) @@ -91,8 +91,10 @@ "expr_missing", "load", "now", + "quit", "rand", "select", + "shutdown", "status", "table_create", "table_list", From null at cozmixng.org Wed Sep 30 21:15:25 2009 From: null at cozmixng.org (null at cozmixng.org) Date: Thu, 01 Oct 2009 10:15:25 +0900 Subject: [groonga-commit:655] groonga [groonga (trunk) r692] Added connect, send and recv methods to Context class. Message-ID: <20091001011525.C7A1A1D1C74@mail.cozmixng.org> retro 2009-10-01 10:15:25 +0900 (Thu, 01 Oct 2009) New Revision: 692 Log: Added connect, send and recv methods to Context class. Modified files: groonga/trunk/ext/rb-grn-context.c Modified: groonga/trunk/ext/rb-grn-context.c (+75 -0) =================================================================== --- groonga/trunk/ext/rb-grn-context.c 2009-09-30 21:26:28 +09:00 (rev 691) +++ groonga/trunk/ext/rb-grn-context.c 2009-10-01 10:15:25 +09:00 (rev 692) @@ -355,6 +355,77 @@ return GRNDB2RVAL(context, grn_ctx_db(context), RB_GRN_FALSE); } +/* + * call-seq: + * context.connect(host, port) + * + * groonga????????? + */ +static VALUE +rb_grn_context_connect (VALUE self, VALUE rb_host, VALUE rb_port) +{ + grn_ctx *context; + char *host; + int port; + int flags = 0; + grn_rc rc; + + context = SELF(self); + host = StringValueCStr(rb_host); + port = NUM2INT(rb_port); + rc = grn_ctx_connect(context, host, port, flags); + rb_grn_context_check(context, self); + rb_grn_rc_check(rc, self); + + return Qnil; +} + +/* + * call-seq: + * context.send(str) -> ID + * + * groonga???????????????? + */ +static VALUE +rb_grn_context_send (VALUE self, VALUE rb_str) +{ + grn_ctx *context; + char *str; + unsigned str_size; + int flags = 0; + unsigned qid; + + context = SELF(self); + str = StringValuePtr(rb_str); + str_size = RSTRING_LEN(rb_str); + qid = grn_ctx_send(context, str, str_size, flags); + rb_grn_context_check(context, self); + + return UINT2NUM(qid); +} + +/* + * call-seq: + * context.recv -> [ID, String] + * + * groonga????????????????????? + */ +static VALUE +rb_grn_context_recv (VALUE self) +{ + grn_ctx *context; + char *str; + unsigned str_size; + int flags = 0; + unsigned qid; + + context = SELF(self); + qid = grn_ctx_recv(context, &str, &str_size, &flags); + rb_grn_context_check(context, self); + + return rb_ary_new3(2, UINT2NUM(qid), rb_str_new(str, str_size)); +} + static const char * grn_type_name_old_to_new (const char *name, unsigned int name_size) { @@ -514,4 +585,8 @@ 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); }