From null at cozmixng.org Wed Dec 2 05:00:32 2009 From: null at cozmixng.org (null at cozmixng.org) Date: Wed, 02 Dec 2009 19:00:32 +0900 Subject: [groonga-commit:810] groonga [groonga (trunk) r855] add tests of offset and limit used by Table#sort and Table::Cursor Message-ID: <20091202100032.E7F0D1D1CCB@mail.cozmixng.org> retro 2009-12-02 19:00:32 +0900 (Wed, 02 Dec 2009) New Revision: 855 Log: add tests of offset and limit used by Table#sort and Table::Cursor Modified files: groonga/trunk/ext/rb-grn-table.c groonga/trunk/test/test-table-cursor.rb Modified: groonga/trunk/ext/rb-grn-table.c (+6 -2) =================================================================== --- groonga/trunk/ext/rb-grn-table.c 2009-12-01 11:02:04 +09:00 (rev 854) +++ groonga/trunk/ext/rb-grn-table.c 2009-12-02 19:00:32 +09:00 (rev 855) @@ -1046,6 +1046,7 @@ VALUE *rb_sort_keys; grn_table_cursor *cursor; VALUE rb_result; + VALUE exception; rb_grn_table_deconstruct(SELF(self), &table, &context, NULL, NULL, @@ -1116,6 +1117,11 @@ NULL, table); n_records = grn_table_sort(context, table, offset, limit, result, keys, n_keys); + exception = rb_grn_context_to_exception(context, self); + if (!NIL_P(exception)) { + grn_obj_close(context, result); + rb_exc_raise(exception); + } rb_result = rb_ary_new(); cursor = grn_table_cursor_open(context, result, NULL, 0, NULL, 0, @@ -1131,8 +1137,6 @@ grn_table_cursor_close(context, cursor); grn_obj_close(context, result); - rb_grn_context_check(context, self); /* FIXME: here is too late */ - return rb_result; } Modified: groonga/trunk/test/test-table-cursor.rb (+99 -0) =================================================================== --- groonga/trunk/test/test-table-cursor.rb 2009-12-01 11:02:04 +09:00 (rev 854) +++ groonga/trunk/test/test-table-cursor.rb 2009-12-02 19:00:32 +09:00 (rev 855) @@ -145,4 +145,103 @@ end bookmarks end + + def get_ids_by_cursor(bookmarks, options={}) + ids = [] + bookmarks.open_cursor(options) do |cursor| + cursor.each do |record| + ids << record["id"] + end + end + ids + end end + +module TestOffsetAndLimitSupport + def test_zero_and_positive_offset + assert_equal(((100+0)...200).to_a, get_ids(:offset => 0)) + assert_equal(((100+32)...200).to_a, get_ids(:offset => 32)) + assert_equal(((100+99)...200).to_a, get_ids(:offset => 99)) + assert_raise(Groonga::InvalidArgument) do + get_ids(:offset => 100) + end + end + + def test_negative_offset + assert_equal(((200-1)...200).to_a, get_ids(:offset => -1)) + assert_equal(((200-32)...200).to_a, get_ids(:offset => -32)) + assert_equal(((200-100)...200).to_a, get_ids(:offset => -100)) + assert_raise(Groonga::InvalidArgument) do + get_ids(:offset => -101) + end + end + + def test_zero_and_positive_limit + assert_equal((100...200).to_a[0,0], get_ids(:limit => 0)) + assert_equal((100...200).to_a[0,32], get_ids(:limit => 32)) + assert_equal((100...200).to_a[0,100], get_ids(:limit => 100)) + assert_nothing_raised do + get_ids(:limit => 101) + end + end + + def test_negative_limit + assert_equal((100...200).to_a[0..-1], get_ids(:limit => -1)) + assert_equal((100...200).to_a[0..-32], get_ids(:limit => -32)) + assert_equal((100...200).to_a[0..-100], get_ids(:limit => -100)) + assert_raise(Groonga::InvalidArgument) do + get_ids(:offset => -101) + end + end + + private + def create_bookmarks + @bookmarks = Groonga::Array.create(:name => "") + @bookmarks.define_column("id", "") + @bookmarks + end + + def add_ids + (0...100).to_a.each do |i| + bookmark = @bookmarks.add + bookmark["id"] = i + 100 + end + @bookmarks + end +end + +class TestOffsetAndLimit < Test::Unit::TestCase + include GroongaTestUtils + def setup + setup_database + @bookmarks = create_bookmarks + add_ids + end +end + +class TestTableCursorOffsetAndLimit < TestOffsetAndLimit + include TestOffsetAndLimitSupport + private + def get_ids(options={}) + ids = [] + @bookmarks.open_cursor(options) do |cursor| + cursor.each do |record| + ids << record["id"] + end + end + ids + end +end + +class TestTableSortOffsetAndLimit < TestOffsetAndLimit + include TestOffsetAndLimitSupport + private + def get_ids(options={}) + ids = [] + @bookmarks.sort([:key => "id", :order => :asc], options).each do |record| + ids << record["id"] + end + ids + end +end + From null at cozmixng.org Wed Dec 2 05:15:33 2009 From: null at cozmixng.org (null at cozmixng.org) Date: Wed, 02 Dec 2009 19:15:33 +0900 Subject: [groonga-commit:811] groonga [groonga (trunk) r856] fallbacks rubygem's json library in case of no system-wide json library Message-ID: <20091202101533.DAE1A1D1CCB@mail.cozmixng.org> retro 2009-12-02 19:15:33 +0900 (Wed, 02 Dec 2009) New Revision: 856 Log: fallbacks rubygem's json library in case of no system-wide json library Modified files: groonga/trunk/test/groonga-test-utils.rb Modified: groonga/trunk/test/groonga-test-utils.rb (+6 -1) =================================================================== --- groonga/trunk/test/groonga-test-utils.rb 2009-12-02 18:52:52 +09:00 (rev 855) +++ groonga/trunk/test/groonga-test-utils.rb 2009-12-02 19:15:33 +09:00 (rev 856) @@ -16,7 +16,12 @@ require 'fileutils' require 'pathname' require 'time' -require 'json' +begin + require 'json' +rescue LoadError + require 'rubygems' + require 'json' +end require 'pkg-config' require 'groonga' From null at cozmixng.org Wed Dec 2 05:15:35 2009 From: null at cozmixng.org (null at cozmixng.org) Date: Wed, 02 Dec 2009 19:15:35 +0900 Subject: [groonga-commit:812] groonga [groonga (trunk) r857] move tests of offset and limit into new file Message-ID: <20091202101535.3E3FF1D1CCC@mail.cozmixng.org> retro 2009-12-02 19:15:34 +0900 (Wed, 02 Dec 2009) New Revision: 857 Log: move tests of offset and limit into new file Copied files: groonga/trunk/test/test-table-offset-and-limit.rb (from rev 855, groonga/trunk/test/test-table-cursor.rb) Modified files: groonga/trunk/test/test-table-cursor.rb Modified: groonga/trunk/test/test-table-cursor.rb (+0 -89) =================================================================== --- groonga/trunk/test/test-table-cursor.rb 2009-12-02 19:04:09 +09:00 (rev 856) +++ groonga/trunk/test/test-table-cursor.rb 2009-12-02 19:15:34 +09:00 (rev 857) @@ -156,92 +156,3 @@ ids end end - -module TestOffsetAndLimitSupport - def test_zero_and_positive_offset - assert_equal(((100+0)...200).to_a, get_ids(:offset => 0)) - assert_equal(((100+32)...200).to_a, get_ids(:offset => 32)) - assert_equal(((100+99)...200).to_a, get_ids(:offset => 99)) - assert_raise(Groonga::InvalidArgument) do - get_ids(:offset => 100) - end - end - - def test_negative_offset - assert_equal(((200-1)...200).to_a, get_ids(:offset => -1)) - assert_equal(((200-32)...200).to_a, get_ids(:offset => -32)) - assert_equal(((200-100)...200).to_a, get_ids(:offset => -100)) - assert_raise(Groonga::InvalidArgument) do - get_ids(:offset => -101) - end - end - - def test_zero_and_positive_limit - assert_equal((100...200).to_a[0,0], get_ids(:limit => 0)) - assert_equal((100...200).to_a[0,32], get_ids(:limit => 32)) - assert_equal((100...200).to_a[0,100], get_ids(:limit => 100)) - assert_nothing_raised do - get_ids(:limit => 101) - end - end - - def test_negative_limit - assert_equal((100...200).to_a[0..-1], get_ids(:limit => -1)) - assert_equal((100...200).to_a[0..-32], get_ids(:limit => -32)) - assert_equal((100...200).to_a[0..-100], get_ids(:limit => -100)) - assert_raise(Groonga::InvalidArgument) do - get_ids(:offset => -101) - end - end - - private - def create_bookmarks - @bookmarks = Groonga::Array.create(:name => "") - @bookmarks.define_column("id", "") - @bookmarks - end - - def add_ids - (0...100).to_a.each do |i| - bookmark = @bookmarks.add - bookmark["id"] = i + 100 - end - @bookmarks - end -end - -class TestOffsetAndLimit < Test::Unit::TestCase - include GroongaTestUtils - def setup - setup_database - @bookmarks = create_bookmarks - add_ids - end -end - -class TestTableCursorOffsetAndLimit < TestOffsetAndLimit - include TestOffsetAndLimitSupport - private - def get_ids(options={}) - ids = [] - @bookmarks.open_cursor(options) do |cursor| - cursor.each do |record| - ids << record["id"] - end - end - ids - end -end - -class TestTableSortOffsetAndLimit < TestOffsetAndLimit - include TestOffsetAndLimitSupport - private - def get_ids(options={}) - ids = [] - @bookmarks.sort([:key => "id", :order => :asc], options).each do |record| - ids << record["id"] - end - ids - end -end - Copied: groonga/trunk/test/test-table-offset-and-limit.rb (+103 -0) =================================================================== --- groonga/trunk/test/test-table-cursor.rb 2009-12-02 18:52:52 +09:00 (rev 855) +++ groonga/trunk/test/test-table-offset-and-limit.rb 2009-12-02 19:15:34 +09:00 (rev 857) @@ -0,0 +1,103 @@ +# 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 TestOffsetAndLimitSupport + def test_zero_and_positive_offset + assert_equal(((100+0)...200).to_a, get_ids(:offset => 0)) + assert_equal(((100+32)...200).to_a, get_ids(:offset => 32)) + assert_equal(((100+99)...200).to_a, get_ids(:offset => 99)) + assert_raise(Groonga::InvalidArgument) do + get_ids(:offset => 100) + end + end + + def test_negative_offset + assert_equal(((200-1)...200).to_a, get_ids(:offset => -1)) + assert_equal(((200-32)...200).to_a, get_ids(:offset => -32)) + assert_equal(((200-100)...200).to_a, get_ids(:offset => -100)) + assert_raise(Groonga::InvalidArgument) do + get_ids(:offset => -101) + end + end + + def test_zero_and_positive_limit + assert_equal((100...200).to_a[0,0], get_ids(:limit => 0)) + assert_equal((100...200).to_a[0,32], get_ids(:limit => 32)) + assert_equal((100...200).to_a[0,100], get_ids(:limit => 100)) + assert_nothing_raised do + get_ids(:limit => 101) + end + end + + def test_negative_limit + assert_equal((100...200).to_a[0..-1], get_ids(:limit => -1)) + assert_equal((100...200).to_a[0..-32], get_ids(:limit => -32)) + assert_equal((100...200).to_a[0..-100], get_ids(:limit => -100)) + assert_raise(Groonga::InvalidArgument) do + get_ids(:offset => -101) + end + end + + private + def create_bookmarks + @bookmarks = Groonga::Array.create(:name => "") + @bookmarks.define_column("id", "") + @bookmarks + end + + def add_ids + (0...100).to_a.each do |i| + bookmark = @bookmarks.add + bookmark["id"] = i + 100 + end + @bookmarks + end +end + +class TestOffsetAndLimit < Test::Unit::TestCase + include GroongaTestUtils + def setup + setup_database + @bookmarks = create_bookmarks + add_ids + end +end + +class TestTableCursorOffsetAndLimit < TestOffsetAndLimit + include TestOffsetAndLimitSupport + private + def get_ids(options={}) + ids = [] + @bookmarks.open_cursor(options) do |cursor| + cursor.each do |record| + ids << record["id"] + end + end + ids + end +end + +class TestTableSortOffsetAndLimit < TestOffsetAndLimit + include TestOffsetAndLimitSupport + private + def get_ids(options={}) + ids = [] + @bookmarks.sort([:key => "id", :order => :asc], options).each do |record| + ids << record["id"] + end + ids + end +end + From null at cozmixng.org Wed Dec 2 08:45:29 2009 From: null at cozmixng.org (null at cozmixng.org) Date: Wed, 02 Dec 2009 22:45:29 +0900 Subject: [groonga-commit:813] groonga [groonga (trunk) r858] * fix style. Message-ID: <20091202134529.9AF6D1D1CCC@mail.cozmixng.org> retro 2009-12-02 22:45:29 +0900 (Wed, 02 Dec 2009) New Revision: 858 Log: * fix style. Modified files: groonga/trunk/test/test-table-offset-and-limit.rb Modified: groonga/trunk/test/test-table-offset-and-limit.rb (+3 -3) =================================================================== --- groonga/trunk/test/test-table-offset-and-limit.rb 2009-12-02 19:07:26 +09:00 (rev 857) +++ groonga/trunk/test/test-table-offset-and-limit.rb 2009-12-02 22:45:29 +09:00 (rev 858) @@ -33,9 +33,9 @@ end def test_zero_and_positive_limit - assert_equal((100...200).to_a[0,0], get_ids(:limit => 0)) - assert_equal((100...200).to_a[0,32], get_ids(:limit => 32)) - assert_equal((100...200).to_a[0,100], get_ids(:limit => 100)) + assert_equal((100...200).to_a[0, 0], get_ids(:limit => 0)) + assert_equal((100...200).to_a[0, 32], get_ids(:limit => 32)) + assert_equal((100...200).to_a[0, 100], get_ids(:limit => 100)) assert_nothing_raised do get_ids(:limit => 101) end From null at cozmixng.org Wed Dec 2 09:15:26 2009 From: null at cozmixng.org (null at cozmixng.org) Date: Wed, 02 Dec 2009 23:15:26 +0900 Subject: [groonga-commit:814] groonga [groonga (trunk) r859] * add documents for -1 case on limit parameter. Message-ID: <20091202141526.196271D1CCB@mail.cozmixng.org> retro 2009-12-02 23:15:25 +0900 (Wed, 02 Dec 2009) New Revision: 859 Log: * add documents for -1 case on limit parameter. Modified files: groonga/trunk/ext/rb-grn-table.c Modified: groonga/trunk/ext/rb-grn-table.c (+4 -0) =================================================================== --- groonga/trunk/ext/rb-grn-table.c 2009-12-02 22:36:12 +09:00 (rev 858) +++ groonga/trunk/ext/rb-grn-table.c 2009-12-02 23:15:25 +09:00 (rev 859) @@ -851,6 +851,8 @@ * * [+:limit+] * ???????????????_:limit_????????? + * ??????????-1????????????????? + * ???????? * * [+:order+] * +:asc+???+:ascending+??????????????? @@ -1031,6 +1033,8 @@ * * [+:limit+] * ??????????????_:limit_????????? + * ??????????-1????????????????? + * ???????? */ static VALUE rb_grn_table_sort (int argc, VALUE *argv, VALUE self) From null at cozmixng.org Wed Dec 2 09:30:31 2009 From: null at cozmixng.org (null at cozmixng.org) Date: Wed, 02 Dec 2009 23:30:31 +0900 Subject: [groonga-commit:815] groonga [groonga (trunk) r860] * fix error check. Message-ID: <20091202143031.779871D1CCB@mail.cozmixng.org> retro 2009-12-02 23:30:30 +0900 (Wed, 02 Dec 2009) New Revision: 860 Log: * fix error check. Modified files: groonga/trunk/ext/rb-grn-expression.c Modified: groonga/trunk/ext/rb-grn-expression.c (+6 -1) =================================================================== --- groonga/trunk/ext/rb-grn-expression.c 2009-12-02 23:02:01 +09:00 (rev 859) +++ groonga/trunk/ext/rb-grn-expression.c 2009-12-02 23:30:30 +09:00 (rev 860) @@ -198,6 +198,7 @@ rb_grn_expression_append_constant (int argc, VALUE *argv, VALUE self) { VALUE rb_constant, rb_operator, rb_n_arguments; + VALUE exception; grn_ctx *context = NULL; grn_obj *expression, *constant = NULL; grn_operator operator = GRN_OP_PUSH; @@ -215,8 +216,12 @@ RVAL2GRNOBJ(rb_constant, context, &constant); grn_expr_append_const(context, expression, constant, operator, n_arguments); + + exception = rb_grn_context_to_exception(context, self); grn_obj_close(context, constant); - rb_grn_context_check(context, self); + if (!NIL_P(exception)) + rb_exc_raise(exception); + return self; } From null at cozmixng.org Wed Dec 2 09:45:30 2009 From: null at cozmixng.org (null at cozmixng.org) Date: Wed, 02 Dec 2009 23:45:30 +0900 Subject: [groonga-commit:816] groonga [groonga (trunk) r861] * fix debug format. Message-ID: <20091202144530.567411D1CCB@mail.cozmixng.org> retro 2009-12-02 23:45:29 +0900 (Wed, 02 Dec 2009) New Revision: 861 Log: * fix debug format. Modified files: groonga/trunk/ext/rb-grn-object.c Modified: groonga/trunk/ext/rb-grn-object.c (+4 -4) =================================================================== --- groonga/trunk/ext/rb-grn-object.c 2009-12-02 23:18:04 +09:00 (rev 860) +++ groonga/trunk/ext/rb-grn-object.c 2009-12-02 23:45:29 +09:00 (rev 861) @@ -93,10 +93,10 @@ grn_obj_user_data(context, grn_object)->ptr = NULL; grn_obj_set_finalizer(context, grn_object, NULL); - debug("finalize %p:%p:%p:%p:%p %x\n", - context, grn_object, rb_grn_object, - rb_grn_object->context, rb_grn_object->object, - grn_object->header.type); + debug("finalize: %p:%p:%p:%p:%p 0x%x\n", + context, grn_object, rb_grn_object, + rb_grn_object->context, rb_grn_object->object, + grn_object->header.type); rb_grn_object->context = NULL; rb_grn_object->object = NULL; From null at cozmixng.org Wed Dec 2 10:30:28 2009 From: null at cozmixng.org (null at cozmixng.org) Date: Thu, 03 Dec 2009 00:30:28 +0900 Subject: [groonga-commit:817] groonga [groonga (trunk) r862] * fix style. Message-ID: <20091202153028.E8E5B1D1CCB@mail.cozmixng.org> retro 2009-12-03 00:30:28 +0900 (Thu, 03 Dec 2009) New Revision: 862 Log: * fix style. Modified files: groonga/trunk/test/test-column.rb Modified: groonga/trunk/test/test-column.rb (+8 -4) =================================================================== --- groonga/trunk/test/test-column.rb 2009-12-02 23:41:07 +09:00 (rev 861) +++ groonga/trunk/test/test-column.rb 2009-12-03 00:30:28 -15:00 (rev 862) @@ -184,7 +184,8 @@ record["body"] end) assert_equal("#", result.expression.inspect) + "{body GET_VALUE \"drive\" MATCH}>", + result.expression.inspect) end def test_select_query_with_parser @@ -196,7 +197,8 @@ record["body"] end) assert_equal("#", result.expression.inspect) + "{body GET_VALUE \"drive\" MATCH}>", + result.expression.inspect) end def test_select_expression @@ -213,7 +215,8 @@ record["body"] end) assert_equal("#", result.expression.inspect) + "{?0 body GET_VALUE \"drive\" MATCH}>", + result.expression.inspect) end def test_select_with_block @@ -227,7 +230,8 @@ record["body"] end) assert_equal("#", result.expression.inspect) + "{?0 body GET_VALUE \"drive\" MATCH}>", + result.expression.inspect) end def test_set_time From null at cozmixng.org Wed Dec 2 10:30:30 2009 From: null at cozmixng.org (null at cozmixng.org) Date: Thu, 03 Dec 2009 00:30:30 +0900 Subject: [groonga-commit:818] groonga [groonga (trunk) r863] * support accessor in select. Message-ID: <20091202153030.4E5091D1CCC@mail.cozmixng.org> retro 2009-12-03 00:30:29 +0900 (Thu, 03 Dec 2009) New Revision: 863 Log: * support accessor in select. Modified files: groonga/trunk/lib/groonga/expression-builder.rb groonga/trunk/test/test-expression-builder.rb Modified: groonga/trunk/test/test-expression-builder.rb (+8 -0) =================================================================== --- groonga/trunk/test/test-expression-builder.rb 2009-12-03 00:27:37 -15:00 (rev 862) +++ groonga/trunk/test/test-expression-builder.rb 2009-12-03 00:30:29 -15:00 (rev 863) @@ -135,4 +135,12 @@ assert_equal(["http://groonga.org/", "http://ruby-lang.org/"], result.collect {|record| record.key["uri"]}) end + + def test_nested_column + result = @bookmarks.select do |record| + record[".user.name"] == @morita["name"] + end + assert_equal(["http://groonga.org/", "http://ruby-lang.org/"], + result.collect {|record| record.key["uri"]}) + end end Modified: groonga/trunk/lib/groonga/expression-builder.rb (+28 -22) =================================================================== --- groonga/trunk/lib/groonga/expression-builder.rb 2009-12-03 00:27:37 -15:00 (rev 862) +++ groonga/trunk/lib/groonga/expression-builder.rb 2009-12-03 00:30:29 -15:00 (rev 863) @@ -115,16 +115,20 @@ end class BinaryExpressionBuilder < ExpressionBuilder # :nodoc: - def initialize(operation, column_name, value) + def initialize(operation, column, value) super() @operation = operation - @column_name = column_name + @default_column = column @value = value end def build(expression, variable) expression.append_object(variable) - expression.append_constant(@column_name) + if @default_column.is_a?(String) + expression.append_constant(@default_column) + else + expression.append_object(@default_column) + end expression.append_operation(Groonga::Operation::GET_VALUE, 2) expression.append_constant(@value) expression.append_operation(@operation, 2) @@ -132,38 +136,38 @@ end class EqualExpressionBuilder < BinaryExpressionBuilder # :nodoc: - def initialize(column_name, value) - super(Groonga::Operation::EQUAL, column_name, value) + def initialize(column, value) + super(Groonga::Operation::EQUAL, column, value) end end class MatchExpressionBuilder < BinaryExpressionBuilder # :nodoc: - def initialize(column_name, value) - super(Groonga::Operation::MATCH, column_name, value) + def initialize(column, value) + super(Groonga::Operation::MATCH, column, value) end end class LessExpressionBuilder < BinaryExpressionBuilder # :nodoc: - def initialize(column_name, value) - super(Groonga::Operation::LESS, column_name, value) + def initialize(column, value) + super(Groonga::Operation::LESS, column, value) end end class LessEqualExpressionBuilder < BinaryExpressionBuilder # :nodoc: - def initialize(column_name, value) - super(Groonga::Operation::LESS_EQUAL, column_name, value) + def initialize(column, value) + super(Groonga::Operation::LESS_EQUAL, column, value) end end class GreaterExpressionBuilder < BinaryExpressionBuilder # :nodoc: - def initialize(column_name, value) - super(Groonga::Operation::GREATER, column_name, value) + def initialize(column, value) + super(Groonga::Operation::GREATER, column, value) end end class GreaterEqualExpressionBuilder < BinaryExpressionBuilder # :nodoc: - def initialize(column_name, value) - super(Groonga::Operation::GREATER_EQUAL, column_name, value) + def initialize(column, value) + super(Groonga::Operation::GREATER_EQUAL, column, value) end end @@ -196,7 +200,9 @@ "for table <#{@table.inspect}>" raise ArgumentError, message end - ColumnExpressionBuilder.new(column, nil, nil) + ColumnExpressionBuilder.new(column, nil, nil, + :table => @table, + :column_name => name) end def match(query, options_or_default_column={}) @@ -214,12 +220,12 @@ class ColumnExpressionBuilder # :nodoc: include ExpressionBuildable - def initialize(column, name, query) + def initialize(column, name, query, options={}) super() - @table = column.table - @range = column.range - @column = column - @default_column = column.local_name + @table = options[:table] || column.table + @default_column = column + @column_name = options[:column_name] || @default_column.local_name + @range = @default_column.range @name = name @query = query end @@ -251,7 +257,7 @@ def match(query, options={}) options = options.dup options[:syntax] ||= :query - options[:default_column] = @default_column + options[:default_column] = @default_column.local_name SubExpressionBuilder.new(query, options) end From null at cozmixng.org Wed Dec 2 10:30:31 2009 From: null at cozmixng.org (null at cozmixng.org) Date: Thu, 03 Dec 2009 00:30:31 +0900 Subject: [groonga-commit:819] groonga [groonga (trunk) r864] * return the same object for the same grn_object. Message-ID: <20091202153031.C1B981D1CCD@mail.cozmixng.org> retro 2009-12-03 00:30:31 +0900 (Thu, 03 Dec 2009) New Revision: 864 Log: * return the same object for the same grn_object. Modified files: groonga/trunk/ext/rb-grn-table.c Modified: groonga/trunk/ext/rb-grn-table.c (+8 -0) =================================================================== --- groonga/trunk/ext/rb-grn-table.c 2009-12-03 00:27:58 -15:00 (rev 863) +++ groonga/trunk/ext/rb-grn-table.c 2009-12-03 00:30:31 -15:00 (rev 864) @@ -657,6 +657,7 @@ static VALUE rb_grn_table_get_column (VALUE self, VALUE rb_name) { + grn_user_data *user_data; grn_ctx *context = NULL; grn_obj *table; grn_obj *column; @@ -686,6 +687,13 @@ column = grn_obj_column(context, table, name, name_size); rb_grn_context_check(context, self); + user_data = grn_obj_user_data(context, column); + if (user_data) { + RbGrnObject *rb_grn_object; + rb_grn_object = user_data->ptr; + if (rb_grn_object) + return rb_grn_object->self; + } owner = (column && column->header.type == GRN_ACCESSOR); rb_column = GRNCOLUMN2RVAL(Qnil, context, column, owner); From null at cozmixng.org Thu Dec 3 04:30:31 2009 From: null at cozmixng.org (null at cozmixng.org) Date: Thu, 03 Dec 2009 18:30:31 +0900 Subject: [groonga-commit:820] groonga [groonga (trunk) r865] * get_ids -> ids. Message-ID: <20091203093031.7604A1D1CCB@mail.cozmixng.org> retro 2009-12-03 18:30:30 +0900 (Thu, 03 Dec 2009) New Revision: 865 Log: * get_ids -> ids. Modified files: groonga/trunk/test/test-table-offset-and-limit.rb Modified: groonga/trunk/test/test-table-offset-and-limit.rb (+20 -18) =================================================================== --- groonga/trunk/test/test-table-offset-and-limit.rb 2009-12-03 00:28:32 -15:00 (rev 864) +++ groonga/trunk/test/test-table-offset-and-limit.rb 2009-12-03 18:30:30 +09:00 (rev 865) @@ -15,38 +15,38 @@ module TestOffsetAndLimitSupport def test_zero_and_positive_offset - assert_equal(((100+0)...200).to_a, get_ids(:offset => 0)) - assert_equal(((100+32)...200).to_a, get_ids(:offset => 32)) - assert_equal(((100+99)...200).to_a, get_ids(:offset => 99)) + assert_equal(((100+0)...200).to_a, ids(:offset => 0)) + assert_equal(((100+32)...200).to_a, ids(:offset => 32)) + assert_equal(((100+99)...200).to_a, ids(:offset => 99)) assert_raise(Groonga::InvalidArgument) do - get_ids(:offset => 100) + ids(:offset => 100) end end def test_negative_offset - assert_equal(((200-1)...200).to_a, get_ids(:offset => -1)) - assert_equal(((200-32)...200).to_a, get_ids(:offset => -32)) - assert_equal(((200-100)...200).to_a, get_ids(:offset => -100)) + assert_equal(((200-1)...200).to_a, ids(:offset => -1)) + assert_equal(((200-32)...200).to_a, ids(:offset => -32)) + assert_equal(((200-100)...200).to_a, ids(:offset => -100)) assert_raise(Groonga::InvalidArgument) do - get_ids(:offset => -101) + ids(:offset => -101) end end def test_zero_and_positive_limit - assert_equal((100...200).to_a[0, 0], get_ids(:limit => 0)) - assert_equal((100...200).to_a[0, 32], get_ids(:limit => 32)) - assert_equal((100...200).to_a[0, 100], get_ids(:limit => 100)) + assert_equal((100...200).to_a[0, 0], ids(:limit => 0)) + assert_equal((100...200).to_a[0, 32], ids(:limit => 32)) + assert_equal((100...200).to_a[0, 100], ids(:limit => 100)) assert_nothing_raised do - get_ids(:limit => 101) + ids(:limit => 101) end end def test_negative_limit - assert_equal((100...200).to_a[0..-1], get_ids(:limit => -1)) - assert_equal((100...200).to_a[0..-32], get_ids(:limit => -32)) - assert_equal((100...200).to_a[0..-100], get_ids(:limit => -100)) + assert_equal((100...200).to_a[0..-1], ids(:limit => -1)) + assert_equal((100...200).to_a[0..-32], ids(:limit => -32)) + assert_equal((100...200).to_a[0..-100], ids(:limit => -100)) assert_raise(Groonga::InvalidArgument) do - get_ids(:offset => -101) + ids(:offset => -101) end end @@ -77,8 +77,9 @@ class TestTableCursorOffsetAndLimit < TestOffsetAndLimit include TestOffsetAndLimitSupport + private - def get_ids(options={}) + def ids(options={}) ids = [] @bookmarks.open_cursor(options) do |cursor| cursor.each do |record| @@ -91,8 +92,9 @@ class TestTableSortOffsetAndLimit < TestOffsetAndLimit include TestOffsetAndLimitSupport + private - def get_ids(options={}) + def ids(options={}) ids = [] @bookmarks.sort([:key => "id", :order => :asc], options).each do |record| ids << record["id"] From null at cozmixng.org Thu Dec 3 04:30:34 2009 From: null at cozmixng.org (null at cozmixng.org) Date: Thu, 03 Dec 2009 18:30:34 +0900 Subject: [groonga-commit:821] groonga [groonga (trunk) r867] * fix style. Message-ID: <20091203093034.5B3031D1CCD@mail.cozmixng.org> retro 2009-12-03 18:30:33 +0900 (Thu, 03 Dec 2009) New Revision: 867 Log: * fix style. Modified files: groonga/trunk/test/test-table-offset-and-limit.rb Modified: groonga/trunk/test/test-table-offset-and-limit.rb (+6 -7) =================================================================== --- groonga/trunk/test/test-table-offset-and-limit.rb 2009-12-03 18:18:51 +09:00 (rev 866) +++ groonga/trunk/test/test-table-offset-and-limit.rb 2009-12-03 18:30:33 +09:00 (rev 867) @@ -15,18 +15,18 @@ module TestOffsetAndLimitSupport def test_zero_and_positive_offset - assert_equal(((100+0)...200).to_a, ids(:offset => 0)) - assert_equal(((100+32)...200).to_a, ids(:offset => 32)) - assert_equal(((100+99)...200).to_a, ids(:offset => 99)) + assert_equal(((100 + 0)...200).to_a, ids(:offset => 0)) + assert_equal(((100 + 32)...200).to_a, ids(:offset => 32)) + assert_equal(((100 + 99)...200).to_a, ids(:offset => 99)) assert_raise(Groonga::InvalidArgument) do ids(:offset => 100) end end def test_negative_offset - assert_equal(((200-1)...200).to_a, ids(:offset => -1)) - assert_equal(((200-32)...200).to_a, ids(:offset => -32)) - assert_equal(((200-100)...200).to_a, ids(:offset => -100)) + assert_equal(((200 - 1)...200).to_a, ids(:offset => -1)) + assert_equal(((200 - 32)...200).to_a, ids(:offset => -32)) + assert_equal(((200 - 100)...200).to_a, ids(:offset => -100)) assert_raise(Groonga::InvalidArgument) do ids(:offset => -101) end @@ -102,4 +102,3 @@ ids end end - From null at cozmixng.org Thu Dec 3 04:30:39 2009 From: null at cozmixng.org (null at cozmixng.org) Date: Thu, 03 Dec 2009 18:30:39 +0900 Subject: [groonga-commit:822] groonga [groonga (trunk) r870] * use collect. Message-ID: <20091203093039.337D31D1CD0@mail.cozmixng.org> retro 2009-12-03 18:30:38 +0900 (Thu, 03 Dec 2009) New Revision: 870 Log: * use collect. Modified files: groonga/trunk/test/test-table-offset-and-limit.rb Modified: groonga/trunk/test/test-table-offset-and-limit.rb (+4 -8) =================================================================== --- groonga/trunk/test/test-table-offset-and-limit.rb 2009-12-03 18:21:20 +09:00 (rev 869) +++ groonga/trunk/test/test-table-offset-and-limit.rb 2009-12-03 18:30:38 +09:00 (rev 870) @@ -82,13 +82,11 @@ private def ids(options={}) - ids = [] @bookmarks.open_cursor(options) do |cursor| - cursor.each do |record| - ids << record["id"] + cursor.collect do |record| + record["id"] end end - ids end end @@ -97,10 +95,8 @@ private def ids(options={}) - ids = [] - @bookmarks.sort([:key => "id", :order => :asc], options).each do |record| - ids << record["id"] + @bookmarks.sort([:key => "id", :order => :asc], options).collect do |record| + record["id"] end - ids end end From null at cozmixng.org Thu Dec 3 04:30:35 2009 From: null at cozmixng.org (null at cozmixng.org) Date: Thu, 03 Dec 2009 18:30:35 +0900 Subject: [groonga-commit:823] groonga [groonga (trunk) r868] * cleanup. Message-ID: <20091203093036.0052F1D1CCE@mail.cozmixng.org> retro 2009-12-03 18:30:35 +0900 (Thu, 03 Dec 2009) New Revision: 868 Log: * cleanup. Modified files: groonga/trunk/test/test-table-offset-and-limit.rb Modified: groonga/trunk/test/test-table-offset-and-limit.rb (+8 -6) =================================================================== --- groonga/trunk/test/test-table-offset-and-limit.rb 2009-12-03 18:19:38 +09:00 (rev 867) +++ groonga/trunk/test/test-table-offset-and-limit.rb 2009-12-03 18:30:35 +09:00 (rev 868) @@ -33,18 +33,20 @@ end def test_zero_and_positive_limit - assert_equal((100...200).to_a[0, 0], ids(:limit => 0)) - assert_equal((100...200).to_a[0, 32], ids(:limit => 32)) - assert_equal((100...200).to_a[0, 100], ids(:limit => 100)) + all_ids = (100...200).to_a + assert_equal(all_ids[0, 0], ids(:limit => 0)) + assert_equal(all_ids[0, 32], ids(:limit => 32)) + assert_equal(all_ids[0, 100], ids(:limit => 100)) assert_nothing_raised do ids(:limit => 101) end end def test_negative_limit - assert_equal((100...200).to_a[0..-1], ids(:limit => -1)) - assert_equal((100...200).to_a[0..-32], ids(:limit => -32)) - assert_equal((100...200).to_a[0..-100], ids(:limit => -100)) + all_ids = (100...200).to_a + assert_equal(all_ids[0..-1], ids(:limit => -1)) + assert_equal(all_ids[0..-32], ids(:limit => -32)) + assert_equal(all_ids[0..-100], ids(:limit => -100)) assert_raise(Groonga::InvalidArgument) do ids(:offset => -101) end From null at cozmixng.org Thu Dec 3 04:30:32 2009 From: null at cozmixng.org (null at cozmixng.org) Date: Thu, 03 Dec 2009 18:30:32 +0900 Subject: [groonga-commit:824] groonga [groonga (trunk) r866] * follow groonga's naming rule. Message-ID: <20091203093032.E2F691D1CCC@mail.cozmixng.org> retro 2009-12-03 18:30:32 +0900 (Thu, 03 Dec 2009) New Revision: 866 Log: * follow groonga's naming rule. Modified files: groonga/trunk/test/test-table-offset-and-limit.rb Modified: groonga/trunk/test/test-table-offset-and-limit.rb (+2 -2) =================================================================== --- groonga/trunk/test/test-table-offset-and-limit.rb 2009-12-03 18:18:20 +09:00 (rev 865) +++ groonga/trunk/test/test-table-offset-and-limit.rb 2009-12-03 18:30:32 +09:00 (rev 866) @@ -52,8 +52,8 @@ private def create_bookmarks - @bookmarks = Groonga::Array.create(:name => "") - @bookmarks.define_column("id", "") + @bookmarks = Groonga::Array.create(:name => "Bookmarks") + @bookmarks.define_column("id", "Int32") @bookmarks end From null at cozmixng.org Thu Dec 3 04:30:37 2009 From: null at cozmixng.org (null at cozmixng.org) Date: Thu, 03 Dec 2009 18:30:37 +0900 Subject: [groonga-commit:825] groonga [groonga (trunk) r869] * use Integer.times. Message-ID: <20091203093037.A15471D1CCF@mail.cozmixng.org> retro 2009-12-03 18:30:37 +0900 (Thu, 03 Dec 2009) New Revision: 869 Log: * use Integer.times. Modified files: groonga/trunk/test/test-table-offset-and-limit.rb Modified: groonga/trunk/test/test-table-offset-and-limit.rb (+1 -1) =================================================================== --- groonga/trunk/test/test-table-offset-and-limit.rb 2009-12-03 18:20:40 +09:00 (rev 868) +++ groonga/trunk/test/test-table-offset-and-limit.rb 2009-12-03 18:30:37 +09:00 (rev 869) @@ -60,7 +60,7 @@ end def add_ids - (0...100).to_a.each do |i| + 100.times do |i| bookmark = @bookmarks.add bookmark["id"] = i + 100 end From null at cozmixng.org Thu Dec 3 22:15:27 2009 From: null at cozmixng.org (null at cozmixng.org) Date: Fri, 04 Dec 2009 12:15:27 +0900 Subject: [groonga-commit:826] groonga [examples r871] show elapsed time. Message-ID: <20091204031527.E3A611D1CCC@mail.cozmixng.org> retro 2009-12-04 12:15:27 +0900 (Fri, 04 Dec 2009) New Revision: 871 Log: show elapsed time. Modified files: examples/message-archiver/searcher.rb examples/message-archiver/views/search.haml Modified: examples/message-archiver/searcher.rb (+2 -0) =================================================================== --- examples/message-archiver/searcher.rb 2009-12-03 18:22:20 +09:00 (rev 870) +++ examples/message-archiver/searcher.rb 2009-12-04 12:15:27 +09:00 (rev 871) @@ -44,9 +44,11 @@ get "/search/" do @query = params[:query] + before = Time.now @messages = @messages.select do |record| record["text"].match(@query) end + @elapsed = Time.now - before haml :search end Modified: examples/message-archiver/views/search.haml (+1 -1) =================================================================== --- examples/message-archiver/views/search.haml 2009-12-03 18:22:20 +09:00 (rev 870) +++ examples/message-archiver/views/search.haml 2009-12-04 12:15:27 +09:00 (rev 871) @@ -1,4 +1,4 @@ -%h2 ???? +%h2 ?????#{@elapsed}?? .result - @messages.each do |message| From null at cozmixng.org Thu Dec 3 22:15:29 2009 From: null at cozmixng.org (null at cozmixng.org) Date: Fri, 04 Dec 2009 12:15:29 +0900 Subject: [groonga-commit:827] groonga [examples r872] * sort by score. Message-ID: <20091204031530.225271D1CCD@mail.cozmixng.org> retro 2009-12-04 12:15:29 +0900 (Fri, 04 Dec 2009) New Revision: 872 Log: * sort by score. Modified files: examples/message-archiver/public/style.css examples/message-archiver/searcher.rb examples/message-archiver/views/search.haml Modified: examples/message-archiver/searcher.rb (+1 -1) =================================================================== --- examples/message-archiver/searcher.rb 2009-12-04 12:03:54 +09:00 (rev 871) +++ examples/message-archiver/searcher.rb 2009-12-04 12:15:29 +09:00 (rev 872) @@ -47,7 +47,7 @@ before = Time.now @messages = @messages.select do |record| record["text"].match(@query) - end + end.sort([["_score", :desc]]) @elapsed = Time.now - before haml :search end Modified: examples/message-archiver/views/search.haml (+2 -1) =================================================================== --- examples/message-archiver/views/search.haml 2009-12-04 12:03:54 +09:00 (rev 871) +++ examples/message-archiver/views/search.haml 2009-12-04 12:15:29 +09:00 (rev 872) @@ -4,5 +4,6 @@ - @messages.each do |message| .message %h3 - %a{"href" => "/#{message.key.id}?query=#{@query}"}&= message["subject"] + %a{"href" => "/#{message.key.id}?query=#{@query}"} + &= "#{message["subject"]} (#{message.score})" %p.snippet= snippet(message) Modified: examples/message-archiver/public/style.css (+7 -0) =================================================================== --- examples/message-archiver/public/style.css 2009-12-04 12:03:54 +09:00 (rev 871) +++ examples/message-archiver/public/style.css 2009-12-04 12:15:29 +09:00 (rev 872) @@ -206,3 +206,10 @@ { clear: both; } + +p.snippet +{ + font-family: monospace; + margin-left: 2em; + max-width: 40em; +} From null at cozmixng.org Thu Dec 3 22:15:31 2009 From: null at cozmixng.org (null at cozmixng.org) Date: Fri, 04 Dec 2009 12:15:31 +0900 Subject: [groonga-commit:828] groonga [examples r873] * use only sans-serif. Message-ID: <20091204031531.85DE71D1CCE@mail.cozmixng.org> retro 2009-12-04 12:15:31 +0900 (Fri, 04 Dec 2009) New Revision: 873 Log: * use only sans-serif. Modified files: examples/message-archiver/public/style.css Modified: examples/message-archiver/public/style.css (+1 -1) =================================================================== --- examples/message-archiver/public/style.css 2009-12-04 12:03:57 +09:00 (rev 872) +++ examples/message-archiver/public/style.css 2009-12-04 12:15:31 +09:00 (rev 873) @@ -4,7 +4,7 @@ background:url(images/page_bg.jpg) top left repeat-x #e2e2e2; margin:0; padding: 0 20px; - font-family: arial, helvetica, sans-serif; + font-family: sans-serif; color:#333; } From null at cozmixng.org Thu Dec 3 22:30:27 2009 From: null at cozmixng.org (null at cozmixng.org) Date: Fri, 04 Dec 2009 12:30:27 +0900 Subject: [groonga-commit:829] groonga [examples r874] * support address. Message-ID: <20091204033027.D96A61D1CCC@mail.cozmixng.org> retro 2009-12-04 12:30:27 +0900 (Fri, 04 Dec 2009) New Revision: 874 Log: * support address. Modified files: examples/message-archiver/archiver.rb examples/message-archiver/models.rb examples/message-archiver/views/show.haml Modified: examples/message-archiver/views/show.haml (+2 -3) =================================================================== --- examples/message-archiver/views/show.haml 2009-12-04 12:04:30 +09:00 (rev 873) +++ examples/message-archiver/views/show.haml 2009-12-04 12:30:27 +09:00 (rev 874) @@ -4,13 +4,12 @@ %dt ??? %dd &= @message[".from.names.value"] - &= "<#{@message[".from._key"]}>" + &= "<#{@message[".from.addresses.value"]}>" %dt ??? %dd - @message["to"].each do |to| &= to[".names.value"] - &= "<#{to["_key"].inspect}>" - , + &= "<#{to[".addresses.value"]}>" %dt ??? %dd&= @message["date"] Modified: examples/message-archiver/models.rb (+7 -3) =================================================================== --- examples/message-archiver/models.rb 2009-12-04 12:04:30 +09:00 (rev 873) +++ examples/message-archiver/models.rb 2009-12-04 12:30:27 +09:00 (rev 874) @@ -30,9 +30,12 @@ table.short_text("value") end - schema.create_table("people", - :type => :hash, - :key_type => "ShortText") do |table| + schema.create_table("addresses") do |table| + table.short_text("value") + end + + schema.create_table("people") do |table| + table.reference("addresses", "addresses", :type => :vector) table.reference("names", "names", :type => :vector) end @@ -79,6 +82,7 @@ table.index("messages.text") table.index("headers.value") table.index("names.value") + table.index("addresses.value") table.index("attachments.filename") table.index("attachments.text") end Modified: examples/message-archiver/archiver.rb (+22 -1) =================================================================== --- examples/message-archiver/archiver.rb 2009-12-04 12:04:30 +09:00 (rev 873) +++ examples/message-archiver/archiver.rb 2009-12-04 12:30:27 +09:00 (rev 874) @@ -14,6 +14,7 @@ @context = Groonga::Context.default @messages = @context["messages"] @people = @context["people"] + @addresses = @context["addresses"] @names = @context["names"] @attachments = @context["attachments"] end @@ -62,13 +63,33 @@ def register_addresses(message, key, address_list, &block) address_list.send(:tree).addresses.each do |address| - person = @people[address.address] || @people.add(address.address) + existing_addresses = @addresses.select do |record| + record["value"] == address.address + end + + if existing_addresses.size.zero? + _address = @addresses.add(:value => address.address) + else + _address = existing_addresses.to_a[0].key + end + existing_people = @people.select do |record| + record[".addresses.value"] == address.address + end + + if existing_people.size.zero? + person = @people.add + person.append("addresses", _address) + else + person = existing_people.to_a[0].key + end + name = address.display_name if name name = to_utf8(name) name = @names.add(:value => name) end person.append("names", name) if name + if block yield(person) else From null at cozmixng.org Thu Dec 3 22:45:24 2009 From: null at cozmixng.org (null at cozmixng.org) Date: Fri, 04 Dec 2009 12:45:24 +0900 Subject: [groonga-commit:830] groonga [groonga (trunk) r875] * use @column_name. Message-ID: <20091204034524.77B501D1CCC@mail.cozmixng.org> retro 2009-12-04 12:45:24 +0900 (Fri, 04 Dec 2009) New Revision: 875 Log: * use @column_name. Modified files: groonga/trunk/lib/groonga/expression-builder.rb Modified: groonga/trunk/lib/groonga/expression-builder.rb (+1 -1) =================================================================== --- groonga/trunk/lib/groonga/expression-builder.rb 2009-12-04 12:19:43 +09:00 (rev 874) +++ groonga/trunk/lib/groonga/expression-builder.rb 2009-12-04 12:45:24 +09:00 (rev 875) @@ -257,7 +257,7 @@ def match(query, options={}) options = options.dup options[:syntax] ||= :query - options[:default_column] = @default_column.local_name + options[:default_column] = @column_name SubExpressionBuilder.new(query, options) end From null at cozmixng.org Thu Dec 10 00:15:25 2009 From: null at cozmixng.org (null at cozmixng.org) Date: Thu, 10 Dec 2009 14:15:25 +0900 Subject: [groonga-commit:831] groonga [groonga (trunk) r876] * fix :with_section place. Message-ID: <20091210051525.B3AB81D1CCF@mail.cozmixng.org> retro 2009-12-10 14:15:25 +0900 (Thu, 10 Dec 2009) New Revision: 876 Log: * fix :with_section place. Modified files: groonga/trunk/ext/rb-grn-index-column.c Modified: groonga/trunk/ext/rb-grn-index-column.c (+2 -2) =================================================================== --- groonga/trunk/ext/rb-grn-index-column.c 2009-12-04 12:37:13 +09:00 (rev 875) +++ groonga/trunk/ext/rb-grn-index-column.c 2009-12-10 14:15:25 +09:00 (rev 876) @@ -132,9 +132,9 @@ * articles.define_column("content", "") * * terms = Groonga::Hash.create(:name => "", - * :with_section => true, * :default_tokenizer => "TokenBigram") - * content_index = terms.define_index_column("content", articles) + * content_index = terms.define_index_column("content", articles, + * :with_section => true) * * content = <<-EOC * groonga ??????????????????????? From null at cozmixng.org Thu Dec 10 00:15:27 2009 From: null at cozmixng.org (null at cozmixng.org) Date: Thu, 10 Dec 2009 14:15:27 +0900 Subject: [groonga-commit:832] groonga [groonga (trunk) r877] * make Context#send and #receive stable APIs. Message-ID: <20091210051527.496061D1CD6@mail.cozmixng.org> retro 2009-12-10 14:15:26 +0900 (Thu, 10 Dec 2009) New Revision: 877 Log: * make Context#send and #receive stable APIs. Modified files: groonga/trunk/ext/rb-grn-context.c Modified: groonga/trunk/ext/rb-grn-context.c (+0 -4) =================================================================== --- groonga/trunk/ext/rb-grn-context.c 2009-12-10 14:02:00 +09:00 (rev 876) +++ groonga/trunk/ext/rb-grn-context.c 2009-12-10 14:15:26 +09:00 (rev 877) @@ -441,8 +441,6 @@ * context.send(string) -> ID * * groonga???????????????? - * - * ???: API????????????? */ static VALUE rb_grn_context_send (VALUE self, VALUE rb_string) @@ -467,8 +465,6 @@ * context.receive -> [ID, String] * * groonga????????????????????? - * - * ???: API????????????? */ static VALUE rb_grn_context_receive (VALUE self) From null at cozmixng.org Thu Dec 10 00:30:30 2009 From: null at cozmixng.org (null at cozmixng.org) Date: Thu, 10 Dec 2009 14:30:30 +0900 Subject: [groonga-commit:833] groonga [groonga (trunk) r878] * support nil as a Time column value. Message-ID: <20091210053030.98C9A1D1CCF@mail.cozmixng.org> retro 2009-12-10 14:30:30 +0900 (Thu, 10 Dec 2009) New Revision: 878 Log: * support nil as a Time column value. Modified files: groonga/trunk/ext/rb-grn-utils.c groonga/trunk/test/test-column.rb Modified: groonga/trunk/ext/rb-grn-utils.c (+4 -0) =================================================================== --- groonga/trunk/ext/rb-grn-utils.c 2009-12-10 14:11:43 +09:00 (rev 877) +++ groonga/trunk/ext/rb-grn-utils.c 2009-12-10 14:30:30 +09:00 (rev 878) @@ -341,6 +341,10 @@ sec = NUM2LL(rb_sec); usec = (int32_t)(NUM2DBL(rb_usec) * 1000000); break; + case T_NIL: + sec = 0; + usec = 0; + break; default: sec = NUM2LL(rb_funcall(object, rb_intern("to_i"), 0)); usec = NUM2INT(rb_funcall(object, rb_intern("usec"), 0)); Modified: groonga/trunk/test/test-column.rb (+8 -0) =================================================================== --- groonga/trunk/test/test-column.rb 2009-12-10 14:11:43 +09:00 (rev 877) +++ groonga/trunk/test/test-column.rb 2009-12-10 14:30:30 +09:00 (rev 878) @@ -246,6 +246,14 @@ assert_in_delta(Time.at(1251380635.1234567).usec, post[".issued"].usec, 10) end + def test_set_nil_to_time + posts = Groonga::Hash.create(:name => "Posts", :key_type => "ShortText") + body = posts.define_column("issued", "Time") + + post = posts.add("hello", :issued => nil) + assert_equal(Time.at(0), post["issued"]) + end + private def assert_content_search(expected_records, term) records = @bookmarks_index_content.search(term).records From null at cozmixng.org Thu Dec 10 00:45:26 2009 From: null at cozmixng.org (null at cozmixng.org) Date: Thu, 10 Dec 2009 14:45:26 +0900 Subject: [groonga-commit:834] groonga [groonga (trunk) r879] * fix tutorial path. Message-ID: <20091210054526.835AE1D1CD6@mail.cozmixng.org> retro 2009-12-10 14:45:26 +0900 (Thu, 10 Dec 2009) New Revision: 879 Log: * fix tutorial path. Modified files: groonga/trunk/html/developer.html groonga/trunk/html/header.html.erb groonga/trunk/html/index.html Modified: groonga/trunk/html/header.html.erb (+1 -1) =================================================================== --- groonga/trunk/html/header.html.erb 2009-12-10 14:20:09 +09:00 (rev 878) +++ groonga/trunk/html/header.html.erb 2009-12-10 14:45:26 +09:00 (rev 879) @@ -8,7 +8,7 @@ Modified: groonga/trunk/html/index.html (+2 -2) =================================================================== --- groonga/trunk/html/index.html 2009-12-10 14:20:09 +09:00 (rev 878) +++ groonga/trunk/html/index.html 2009-12-10 14:45:26 +09:00 (rev 879) @@ -21,7 +21,7 @@ @@ -58,7 +58,7 @@

ActiveGroonga

Modified: groonga/trunk/html/developer.html (+1 -1) =================================================================== --- groonga/trunk/html/developer.html 2009-12-10 14:20:09 +09:00 (rev 878) +++ groonga/trunk/html/developer.html 2009-12-10 14:45:26 +09:00 (rev 879) @@ -21,7 +21,7 @@ From null at cozmixng.org Fri Dec 18 04:30:27 2009 From: null at cozmixng.org (null at cozmixng.org) Date: Fri, 18 Dec 2009 18:30:27 +0900 Subject: [groonga-commit:835] groonga [groonga (trunk) r880] * accept just column name as source. Message-ID: <20091218093027.8CD511D1CE1@mail.cozmixng.org> retro 2009-12-18 18:30:27 +0900 (Fri, 18 Dec 2009) New Revision: 880 Log: * accept just column name as source. Modified files: groonga/trunk/ext/rb-grn-index-column.c groonga/trunk/test/test-table-select.rb Modified: groonga/trunk/ext/rb-grn-index-column.c (+50 -13) =================================================================== --- groonga/trunk/ext/rb-grn-index-column.c 2009-12-10 14:41:04 +09:00 (rev 879) +++ groonga/trunk/ext/rb-grn-index-column.c 2009-12-18 18:30:27 +09:00 (rev 880) @@ -18,6 +18,8 @@ #include "rb-grn.h" +#include + #define SELF(object) ((RbGrnIndexColumn *)DATA_PTR(object)) VALUE rb_cGrnIndexColumn; @@ -264,6 +266,53 @@ return rb_sources; } +static grn_id +resolve_source_id (grn_ctx *context, grn_obj *column, VALUE rb_source) +{ + grn_id source_id; + + if (CBOOL2RVAL(rb_obj_is_kind_of(rb_source, rb_cInteger))) { + source_id = NUM2UINT(rb_source); + } else { + grn_obj *source; + + if (TYPE(rb_source) == T_STRING) { + grn_obj *table; + const char *name; + const char *dot_point; + int length; + + table = grn_ctx_at(context, grn_obj_get_range(context, column)); + name = StringValueCStr(rb_source); + length = RSTRING_LEN(rb_source); + dot_point = strstr(name, "."); + if (dot_point) { + char table_name[4096]; + int table_name_length; + + table_name_length = grn_obj_name(context, table, + table_name, sizeof(table_name)); + table_name[table_name_length] = '\0'; + if (strncmp(table_name, name, dot_point - name) != 0) { + rb_raise(rb_eArgError, + "wrong table's column: <%s>: " + "expected table: <%s>", + name, table_name); + } + length -= (dot_point - name) + 1; + name = dot_point + 1; + } + source = grn_obj_column(context, table, name, length); + } else { + source = RVAL2GRNOBJECT(rb_source, &context); + } + rb_grn_context_check(context, rb_source); + source_id = grn_obj_id(context, source); + } + + return source_id; +} + /* * call-seq: * column.sources = Groonga::Column??? @@ -290,19 +339,7 @@ rb_source_values = RARRAY_PTR(rb_sources); sources = ALLOCA_N(grn_id, n); for (i = 0; i < n; i++) { - VALUE rb_source_id; - grn_obj *source; - grn_id source_id; - - rb_source_id = rb_source_values[i]; - if (CBOOL2RVAL(rb_obj_is_kind_of(rb_source_id, rb_cInteger))) { - source_id = NUM2UINT(rb_source_id); - } else { - source = RVAL2GRNOBJECT(rb_source_id, &context); - rb_grn_context_check(context, rb_source_id); - source_id = grn_obj_id(context, source); - } - sources[i] = source_id; + sources[i] = resolve_source_id(context, column, rb_source_values[i]); } { Modified: groonga/trunk/test/test-table-select.rb (+1 -1) =================================================================== --- groonga/trunk/test/test-table-select.rb 2009-12-10 14:41:04 +09:00 (rev 879) +++ groonga/trunk/test/test-table-select.rb 2009-12-18 18:30:27 +09:00 (rev 880) @@ -28,7 +28,7 @@ :default_tokenizer => "TokenBigram") terms.define_index_column("comment_content", @comments, :with_section => true, - :source => "comments.content") + :source => "content") @comment1 = @comments.add(:content => "Hello Good-bye!", :created_at => Time.parse("2009-08-09")) @comment2 = @comments.add(:content => "Hello World", From null at cozmixng.org Sun Dec 20 19:15:24 2009 From: null at cozmixng.org (null at cozmixng.org) Date: Mon, 21 Dec 2009 09:15:24 +0900 Subject: [groonga-commit:836] groonga [groonga (trunk) r881] make test_merge! actually test Table::merge! method Message-ID: <20091221001524.B38541D1CDD@mail.cozmixng.org> retro 2009-12-21 09:15:24 +0900 (Mon, 21 Dec 2009) New Revision: 881 Log: make test_merge! actually test Table::merge! method Modified files: groonga/trunk/test/test-table.rb Modified: groonga/trunk/test/test-table.rb (+4 -4) =================================================================== --- groonga/trunk/test/test-table.rb 2009-12-18 18:17:52 +09:00 (rev 880) +++ groonga/trunk/test/test-table.rb 2009-12-21 09:15:24 +09:00 (rev 881) @@ -477,18 +477,18 @@ end def test_merge! - omit("should write a test") bookmarks = Groonga::Hash.create(:name => "bookmarks") bookmarks.define_column("title", "ShortText") bookmarks.add("http://groonga.org/", :title => "groonga") bookmarks.add("http://ruby-lang.org/", :title => "Ruby") - ruby_bookmarks = bookmarks.select {|record| record["title"] == "Ruby"} + ruby_bookmarks = bookmarks.select {|record| (record["title"] == "Ruby") & + (record["title"] == "Ruby") } all_bookmarks = bookmarks.select - assert_equal(["groonga"], + assert_equal([["groonga", 1], ["Ruby", 2]], all_bookmarks.merge!(ruby_bookmarks).collect do |record| - [record[".title"], record[".:score"]] + [record[".title"], record.score] end) end From null at cozmixng.org Sun Dec 20 19:45:27 2009 From: null at cozmixng.org (null at cozmixng.org) Date: Mon, 21 Dec 2009 09:45:27 +0900 Subject: [groonga-commit:837] groonga [groonga (trunk) r882] add documentation for various table operations Message-ID: <20091221004527.9E11D1D1CDD@mail.cozmixng.org> retro 2009-12-21 09:45:27 +0900 (Mon, 21 Dec 2009) New Revision: 882 Log: add documentation for various table operations Modified files: groonga/trunk/ext/rb-grn-table.c Modified: groonga/trunk/ext/rb-grn-table.c (+33 -0) =================================================================== --- groonga/trunk/ext/rb-grn-table.c 2009-12-21 09:06:15 +09:00 (rev 881) +++ groonga/trunk/ext/rb-grn-table.c 2009-12-21 09:45:27 +09:00 (rev 882) @@ -1695,24 +1695,57 @@ return self; } +/* + * call-seq: + * table.union!(other) -> Groonga::Table + * + * ???????_table_??????????_other_???? + * ??_table_?????? + * + */ static VALUE rb_grn_table_union_bang (VALUE self, VALUE rb_other) { return rb_grn_table_set_operation_bang(self ,rb_other, GRN_OP_OR); } + +/* + * call-seq: + * table.intersection!(other) -> Groonga::Table + * + * ???????_other_??????????????? + * _table_??????? + * + */ static VALUE rb_grn_table_intersection_bang (VALUE self, VALUE rb_other) { return rb_grn_table_set_operation_bang(self ,rb_other, GRN_OP_AND); } +/* + * call-seq: + * table.difference!(other) -> Groonga::Table + * + * ???????_other_??????????????_table_ + * ??????? + * + */ static VALUE rb_grn_table_difference_bang (VALUE self, VALUE rb_other) { return rb_grn_table_set_operation_bang(self ,rb_other, GRN_OP_BUT); } +/* + * call-seq: + * table.merge!(other) -> Groonga::Table + * + * ???????_other_?????????_table_????? + * ?????_other_??????????? + * + */ static VALUE rb_grn_table_merge_bang (VALUE self, VALUE rb_other) { From null at cozmixng.org Sun Dec 20 20:00:30 2009 From: null at cozmixng.org (null at cozmixng.org) Date: Mon, 21 Dec 2009 10:00:30 +0900 Subject: [groonga-commit:838] groonga [groonga (trunk) r883] * fix style. Message-ID: <20091221010030.C00C91D1CDD@mail.cozmixng.org> retro 2009-12-21 10:00:30 +0900 (Mon, 21 Dec 2009) New Revision: 883 Log: * fix style. Modified files: groonga/trunk/ext/rb-grn-table.c Modified: groonga/trunk/ext/rb-grn-table.c (+4 -4) =================================================================== --- groonga/trunk/ext/rb-grn-table.c 2009-12-21 09:41:58 +09:00 (rev 882) +++ groonga/trunk/ext/rb-grn-table.c 2009-12-21 10:00:30 +09:00 (rev 883) @@ -1706,7 +1706,7 @@ static VALUE rb_grn_table_union_bang (VALUE self, VALUE rb_other) { - return rb_grn_table_set_operation_bang(self ,rb_other, GRN_OP_OR); + return rb_grn_table_set_operation_bang(self, rb_other, GRN_OP_OR); } @@ -1721,7 +1721,7 @@ static VALUE rb_grn_table_intersection_bang (VALUE self, VALUE rb_other) { - return rb_grn_table_set_operation_bang(self ,rb_other, GRN_OP_AND); + return rb_grn_table_set_operation_bang(self, rb_other, GRN_OP_AND); } /* @@ -1735,7 +1735,7 @@ static VALUE rb_grn_table_difference_bang (VALUE self, VALUE rb_other) { - return rb_grn_table_set_operation_bang(self ,rb_other, GRN_OP_BUT); + return rb_grn_table_set_operation_bang(self, rb_other, GRN_OP_BUT); } /* @@ -1749,7 +1749,7 @@ static VALUE rb_grn_table_merge_bang (VALUE self, VALUE rb_other) { - return rb_grn_table_set_operation_bang(self ,rb_other, GRN_OP_ADJUST); + return rb_grn_table_set_operation_bang(self, rb_other, GRN_OP_ADJUST); } void From null at cozmixng.org Sun Dec 20 20:30:28 2009 From: null at cozmixng.org (null at cozmixng.org) Date: Mon, 21 Dec 2009 10:30:28 +0900 Subject: [groonga-commit:839] groonga [groonga (trunk) r884] add document of Table::group Message-ID: <20091221013028.9F3471D1CE1@mail.cozmixng.org> retro 2009-12-21 10:30:28 +0900 (Mon, 21 Dec 2009) New Revision: 884 Log: add document of Table::group Modified files: groonga/trunk/ext/rb-grn-table.c Modified: groonga/trunk/ext/rb-grn-table.c (+9 -0) =================================================================== --- groonga/trunk/ext/rb-grn-table.c 2009-12-21 09:57:01 +09:00 (rev 883) +++ groonga/trunk/ext/rb-grn-table.c 2009-12-21 10:30:28 +09:00 (rev 884) @@ -1152,6 +1152,15 @@ return rb_result; } +/* + * call-seq: + * table.group(keys) -> Groonga::Table??? + * Groonga::Table??? + * + * _table_??????_keys_???????????????? + * ?????????????? + * + */ static VALUE rb_grn_table_group (int argc, VALUE *argv, VALUE self) { From null at cozmixng.org Sun Dec 20 21:00:31 2009 From: null at cozmixng.org (null at cozmixng.org) Date: Mon, 21 Dec 2009 11:00:31 +0900 Subject: [groonga-commit:840] groonga [groonga (trunk) r885] add document of Groonga::Table::KeySupport of [] and []= Message-ID: <20091221020031.E86021D1CE1@mail.cozmixng.org> retro 2009-12-21 11:00:31 +0900 (Mon, 21 Dec 2009) New Revision: 885 Log: add document of Groonga::Table::KeySupport of [] and []= Modified files: groonga/trunk/ext/rb-grn-table-key-support.c Modified: groonga/trunk/ext/rb-grn-table-key-support.c (+20 -0) =================================================================== --- groonga/trunk/ext/rb-grn-table-key-support.c 2009-12-21 10:26:31 +09:00 (rev 884) +++ groonga/trunk/ext/rb-grn-table-key-support.c 2009-12-21 11:00:31 +09:00 (rev 885) @@ -303,6 +303,16 @@ return rb_str_new(GRN_BULK_HEAD(value), GRN_BULK_VSIZE(value)); } +/* + * Document-method: [] + * + * call-seq: + * table[key] -> ? + * + * _table_?_key_??????????_key_?Fixnum??? + * ?_id_?????????????????Table::[]??? + * ??? + */ static VALUE rb_grn_table_key_support_array_reference (VALUE self, VALUE rb_id_or_key) { @@ -348,6 +358,16 @@ return rb_value; } +/* + * Document-method: []= + * + * call-seq: + * table[key] = ? + * + * _table_?_key_????????????_key_?Fixnum??? + * ?_id_?????????????????Table::[]=??? + * ??????????????? + */ static VALUE rb_grn_table_key_support_array_set (VALUE self, VALUE rb_id_or_key, VALUE rb_value) From null at cozmixng.org Sun Dec 20 21:15:35 2009 From: null at cozmixng.org (null at cozmixng.org) Date: Mon, 21 Dec 2009 11:15:35 +0900 Subject: [groonga-commit:841] groonga [groonga (trunk) r886] * add document for id. Message-ID: <20091221021535.7B5E11D1CE5@mail.cozmixng.org> retro 2009-12-21 11:15:34 +0900 (Mon, 21 Dec 2009) New Revision: 886 Log: * add document for id. Modified files: groonga/trunk/ext/rb-grn-table-key-support.c Modified: groonga/trunk/ext/rb-grn-table-key-support.c (+6 -6) =================================================================== --- groonga/trunk/ext/rb-grn-table-key-support.c 2009-12-21 10:48:12 +09:00 (rev 885) +++ groonga/trunk/ext/rb-grn-table-key-support.c 2009-12-21 11:15:34 +09:00 (rev 886) @@ -307,11 +307,11 @@ * Document-method: [] * * call-seq: + * table[id] -> ? * table[key] -> ? * - * _table_?_key_??????????_key_?Fixnum??? - * ?_id_?????????????????Table::[]??? - * ??? + * _table_?_id_???_key_??????????_id_?Fixnum? + * ????? */ static VALUE rb_grn_table_key_support_array_reference (VALUE self, VALUE rb_id_or_key) @@ -362,11 +362,11 @@ * Document-method: []= * * call-seq: + * table[id] = ? * table[key] = ? * - * _table_?_key_????????????_key_?Fixnum??? - * ?_id_?????????????????Table::[]=??? - * ??????????????? + * _table_?_id_???_key_????????????_id_? + * Fixnum?????????????????? */ static VALUE rb_grn_table_key_support_array_set (VALUE self, From null at cozmixng.org Sun Dec 20 21:15:37 2009 From: null at cozmixng.org (null at cozmixng.org) Date: Mon, 21 Dec 2009 11:15:37 +0900 Subject: [groonga-commit:842] groonga [groonga (trunk) r887] add document of setter and getter of default_tokenizer of Message-ID: <20091221021537.DAEA91D1CE6@mail.cozmixng.org> retro 2009-12-21 11:15:37 +0900 (Mon, 21 Dec 2009) New Revision: 887 Log: add document of setter and getter of default_tokenizer of Groonga::Table::KeySupport Modified files: groonga/trunk/ext/rb-grn-table-key-support.c Modified: groonga/trunk/ext/rb-grn-table-key-support.c (+12 -0) =================================================================== --- groonga/trunk/ext/rb-grn-table-key-support.c 2009-12-21 11:06:28 +09:00 (rev 886) +++ groonga/trunk/ext/rb-grn-table-key-support.c 2009-12-21 11:15:37 +09:00 (rev 887) @@ -381,6 +381,12 @@ } } +/* + * call-seq: + * default_tokenizer -> nil???Groonga::Procedure + * + * Groonga::IndexColumn??????????????? + */ static VALUE rb_grn_table_key_support_get_default_tokenizer (VALUE self) { @@ -399,6 +405,12 @@ return GRNOBJECT2RVAL(Qnil, context, tokenizer, RB_GRN_FALSE); } +/* + * call-seq: + * default_tokenizer = "TokenBigram"????????? + * + * Groonga::IndexColumn????????????????? + */ static VALUE rb_grn_table_key_support_set_default_tokenizer (VALUE self, VALUE rb_tokenizer) { From null at cozmixng.org Sun Dec 20 21:30:28 2009 From: null at cozmixng.org (null at cozmixng.org) Date: Mon, 21 Dec 2009 11:30:28 +0900 Subject: [groonga-commit:843] groonga [groonga (trunk) r888] add document of Table::KeySupport#has_key? Message-ID: <20091221023028.C30711D1CE3@mail.cozmixng.org> retro 2009-12-21 11:30:28 +0900 (Mon, 21 Dec 2009) New Revision: 888 Log: add document of Table::KeySupport#has_key? Modified files: groonga/trunk/ext/rb-grn-table-key-support.c Modified: groonga/trunk/ext/rb-grn-table-key-support.c (+6 -0) =================================================================== --- groonga/trunk/ext/rb-grn-table-key-support.c 2009-12-21 11:15:07 +09:00 (rev 887) +++ groonga/trunk/ext/rb-grn-table-key-support.c 2009-12-21 11:30:28 +09:00 (rev 888) @@ -181,6 +181,12 @@ return rb_key; } +/* + * call-seq: + * table.has_key?(key) -> true/false + * + * ?????????_key_??????????true???? + */ static VALUE rb_grn_table_key_support_has_key (VALUE self, VALUE rb_key) { From null at cozmixng.org Sun Dec 20 21:30:30 2009 From: null at cozmixng.org (null at cozmixng.org) Date: Mon, 21 Dec 2009 11:30:30 +0900 Subject: [groonga-commit:844] groonga [groonga (trunk) r889] add document of Object#remove Message-ID: <20091221023030.2894B1D1CE5@mail.cozmixng.org> retro 2009-12-21 11:30:29 +0900 (Mon, 21 Dec 2009) New Revision: 889 Log: add document of Object#remove Modified files: groonga/trunk/ext/rb-grn-object.c Modified: groonga/trunk/ext/rb-grn-object.c (+9 -0) =================================================================== --- groonga/trunk/ext/rb-grn-object.c 2009-12-21 11:23:48 +09:00 (rev 888) +++ groonga/trunk/ext/rb-grn-object.c 2009-12-21 11:30:29 +09:00 (rev 889) @@ -1078,6 +1078,15 @@ return rb_grn_object_set(self, rb_id, rb_value, GRN_OBJ_PREPEND); } +/* + * Document-method: remove + * + * call-seq: + * object.remove + * + * _object_???????????????????????? + * ????????????????????? + */ static VALUE rb_grn_object_remove (VALUE self) { From null at cozmixng.org Sun Dec 20 21:45:32 2009 From: null at cozmixng.org (null at cozmixng.org) Date: Mon, 21 Dec 2009 11:45:32 +0900 Subject: [groonga-commit:845] groonga [groonga (trunk) r890] * use new tokenizer name. Message-ID: <20091221024532.8F6161D1CE3@mail.cozmixng.org> retro 2009-12-21 11:45:32 +0900 (Mon, 21 Dec 2009) New Revision: 890 Log: * use new tokenizer name. Modified files: groonga/trunk/test/test-hash.rb Modified: groonga/trunk/test/test-hash.rb (+2 -2) =================================================================== --- groonga/trunk/test/test-hash.rb 2009-12-21 11:30:09 +09:00 (rev 889) +++ groonga/trunk/test/test-hash.rb 2009-12-21 11:45:32 +09:00 (rev 890) @@ -128,8 +128,8 @@ def test_tokenizer hash = Groonga::Hash.create assert_nil(hash.default_tokenizer) - hash.default_tokenizer = "" - assert_equal(Groonga::Context.default[""], + hash.default_tokenizer = "TokenBigram" + assert_equal(Groonga::Context.default["TokenBigram"], hash.default_tokenizer) end From null at cozmixng.org Sun Dec 20 21:45:34 2009 From: null at cozmixng.org (null at cozmixng.org) Date: Mon, 21 Dec 2009 11:45:34 +0900 Subject: [groonga-commit:846] groonga [groonga (trunk) r891] * add examples. Message-ID: <20091221024534.1A4551D1CE5@mail.cozmixng.org> retro 2009-12-21 11:45:33 +0900 (Mon, 21 Dec 2009) New Revision: 891 Log: * add examples. Modified files: groonga/trunk/ext/rb-grn-table-key-support.c Modified: groonga/trunk/ext/rb-grn-table-key-support.c (+18 -2) =================================================================== --- groonga/trunk/ext/rb-grn-table-key-support.c 2009-12-21 11:30:33 +09:00 (rev 890) +++ groonga/trunk/ext/rb-grn-table-key-support.c 2009-12-21 11:45:33 +09:00 (rev 891) @@ -389,7 +389,7 @@ /* * call-seq: - * default_tokenizer -> nil???Groonga::Procedure + * table.default_tokenizer -> nil???Groonga::Procedure * * Groonga::IndexColumn??????????????? */ @@ -413,9 +413,25 @@ /* * call-seq: - * default_tokenizer = "TokenBigram"????????? + * table.default_tokenizer = ?????? * * Groonga::IndexColumn????????????????? + * + * ?: + * # 2-gram???? + * table.default_tokenizer = "TokenBigram" + * # ????????? + * table.default_tokenizer = Groonga::Context.default["TokenBigram"] + * # ??????ID??? + * table.default_tokenizer = Groonga::Type::BIGRAM + * # N-gram??????????????Groonga::IndexColumn + * # ??????:with_section => true??????? + * index = table.define_index_column("blog_content", "Blogs", + * :source => "content") + * p index # -> #> + * + * # MeCab??? + * table.default_tokenizer = "TokenMecab" */ static VALUE rb_grn_table_key_support_set_default_tokenizer (VALUE self, VALUE rb_tokenizer) From null at cozmixng.org Sun Dec 20 21:45:35 2009 From: null at cozmixng.org (null at cozmixng.org) Date: Mon, 21 Dec 2009 11:45:35 +0900 Subject: [groonga-commit:847] groonga [groonga (trunk) r892] add :nodoc: to the private method Record#column(name) Message-ID: <20091221024535.9174A1D1CE3@mail.cozmixng.org> retro 2009-12-21 11:45:35 +0900 (Mon, 21 Dec 2009) New Revision: 892 Log: add :nodoc: to the private method Record#column(name) Modified files: groonga/trunk/lib/groonga/record.rb Modified: groonga/trunk/lib/groonga/record.rb (+1 -1) =================================================================== --- groonga/trunk/lib/groonga/record.rb 2009-12-21 11:31:34 +09:00 (rev 891) +++ groonga/trunk/lib/groonga/record.rb 2009-12-21 11:45:35 +09:00 (rev 892) @@ -249,7 +249,7 @@ end private - def column(name) + def column(name) # :nodoc: _column = @table.column(name.to_s) raise InvalidArgument, "column(#{name.inspect}) is nil" if _column.nil? _column From null at cozmixng.org Sun Dec 20 22:00:33 2009 From: null at cozmixng.org (null at cozmixng.org) Date: Mon, 21 Dec 2009 12:00:33 +0900 Subject: [groonga-commit:847] groonga [groonga (trunk) r893] fixes an example of IndexColumn#[] Message-ID: <20091221030033.672761D1CE3@mail.cozmixng.org> retro 2009-12-21 12:00:33 +0900 (Mon, 21 Dec 2009) New Revision: 893 Log: fixes an example of IndexColumn#[] Modified files: groonga/trunk/ext/rb-grn-index-column.c Modified: groonga/trunk/ext/rb-grn-index-column.c (+3 -3) =================================================================== --- groonga/trunk/ext/rb-grn-index-column.c 2009-12-21 11:40:38 +09:00 (rev 892) +++ groonga/trunk/ext/rb-grn-index-column.c 2009-12-21 12:00:33 +09:00 (rev 893) @@ -130,8 +130,8 @@ * * ??????????????? * articles = Groonga::Array.create(:name => "") - * articles.define_column("title", "") - * articles.define_column("content", "") + * articles.define_column("title", "ShortText") + * articles.define_column("content", "Text") * * terms = Groonga::Hash.create(:name => "", * :default_tokenizer => "TokenBigram") @@ -159,7 +159,7 @@ * content_index[groonga] = {:value => sentence, :section => i + 1} * end * - * content.search("????").collect do |record| + * content_index.search("????").collect do |record| * p record.key["title"] # -> "groonga" * end */ From null at cozmixng.org Sun Dec 20 22:15:39 2009 From: null at cozmixng.org (null at cozmixng.org) Date: Mon, 21 Dec 2009 12:15:39 +0900 Subject: [groonga-commit:848] groonga [groonga (trunk) r894] add document of Record#search Message-ID: <20091221031539.E0D751D1CE3@mail.cozmixng.org> retro 2009-12-21 12:15:39 +0900 (Mon, 21 Dec 2009) New Revision: 894 Log: add document of Record#search Modified files: groonga/trunk/lib/groonga/record.rb Modified: groonga/trunk/lib/groonga/record.rb (+6 -0) =================================================================== --- groonga/trunk/lib/groonga/record.rb 2009-12-21 11:47:26 +09:00 (rev 893) +++ groonga/trunk/lib/groonga/record.rb 2009-12-21 12:15:39 +09:00 (rev 894) @@ -103,6 +103,12 @@ column(name).range.is_a?(Groonga::Table) end + # call-seq: + # record.search(name, query, options={}) -> Groonga::Hash + # + # ???_name_?Groonga::IndexColumn?search???????? + # _query_?_options_???????????????????? + # ?Groonga::IndexColumn#search???? def search(name, query, options={}) column(name).search(query, options) end From null at cozmixng.org Sun Dec 20 22:30:34 2009 From: null at cozmixng.org (null at cozmixng.org) Date: Mon, 21 Dec 2009 12:30:34 +0900 Subject: [groonga-commit:849] groonga [groonga (trunk) r895] add test of Expression#[] Message-ID: <20091221033034.9B0B21D1CDD@mail.cozmixng.org> retro 2009-12-21 12:30:34 +0900 (Mon, 21 Dec 2009) New Revision: 895 Log: add test of Expression#[] Modified files: groonga/trunk/test/test-expression.rb Modified: groonga/trunk/test/test-expression.rb (+15 -0) =================================================================== --- groonga/trunk/test/test-expression.rb 2009-12-21 12:01:59 +09:00 (rev 894) +++ groonga/trunk/test/test-expression.rb 2009-12-21 12:30:34 +09:00 (rev 895) @@ -19,6 +19,21 @@ setup :setup_database + def test_array_reference + expression = Groonga::Expression.new + ryoqun = expression.define_variable({:name => "user"}) + ryoqun.value = "ryoqun" + mori = expression.define_variable + mori.value = "mori" + + expression.append_object(ryoqun) + expression.append_object(mori) + + assert_equal("ryoqun", expression["user"]) + assert_equal("ryoqun", expression[0]) + assert_equal("mori", expression[1]) + end + def test_get_value users = Groonga::Hash.create(:name => "") name = users.define_column("name", "") From null at cozmixng.org Sun Dec 20 22:45:35 2009 From: null at cozmixng.org (null at cozmixng.org) Date: Mon, 21 Dec 2009 12:45:35 +0900 Subject: [groonga-commit:850] groonga [groonga (trunk) r896] add document of Expression#[] Message-ID: <20091221034535.77C2C1D1CDD@mail.cozmixng.org> retro 2009-12-21 12:45:35 +0900 (Mon, 21 Dec 2009) New Revision: 896 Log: add document of Expression#[] Modified files: groonga/trunk/ext/rb-grn-expression.c Modified: groonga/trunk/ext/rb-grn-expression.c (+9 -0) =================================================================== --- groonga/trunk/ext/rb-grn-expression.c 2009-12-21 12:25:00 +09:00 (rev 895) +++ groonga/trunk/ext/rb-grn-expression.c 2009-12-21 12:45:35 +09:00 (rev 896) @@ -479,6 +479,15 @@ return Qnil; } +/* + * call-seq: + * expression[name] -> ???? + * expression[offset] -> ???? + * + * _expression_???????????????_name_??? + * _offset_???Expression#append_object????????? + * ?? + */ static VALUE rb_grn_expression_array_reference (VALUE self, VALUE rb_name_or_offset) { From null at cozmixng.org Mon Dec 21 00:46:02 2009 From: null at cozmixng.org (null at cozmixng.org) Date: Mon, 21 Dec 2009 14:46:02 +0900 Subject: [groonga-commit:851] groonga [groonga (trunk) r897] add document of Groonga::Logger Message-ID: <20091221054602.81CCF1D1CE3@mail.cozmixng.org> retro 2009-12-21 14:46:01 +0900 (Mon, 21 Dec 2009) New Revision: 897 Log: add document of Groonga::Logger Modified files: groonga/trunk/ext/rb-grn-logger.c Modified: groonga/trunk/ext/rb-grn-logger.c (+48 -0) =================================================================== --- groonga/trunk/ext/rb-grn-logger.c 2009-12-21 12:37:51 +09:00 (rev 896) +++ groonga/trunk/ext/rb-grn-logger.c 2009-12-21 14:46:01 +09:00 (rev 897) @@ -18,6 +18,13 @@ #include "rb-grn.h" +/* + * Document-class: Groonga::Logger + * + * groonga????????????????????? + * + */ + #define RVAL2GRNWRAPPER(object) (rb_grn_logger_info_wrapper_from_ruby_object(object)) #define RVAL2GRNLOGLEVEL(object) (rb_grn_log_level_from_ruby_object(object)) #define GRNLOGLEVEL2RVAL(level) (rb_grn_log_level_to_ruby_object(level)) @@ -235,6 +242,47 @@ return Qnil; } +/* + * call-seq: + * Groonga::Logger.register(options={}) + {|level, time, title, message, location| ...} + * + * groonga???????????????????????? + * ?? + * + * ??????????????_level_, _time_, _title_, + * _message_, _location_?5???_level_?Symbol?????? + * ?????????????4??????_options_?+false+ + * ???????????????????????????? + * ??????????????????? + * + * _options_?????????????? + * + * [+:level+] + * ???????+:none+, +:emergency+, +:alert+, + * +:critical+, +:error+, +:warning+, +:notice+, +:info+, + * +:debug+, +:dump+??????????????????? + * ????????????????????????? + * +:notice+? + * + * [+:time+] + * ??????????????????????+true+?? + * ?????????????? + * + * [+:title+] + * ???????????????????+true+???? + * ????????????(FIXME: groonga??????? + * ???) + * + * [+:message+] + * ????????????????????+true+???? + * ???????????? + * + * [+:location+] + * ???????????ID?groonga??????????? + * ??????????????????????+true+?? + * ?????????????? + */ static VALUE rb_grn_logger_s_register (int argc, VALUE *argv, VALUE klass) { From null at cozmixng.org Mon Dec 21 01:30:31 2009 From: null at cozmixng.org (null at cozmixng.org) Date: Mon, 21 Dec 2009 15:30:31 +0900 Subject: [groonga-commit:852] groonga [groonga (trunk) r898] add document of Groonga::Query Message-ID: <20091221063031.81EA41D1CDD@mail.cozmixng.org> retro 2009-12-21 15:30:31 +0900 (Mon, 21 Dec 2009) New Revision: 898 Log: add document of Groonga::Query Modified files: groonga/trunk/ext/rb-grn-query.c Modified: groonga/trunk/ext/rb-grn-query.c (+36 -0) =================================================================== --- groonga/trunk/ext/rb-grn-query.c 2009-12-21 14:32:15 +09:00 (rev 897) +++ groonga/trunk/ext/rb-grn-query.c 2009-12-21 15:30:31 +09:00 (rev 898) @@ -18,6 +18,14 @@ #include "rb-grn.h" +/* + * Document-class: Groonga::Query + * + * ???????????????????????????? + * Groonga::IndexColumn#search?????????? + * + */ + #define SELF(object) (rb_rb_grn_query_from_ruby_object(object)) typedef struct _RbGrnQuery RbGrnQuery; @@ -119,6 +127,34 @@ return operator; } +/* + * call-seq: + * query.new(string, options={}) + * + * _string_???????????????????????? + * ??????Groonga::IndexColumn#search????????? + * ???????? + * + * _options_?????????????? + * + * [+:context+] + * ????????Groonga::Context?????? + * Groonga::Context.default????? + * + * [+:default_operator+] + * ???????(???????????????????) + * ?????? + * + * [Groonga::Operation::OR] + * [Groonga::Operation::AND] + * [Groonga::Operation::BUT] + * [Groonga::Operation::ADJUST] + * (FIXME: ???????????????? + * Groonga::Expression???????) + * + * [+:max_expressions+] + * ????????????????????? + */ static VALUE rb_grn_query_initialize (int argc, VALUE *argv, VALUE self) { From null at cozmixng.org Mon Dec 21 02:00:35 2009 From: null at cozmixng.org (null at cozmixng.org) Date: Mon, 21 Dec 2009 16:00:35 +0900 Subject: [groonga-commit:853] groonga [groonga (trunk) r899] added a note about being obsoleted to Groonga::Query Message-ID: <20091221070035.4A7021D1CE3@mail.cozmixng.org> retro 2009-12-21 16:00:33 +0900 (Mon, 21 Dec 2009) New Revision: 899 Log: added a note about being obsoleted to Groonga::Query Modified files: groonga/trunk/ext/rb-grn-query.c Modified: groonga/trunk/ext/rb-grn-query.c (+3 -2) =================================================================== --- groonga/trunk/ext/rb-grn-query.c 2009-12-21 15:23:47 +09:00 (rev 898) +++ groonga/trunk/ext/rb-grn-query.c 2009-12-21 16:00:33 +09:00 (rev 899) @@ -22,8 +22,9 @@ * Document-class: Groonga::Query * * ???????????????????????????? - * Groonga::IndexColumn#search?????????? - * + * Groonga::IndexColumn#search??????????(???? + * ???????????Groonga::Expression???????) + * */ #define SELF(object) (rb_rb_grn_query_from_ruby_object(object)) From null at cozmixng.org Mon Dec 21 02:00:40 2009 From: null at cozmixng.org (null at cozmixng.org) Date: Mon, 21 Dec 2009 16:00:40 +0900 Subject: [groonga-commit:854] groonga [groonga (trunk) r900] add document of Context#pop Message-ID: <20091221070040.BBCAB1D1CE3@mail.cozmixng.org> retro 2009-12-21 16:00:40 +0900 (Mon, 21 Dec 2009) New Revision: 900 Log: add document of Context#pop Modified files: groonga/trunk/ext/rb-grn-context.c Modified: groonga/trunk/ext/rb-grn-context.c (+7 -0) =================================================================== --- groonga/trunk/ext/rb-grn-context.c 2009-12-21 15:48:31 +09:00 (rev 899) +++ groonga/trunk/ext/rb-grn-context.c 2009-12-21 16:00:40 +09:00 (rev 900) @@ -603,6 +603,13 @@ return GRNOBJECT2RVAL(Qnil, context, object, RB_GRN_FALSE); } +/* + * call-seq: + * context.pop -> ? + * + * ???????????????????????????? + * ???Groonga::Expression#execute???????????? + */ static VALUE rb_grn_context_pop (VALUE self) { From null at cozmixng.org Mon Dec 21 21:45:46 2009 From: null at cozmixng.org (null at cozmixng.org) Date: Tue, 22 Dec 2009 11:45:46 +0900 Subject: [groonga-commit:855] groonga [groonga (trunk) r901] added missing document of :key_normalize and :key_with_sis Message-ID: <20091222024546.4EC501D1CDD@mail.cozmixng.org> retro 2009-12-22 11:45:45 +0900 (Tue, 22 Dec 2009) New Revision: 901 Log: added missing document of :key_normalize and :key_with_sis Modified files: groonga/trunk/ext/rb-grn-patricia-trie.c Modified: groonga/trunk/ext/rb-grn-patricia-trie.c (+7 -0) =================================================================== --- groonga/trunk/ext/rb-grn-patricia-trie.c 2009-12-21 15:52:45 +09:00 (rev 900) +++ groonga/trunk/ext/rb-grn-patricia-trie.c 2009-12-22 11:45:45 +09:00 (rev 901) @@ -64,6 +64,13 @@ * Groonga::Context??????????????????? * ???????????????? * + * [+:key_normalize+] + * +true+??????????????? + * + * [+:key_with_sis+] + * +true+??????????????suffix?????? + * ????? + * * [+:key_type+] * ???????????????????????????? * ??"Int32"?"ShortText"??????Groonga::Type??? From null at cozmixng.org Mon Dec 21 22:30:27 2009 From: null at cozmixng.org (null at cozmixng.org) Date: Tue, 22 Dec 2009 12:30:27 +0900 Subject: [groonga-commit:856] groonga [groonga (trunk) r902] added document of public class methods of Schema Message-ID: <20091222033027.EF8F51D1CE3@mail.cozmixng.org> retro 2009-12-22 12:30:27 +0900 (Tue, 22 Dec 2009) New Revision: 902 Log: added document of public class methods of Schema Modified files: groonga/trunk/lib/groonga/schema.rb Modified: groonga/trunk/lib/groonga/schema.rb (+78 -1) =================================================================== --- groonga/trunk/lib/groonga/schema.rb 2009-12-22 11:31:43 +09:00 (rev 901) +++ groonga/trunk/lib/groonga/schema.rb 2009-12-22 12:30:27 +09:00 (rev 902) @@ -50,8 +50,12 @@ # # ????????????????Groonga::Schema?? # ??????????????????????????? - # ??????? + # ?????????????? # + # schema = Groonga::Scheme.new(options) + # ... + # schema.define + # # _options_?????????????? # # [+:context+] @@ -80,6 +84,15 @@ # # _options_?????????????? # + # [+:force+] + # +true+?????????????????????? + # ????????????????? + # + # [+:type+] + # ????????????+:array+, +:hash+, + # +:patricia_trie+????????????????? + # ?+:array+???? + # # [+:context+] # ????????????Groonga::Context?????? # ???????Groonga::Context.default?????? @@ -96,6 +109,49 @@ # [+:value_type+] # ???????????????????????????? # ??????????????????? + # + # [+:sub_records+] + # +true+??????Groonga::Table#group?????? + # ??????Groonga::Record#n_sub_records???? + # ???????????????????? + # + # ???+:type+?+:hash+????+:patricia_trie+??? + # ????????? + # + # [+:key_type+] + # ????????????????????????? + # ?????"Int32"?"ShortText"?????? + # Groonga::Type????????Groonga::Array? + # Groonga::Hash?Groonga::PatriciaTrie??????? + # ???? + # + # Groonga::Type?????????????????? + # ????????????????????????? + # 4096?????????Groonga::Type::TEXT? + # Groonga::Type::LONG_TEXT???????? + # + # ????????????????ID???????? + # ????????????Groonga::Record????? + # ???????????????????? + # Groonga::Record??????ID?????? + # + # ?????????????????????????? + # 4096????????????? + # + # [+:default_tokenizer+] + # Groonga::IndexColumn??????????????? + # ????????????????????????? + # ??Groonga::IndexColumn???????? + # "TokenBigram"????????????? + # + # ???+:type+?+:patricia_trie+???????????? + # + # [+:key_normalize+] + # +true+??????????????? + # + # [+:key_with_sis+] + # +true+??????????????suffix????? + # ?????? def create_table(name, options={}, &block) define do |schema| schema.create_table(name, options, &block) @@ -103,6 +159,7 @@ end # ???_name_??????????? + # # _options_?????????????? # # [+:context+] @@ -114,6 +171,26 @@ end end + # call-seq: + # Groonga::Schema.change_table(name, options={}) {|table| ...} + # + # ???_name_?????????????????? + # + # Groonga::Schema.define do |schema| + # schema.change_table(name, options) do |table| + # ... + # end + # end + # + # ??????Groonga::Schema::TableDefinition???? + # ?????????????????????????? + # ????????? + # + # _options_?????????????? + # + # [+:context+] + # ????????????Groonga::Context?????? + # ???????Groonga::Context.default?????? def change_table(name, options={}, &block) define do |schema| schema.change_table(name, options, &block) From null at cozmixng.org Mon Dec 21 23:00:33 2009 From: null at cozmixng.org (null at cozmixng.org) Date: Tue, 22 Dec 2009 13:00:33 +0900 Subject: [groonga-commit:857] groonga [groonga (trunk) r903] added document of public instance methods of Schema Message-ID: <20091222040033.0CA661D1CDD@mail.cozmixng.org> retro 2009-12-22 13:00:30 +0900 (Tue, 22 Dec 2009) New Revision: 903 Log: added document of public instance methods of Schema Modified files: groonga/trunk/lib/groonga/schema.rb Modified: groonga/trunk/lib/groonga/schema.rb (+80 -2) =================================================================== --- groonga/trunk/lib/groonga/schema.rb 2009-12-22 12:24:22 +09:00 (rev 902) +++ groonga/trunk/lib/groonga/schema.rb 2009-12-22 13:00:30 +09:00 (rev 903) @@ -280,13 +280,25 @@ instance_eval(dumped_text) end + # call-seq: + # schema.create_table(name, options={}) {|table| ...} + # # ???_name_??????????? # - # ?????????#define?????????????? - # ?????????? + # ????????#define??????????????? + # ????????? # # _options_?????????????? # + # [+:force+] + # +true+?????????????????????? + # ????????????????? + # + # [+:type+] + # ????????????+:array+, +:hash+, + # +:patricia_trie+????????????????? + # ?+:array+???? + # # [+:context+] # ????????????Groonga::Context?????? # ???????Groonga::Schema.new????? @@ -307,17 +319,83 @@ # ????????????????????? # # ??: Groonga::Type.new + # + # [+:sub_records+] + # +true+??????Groonga::Table#group?????? + # ??????Groonga::Record#n_sub_records???? + # ???????????????????? + # + # ???+:type+?+:hash+????+:patricia_trie+??? + # ????????? + # + # [+:key_type+] + # ????????????????????????? + # ?????"Int32"?"ShortText"?????? + # Groonga::Type????????Groonga::Array? + # Groonga::Hash?Groonga::PatriciaTrie??????? + # ???? + # + # Groonga::Type?????????????????? + # ????????????????????????? + # 4096?????????Groonga::Type::TEXT? + # Groonga::Type::LONG_TEXT???????? + # + # ????????????????ID???????? + # ????????????Groonga::Record????? + # ???????????????????? + # Groonga::Record??????ID?????? + # + # ?????????????????????????? + # 4096????????????? + # + # [+:default_tokenizer+] + # Groonga::IndexColumn??????????????? + # ????????????????????????? + # ??Groonga::IndexColumn???????? + # "TokenBigram"????????????? + # + # ???+:type+?+:patricia_trie+???????????? + # + # [+:key_normalize+] + # +true+??????????????? + # + # [+:key_with_sis+] + # +true+??????????????suffix????? + # ?????? def create_table(name, options={}) definition = TableDefinition.new(name, @options.merge(options || {})) yield(definition) @definitions << definition end + # ???_name_??????????? + # + # ????????#define??????????????? + # ????????? + # + # _options_?????????????? + # + # [+:context+] + # ????????????Groonga::Context?????? + # ???????Groonga::Context.default?????? def remove_table(name, options={}) definition = TableRemoveDefinition.new(name, @options.merge(options || {})) @definitions << definition end + # call-seq: + # schema.change_table(name, options={}) {|table| ...} + # + # ???_name_??????????? + # + # ????????#define??????????????? + # ????????? + # + # _options_?????????????? + # + # [+:context+] + # ????????????Groonga::Context?????? + # ???????Groonga::Context.default?????? def change_table(name, options={}) options = @options.merge(options || {}).merge(:change => true) definition = TableDefinition.new(name, options) From null at cozmixng.org Mon Dec 21 23:00:34 2009 From: null at cozmixng.org (null at cozmixng.org) Date: Tue, 22 Dec 2009 13:00:34 +0900 Subject: [groonga-commit:858] groonga [groonga (trunk) r904] don't document implementation classes Message-ID: <20091222040034.84EED1D1CE3@mail.cozmixng.org> retro 2009-12-22 13:00:34 +0900 (Tue, 22 Dec 2009) New Revision: 904 Log: don't document implementation classes Modified files: groonga/trunk/lib/groonga/schema.rb Modified: groonga/trunk/lib/groonga/schema.rb (+5 -5) =================================================================== --- groonga/trunk/lib/groonga/schema.rb 2009-12-22 12:46:48 +09:00 (rev 903) +++ groonga/trunk/lib/groonga/schema.rb 2009-12-22 13:00:34 +09:00 (rev 904) @@ -611,7 +611,7 @@ end end - class TableRemoveDefinition + class TableRemoveDefinition # :nodoc: def initialize(name, options={}) @name = name @options = options @@ -623,7 +623,7 @@ end end - class ColumnDefinition + class ColumnDefinition # :nodoc: attr_accessor :name, :type attr_reader :options @@ -660,7 +660,7 @@ end end - class ColumnRemoveDefinition + class ColumnRemoveDefinition # :nodoc: attr_accessor :name attr_reader :options @@ -675,7 +675,7 @@ end end - class IndexColumnDefinition + class IndexColumnDefinition # :nodoc: attr_accessor :name, :target attr_reader :options @@ -720,7 +720,7 @@ end end - class Dumper + class Dumper # :nodoc: def initialize(options={}) @options = (options || {}).dup end From null at cozmixng.org Tue Dec 22 00:30:25 2009 From: null at cozmixng.org (null at cozmixng.org) Date: Tue, 22 Dec 2009 14:30:25 +0900 Subject: [groonga-commit:859] groonga [groonga (trunk) r905] add tests of options of TableDefinition#column and Message-ID: <20091222053025.A48381D1CE3@mail.cozmixng.org> retro 2009-12-22 14:30:25 +0900 (Tue, 22 Dec 2009) New Revision: 905 Log: add tests of options of TableDefinition#column and TableDefinition#index Modified files: groonga/trunk/test/test-schema.rb Modified: groonga/trunk/test/test-schema.rb (+59 -0) =================================================================== --- groonga/trunk/test/test-schema.rb 2009-12-22 12:55:02 +09:00 (rev 904) +++ groonga/trunk/test/test-schema.rb 2009-12-22 14:30:25 +09:00 (rev 905) @@ -136,6 +136,31 @@ table.inspect) end + def test_column_with_full_option + path = @tmp_dir + "column.groonga" + type = Groonga::Type.new("Niku", :size => 29) + Groonga::Schema.create_table("") do |table| + table.column("rate", + type, + :path => path, + :persistent => true, + :type => :vector, + :compress => :lzo) + end + + table = context[""] + column_name = ".rate" + column = context[column_name] + assert_equal("#, " + + "name: <#{column_name}>, " + + "path: <#{path}>, " + + "domain: <#{table.inspect}>, " + + "range: <#{type.inspect}>, " + + "flags: >", + column.inspect) + end + def test_integer32_column assert_nil(context[".rate"]) Groonga::Schema.create_table("") do |table| @@ -256,6 +281,40 @@ context["._content"].sources) end + def test_index_with_full_option + path = @tmp_dir + "index-column.groonga" + assert_nil(context[".content"]) + index_column_name = "posts-index" + + Groonga::Schema.create_table("") do |table| + table.long_text :content + end + Groonga::Schema.create_table("") do |table| + table.index(".content", + :name => index_column_name, + :path => path, + :persistent => true, + :with_section => true, + :with_weight => true, + :with_position => true) + end + + posts = context[""] + terms = context[""] + full_index_column_name = ".#{index_column_name}" + index_column = context[full_index_column_name] + assert_equal("#, " + + "name: <#{full_index_column_name}>, " + + "path: <#{path}>, " + + "domain: <#{terms.inspect}>, " + + "range: <#{posts.inspect}>, " + + "flags: >", + index_column.inspect) + end + def test_index_again Groonga::Schema.create_table("posts") do |table| table.long_text :content From null at cozmixng.org Tue Dec 22 00:45:24 2009 From: null at cozmixng.org (null at cozmixng.org) Date: Tue, 22 Dec 2009 14:45:24 +0900 Subject: [groonga-commit:860] groonga [groonga (trunk) r906] add document of Scheme::TableDefinition Message-ID: <20091222054524.930561D1CE3@mail.cozmixng.org> retro 2009-12-22 14:45:24 +0900 (Tue, 22 Dec 2009) New Revision: 906 Log: add document of Scheme::TableDefinition Modified files: groonga/trunk/lib/groonga/schema.rb Modified: groonga/trunk/lib/groonga/schema.rb (+125 -11) =================================================================== --- groonga/trunk/lib/groonga/schema.rb 2009-12-22 14:29:02 +09:00 (rev 905) +++ groonga/trunk/lib/groonga/schema.rb 2009-12-22 14:45:24 +09:00 (rev 906) @@ -403,10 +403,14 @@ @definitions << definition end + # ????????Groonga::Schema.create_table? + # Groonga::Schema#create_table????????????? + # ?????? class TableDefinition + # ??????? attr_reader :name - def initialize(name, options) + def initialize(name, options) # :nodoc: @name = name @name = @name.to_s if @name.is_a?(Symbol) @definitions = [] @@ -415,7 +419,7 @@ @table_type = table_type end - def define + def define # :nodoc: table = context[@name] if @options[:change] raise ArgumentError, "table doesn't exist: #{@name}" if table.nil? @@ -432,6 +436,39 @@ table end + # ???_name_???_type_?????????? + # + # _options_?????????????? + # + # [+:force+] + # +true+????????????????????? + # ??????????????????? + # + # [+:path+] + # ??????????? + # + # [+:persistent+] + # +true+???????????????+:path+??? + # ?????????????????? + # + # [+:type+] + # ??????????????????????????? + # +:scalar+???? + # + # [+:scalar+] + # ????(????)?????? + # + # [+:vector+] + # ?????????? + # + # [+:compress+] + # ?????????????????????????? + # + # [+:zlib+] + # ??zlib????????? + # + # [+:lzo+] + # ??lzo????????? def column(name, type, options={}) definition = self[name, ColumnDefinition] if definition.nil? @@ -443,6 +480,10 @@ self end + # ???_name_?????????? + # + # _options_??????????(TODO _options_????)? + # def remove_column(name, options={}) definition = self[name, ColumnRemoveDefinition] if definition.nil? @@ -453,6 +494,33 @@ self end + # _taget_column_??????????????????? + # ?? + # + # _options_?????????????? + # + # [+:name+] + # ??????????????????????? + # + # [+:force+] + # +true+????????????????????? + # ??????????????????? + # + # [+:path+] + # ??????????? + # + # [+:persistent+] + # +true+???????????????+:path+??? + # ?????????????????? + # + # [+:with_section+] + # ?????section(????)?????????? + # + # [+:with_weight+] + # ?????weight???????????? + # + # [+:with_position+] + # ????????????????????? def index(target_column, options={}) name = options.delete(:name) if name.nil? @@ -475,66 +543,112 @@ self end + # ???_name_?32bit???????????????? + # + # _options_???????? + # Groonga::Schema::TableDefinition#column???? def integer32(name, options={}) column(name, "Int32", options) end alias_method :integer, :integer32 alias_method :int32, :integer32 + # ???_name_?64bit???????????????? + # + # _options_???????? + # Groonga::Schema::TableDefinition#column???? def integer64(name, options={}) column(name, "Int64", options) end alias_method :int64, :integer64 + # ???_name_?32bit???????????????? + # + # _options_???????? + # Groonga::Schema::TableDefinition#column???? def unsigned_integer32(name, options={}) column(name, "UInt32", options) end alias_method :unsigned_integer, :unsigned_integer32 alias_method :uint32, :unsigned_integer32 + # ???_name_?64bit???????????????? + # + # _options_???????? + # Groonga::Schema::TableDefinition#column???? def unsigned_integer64(name, options={}) column(name, "UInt64", options) end alias_method :uint64, :unsigned_integer64 + # ???_name_?ieee754???64bit?????????? + # ?????? + # + # _options_???????? + # Groonga::Schema::TableDefinition#column???? def float(name, options={}) column(name, "Float", options) end + # ???_name_?64bit???????1970?1?1?0?0? + # 0?????????????????????????? + # + # _options_???????? + # Groonga::Schema::TableDefinition#column???? def time(name, options={}) column(name, "Time", options) end + # ???_name_?4Kbyte???????????????? + # ????? + # + # _options_???????? + # Groonga::Schema::TableDefinition#column???? def short_text(name, options={}) column(name, "ShortText", options) end alias_method :string, :short_text + # ???_name_?64Kbyte???????????????? + # ????? + # + # _options_???????? + # Groonga::Schema::TableDefinition#column???? def text(name, options={}) column(name, "Text", options) end + # ???_name_?2Gbyte???????????????? + # ????? + # + # _options_???????? + # Groonga::Schema::TableDefinition#column???? def long_text(name, options={}) column(name, "LongText", options) end + # ???_name_?_table_?????ID????????? + # ??????? + # + # _options_???????? + # Groonga::Schema::TableDefinition#column???? def reference(name, table, options={}) column(name, table, options) end - def [](name, definition_class=nil) + def [](name, definition_class=nil) # :nodoc: @definitions.find do |definition| definition.name.to_s == name.to_s and (definition_class.nil? or definition.is_a?(definition_class)) end end - def context + def context # :nodoc: @options[:context] || Groonga::Context.default end private - def update_definition(name, definition_class, definition) + def update_definition(name, definition_class, definition) # :nodoc: old_definition = self[name, definition_class] if old_definition index = @definitions.index(old_definition) @@ -548,8 +662,8 @@ :type, :path, :persistent, :key_type, :value_type, :sub_records, :default_tokenizer, - :key_normalize, :key_with_sis] - def validate_options(options) + :key_normalize, :key_with_sis] # :nodoc: + def validate_options(options) # :nodoc: return if options.nil? unknown_keys = options.keys - AVAILABLE_OPTION_KEYS unless unknown_keys.empty? @@ -559,7 +673,7 @@ end end - def table_type + def table_type # :nodoc: type = @options[:type] case type when :array, nil @@ -573,7 +687,7 @@ end end - def create_options + def create_options # :nodoc: common = { :name => @name, :path => @options[:path], @@ -602,11 +716,11 @@ end end - def column_options + def column_options # :nodoc: {:persistent => persistent?} end - def persistent? + def persistent? # :nodoc: @options[:persistent].nil? ? true : @options[:persistent] end end