rroonga 11.0.0 → 12.0.2

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
  SHA256:
3
- metadata.gz: d2e5c28e453fae2876164e7ea4ef8e3e24b0e789bec2c6cd270850905296a9c5
4
- data.tar.gz: 8f8cac4d824bc94e0f89dd8ee60e8b2a0fd0fb92b1e666dfbb7732ef43c7bb96
3
+ metadata.gz: 9e1afd17d5a479b6e5c472729d3548f3551b15cec0db30bbf46f8a43266d96a1
4
+ data.tar.gz: 05b218925dfbf29f4deb9d34c5ab6408cbcecdf11de588d2c8d45efaf0e28417
5
5
  SHA512:
6
- metadata.gz: e23a7b4d5aaa7375ee7347fdce6706d90311f8447ec41d7ecf7d0864258f9992cbba7a9521d5afd5589197a25e3b3acece7c7c515ecfb2980daa8329639a678b
7
- data.tar.gz: cefd86c0fc0053aa34d669b4cb94f78d38dc63ee4faea9c32b1a5519fc231f99bc1146e8f54bb50d38a60d89e1129a7e5145bc03107f05cf3925cd8687cf98fa
6
+ metadata.gz: ce775711f0f90338164a3f5c3f5c7731b9f8d06e8563836f0adb7de325f471d43d9be5bb09a428f2598e801dca502564fbea3b9cb285bb38d8f7310cd22a7251
7
+ data.tar.gz: fe208b1bf0ee5e04fbccbe6220b2b0b44e80e9825c8b9aaab86017d7d87de8185a7a51eea026532b6d13fdcd310cab7e8484702514e5b256d6957f984107f2c2
data/doc/text/news.md CHANGED
@@ -1,5 +1,35 @@
1
1
  # NEWS
2
2
 
3
+ ## 12.0.2: 2022-04-04 {#version-12-0-2}
4
+
5
+ ### Improvements
6
+
7
+ * Added support for `:weight_float32` for vector column. This
8
+ requires Groonga 12.0.2 or later.
9
+
10
+ * Removed needless `Groonga::IndexColumn#with_weight?`.
11
+
12
+ * Added support for `:missing_mode` and `:invalid_mode` for scalar
13
+ column and vector column. This requires Groonga 12.0.2 or later.
14
+
15
+ ## 12.0.0: 2022-02-09 {#version-12-0-0}
16
+
17
+ ### Improvements
18
+
19
+ * Added support for Ruby 3.1.
20
+
21
+ ## 11.0.6: 2021-09-24 {#version-11-0-6}
22
+
23
+ ### Improvements
24
+
25
+ * Installed Groonga automatically when native package isn't
26
+ installed automatically.
27
+ [GitHub#204][Patch by skawaji]
28
+
29
+ ### Thanks
30
+
31
+ * skawaji
32
+
3
33
  ## 11.0.0: 2021-02-09 {#version-11-0-0}
4
34
 
5
35
  ### Improvements
@@ -231,6 +231,8 @@ unless PKGConfig.have_package(package_name, major, minor, micro)
231
231
  msys2: "groonga")
232
232
  need_auto_groonga_install =
233
233
  !PKGConfig.have_package(package_name, major, minor, micro)
234
+ else
235
+ need_auto_groonga_install = true
234
236
  end
235
237
  end
236
238
  if need_auto_groonga_install
@@ -1,7 +1,7 @@
1
1
  /* -*- coding: utf-8; mode: C; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2
2
  /* vim: set sts=4 sw=4 ts=8 noet: */
3
3
  /*
4
- Copyright (C) 2009-2021 Sutou Kouhei <kou@clear-code.com>
4
+ Copyright (C) 2009-2022 Sutou Kouhei <kou@clear-code.com>
5
5
  Copyright (C) 2016 Masafumi Yokoyama <yokoyama@clear-code.com>
6
6
 
7
7
  This library is free software; you can redistribute it and/or
@@ -714,7 +714,7 @@ rb_grn_column_data_p (VALUE self)
714
714
 
715
715
  /*
716
716
  * @overload with_weight?
717
- * @return [Boolean] @true@ if the column is vector and created with
717
+ * @return [Boolean] @true@ if the column is created with
718
718
  * @:with_weight => true@ flag, @false@ otherwise.
719
719
  * @since 4.0.1
720
720
  */
@@ -733,6 +733,26 @@ rb_grn_column_with_weight_p(VALUE self)
733
733
  return CBOOL2RVAL(flags & GRN_OBJ_WITH_WEIGHT);
734
734
  }
735
735
 
736
+ /*
737
+ * @overload weight_float32?
738
+ * @return [Boolean] @true@ if the column uses 32 bit float for weight.
739
+ * @since 12.0.2
740
+ */
741
+ static VALUE
742
+ rb_grn_column_weight_float32_p(VALUE self)
743
+ {
744
+ grn_obj *column;
745
+ grn_ctx *context;
746
+ grn_column_flags flags;
747
+
748
+ rb_grn_column_deconstruct(SELF(self), &column, &context,
749
+ NULL, NULL,
750
+ NULL, NULL, NULL);
751
+
752
+ flags = grn_column_get_flags(context, column);
753
+ return CBOOL2RVAL(flags & GRN_OBJ_WEIGHT_FLOAT32);
754
+ }
755
+
736
756
  /*
737
757
  * Return indexes on `column`. If operator is specified, indexes that
738
758
  * can executes the operator are only returned. Otherwise, all indexes
@@ -867,6 +887,8 @@ rb_grn_init_column (VALUE mGrn)
867
887
 
868
888
  rb_define_method(rb_cGrnColumn, "with_weight?",
869
889
  rb_grn_column_with_weight_p, 0);
890
+ rb_define_method(rb_cGrnColumn, "weight_float32?",
891
+ rb_grn_column_weight_float32_p, 0);
870
892
 
871
893
  rb_define_method(rb_cGrnColumn, "find_indexes",
872
894
  rb_grn_column_find_indexes, -1);
@@ -1,7 +1,7 @@
1
1
  /* -*- coding: utf-8; mode: C; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2
2
  /* vim: set sts=4 sw=4 ts=8 noet: */
3
3
  /*
4
- Copyright (C) 2016-2021 Sutou Kouhei <kou@clear-code.com>
4
+ Copyright (C) 2016-2022 Sutou Kouhei <kou@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
@@ -245,6 +245,180 @@ rb_grn_data_column_apply_expression (VALUE self)
245
245
  return self;
246
246
  }
247
247
 
248
+ /*
249
+ * @overload missing_mode
250
+ * @return [:add, :ignore, :nil] The missing mode of the column.
251
+ * @since 12.0.2
252
+ */
253
+ static VALUE
254
+ rb_grn_data_column_get_missing_mode(VALUE self)
255
+ {
256
+ grn_obj *column;
257
+ grn_ctx *context;
258
+ grn_column_flags flags;
259
+
260
+ rb_grn_column_deconstruct(SELF(self), &column, &context,
261
+ NULL, NULL,
262
+ NULL, NULL, NULL);
263
+
264
+ flags = grn_column_get_flags(context, column);
265
+ switch ((flags & GRN_OBJ_MISSING_MASK)) {
266
+ case GRN_OBJ_MISSING_IGNORE:
267
+ return rb_id2sym(rb_intern("ignore"));
268
+ case GRN_OBJ_MISSING_NIL:
269
+ return rb_id2sym(rb_intern("nil"));
270
+ default:
271
+ return rb_id2sym(rb_intern("add"));
272
+ }
273
+ }
274
+
275
+ /*
276
+ * @overload missing_add?
277
+ * @return [Boolean] @true@ if the column uses @:add@ missing mode.
278
+ * @since 12.0.2
279
+ */
280
+ static VALUE
281
+ rb_grn_data_column_missing_add_p(VALUE self)
282
+ {
283
+ grn_obj *column;
284
+ grn_ctx *context;
285
+ grn_column_flags flags;
286
+
287
+ rb_grn_column_deconstruct(SELF(self), &column, &context,
288
+ NULL, NULL,
289
+ NULL, NULL, NULL);
290
+
291
+ flags = grn_column_get_flags(context, column);
292
+ return CBOOL2RVAL((flags & GRN_OBJ_MISSING_MASK) == GRN_OBJ_MISSING_ADD);
293
+ }
294
+
295
+ /*
296
+ * @overload missing_ignore?
297
+ * @return [Boolean] @true@ if the column uses @:ignore@ missing mode.
298
+ * @since 12.0.2
299
+ */
300
+ static VALUE
301
+ rb_grn_data_column_missing_ignore_p(VALUE self)
302
+ {
303
+ grn_obj *column;
304
+ grn_ctx *context;
305
+ grn_column_flags flags;
306
+
307
+ rb_grn_column_deconstruct(SELF(self), &column, &context,
308
+ NULL, NULL,
309
+ NULL, NULL, NULL);
310
+
311
+ flags = grn_column_get_flags(context, column);
312
+ return CBOOL2RVAL((flags & GRN_OBJ_MISSING_MASK) == GRN_OBJ_MISSING_IGNORE);
313
+ }
314
+
315
+ /*
316
+ * @overload missing_nil?
317
+ * @return [Boolean] @true@ if the column uses @:nil@ missing mode.
318
+ * @since 12.0.2
319
+ */
320
+ static VALUE
321
+ rb_grn_data_column_missing_nil_p(VALUE self)
322
+ {
323
+ grn_obj *column;
324
+ grn_ctx *context;
325
+ grn_column_flags flags;
326
+
327
+ rb_grn_column_deconstruct(SELF(self), &column, &context,
328
+ NULL, NULL,
329
+ NULL, NULL, NULL);
330
+
331
+ flags = grn_column_get_flags(context, column);
332
+ return CBOOL2RVAL((flags & GRN_OBJ_MISSING_MASK) == GRN_OBJ_MISSING_NIL);
333
+ }
334
+
335
+ /*
336
+ * @overload invalid_mode
337
+ * @return [:error, :warn, :ignore] The invalid mode of the column.
338
+ * @since 12.0.2
339
+ */
340
+ static VALUE
341
+ rb_grn_data_column_get_invalid_mode(VALUE self)
342
+ {
343
+ grn_obj *column;
344
+ grn_ctx *context;
345
+ grn_column_flags flags;
346
+
347
+ rb_grn_column_deconstruct(SELF(self), &column, &context,
348
+ NULL, NULL,
349
+ NULL, NULL, NULL);
350
+
351
+ flags = grn_column_get_flags(context, column);
352
+ switch ((flags & GRN_OBJ_INVALID_MASK)) {
353
+ case GRN_OBJ_INVALID_WARN:
354
+ return rb_id2sym(rb_intern("warn"));
355
+ case GRN_OBJ_INVALID_IGNORE:
356
+ return rb_id2sym(rb_intern("ignore"));
357
+ default:
358
+ return rb_id2sym(rb_intern("error"));
359
+ }
360
+ }
361
+
362
+ /*
363
+ * @overload invalid_error?
364
+ * @return [Boolean] @true@ if the column uses @:error@ invalid mode.
365
+ * @since 12.0.2
366
+ */
367
+ static VALUE
368
+ rb_grn_data_column_invalid_error_p(VALUE self)
369
+ {
370
+ grn_obj *column;
371
+ grn_ctx *context;
372
+ grn_column_flags flags;
373
+
374
+ rb_grn_column_deconstruct(SELF(self), &column, &context,
375
+ NULL, NULL,
376
+ NULL, NULL, NULL);
377
+
378
+ flags = grn_column_get_flags(context, column);
379
+ return CBOOL2RVAL((flags & GRN_OBJ_INVALID_MASK) == GRN_OBJ_INVALID_ERROR);
380
+ }
381
+
382
+ /*
383
+ * @overload invalid_warn?
384
+ * @return [Boolean] @true@ if the column uses @:warn@ invalid mode.
385
+ * @since 12.0.2
386
+ */
387
+ static VALUE
388
+ rb_grn_data_column_invalid_warn_p(VALUE self)
389
+ {
390
+ grn_obj *column;
391
+ grn_ctx *context;
392
+ grn_column_flags flags;
393
+
394
+ rb_grn_column_deconstruct(SELF(self), &column, &context,
395
+ NULL, NULL,
396
+ NULL, NULL, NULL);
397
+
398
+ flags = grn_column_get_flags(context, column);
399
+ return CBOOL2RVAL((flags & GRN_OBJ_INVALID_MASK) == GRN_OBJ_INVALID_WARN);
400
+ }
401
+
402
+ /*
403
+ * @overload invalid_ignore?
404
+ * @return [Boolean] @true@ if the column uses @:ignore@ invalid mode.
405
+ * @since 12.0.2
406
+ */
407
+ static VALUE
408
+ rb_grn_data_column_invalid_ignore_p(VALUE self)
409
+ {
410
+ grn_obj *column;
411
+ grn_ctx *context;
412
+ grn_column_flags flags;
413
+
414
+ rb_grn_column_deconstruct(SELF(self), &column, &context,
415
+ NULL, NULL,
416
+ NULL, NULL, NULL);
417
+
418
+ flags = grn_column_get_flags(context, column);
419
+ return CBOOL2RVAL((flags & GRN_OBJ_INVALID_MASK) == GRN_OBJ_INVALID_IGNORE);
420
+ }
421
+
248
422
  void
249
423
  rb_grn_init_data_column (VALUE mGrn)
250
424
  {
@@ -255,6 +429,24 @@ rb_grn_init_data_column (VALUE mGrn)
255
429
  rb_define_method(rb_cGrnDataColumn, "apply_expression",
256
430
  rb_grn_data_column_apply_expression, 0);
257
431
 
432
+ rb_define_method(rb_cGrnDataColumn, "missing_mode",
433
+ rb_grn_data_column_get_missing_mode, 0);
434
+ rb_define_method(rb_cGrnDataColumn, "missing_add?",
435
+ rb_grn_data_column_missing_add_p, 0);
436
+ rb_define_method(rb_cGrnDataColumn, "missing_ignore?",
437
+ rb_grn_data_column_missing_ignore_p, 0);
438
+ rb_define_method(rb_cGrnDataColumn, "missing_nil?",
439
+ rb_grn_data_column_missing_nil_p, 0);
440
+
441
+ rb_define_method(rb_cGrnDataColumn, "invalid_mode",
442
+ rb_grn_data_column_get_invalid_mode, 0);
443
+ rb_define_method(rb_cGrnDataColumn, "invalid_error?",
444
+ rb_grn_data_column_invalid_error_p, 0);
445
+ rb_define_method(rb_cGrnDataColumn, "invalid_warn?",
446
+ rb_grn_data_column_invalid_warn_p, 0);
447
+ rb_define_method(rb_cGrnDataColumn, "invalid_ignore?",
448
+ rb_grn_data_column_invalid_ignore_p, 0);
449
+
258
450
  rb_grn_init_fix_size_column(mGrn);
259
451
  rb_grn_init_variable_size_column(mGrn);
260
452
  }
@@ -1,6 +1,6 @@
1
1
  /* -*- coding: utf-8; mode: C; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2
2
  /*
3
- Copyright (C) 2009-2020 Sutou Kouhei <kou@clear-code.com>
3
+ Copyright (C) 2009-2022 Sutou Kouhei <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,53 +21,55 @@
21
21
  VALUE rb_cGrnRecordExpressionBuilder;
22
22
  VALUE rb_cGrnColumnExpressionBuilder;
23
23
 
24
+ static ID id_build;
25
+ static ID id_call;
26
+ static ID id_new;
27
+
24
28
  VALUE
25
29
  rb_grn_record_expression_builder_new (VALUE table, VALUE name)
26
30
  {
27
31
  return rb_funcall(rb_cGrnRecordExpressionBuilder,
28
- rb_intern("new"), 2, table, name);
32
+ id_new, 2, table, name);
29
33
  }
30
34
 
31
35
  VALUE
32
36
  rb_grn_column_expression_builder_new (VALUE column, VALUE name, VALUE query)
33
37
  {
34
38
  return rb_funcall(rb_cGrnColumnExpressionBuilder,
35
- rb_intern("new"), 3, column, name, query);
36
- }
37
-
38
- static VALUE
39
- build (VALUE self)
40
- {
41
- return rb_funcall(self, rb_intern("build"), 0);
39
+ id_new, 3, column, name, query);
42
40
  }
43
41
 
44
42
  static VALUE
45
43
  build_block (RB_BLOCK_CALL_FUNC_ARGLIST(yielded_arg, callback_arg))
46
44
  {
47
- return rb_funcall(rb_block_proc(), rb_intern("call"), 1, yielded_arg);
45
+ return rb_funcall(rb_block_proc(), id_call, 1, yielded_arg);
48
46
  }
49
47
 
50
48
  VALUE
51
49
  rb_grn_record_expression_builder_build (VALUE self)
52
50
  {
53
51
  if (rb_block_given_p())
54
- return rb_iterate(build, self, build_block, self);
52
+ return rb_block_call(self, id_build, 0, NULL, build_block, self);
55
53
  else
56
- return build(self);
54
+ return rb_funcall(self, id_build, 0);
57
55
  }
58
56
 
59
57
  VALUE
60
58
  rb_grn_column_expression_builder_build (VALUE self)
61
59
  {
62
60
  if (rb_block_given_p())
63
- return rb_iterate(build, self, build_block, self);
61
+ return rb_block_call(self, id_build, 0, NULL, build_block, self);
64
62
  else
65
- return build(self);
63
+ return rb_funcall(self, id_build, 0);
66
64
  }
67
65
 
68
66
  void
69
67
  rb_grn_init_expression_builder (VALUE mGrn)
70
68
  {
69
+ id_build = rb_intern("build");
70
+ id_call = rb_intern("call");
71
+ id_new = rb_intern("new");
72
+
71
73
  rb_cGrnRecordExpressionBuilder =
72
74
  rb_const_get(mGrn, rb_intern("RecordExpressionBuilder"));
73
75
  rb_cGrnColumnExpressionBuilder =
@@ -1,6 +1,6 @@
1
1
  /* -*- coding: utf-8; mode: C; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2
2
  /*
3
- Copyright (C) 2009-2021 Sutou Kouhei <kou@clear-code.com>
3
+ Copyright (C) 2009-2022 Sutou Kouhei <kou@clear-code.com>
4
4
  Copyright (C) 2016 Masafumi Yokoyama <yokoyama@clear-code.com>
5
5
  Copyright (C) 2019 Horimoto Yasuhiro <horimoto@clear-code.com>
6
6
 
@@ -881,27 +881,6 @@ rb_grn_index_column_with_section_p (VALUE self)
881
881
  return CBOOL2RVAL(flags & GRN_OBJ_WITH_SECTION);
882
882
  }
883
883
 
884
- /*
885
- * _column_ がウェイト情報も格納する場合は +true+ を返します。
886
- *
887
- * @overload with_weight?
888
- */
889
- static VALUE
890
- rb_grn_index_column_with_weight_p (VALUE self)
891
- {
892
- grn_obj *column;
893
- grn_ctx *context;
894
- grn_column_flags flags;
895
-
896
- rb_grn_index_column_deconstruct(SELF(self), &column, &context,
897
- NULL, NULL,
898
- NULL, NULL, NULL, NULL, NULL,
899
- NULL, NULL);
900
-
901
- flags = grn_column_get_flags(context, column);
902
- return CBOOL2RVAL(flags & GRN_OBJ_WITH_WEIGHT);
903
- }
904
-
905
884
  /*
906
885
  * _column_ が位置情報も格納する場合は +true+ を返します。
907
886
  *
@@ -1460,8 +1439,6 @@ rb_grn_init_index_column (VALUE mGrn)
1460
1439
 
1461
1440
  rb_define_method(rb_cGrnIndexColumn, "with_section?",
1462
1441
  rb_grn_index_column_with_section_p, 0);
1463
- rb_define_method(rb_cGrnIndexColumn, "with_weight?",
1464
- rb_grn_index_column_with_weight_p, 0);
1465
1442
  rb_define_method(rb_cGrnIndexColumn, "with_position?",
1466
1443
  rb_grn_index_column_with_position_p, 0);
1467
1444
  rb_define_method(rb_cGrnIndexColumn, "small?",
@@ -1,6 +1,6 @@
1
1
  /* -*- coding: utf-8; mode: C; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2
2
  /*
3
- Copyright (C) 2017-2021 Sutou Kouhei <kou@clear-code.com>
3
+ Copyright (C) 2017-2022 Sutou Kouhei <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
@@ -56,6 +56,15 @@ static const rb_data_type_t rb_grn_inverted_index_cursor_type = {
56
56
  RUBY_TYPED_FREE_IMMEDIATELY,
57
57
  };
58
58
 
59
+ static VALUE
60
+ rb_grn_inverted_index_cursor_alloc (VALUE klass)
61
+ {
62
+ return TypedData_Wrap_Struct(klass,
63
+ &rb_grn_inverted_index_cursor_type,
64
+ NULL);
65
+ }
66
+
67
+
59
68
  VALUE
60
69
  rb_grn_inverted_index_cursor_to_ruby_object (grn_ctx *context,
61
70
  grn_ii_cursor *cursor,
@@ -256,6 +265,8 @@ rb_grn_init_inverted_index_cursor (VALUE mGrn)
256
265
  {
257
266
  rb_cGrnInvertedIndexCursor =
258
267
  rb_define_class_under(mGrn, "InvertedIndexCursor", rb_cObject);
268
+ rb_define_alloc_func(rb_cGrnInvertedIndexCursor,
269
+ rb_grn_inverted_index_cursor_alloc);
259
270
  rb_include_module(rb_cGrnInvertedIndexCursor, rb_mEnumerable);
260
271
 
261
272
  rb_define_method(rb_cGrnInvertedIndexCursor, "next",
@@ -1,6 +1,6 @@
1
1
  /* -*- coding: utf-8; mode: C; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2
2
  /*
3
- Copyright (C) 2009-2021 Sutou Kouhei <kou@clear-code.com>
3
+ Copyright (C) 2009-2022 Sutou Kouhei <kou@clear-code.com>
4
4
  Copyright (C) 2014-2016 Masafumi Yokoyama <yokoyama@clear-code.com>
5
5
  Copyright (C) 2019 Horimoto Yasuhiro <horimoto@clear-code.com>
6
6
 
@@ -927,6 +927,30 @@ rb_grn_object_inspect_content_flags_with_label (VALUE inspected,
927
927
  rb_ary_push(inspected_flags, rb_str_new_cstr("COLUMN_SCALAR"));
928
928
  } else if (column_flags & GRN_OBJ_COLUMN_VECTOR) {
929
929
  rb_ary_push(inspected_flags, rb_str_new_cstr("COLUMN_VECTOR"));
930
+ if (column_flags & GRN_OBJ_WITH_WEIGHT)
931
+ rb_ary_push(inspected_flags, rb_str_new_cstr("WITH_WEIGHT"));
932
+ if (column_flags & GRN_OBJ_WEIGHT_FLOAT32)
933
+ rb_ary_push(inspected_flags, rb_str_new_cstr("WEIGHT_FLOAT32"));
934
+ }
935
+ switch (column_flags & GRN_OBJ_MISSING_MASK) {
936
+ case GRN_OBJ_MISSING_IGNORE:
937
+ rb_ary_push(inspected_flags, rb_str_new_cstr("MISSING_IGNORE"));
938
+ break;
939
+ case GRN_OBJ_MISSING_NIL:
940
+ rb_ary_push(inspected_flags, rb_str_new_cstr("MISSING_NIL"));
941
+ break;
942
+ default:
943
+ break;
944
+ }
945
+ switch (column_flags & GRN_OBJ_INVALID_MASK) {
946
+ case GRN_OBJ_INVALID_WARN:
947
+ rb_ary_push(inspected_flags, rb_str_new_cstr("INVALID_WARN"));
948
+ break;
949
+ case GRN_OBJ_INVALID_IGNORE:
950
+ rb_ary_push(inspected_flags, rb_str_new_cstr("INVALID_IGNORE"));
951
+ break;
952
+ default:
953
+ break;
930
954
  }
931
955
  break;
932
956
  default:
@@ -1,6 +1,6 @@
1
1
  /* -*- coding: utf-8; mode: C; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2
2
  /*
3
- Copyright (C) 2016-2021 Sutou Kouhei <kou@clear-code.com>
3
+ Copyright (C) 2016-2022 Sutou Kouhei <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
@@ -38,6 +38,12 @@ static rb_data_type_t data_type = {
38
38
  0
39
39
  };
40
40
 
41
+ static VALUE
42
+ rb_grn_request_timer_id_alloc (VALUE klass)
43
+ {
44
+ return TypedData_Wrap_Struct(klass, &data_type, NULL);
45
+ }
46
+
41
47
  void *
42
48
  rb_grn_request_timer_id_from_ruby_object (VALUE rb_id)
43
49
  {
@@ -61,4 +67,6 @@ rb_grn_init_request_timer_id (VALUE mGrn)
61
67
  {
62
68
  rb_cGrnRequestTimerID =
63
69
  rb_define_class_under(mGrn, "RequestTimerID", rb_cObject);
70
+ rb_define_alloc_func(rb_cGrnRequestTimerID,
71
+ rb_grn_request_timer_id_alloc);
64
72
  }
@@ -1,6 +1,6 @@
1
1
  /* -*- coding: utf-8; mode: C; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2
2
  /*
3
- Copyright (C) 2009-2021 Sutou Kouhei <kou@clear-code.com>
3
+ Copyright (C) 2009-2022 Sutou Kouhei <kou@clear-code.com>
4
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
@@ -344,7 +344,7 @@ rb_grn_table_key_support_get_key (VALUE self, VALUE rb_id)
344
344
  if (key_size == 0)
345
345
  return Qnil;
346
346
 
347
- if (GRN_BULK_VSIZE(key) < key_size) {
347
+ if (GRN_BULK_VSIZE(key) < (size_t)key_size) {
348
348
  grn_bulk_reserve(context, key, key_size);
349
349
  grn_table_get_key(context, table, id, GRN_BULK_HEAD(key), key_size);
350
350
  }
@@ -540,7 +540,11 @@ rb_grn_table_key_support_array_set (VALUE self, VALUE rb_key, VALUE rb_values)
540
540
  data.id = id;
541
541
  data.table = table;
542
542
  data.rb_grn_object.context = context;
543
- rb_iterate(rb_each, rb_values, set_value, (VALUE)&data);
543
+ {
544
+ ID id_each;
545
+ CONST_ID(id_each, "each");
546
+ rb_block_call(rb_values, id_each, 0, NULL, set_value, (VALUE)&data);
547
+ }
544
548
 
545
549
  return Qnil;
546
550
  }
@@ -1,6 +1,6 @@
1
1
  /* -*- coding: utf-8; mode: C; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2
2
  /*
3
- Copyright (C) 2009-2021 Sutou Kouhei <kou@clear-code.com>
3
+ Copyright (C) 2009-2022 Sutou Kouhei <kou@clear-code.com>
4
4
  Copyright (C) 2014-2016 Masafumi Yokoyama <yokoyama@clear-code.com>
5
5
  Copyright (C) 2019 Horimoto Yasuhiro <horimoto@clear-code.com>
6
6
 
@@ -255,6 +255,36 @@ rb_grn_table_inspect (VALUE self)
255
255
  * * `:lz4`: Compressed by LZ4.
256
256
  * * `:zstd`: Compressed by Zstandard.
257
257
  * * `:zstandard`: Compressed by Zstandard.
258
+ * @option options :weight_float32 [Boolean] (false)
259
+ * It specifies whether weight is stored as 32 bit float or not.
260
+ *
261
+ * You can't use this option for scalar column.
262
+ *
263
+ * @since 12.0.2
264
+ * @option options [:add, :ignore, :nil, nil] :missing_mode (nil)
265
+ * It specifies how to process missing value.
266
+ *
267
+ * * `:add`, `nil`: Correspond to `MISSING_ADD`
268
+ * * `:ignore`: Correspond to `MISSING_IGNORE`
269
+ * * `:nil`: Correspond to `MISSING_NIL`
270
+ *
271
+ * See
272
+ * https://groonga.org/docs/reference/commands/column_create.html#column-create-missing-mode
273
+ * for each `MISSING_*` values.
274
+ *
275
+ * @since 12.0.2
276
+ * @option options [:error, :warn, :ignore, nil] :invalid_mode (nil)
277
+ * It specifies how to process invalid value.
278
+ *
279
+ * * `:add`, `nil`: Correspond to `INVALID_ERROR`
280
+ * * `:warn`: Correspond to `INVALID_WARN`
281
+ * * `:ignore`: Correspond to `INVALID_IGNORE`
282
+ *
283
+ * See
284
+ * https://groonga.org/docs/reference/commands/column_create.html#column-create-invalid-mode
285
+ * for each `INVALID_*` values.
286
+ *
287
+ * @since 12.0.2
258
288
  *
259
289
  * @return [Groonga::FixSizeColumn, Groonga::VariableSizeColumn]
260
290
  */
@@ -269,6 +299,9 @@ rb_grn_table_define_column (int argc, VALUE *argv, VALUE self)
269
299
  grn_column_flags flags = 0;
270
300
  VALUE rb_name, rb_value_type;
271
301
  VALUE options, rb_path, rb_persistent, rb_compress, rb_type, rb_with_weight;
302
+ VALUE rb_weight_float32;
303
+ VALUE rb_missing_mode;
304
+ VALUE rb_invalid_mode;
272
305
  VALUE columns;
273
306
  VALUE rb_column;
274
307
 
@@ -288,6 +321,9 @@ rb_grn_table_define_column (int argc, VALUE *argv, VALUE self)
288
321
  "type", &rb_type,
289
322
  "with_weight", &rb_with_weight,
290
323
  "compress", &rb_compress,
324
+ "weight_float32", &rb_weight_float32,
325
+ "missing_mode", &rb_missing_mode,
326
+ "invalid_mode", &rb_invalid_mode,
291
327
  NULL);
292
328
 
293
329
  value_type = RVAL2GRNOBJECT(rb_value_type, &context);
@@ -347,6 +383,43 @@ rb_grn_table_define_column (int argc, VALUE *argv, VALUE self)
347
383
  rb_grn_inspect(rb_compress));
348
384
  }
349
385
 
386
+ if (RVAL2CBOOL(rb_weight_float32)) {
387
+ if (flags & GRN_OBJ_COLUMN_VECTOR) {
388
+ flags |= GRN_OBJ_WEIGHT_FLOAT32;
389
+ } else {
390
+ rb_raise(rb_eArgError,
391
+ "can't use 32 bit float weight for scalar column");
392
+ }
393
+ }
394
+
395
+ if (NIL_P(rb_missing_mode) ||
396
+ rb_grn_equal_option(rb_missing_mode, "add")) {
397
+ flags |= GRN_OBJ_MISSING_ADD;
398
+ } else if (rb_grn_equal_option(rb_missing_mode, "ignore")) {
399
+ flags |= GRN_OBJ_MISSING_IGNORE;
400
+ } else if (rb_grn_equal_option(rb_missing_mode, "nil")) {
401
+ flags |= GRN_OBJ_MISSING_NIL;
402
+ } else {
403
+ rb_raise(rb_eArgError,
404
+ "invalid missing mode: %s: "
405
+ "available types: [:add, :ignore, :nil, nil]",
406
+ rb_grn_inspect(rb_missing_mode));
407
+ }
408
+
409
+ if (NIL_P(rb_invalid_mode) ||
410
+ rb_grn_equal_option(rb_invalid_mode, "error")) {
411
+ flags |= GRN_OBJ_INVALID_ERROR;
412
+ } else if (rb_grn_equal_option(rb_invalid_mode, "warn")) {
413
+ flags |= GRN_OBJ_INVALID_WARN;
414
+ } else if (rb_grn_equal_option(rb_invalid_mode, "ignore")) {
415
+ flags |= GRN_OBJ_INVALID_IGNORE;
416
+ } else {
417
+ rb_raise(rb_eArgError,
418
+ "invalid invalid mode: %s: "
419
+ "available types: [:add, :warn, :ignore, nil]",
420
+ rb_grn_inspect(rb_invalid_mode));
421
+ }
422
+
350
423
  column = grn_column_create(context, table, name, name_size,
351
424
  path, flags, value_type);
352
425
  if (context->rc) {