rroonga 5.0.9 → 5.1.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: dec6c3b794a8d1a4e51430b65fbac2af82edb7e2
4
- data.tar.gz: eaf0e7543c579f3d279d7dee8e31bd3ffcd80f33
3
+ metadata.gz: dd322f4e7d09549b297741d7844509cfdee161f8
4
+ data.tar.gz: 505a55c349328722cc84a66931082b63b3bea98c
5
5
  SHA512:
6
- metadata.gz: a5c0b4c8a6cb3521cb3b8911a58adf1e3a5db700271dcdb92f73fc84a19f6df5e745afc30cb87cd5f7fe0ddab7b62606e39db02ad5a954062c8bdd822e2bde2b
7
- data.tar.gz: e026c373a0d75f3f3acb3c6bf6191373985d15650a1712e02a113492de9bda6a679f8d9a32f9c8b74b40d377bf1490d299b41c579439a63df488847ec00b3d87
6
+ metadata.gz: f5603abe42c2c29c4ee01baf3852a60b4adfdc594a9f7776a4acdd3c84a2a51f45131dc6a8bfba8b2d127846e8a18ab2e8d27c0028ec8747d7b2d3685381ca61
7
+ data.tar.gz: 9c064d2e23eb9cd6bd53c3cf7b38baa6a69c2204973604c41717044fd12c4f213e1d1311b8f4f3758689f9ecd9ecb675a6ff17f3955688076a2c03e9c9a497a8
data/Rakefile CHANGED
@@ -157,7 +157,7 @@ windows_architectures = [:x86, :x64]
157
157
 
158
158
  namespace :build do
159
159
  namespace :windows do
160
- ruby_versions = "2.0.0:2.1.6:2.2.2"
160
+ ruby_versions = "2.0.0:2.1.6:2.2.2:2.3.0"
161
161
 
162
162
  windows_architectures.each do |architecture|
163
163
  desc "Build gem for Windows #{architecture}"
@@ -169,6 +169,7 @@ namespace :build do
169
169
  commands = [
170
170
  ["git", "clone", "file://#{Dir.pwd}/.git", build_dir],
171
171
  ["cd", build_dir],
172
+ ["gem", "install", "json"],
172
173
  ["bundle"],
173
174
  ["rake", "cross", "native", "gem", "RUBY_CC_VERSION=#{ruby_versions}"],
174
175
  ]
@@ -1,6 +1,6 @@
1
1
  /* -*- coding: utf-8; mode: C; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2
2
  /*
3
- Copyright (C) 2015 Kouhei Sutou <kou@clear-code.com>
3
+ Copyright (C) 2015-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
@@ -21,7 +21,7 @@
21
21
  #define SELF(object) (RVAL2GRNCONTEXT(object))
22
22
 
23
23
  /*
24
- * Document-class: Groonga::Conf
24
+ * Document-class: Groonga::Config
25
25
  *
26
26
  * This class manages database global configurations. Each
27
27
  * configuration is key and value pair.
@@ -37,7 +37,7 @@
37
37
  * @since 5.0.9
38
38
  */
39
39
  static VALUE
40
- rb_grn_conf_initialize (VALUE self, VALUE rb_context)
40
+ rb_grn_config_initialize (VALUE self, VALUE rb_context)
41
41
  {
42
42
  rb_iv_set(self, "@context", rb_context);
43
43
 
@@ -47,14 +47,14 @@ rb_grn_conf_initialize (VALUE self, VALUE rb_context)
47
47
  /*
48
48
  * Gets a configuration value for key.
49
49
  *
50
- * @overload conf[](key)
50
+ * @overload config[](key)
51
51
  * @param [String] key The key.
52
52
  * @return [String, nil] The value associated with `key`.
53
53
  *
54
54
  * @since 5.0.9
55
55
  */
56
56
  static VALUE
57
- rb_grn_conf_get (VALUE self, VALUE rb_key)
57
+ rb_grn_config_get (VALUE self, VALUE rb_key)
58
58
  {
59
59
  VALUE rb_context;
60
60
  VALUE rb_value;
@@ -73,6 +73,8 @@ rb_grn_conf_get (VALUE self, VALUE rb_key)
73
73
 
74
74
  {
75
75
  grn_rc rc;
76
+ /* TODO: Replace it with grn_config_get() after Groonga 5.1.2
77
+ * is released.*/
76
78
  rc = grn_conf_get(context,
77
79
  key, key_size,
78
80
  &value, &value_size);
@@ -92,13 +94,13 @@ rb_grn_conf_get (VALUE self, VALUE rb_key)
92
94
  /*
93
95
  * Sets a configuration key and value pair.
94
96
  *
95
- * @overload conf[]=(key, value)
97
+ * @overload config[]=(key, value)
96
98
  * @param [String] key The key.
97
99
  * @param [String] value The value to be assigned.
98
100
  * @return [String] `value`.
99
101
  */
100
102
  static VALUE
101
- rb_grn_conf_set (VALUE self, VALUE rb_key, VALUE rb_value)
103
+ rb_grn_config_set (VALUE self, VALUE rb_key, VALUE rb_value)
102
104
  {
103
105
  VALUE rb_value_original = rb_value;
104
106
  VALUE rb_context;
@@ -121,6 +123,8 @@ rb_grn_conf_set (VALUE self, VALUE rb_key, VALUE rb_value)
121
123
 
122
124
  {
123
125
  grn_rc rc;
126
+ /* TODO: Replace it with grn_config_set() after Groonga 5.1.2
127
+ * is released.*/
124
128
  rc = grn_conf_set(context,
125
129
  key, key_size,
126
130
  value, value_size);
@@ -132,14 +136,15 @@ rb_grn_conf_set (VALUE self, VALUE rb_key, VALUE rb_value)
132
136
  }
133
137
 
134
138
  void
135
- rb_grn_init_conf (VALUE mGrn)
139
+ rb_grn_init_config (VALUE mGrn)
136
140
  {
137
- VALUE cGrnConf;
141
+ VALUE cGrnConfig;
138
142
 
139
- cGrnConf = rb_define_class_under(mGrn, "Conf", rb_cObject);
143
+ cGrnConfig = rb_define_class_under(mGrn, "Config", rb_cObject);
144
+ rb_define_const(mGrn, "Conf", cGrnConfig);
140
145
 
141
- rb_define_method(cGrnConf, "initialize", rb_grn_conf_initialize, 1);
146
+ rb_define_method(cGrnConfig, "initialize", rb_grn_config_initialize, 1);
142
147
 
143
- rb_define_method(cGrnConf, "[]", rb_grn_conf_get, 1);
144
- rb_define_method(cGrnConf, "[]=", rb_grn_conf_set, 2);
148
+ rb_define_method(cGrnConfig, "[]", rb_grn_config_get, 1);
149
+ rb_define_method(cGrnConfig, "[]=", rb_grn_config_set, 2);
145
150
  }
@@ -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
@@ -623,6 +624,87 @@ rb_grn_database_unmap (VALUE self)
623
624
  return Qnil;
624
625
  }
625
626
 
627
+ /*
628
+ * Recreates all index columns in the database.
629
+ *
630
+ * This method is useful when you have any broken index columns in
631
+ * the database. You don't need to specify each index column. But
632
+ * this method spends more time rather than you specify only reindex
633
+ * needed index columns.
634
+ *
635
+ * You can use {Groonga::TableKeySupport#reindex} to specify reindex
636
+ * target index columns in a table.
637
+ *
638
+ * You can use {Groonga::FixSizeColumn#reindex} or
639
+ * {Groonga::VariableSizeColumn#reindex} to specify reindex target
640
+ * index columns. They use index columns of the data column as
641
+ * reindex target index columns.
642
+ *
643
+ * You can use {Groonga::IndexColumn#reindex} to specify the reindex
644
+ * target index column.
645
+ *
646
+ * @example How to recreate all index columns in the database
647
+ * database = Groonga::Database.create(:path => "/tmp/db")
648
+ *
649
+ * Groonga::Schema.define do |schema|
650
+ * schema.create_table("Memos") do |table|
651
+ * table.short_text("title")
652
+ * table.text("content")
653
+ * end
654
+ *
655
+ * schema.create_table("BigramTerms",
656
+ * :type => :patricia_trie,
657
+ * :key_type => :short_text,
658
+ * :normalizer => "NormalizerAuto",
659
+ * :default_tokenizer => "TokenBigram") do |table|
660
+ * table.index("Memos.title")
661
+ * table.index("Memos.content")
662
+ * end
663
+ *
664
+ * schema.create_table("MeCabTerms",
665
+ * :type => :patricia_trie,
666
+ * :key_type => :short_text,
667
+ * :normalizer => "NormalizerAuto",
668
+ * :default_tokenizer => "TokenMecab") do |table|
669
+ * table.index("Memos.title")
670
+ * table.index("Memos.content")
671
+ * end
672
+ * end
673
+ *
674
+ * database.reindex
675
+ * # They are called:
676
+ * # Groonga["BigramTerms.Memos_title"].reindex
677
+ * # Groonga["BigramTerms.Memos_content"].reindex
678
+ * # Groonga["MeCabTerms.Memos_title"].reindex
679
+ * # Groonga["MeCabTerms.Memos_content"].reindex
680
+ *
681
+ * @overload reindex
682
+ * @return [void]
683
+ *
684
+ * @see Groonga::TableKeySupport#reindex
685
+ * @see Groonga::FixSizeColumn#reindex
686
+ * @see Groonga::VariableSizeColumn#reindex
687
+ * @see Groonga::IndexColumn#reindex
688
+ *
689
+ * @since 5.1.1
690
+ */
691
+ static VALUE
692
+ rb_grn_database_reindex (VALUE self)
693
+ {
694
+ grn_rc rc;
695
+ grn_ctx *context;
696
+ grn_obj *database;
697
+
698
+ rb_grn_database_deconstruct(SELF(self), &database, &context,
699
+ NULL, NULL, NULL, NULL);
700
+
701
+ rc = grn_obj_reindex(context, database);
702
+ rb_grn_context_check(context, self);
703
+ rb_grn_rc_check(rc, self);
704
+
705
+ return Qnil;
706
+ }
707
+
626
708
  void
627
709
  rb_grn_init_database (VALUE mGrn)
628
710
  {
@@ -657,4 +739,5 @@ rb_grn_init_database (VALUE mGrn)
657
739
  rb_define_method(rb_cGrnDatabase, "defrag", rb_grn_database_defrag, -1);
658
740
  rb_define_method(rb_cGrnDatabase, "recover", rb_grn_database_recover, 0);
659
741
  rb_define_method(rb_cGrnDatabase, "unmap", rb_grn_database_unmap, 0);
742
+ rb_define_method(rb_cGrnDatabase, "reindex", rb_grn_database_reindex, 0);
660
743
  }
@@ -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-2010 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
@@ -141,6 +142,87 @@ rb_grn_fix_size_column_decrement (int argc, VALUE *argv, VALUE self)
141
142
  return rb_grn_fix_size_column_integer_set(argc, argv, self, GRN_OBJ_DECR);
142
143
  }
143
144
 
145
+ /*
146
+ * Recreates all index columns for the column.
147
+ *
148
+ * This method is useful when you have any broken index columns for
149
+ * the column. You don't need to specify each index column. But this
150
+ * method spends more time rather than you specify only reindex
151
+ * needed index columns.
152
+ *
153
+ * You can use {Groonga::Database#reindex} to recreate all index
154
+ * columns in a database.
155
+ *
156
+ * You can use {Groonga::TableKeySupport#reindex} to recreate all
157
+ * index columns in a table.
158
+ *
159
+ * You can use {Groonga::IndexColumn#reindex} to specify the reindex
160
+ * target index column.
161
+ *
162
+ * @example How to recreate all index columns for the column
163
+ * Groonga::Schema.define do |schema|
164
+ * schema.create_table("Users") do |table|
165
+ * table.integer32("age")
166
+ * table.integer32("score")
167
+ * end
168
+ *
169
+ * schema.create_table("Numbers",
170
+ * :type => :patricia_trie,
171
+ * :key_type => :integer32) do |table|
172
+ * table.index("Users.age")
173
+ * table.index("Users.score")
174
+ * end
175
+ *
176
+ * schema.create_table("Ages",
177
+ * :type => :patricia_trie,
178
+ * :key_type => :integer32) do |table|
179
+ * table.index("Users.age")
180
+ * end
181
+ *
182
+ * schema.create_table("Scores",
183
+ * :type => :patricia_trie,
184
+ * :key_type => :integer32) do |table|
185
+ * table.index("Users.score")
186
+ * end
187
+ * end
188
+ *
189
+ * Groonga["Users.age"].reindex
190
+ * # They are called:
191
+ * # Groonga["Numbers.Users_age"].reindex
192
+ * # Groonga["Ages.Users_age"].reindex
193
+ * #
194
+ * # They aren't called:
195
+ * # Groonga["Numbers.Users_score"].reindex
196
+ * # Groonga["Scores.Users_score"].reindex
197
+ *
198
+ * @overload reindex
199
+ * @return [void]
200
+ *
201
+ * @see Groonga::Database#reindex
202
+ * @see Groonga::TableKeySupport#reindex
203
+ * @see Groonga::VariableSizeColumn#reindex
204
+ * @see Groonga::IndexColumn#reindex
205
+ *
206
+ * @since 5.1.1
207
+ */
208
+ static VALUE
209
+ rb_grn_fix_size_column_reindex (VALUE self)
210
+ {
211
+ grn_rc rc;
212
+ grn_ctx *context;
213
+ grn_obj *column;
214
+
215
+ rb_grn_column_deconstruct(SELF(self), &column, &context,
216
+ NULL, NULL,
217
+ NULL, NULL, NULL);
218
+
219
+ rc = grn_obj_reindex(context, column);
220
+ rb_grn_context_check(context, self);
221
+ rb_grn_rc_check(rc, self);
222
+
223
+ return Qnil;
224
+ }
225
+
144
226
  void
145
227
  rb_grn_init_fix_size_column (VALUE mGrn)
146
228
  {
@@ -156,4 +238,7 @@ rb_grn_init_fix_size_column (VALUE mGrn)
156
238
  rb_grn_fix_size_column_increment, -1);
157
239
  rb_define_method(rb_cGrnFixSizeColumn, "decrement!",
158
240
  rb_grn_fix_size_column_decrement, -1);
241
+
242
+ rb_define_method(rb_cGrnFixSizeColumn, "reindex",
243
+ rb_grn_fix_size_column_reindex, 0);
159
244
  }
@@ -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
@@ -1187,6 +1188,84 @@ rb_grn_index_column_estimate_size (int argc, VALUE *argv, VALUE self)
1187
1188
  return UINT2NUM(size);
1188
1189
  }
1189
1190
 
1191
+ /*
1192
+ * Recreates the index column.
1193
+ *
1194
+ * This method is useful when you have a broken index column.
1195
+ *
1196
+ * You can use {Groonga::Database#reindex} to recreate all index
1197
+ * columns in a database.
1198
+ *
1199
+ * You can use {Groonga::TableKeySupport#reindex} to recreate all
1200
+ * index columns in a table.
1201
+ *
1202
+ * You can use {Groonga::FixSizeColumn#reindex} or
1203
+ * {Groonga::VariableSizeColumn#reindex} to recreate all index
1204
+ * columns. They use index columns of the data column as
1205
+ * reindex target index columns.
1206
+ *
1207
+ * @example How to recreate the index column.
1208
+ * Groonga::Schema.define do |schema|
1209
+ * schema.create_table("Memos") do |table|
1210
+ * table.short_text("title")
1211
+ * table.text("content")
1212
+ * end
1213
+ *
1214
+ * schema.create_table("BigramTerms",
1215
+ * :type => :patricia_trie,
1216
+ * :key_type => :short_text,
1217
+ * :normalizer => "NormalizerAuto",
1218
+ * :default_tokenizer => "TokenBigram") do |table|
1219
+ * table.index("Memos.title")
1220
+ * table.index("Memos.content")
1221
+ * end
1222
+ *
1223
+ * schema.create_table("MeCabTerms",
1224
+ * :type => :patricia_trie,
1225
+ * :key_type => :short_text,
1226
+ * :normalizer => "NormalizerAuto",
1227
+ * :default_tokenizer => "TokenMecab") do |table|
1228
+ * table.index("Memos.title")
1229
+ * table.index("Memos.content")
1230
+ * end
1231
+ * end
1232
+ *
1233
+ * Groonga["MeCabTerms.Memos_content"].reindex
1234
+ * # They aren't called:
1235
+ * # Groonga["BigramTerms.Memos_title"].reindex
1236
+ * # Groonga["BigramTerms.Memos_content"].reindex
1237
+ * # Groonga["MeCabTerms.Memos_title"].reindex
1238
+ *
1239
+ * @overload reindex
1240
+ * @return [void]
1241
+ *
1242
+ * @see Groonga::Database#reindex
1243
+ * @see Groonga::TableKeySupport#reindex
1244
+ * @see Groonga::FixSizeColumn#reindex
1245
+ * @see Groonga::VariableSizeColumn#reindex
1246
+ *
1247
+ * @since 5.1.1
1248
+ */
1249
+ static VALUE
1250
+ rb_grn_index_column_reindex (VALUE self)
1251
+ {
1252
+ grn_rc rc;
1253
+ grn_ctx *context;
1254
+ grn_obj *column;
1255
+
1256
+ rb_grn_index_column_deconstruct(SELF(self), &column, &context,
1257
+ NULL, NULL,
1258
+ NULL, NULL, NULL,
1259
+ NULL, NULL,
1260
+ NULL, NULL);
1261
+
1262
+ rc = grn_obj_reindex(context, column);
1263
+ rb_grn_context_check(context, self);
1264
+ rb_grn_rc_check(rc, self);
1265
+
1266
+ return Qnil;
1267
+ }
1268
+
1190
1269
  void
1191
1270
  rb_grn_init_index_column (VALUE mGrn)
1192
1271
  {
@@ -1225,4 +1304,7 @@ rb_grn_init_index_column (VALUE mGrn)
1225
1304
 
1226
1305
  rb_define_method(rb_cGrnIndexColumn, "estimate_size",
1227
1306
  rb_grn_index_column_estimate_size, -1);
1307
+
1308
+ rb_define_method(rb_cGrnIndexColumn, "reindex",
1309
+ rb_grn_index_column_reindex, 0);
1228
1310
  }
@@ -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-2015 Masafumi Yokoyama <yokoyama@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
@@ -1656,6 +1656,68 @@ rb_grn_object_scorer_procedure_p (VALUE self)
1656
1656
  return CBOOL2RVAL(scorer_procedure_p);
1657
1657
  }
1658
1658
 
1659
+ /*
1660
+ * Checks whether the object is accessor or not.
1661
+ *
1662
+ * @overload accessor?
1663
+ * @return [Boolean] `true` if the object is accessor,
1664
+ * `false` otherwise.
1665
+ *
1666
+ * @since 5.1.1
1667
+ */
1668
+ static VALUE
1669
+ rb_grn_object_accessor_p (VALUE self)
1670
+ {
1671
+ grn_ctx *context;
1672
+ grn_obj *object;
1673
+ grn_bool accessor_p = GRN_FALSE;
1674
+
1675
+ rb_grn_object_deconstruct(SELF(self), &object, &context,
1676
+ NULL, NULL, NULL, NULL);
1677
+
1678
+ if (context && object) {
1679
+ accessor_p = grn_obj_is_accessor(context, object);
1680
+ }
1681
+
1682
+ return CBOOL2RVAL(accessor_p);
1683
+ }
1684
+
1685
+ /*
1686
+ * Checks whether the object is key accessor or not.
1687
+ *
1688
+ * @example `true` case: `column("_key")` is an accessor and it's an accessor for `_key`
1689
+ * Groonga::Schema.create_table("Users", :key_type => :short_text)
1690
+ * users = Groonga["Users"]
1691
+ * users.column("_key").key_accessor? # => true
1692
+ *
1693
+ * @example `false` case: `column("_id")` is an accessor but it's not an accessor for `_key`
1694
+ * Groonga::Schema.create_table("Users", :key_type => :short_text)
1695
+ * users = Groonga["Users"]
1696
+ * users.column("_id").key_accessor? # => false
1697
+ *
1698
+ * @overload key_accessor?
1699
+ * @return [Boolean] `true` if the object is key accessor,
1700
+ * `false` otherwise.
1701
+ *
1702
+ * @since 5.1.1
1703
+ */
1704
+ static VALUE
1705
+ rb_grn_object_key_accessor_p (VALUE self)
1706
+ {
1707
+ grn_ctx *context;
1708
+ grn_obj *object;
1709
+ grn_bool key_accessor_p = GRN_FALSE;
1710
+
1711
+ rb_grn_object_deconstruct(SELF(self), &object, &context,
1712
+ NULL, NULL, NULL, NULL);
1713
+
1714
+ if (context && object) {
1715
+ key_accessor_p = grn_obj_is_key_accessor(context, object);
1716
+ }
1717
+
1718
+ return CBOOL2RVAL(key_accessor_p);
1719
+ }
1720
+
1659
1721
  void
1660
1722
  rb_grn_init_object (VALUE mGrn)
1661
1723
  {
@@ -1701,4 +1763,8 @@ rb_grn_init_object (VALUE mGrn)
1701
1763
  rb_grn_object_selector_only_procedure_p, 0);
1702
1764
  rb_define_method(rb_cGrnObject, "scorer_procedure?",
1703
1765
  rb_grn_object_scorer_procedure_p, 0);
1766
+ rb_define_method(rb_cGrnObject, "accessor?",
1767
+ rb_grn_object_accessor_p, 0);
1768
+ rb_define_method(rb_cGrnObject, "key_accessor?",
1769
+ rb_grn_object_key_accessor_p, 0);
1704
1770
  }