rroonga 5.0.9 → 5.1.1

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,7 +1,7 @@
1
1
  /* -*- coding: utf-8; mode: C; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2
2
  /*
3
- Copyright (C) 2014 Masafumi Yokoyama <myokoym@gmail.com>
4
3
  Copyright (C) 2009-2014 Kouhei Sutou <kou@clear-code.com>
4
+ Copyright (C) 2014-2016 Masafumi Yokoyama <yokoyama@clear-code.com>
5
5
 
6
6
  This library is free software; you can redistribute it and/or
7
7
  modify it under the terms of the GNU Lesser General Public
@@ -1025,6 +1025,89 @@ rb_grn_table_key_support_tokenize (int argc, VALUE *argv, VALUE self)
1025
1025
  return rb_tokens;
1026
1026
  }
1027
1027
 
1028
+ /*
1029
+ * Recreates all index columns in the table.
1030
+ *
1031
+ * This method is useful when you have any broken index columns in
1032
+ * the table. You don't need to specify each index column. But this
1033
+ * method spends more time rather than you specify only reindex
1034
+ * needed index columns.
1035
+ *
1036
+ * You can use {Groonga::Database#reindex} to recreate all index
1037
+ * columns in a database.
1038
+ *
1039
+ * You can use {Groonga::FixSizeColumn#reindex} or
1040
+ * {Groonga::VariableSizeColumn#reindex} to specify reindex target
1041
+ * index columns. They use index columns of the data column as
1042
+ * reindex target index columns.
1043
+ *
1044
+ * You can use {Groonga::IndexColumn#reindex} to specify the reindex
1045
+ * target index column.
1046
+ *
1047
+ * @example How to recreate all index columns in the table
1048
+ * Groonga::Schema.define do |schema|
1049
+ * schema.create_table("Memos") do |table|
1050
+ * table.short_text("title")
1051
+ * table.text("content")
1052
+ * end
1053
+ *
1054
+ * schema.create_table("BigramTerms",
1055
+ * :type => :patricia_trie,
1056
+ * :key_type => :short_text,
1057
+ * :normalizer => "NormalizerAuto",
1058
+ * :default_tokenizer => "TokenBigram") do |table|
1059
+ * table.index("Memos.title")
1060
+ * table.index("Memos.content")
1061
+ * end
1062
+ *
1063
+ * schema.create_table("MeCabTerms",
1064
+ * :type => :patricia_trie,
1065
+ * :key_type => :short_text,
1066
+ * :normalizer => "NormalizerAuto",
1067
+ * :default_tokenizer => "TokenMecab") do |table|
1068
+ * table.index("Memos.title")
1069
+ * table.index("Memos.content")
1070
+ * end
1071
+ * end
1072
+ *
1073
+ * Groonga["BigramTerms"].reindex
1074
+ * # They are called:
1075
+ * # Groonga["BigramTerms.Memos_title"].reindex
1076
+ * # Groonga["BigramTerms.Memos_content"].reindex
1077
+ * #
1078
+ * # They aren't called:
1079
+ * # Groonga["MeCabTerms.Memos_title"].reindex
1080
+ * # Groonga["MeCabTerms.Memos_content"].reindex
1081
+ *
1082
+ * @overload reindex
1083
+ * @return [void]
1084
+ *
1085
+ * @see Groonga::Database#reindex
1086
+ * @see Groonga::FixSizeColumn#reindex
1087
+ * @see Groonga::VariableSizeColumn#reindex
1088
+ * @see Groonga::IndexColumn#reindex
1089
+ *
1090
+ * @since 5.1.1
1091
+ */
1092
+ static VALUE
1093
+ rb_grn_table_key_support_reindex (VALUE self)
1094
+ {
1095
+ grn_rc rc;
1096
+ grn_ctx *context;
1097
+ grn_obj *table;
1098
+
1099
+ rb_grn_table_key_support_deconstruct(SELF(self), &table, &context,
1100
+ NULL, NULL, NULL,
1101
+ NULL, NULL, NULL,
1102
+ NULL);
1103
+
1104
+ rc = grn_obj_reindex(context, table);
1105
+ rb_grn_context_check(context, self);
1106
+ rb_grn_rc_check(rc, self);
1107
+
1108
+ return Qnil;
1109
+ }
1110
+
1028
1111
  void
1029
1112
  rb_grn_init_table_key_support (VALUE mGrn)
1030
1113
  {
@@ -1084,4 +1167,7 @@ rb_grn_init_table_key_support (VALUE mGrn)
1084
1167
 
1085
1168
  rb_define_method(rb_mGrnTableKeySupport, "tokenize",
1086
1169
  rb_grn_table_key_support_tokenize, -1);
1170
+
1171
+ rb_define_method(rb_mGrnTableKeySupport, "reindex",
1172
+ rb_grn_table_key_support_reindex, 0);
1087
1173
  }
@@ -1,7 +1,7 @@
1
1
  /* -*- coding: utf-8; mode: C; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2
2
  /*
3
- Copyright (C) 2014-2015 Masafumi Yokoyama <yokoyama@clear-code.com>
4
3
  Copyright (C) 2009-2015 Kouhei Sutou <kou@clear-code.com>
4
+ Copyright (C) 2014-2016 Masafumi Yokoyama <yokoyama@clear-code.com>
5
5
 
6
6
  This library is free software; you can redistribute it and/or
7
7
  modify it under the terms of the GNU Lesser General Public
@@ -1376,7 +1376,7 @@ rb_grn_table_geo_sort (int argc, VALUE *argv, VALUE self)
1376
1376
 
1377
1377
  rb_scan_args(argc, argv, "21", &rb_column, &rb_base_geo_point, &rb_options);
1378
1378
 
1379
- column = RVAL2GRNCOLUMN(rb_column, &context);
1379
+ column = RVAL2GRNOBJECT(rb_column, &context);
1380
1380
  column_range_id = grn_obj_get_range(context, column);
1381
1381
  switch (column_range_id) {
1382
1382
  case GRN_DB_TOKYO_GEO_POINT:
@@ -1,7 +1,7 @@
1
1
  /* -*- coding: utf-8; mode: C; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2
2
  /*
3
3
  Copyright (C) 2009-2014 Kouhei Sutou <kou@clear-code.com>
4
- Copyright (C) 2014 Masafumi Yokoyama <myokoym@gmail.com>
4
+ Copyright (C) 2014-2016 Masafumi Yokoyama <yokoyama@clear-code.com>
5
5
 
6
6
  This library is free software; you can redistribute it and/or
7
7
  modify it under the terms of the GNU Lesser General Public
@@ -564,6 +564,86 @@ rb_grn_variable_size_column_defrag (int argc, VALUE *argv, VALUE self)
564
564
  return INT2NUM(n_segments);
565
565
  }
566
566
 
567
+ /*
568
+ * Recreates all index columns for the column.
569
+ *
570
+ * This method is useful when you have any broken index columns for
571
+ * the column. You don't need to specify each index column. But this
572
+ * method spends more time rather than you specify only reindex
573
+ * needed index columns.
574
+ *
575
+ * You can use {Groonga::Database#reindex} to recreate all index
576
+ * columns in a database.
577
+ *
578
+ * You can use {Groonga::TableKeySupport#reindex} to recreate all
579
+ * index columns in a table.
580
+ *
581
+ * You can use {Groonga::IndexColumn#reindex} to specify the reindex
582
+ * target index column.
583
+ *
584
+ * @example How to recreate all index columns for the column
585
+ * Groonga::Schema.define do |schema|
586
+ * schema.create_table("Memos") do |table|
587
+ * table.short_text("title")
588
+ * table.text("content")
589
+ * end
590
+ *
591
+ * schema.create_table("BigramTerms",
592
+ * :type => :patricia_trie,
593
+ * :key_type => :short_text,
594
+ * :normalizer => "NormalizerAuto",
595
+ * :default_tokenizer => "TokenBigram") do |table|
596
+ * table.index("Memos.title")
597
+ * table.index("Memos.content")
598
+ * end
599
+ *
600
+ * schema.create_table("MeCabTerms",
601
+ * :type => :patricia_trie,
602
+ * :key_type => :short_text,
603
+ * :normalizer => "NormalizerAuto",
604
+ * :default_tokenizer => "TokenMecab") do |table|
605
+ * table.index("Memos.title")
606
+ * table.index("Memos.content")
607
+ * end
608
+ * end
609
+ *
610
+ * Groonga["Memos.content"].reindex
611
+ * # They are called:
612
+ * # Groonga["BigramTerms.Memos_content"].reindex
613
+ * # Groonga["MeCabTerms.Memos_content"].reindex
614
+ * #
615
+ * # They aren't called:
616
+ * # Groonga["BigramTerms.Memos_title"].reindex
617
+ * # Groonga["MeCabTerms.Memos_title"].reindex
618
+ *
619
+ * @overload reindex
620
+ * @return [void]
621
+ *
622
+ * @see Groonga::Database#reindex
623
+ * @see Groonga::TableKeySupport#reindex
624
+ * @see Groonga::FixSizeColumn#reindex
625
+ * @see Groonga::IndexColumn#reindex
626
+ *
627
+ * @since 5.1.1
628
+ */
629
+ static VALUE
630
+ rb_grn_variable_size_column_reindex (VALUE self)
631
+ {
632
+ grn_rc rc;
633
+ grn_ctx *context;
634
+ grn_obj *column;
635
+
636
+ rb_grn_variable_size_column_deconstruct(SELF(self), &column, &context,
637
+ NULL, NULL, NULL, NULL,
638
+ NULL, NULL);
639
+
640
+ rc = grn_obj_reindex(context, column);
641
+ rb_grn_context_check(context, self);
642
+ rb_grn_rc_check(rc, self);
643
+
644
+ return Qnil;
645
+ }
646
+
567
647
  void
568
648
  rb_grn_init_variable_size_column (VALUE mGrn)
569
649
  {
@@ -579,4 +659,7 @@ rb_grn_init_variable_size_column (VALUE mGrn)
579
659
  rb_grn_variable_size_column_compressed_p, -1);
580
660
  rb_define_method(rb_cGrnVariableSizeColumn, "defrag",
581
661
  rb_grn_variable_size_column_defrag, -1);
662
+
663
+ rb_define_method(rb_cGrnVariableSizeColumn, "reindex",
664
+ rb_grn_variable_size_column_reindex, 0);
582
665
  }
@@ -1,7 +1,7 @@
1
1
  /* -*- coding: utf-8; mode: C; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2
2
  /*
3
- Copyright (C) 2015 Masafumi Yokoyama <yokoyama@clear-code.com>
4
- Copyright (C) 2009-2015 Kouhei Sutou <kou@clear-code.com>
3
+ Copyright (C) 2009-2016 Kouhei Sutou <kou@clear-code.com>
4
+ Copyright (C) 2015-2016 Masafumi Yokoyama <yokoyama@clear-code.com>
5
5
 
6
6
  This library is free software; you can redistribute it and/or
7
7
  modify it under the terms of the GNU Lesser General Public
@@ -100,8 +100,8 @@ RB_GRN_BEGIN_DECLS
100
100
  #endif
101
101
 
102
102
  #define RB_GRN_MAJOR_VERSION 5
103
- #define RB_GRN_MINOR_VERSION 0
104
- #define RB_GRN_MICRO_VERSION 9
103
+ #define RB_GRN_MINOR_VERSION 1
104
+ #define RB_GRN_MICRO_VERSION 1
105
105
 
106
106
  #define RB_GRN_QUERY_DEFAULT_MAX_EXPRESSIONS 32
107
107
 
@@ -354,7 +354,7 @@ void rb_grn_init_snippet (VALUE mGrn);
354
354
  void rb_grn_init_plugin (VALUE mGrn);
355
355
  void rb_grn_init_normalizer (VALUE mGrn);
356
356
  void rb_grn_init_thread (VALUE mGrn);
357
- void rb_grn_init_conf (VALUE mGrn);
357
+ void rb_grn_init_config (VALUE mGrn);
358
358
 
359
359
  VALUE rb_grn_rc_to_exception (grn_rc rc);
360
360
  const char *rb_grn_rc_to_message (grn_rc rc);
@@ -1,6 +1,7 @@
1
1
  /* -*- coding: utf-8; mode: C; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2
2
  /*
3
3
  Copyright (C) 2009-2015 Kouhei Sutou <kou@clear-code.com>
4
+ Copyright (C) 2016 Masafumi Yokoyama <yokoyama@clear-code.com>
4
5
 
5
6
  This library is free software; you can redistribute it and/or
6
7
  modify it under the terms of the GNU Lesser General Public
@@ -148,6 +149,30 @@ rb_grn_init_lock_timeout (VALUE mGrn)
148
149
  rb_grn_s_set_lock_timeout, 1);
149
150
  }
150
151
 
152
+ /*
153
+ * Returns the Groonga package's label. It's `"Groonga"`.
154
+ *
155
+ * @example How to get the Groonga package's label
156
+ * Groonga.package_label # => "Groonga"
157
+ *
158
+ * @overload package_label
159
+ * @return [String] `"Groonga"`
160
+ *
161
+ * @since 5.1.1
162
+ */
163
+ static VALUE
164
+ rb_grn_s_get_package_label (VALUE klass)
165
+ {
166
+ return rb_str_new_cstr(grn_get_package_label());
167
+ }
168
+
169
+ static void
170
+ rb_grn_init_package_label (VALUE mGrn)
171
+ {
172
+ rb_define_singleton_method(mGrn, "package_label",
173
+ rb_grn_s_get_package_label, 0);
174
+ }
175
+
151
176
  void
152
177
  Init_groonga (void)
153
178
  {
@@ -162,6 +187,7 @@ Init_groonga (void)
162
187
 
163
188
  rb_grn_init_version(mGrn);
164
189
  rb_grn_init_lock_timeout(mGrn);
190
+ rb_grn_init_package_label(mGrn);
165
191
 
166
192
  rb_grn_init_utils(mGrn);
167
193
  rb_grn_init_encoding(mGrn);
@@ -192,5 +218,5 @@ Init_groonga (void)
192
218
  rb_grn_init_plugin(mGrn);
193
219
  rb_grn_init_normalizer(mGrn);
194
220
  rb_grn_init_thread(mGrn);
195
- rb_grn_init_conf(mGrn);
221
+ rb_grn_init_config(mGrn);
196
222
  }
@@ -1,6 +1,6 @@
1
1
  # -*- coding: utf-8 -*-
2
2
  #
3
- # Copyright (C) 2010-2015 Kouhei Sutou <kou@clear-code.com>
3
+ # Copyright (C) 2010-2016 Kouhei Sutou <kou@clear-code.com>
4
4
  #
5
5
  # This library is free software; you can redistribute it and/or
6
6
  # modify it under the terms of the GNU Lesser General Public
@@ -347,12 +347,21 @@ module Groonga
347
347
  memory_pool.register(object)
348
348
  end
349
349
 
350
- # @return [Groonga::Conf] The database level configuration sets of
350
+ # @return [Groonga::Config] The database level configuration sets of
351
351
  # this context.
352
352
  #
353
353
  # @since 5.0.9
354
+ # @deprecated since 5.1.1. Use {Groonga::Context#config} instead.
354
355
  def conf
355
- @conf ||= Conf.new(self)
356
+ config
357
+ end
358
+
359
+ # @return [Groonga::Config] The database level configuration sets of
360
+ # this context.
361
+ #
362
+ # @since 5.1.1
363
+ def config
364
+ @config ||= Config.new(self)
356
365
  end
357
366
  end
358
367
  end
@@ -81,7 +81,8 @@ module Groonga
81
81
  end
82
82
 
83
83
  if builders.empty?
84
- expression.append_constant(true)
84
+ expression.append_object(@table.context["all_records"])
85
+ expression.append_operation(Operation::CALL, 0)
85
86
  else
86
87
  combined_builder = builders.inject(nil) do |previous, builder|
87
88
  if previous.nil?
@@ -1,7 +1,7 @@
1
1
  #!/usr/bin/env ruby
2
2
  #
3
3
  # Copyright (C) 2009-2015 Kouhei Sutou <kou@clear-code.com>
4
- # Copyright (C) 2015 Masafumi Yokoyama <yokoyama@clear-code.com>
4
+ # Copyright (C) 2015-2016 Masafumi Yokoyama <yokoyama@clear-code.com>
5
5
  #
6
6
  # This library is free software; you can redistribute it and/or
7
7
  # modify it under the terms of the GNU Lesser General Public
@@ -19,16 +19,16 @@
19
19
  module RroongaBuild
20
20
  module RequiredGroongaVersion
21
21
  MAJOR = 5
22
- MINOR = 0
23
- MICRO = 9
22
+ MINOR = 1
23
+ MICRO = 0
24
24
  VERSION = [MAJOR, MINOR, MICRO]
25
- RELEASED_DATE = Time.utc(2015, 10, 29)
25
+ RELEASED_DATE = Time.utc(2015, 11, 29)
26
26
  end
27
27
 
28
28
  module LatestGroongaVersion
29
29
  MAJOR = 5
30
- MINOR = 0
31
- MICRO = 9
30
+ MINOR = 1
31
+ MICRO = 1
32
32
  VERSION = [MAJOR, MINOR, MICRO]
33
33
  end
34
34
 
@@ -1,4 +1,5 @@
1
1
  # Copyright (C) 2011 Kouhei Sutou <kou@clear-code.com>
2
+ # Copyright (C) 2016 Masafumi Yokoyama <yokoyama@clear-code.com>
2
3
  #
3
4
  # This library is free software; you can redistribute it and/or
4
5
  # modify it under the terms of the GNU Lesser General Public
@@ -33,4 +34,33 @@ class AccessorTest < Test::Unit::TestCase
33
34
  def test_local_name
34
35
  assert_equal("_id", @id.local_name)
35
36
  end
37
+
38
+ sub_test_case "#accessor?" do
39
+ test "true" do
40
+ assert do
41
+ @id.accessor?
42
+ end
43
+ end
44
+
45
+ test "false" do
46
+ assert do
47
+ not @posts.accessor?
48
+ end
49
+ end
50
+ end
51
+
52
+ sub_test_case "#key_accessor?" do
53
+ test "true" do
54
+ key = @posts.column("_key")
55
+ assert do
56
+ key.key_accessor?
57
+ end
58
+ end
59
+
60
+ test "false" do
61
+ assert do
62
+ not @id.key_accessor?
63
+ end
64
+ end
65
+ end
36
66
  end
@@ -1,4 +1,4 @@
1
- # Copyright (C) 2015 Kouhei Sutou <kou@clear-code.com>
1
+ # Copyright (C) 2015-2016 Kouhei Sutou <kou@clear-code.com>
2
2
  #
3
3
  # This library is free software; you can redistribute it and/or
4
4
  # modify it under the terms of the GNU Lesser General Public
@@ -13,19 +13,19 @@
13
13
  # License along with this library; if not, write to the Free Software
14
14
  # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
15
15
 
16
- class ConfTest < Test::Unit::TestCase
16
+ class ConfigTest < Test::Unit::TestCase
17
17
  include GroongaTestUtils
18
18
 
19
19
  setup :setup_database
20
20
 
21
21
  sub_test_case "#[]" do
22
22
  test "existent" do
23
- context.conf["rroonga.key"] = "value"
24
- assert_equal("value", context.conf["rroonga.key"])
23
+ context.config["rroonga.key"] = "value"
24
+ assert_equal("value", context.config["rroonga.key"])
25
25
  end
26
26
 
27
27
  test "nonexistent" do
28
- assert_nil(context.conf["nonexistent"])
28
+ assert_nil(context.config["nonexistent"])
29
29
  end
30
30
  end
31
31
  end