rroonga 12.0.0 → 12.0.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 79bff23494809c1f6cf740acf2151f06889ad139828c4c4baad981d3bf998127
4
- data.tar.gz: 04476d31b9221f714880ebb3e36532cbcdca343d715d4202ececac2d3bff7ec8
3
+ metadata.gz: 9e1afd17d5a479b6e5c472729d3548f3551b15cec0db30bbf46f8a43266d96a1
4
+ data.tar.gz: 05b218925dfbf29f4deb9d34c5ab6408cbcecdf11de588d2c8d45efaf0e28417
5
5
  SHA512:
6
- metadata.gz: ca0f800a11f9cb6135d5117d0cbed6d349d590178b8d2f0aafe7766f0a89148defadd77055392e1c556550850faf254299487367a9a1b1bb119d971f285f9058
7
- data.tar.gz: a831fc078b87ba358730984240556cc2063bc185e3e00f3a2cb2789ba6d51aa4c543ea167a6f8da7cca086c0daddffa24eb455e18866adf61055cadcfa8927d9
6
+ metadata.gz: ce775711f0f90338164a3f5c3f5c7731b9f8d06e8563836f0adb7de325f471d43d9be5bb09a428f2598e801dca502564fbea3b9cb285bb38d8f7310cd22a7251
7
+ data.tar.gz: fe208b1bf0ee5e04fbccbe6220b2b0b44e80e9825c8b9aaab86017d7d87de8185a7a51eea026532b6d13fdcd310cab7e8484702514e5b256d6957f984107f2c2
data/doc/text/news.md CHANGED
@@ -1,5 +1,17 @@
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
+
3
15
  ## 12.0.0: 2022-02-09 {#version-12-0-0}
4
16
 
5
17
  ### Improvements
@@ -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) {
@@ -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
@@ -193,23 +193,24 @@ rb_grn_variable_size_column_array_reference (VALUE self, VALUE rb_id)
193
193
  rb_value = rb_ary_new2(n);
194
194
  for (i = 0; i < n; i++) {
195
195
  VALUE rb_element_value;
196
- unsigned int weight = 0;
196
+ float weight = 0.0;
197
197
  grn_id domain;
198
198
  VALUE rb_element;
199
199
 
200
200
  if (value->header.type == GRN_UVECTOR) {
201
201
  grn_id id;
202
- id = grn_uvector_get_element(context, value, i, &weight);
202
+ id = grn_uvector_get_element_record(context, value, i, &weight);
203
203
  rb_element_value = rb_grn_record_new(rb_range, id, Qnil);
204
204
  } else {
205
205
  const char *element_value;
206
206
  unsigned int element_value_length;
207
- element_value_length = grn_vector_get_element(context,
208
- value,
209
- i,
210
- &element_value,
211
- &weight,
212
- &domain);
207
+ element_value_length =
208
+ grn_vector_get_element_float(context,
209
+ value,
210
+ i,
211
+ &element_value,
212
+ &weight,
213
+ &domain);
213
214
  rb_element_value = rb_str_new(element_value, element_value_length);
214
215
  }
215
216
 
@@ -217,9 +218,15 @@ rb_grn_variable_size_column_array_reference (VALUE self, VALUE rb_id)
217
218
  rb_hash_aset(rb_element,
218
219
  RB_GRN_INTERN("value"),
219
220
  rb_element_value);
220
- rb_hash_aset(rb_element,
221
- RB_GRN_INTERN("weight"),
222
- UINT2NUM(weight));
221
+ if (flags & GRN_OBJ_WEIGHT_FLOAT32) {
222
+ rb_hash_aset(rb_element,
223
+ RB_GRN_INTERN("weight"),
224
+ rb_float_new(weight));
225
+ } else {
226
+ rb_hash_aset(rb_element,
227
+ RB_GRN_INTERN("weight"),
228
+ UINT2NUM((uint32_t)weight));
229
+ }
223
230
 
224
231
  rb_ary_push(rb_value, rb_element);
225
232
  }
@@ -240,22 +247,22 @@ hash_element_to_vector_element(VALUE key, VALUE value, VALUE user_data)
240
247
  {
241
248
  HashElementToVectorElementData *data =
242
249
  (HashElementToVectorElementData *)user_data;
243
- unsigned int weight;
250
+ float weight;
244
251
 
245
- weight = NUM2UINT(value);
252
+ weight = (float)NUM2DBL(value);
246
253
 
247
254
  if (data->vector->header.type == GRN_UVECTOR) {
248
255
  grn_id id = RVAL2GRNID(key, data->context, data->range, data->self);
249
- grn_uvector_add_element(data->context, data->vector, id, weight);
256
+ grn_uvector_add_element_record(data->context, data->vector, id, weight);
250
257
  } else {
251
258
  GRN_BULK_REWIND(data->element_value);
252
259
  RVAL2GRNBULK(key, data->context, data->element_value);
253
260
 
254
- grn_vector_add_element(data->context, data->vector,
255
- GRN_BULK_HEAD(data->element_value),
256
- GRN_BULK_VSIZE(data->element_value),
257
- weight,
258
- data->element_value->header.domain);
261
+ grn_vector_add_element_float(data->context, data->vector,
262
+ GRN_BULK_HEAD(data->element_value),
263
+ GRN_BULK_VSIZE(data->element_value),
264
+ weight,
265
+ data->element_value->header.domain);
259
266
  }
260
267
 
261
268
  return ST_CONTINUE;
@@ -405,7 +412,7 @@ rb_grn_variable_size_column_array_set (VALUE self, VALUE rb_id, VALUE rb_value)
405
412
  int i, n;
406
413
  n = RARRAY_LEN(rb_value);
407
414
  for (i = 0; i < n; i++) {
408
- unsigned int weight = 0;
415
+ float weight = 0;
409
416
  VALUE rb_element_value, rb_weight;
410
417
 
411
418
  rb_grn_scan_options(RARRAY_PTR(rb_value)[i],
@@ -414,23 +421,23 @@ rb_grn_variable_size_column_array_set (VALUE self, VALUE rb_id, VALUE rb_value)
414
421
  NULL);
415
422
 
416
423
  if (!NIL_P(rb_weight)) {
417
- weight = NUM2UINT(rb_weight);
424
+ weight = (float)NUM2DBL(rb_weight);
418
425
  }
419
426
 
420
427
  if (value->header.type == GRN_UVECTOR) {
421
428
  grn_id id = RVAL2GRNID(rb_element_value, context, range, self);
422
- grn_uvector_add_element(context, value, id, weight);
429
+ grn_uvector_add_element_record(context, value, id, weight);
423
430
  } else {
424
431
  GRN_BULK_REWIND(element_value);
425
432
  if (!NIL_P(rb_element_value)) {
426
433
  RVAL2GRNBULK(rb_element_value, context, element_value);
427
434
  }
428
435
 
429
- grn_vector_add_element(context, value,
430
- GRN_BULK_HEAD(element_value),
431
- GRN_BULK_VSIZE(element_value),
432
- weight,
433
- element_value->header.domain);
436
+ grn_vector_add_element_float(context, value,
437
+ GRN_BULK_HEAD(element_value),
438
+ GRN_BULK_VSIZE(element_value),
439
+ weight,
440
+ element_value->header.domain);
434
441
  }
435
442
  }
436
443
  } else if (RVAL2CBOOL(rb_obj_is_kind_of(rb_value, rb_cHash))) {
data/ext/groonga/rb-grn.h CHANGED
@@ -93,7 +93,7 @@ RB_GRN_BEGIN_DECLS
93
93
 
94
94
  #define RB_GRN_MAJOR_VERSION 12
95
95
  #define RB_GRN_MINOR_VERSION 0
96
- #define RB_GRN_MICRO_VERSION 0
96
+ #define RB_GRN_MICRO_VERSION 2
97
97
 
98
98
  #define RB_GRN_OBJECT(object) ((RbGrnObject *)(object))
99
99
  #define RB_GRN_NAMED_OBJECT(object) ((RbGrnNamedObject *)(object))
@@ -1,6 +1,4 @@
1
- # -*- coding: utf-8 -*-
2
- #
3
- # Copyright (C) 2009-2016 Kouhei Sutou <kou@clear-code.com>
1
+ # Copyright (C) 2009-2022 Sutou Kouhei <kou@clear-code.com>
4
2
  # Copyright (C) 2014-2015 Masafumi Yokoyama <yokoyama@clear-code.com>
5
3
  #
6
4
  # This library is free software; you can redistribute it and/or
@@ -867,6 +865,36 @@ module Groonga
867
865
  # * `:lz4`: Compzressed by LZ4.
868
866
  # * `:zstd`: Compressed by Zstandard.
869
867
  # * `:zstandard`: Compressed by Zstandard.
868
+ # @option options [Boolean] :weight_float32 (false)
869
+ # It specifies whether the column uses 32 bit float for weight or not.
870
+ #
871
+ # You can't use this option for scalar column.
872
+ #
873
+ # @since 12.0.2
874
+ # @option options [:add, :ignore, :nil, nil] :missing_mode (nil)
875
+ # It specifies how to process missing value.
876
+ #
877
+ # * `:add`, `nil`: Correspond to `MISSING_ADD`
878
+ # * `:ignore`: Correspond to `MISSING_IGNORE`
879
+ # * `:nil`: Correspond to `MISSING_NIL`
880
+ #
881
+ # See
882
+ # https://groonga.org/docs/reference/commands/column_create.html#column-create-missing-mode
883
+ # for each `MISSING_*` values.
884
+ #
885
+ # @since 12.0.2
886
+ # @option options [:error, :warn, :ignore, nil] :invalid_mode (nil)
887
+ # It specifies how to process invalid value.
888
+ #
889
+ # * `:add`, `nil`: Correspond to `INVALID_ERROR`
890
+ # * `:warn`: Correspond to `INVALID_WARN`
891
+ # * `:ignore`: Correspond to `INVALID_IGNORE`
892
+ #
893
+ # See
894
+ # https://groonga.org/docs/reference/commands/column_create.html#column-create-invalid-mode
895
+ # for each `INVALID_*` values.
896
+ #
897
+ # @since 12.0.2
870
898
  def column(name, type, options={})
871
899
  definition = self[name, ColumnDefinition]
872
900
  if definition.nil?
@@ -1540,6 +1568,9 @@ module Groonga
1540
1568
  :type => @options[:type],
1541
1569
  :with_weight => @options[:with_weight],
1542
1570
  :compress => @options[:compress],
1571
+ :weight_float32 => @options[:weight_float32],
1572
+ :missing_mode => @options[:missing_mode],
1573
+ :invalid_mode => @options[:invalid_mode],
1543
1574
  }
1544
1575
  end
1545
1576
 
data/rroonga-build.rb CHANGED
@@ -1,4 +1,4 @@
1
- # Copyright (C) 2009-2021 Kouhei Sutou <kou@clear-code.com>
1
+ # Copyright (C) 2009-2022 Sutou Kouhei <kou@clear-code.com>
2
2
  # Copyright (C) 2015-2017 Masafumi Yokoyama <yokoyama@clear-code.com>
3
3
  #
4
4
  # This library is free software; you can redistribute it and/or
@@ -16,12 +16,12 @@
16
16
 
17
17
  module RroongaBuild
18
18
  module RequiredGroongaVersion
19
- MAJOR = 11
19
+ MAJOR = 12
20
20
  MINOR = 0
21
- MICRO = 0
21
+ MICRO = 2
22
22
  VERSION = [MAJOR, MINOR, MICRO]
23
23
  STRING = VERSION.join(".")
24
- RELEASED_DATE = Time.utc(2021, 2, 9)
24
+ RELEASED_DATE = Time.utc(2022, 3, 29)
25
25
  end
26
26
 
27
27
  module_function
data/test/test-column.rb CHANGED
@@ -1,4 +1,4 @@
1
- # Copyright (C) 2009-2020 Sutou Kouhei <kou@clear-code.com>
1
+ # Copyright (C) 2009-2022 Sutou Kouhei <kou@clear-code.com>
2
2
  # Copyright (C) 2016 Masafumi Yokoyama <yokoyama@clear-code.com>
3
3
  #
4
4
  # This library is free software; you can redistribute it and/or
@@ -431,12 +431,19 @@ class ColumnTest < Test::Unit::TestCase
431
431
  def setup_schema
432
432
  Groonga::Schema.define do |schema|
433
433
  schema.create_table("Shops", :type => :hash) do |table|
434
- table.short_text("tags", :type => :vector)
434
+ table.short_text("tags",
435
+ type: :vector,
436
+ with_weight: true)
437
+ table.short_text("tags_float32",
438
+ type: :vector,
439
+ with_weight: true,
440
+ weight_float32: true)
435
441
  end
436
442
 
437
443
  schema.create_table("Tags",
438
444
  :type => :patricia_trie) do |table|
439
- table.index("Shops.tags", :with_weight => true)
445
+ table.index("Shops.tags",
446
+ with_weight: true)
440
447
  end
441
448
  end
442
449
 
@@ -453,6 +460,33 @@ class ColumnTest < Test::Unit::TestCase
453
460
  select_by_tag("curry"))
454
461
  end
455
462
 
463
+ def test_vector_weight_float32
464
+ @shops.add("Soul Food India",
465
+ :tags_float32 => [
466
+ {:value => "curry", :weight => 11.1},
467
+ {:value => "hot", :weight => 33.3},
468
+ ])
469
+ actual = @shops.collect do |shop|
470
+ attributes = shop.attributes
471
+ attributes["tags_float32"].each do |tag|
472
+ tag[:weight] = tag[:weight].round(1)
473
+ end
474
+ attributes
475
+ end
476
+ assert_equal([
477
+ {
478
+ "_id" => 1,
479
+ "_key" => "Soul Food India",
480
+ "tags" => [],
481
+ "tags_float32" => [
482
+ {:value => "curry", :weight => 11.1},
483
+ {:value => "hot", :weight => 33.3},
484
+ ]
485
+ },
486
+ ],
487
+ actual)
488
+ end
489
+
456
490
  def test_offline_index
457
491
  @shops.add("Soul Food India",
458
492
  :tags => [
@@ -1,4 +1,4 @@
1
- # Copyright (C) 2016-2017 Kouhei Sutou <kou@clear-code.com>
1
+ # Copyright (C) 2016-2022 Sutou Kouhei <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
@@ -119,4 +119,198 @@ class DataColumnTest < Test::Unit::TestCase
119
119
  comments.collect {|comment| [comment.base, comment.plus1]})
120
120
  end
121
121
  end
122
+
123
+ sub_test_case "#missing_mode" do
124
+ def test_add
125
+ Groonga::Schema.define do |schema|
126
+ schema.create_table("Tags",
127
+ type: :hash,
128
+ key_type: :short_text) do |table|
129
+ end
130
+ schema.create_table("Memos") do |table|
131
+ table.reference("tags",
132
+ "Tags",
133
+ type: :vector,
134
+ missing_mode: :add)
135
+ end
136
+ end
137
+ memos = Groonga["Memos"]
138
+ memos_tags = Groonga["Memos.tags"]
139
+ tags = Groonga["Tags"]
140
+
141
+ record = memos.add(tags: ["nonexistent"])
142
+
143
+ assert_equal({
144
+ missing_mode: :add,
145
+ missing_add: true,
146
+ missing_ignore: false,
147
+ missing_nil: false,
148
+ values: [tags["nonexistent"]],
149
+ },
150
+ {
151
+ missing_mode: memos_tags.missing_mode,
152
+ missing_add: memos_tags.missing_add?,
153
+ missing_ignore: memos_tags.missing_ignore?,
154
+ missing_nil: memos_tags.missing_nil?,
155
+ values: record.tags,
156
+ })
157
+ end
158
+
159
+ def test_ignore
160
+ Groonga::Schema.define do |schema|
161
+ schema.create_table("Tags",
162
+ type: :hash,
163
+ key_type: :short_text) do |table|
164
+ end
165
+ schema.create_table("Memos") do |table|
166
+ table.reference("tags",
167
+ "Tags",
168
+ type: :vector,
169
+ missing_mode: :ignore)
170
+ end
171
+ end
172
+ memos = Groonga["Memos"]
173
+ memos_tags = Groonga["Memos.tags"]
174
+
175
+ record = memos.add(tags: ["nonexistent"])
176
+
177
+ assert_equal({
178
+ missing_mode: :ignore,
179
+ missing_add: false,
180
+ missing_ignore: true,
181
+ missing_nil: false,
182
+ values: [],
183
+ },
184
+ {
185
+ missing_mode: memos_tags.missing_mode,
186
+ missing_add: memos_tags.missing_add?,
187
+ missing_ignore: memos_tags.missing_ignore?,
188
+ missing_nil: memos_tags.missing_nil?,
189
+ values: record.tags,
190
+ })
191
+ end
192
+
193
+ def test_nil
194
+ Groonga::Schema.define do |schema|
195
+ schema.create_table("Tags",
196
+ type: :hash,
197
+ key_type: :short_text) do |table|
198
+ end
199
+ schema.create_table("Memos") do |table|
200
+ table.reference("tags",
201
+ "Tags",
202
+ type: :vector,
203
+ missing_mode: :nil,
204
+ invalid_mode: :ignore)
205
+ end
206
+ end
207
+ memos = Groonga["Memos"]
208
+ memos_tags = Groonga["Memos.tags"]
209
+
210
+ record = memos.add(tags: ["nonexistent"])
211
+
212
+ assert_equal({
213
+ missing_mode: :nil,
214
+ missing_add: false,
215
+ missing_ignore: false,
216
+ missing_nil: true,
217
+ values: [nil],
218
+ },
219
+ {
220
+ missing_mode: memos_tags.missing_mode,
221
+ missing_add: memos_tags.missing_add?,
222
+ missing_ignore: memos_tags.missing_ignore?,
223
+ missing_nil: memos_tags.missing_nil?,
224
+ values: record.tags,
225
+ })
226
+ end
227
+ end
228
+
229
+ sub_test_case "#invalid_mode" do
230
+ def test_error
231
+ Groonga::Schema.define do |schema|
232
+ schema.create_table("Memos") do |table|
233
+ table.uint32("count", invalid_mode: :error)
234
+ end
235
+ end
236
+ memos = Groonga["Memos"]
237
+ memos_count = Groonga["Memos.count"]
238
+
239
+ record = memos.add
240
+ assert_raise(Groonga::InvalidArgument) do
241
+ record.count = "invalid"
242
+ end
243
+
244
+ assert_equal({
245
+ invalid_mode: :error,
246
+ invalid_error: true,
247
+ invalid_warn: false,
248
+ invalid_ignore: false,
249
+ value: 0,
250
+ },
251
+ {
252
+ invalid_mode: memos_count.invalid_mode,
253
+ invalid_error: memos_count.invalid_error?,
254
+ invalid_warn: memos_count.invalid_warn?,
255
+ invalid_ignore: memos_count.invalid_ignore?,
256
+ value: record.count,
257
+ })
258
+ end
259
+
260
+ def test_warn
261
+ Groonga::Schema.define do |schema|
262
+ schema.create_table("Memos") do |table|
263
+ table.uint32("count", invalid_mode: :warn)
264
+ end
265
+ end
266
+ memos = Groonga["Memos"]
267
+ memos_count = Groonga["Memos.count"]
268
+
269
+ record = memos.add
270
+ record.count = "invalid"
271
+
272
+ assert_equal({
273
+ invalid_mode: :warn,
274
+ invalid_error: false,
275
+ invalid_warn: true,
276
+ invalid_ignore: false,
277
+ value: 0,
278
+ },
279
+ {
280
+ invalid_mode: memos_count.invalid_mode,
281
+ invalid_error: memos_count.invalid_error?,
282
+ invalid_warn: memos_count.invalid_warn?,
283
+ invalid_ignore: memos_count.invalid_ignore?,
284
+ value: record.count,
285
+ })
286
+ end
287
+
288
+ def test_ignore
289
+ Groonga::Schema.define do |schema|
290
+ schema.create_table("Memos") do |table|
291
+ table.uint32("count", invalid_mode: :ignore)
292
+ end
293
+ end
294
+ memos = Groonga["Memos"]
295
+ memos_count = Groonga["Memos.count"]
296
+
297
+ record = memos.add
298
+ record.count = "invalid"
299
+
300
+ assert_equal({
301
+ invalid_mode: :ignore,
302
+ invalid_error: false,
303
+ invalid_warn: false,
304
+ invalid_ignore: true,
305
+ value: 0,
306
+ },
307
+ {
308
+ invalid_mode: memos_count.invalid_mode,
309
+ invalid_error: memos_count.invalid_error?,
310
+ invalid_warn: memos_count.invalid_warn?,
311
+ invalid_ignore: memos_count.invalid_ignore?,
312
+ value: record.count,
313
+ })
314
+ end
315
+ end
122
316
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rroonga
3
3
  version: !ruby/object:Gem::Version
4
- version: 12.0.0
4
+ version: 12.0.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Kouhei Sutou
@@ -12,7 +12,7 @@ authors:
12
12
  autorequire:
13
13
  bindir: bin
14
14
  cert_chain: []
15
- date: 2022-02-09 00:00:00.000000000 Z
15
+ date: 2022-04-04 00:00:00.000000000 Z
16
16
  dependencies:
17
17
  - !ruby/object:Gem::Dependency
18
18
  name: groonga-client
@@ -166,10 +166,10 @@ email:
166
166
  - y.hayamizu@gmail.com
167
167
  - dara@shidara.net
168
168
  executables:
169
+ - grndump
169
170
  - grntest-log-analyze
170
- - groonga-index-dump
171
171
  - groonga-database-inspect
172
- - grndump
172
+ - groonga-index-dump
173
173
  extensions:
174
174
  - ext/groonga/extconf.rb
175
175
  extra_rdoc_files:
@@ -370,7 +370,7 @@ homepage: http://ranguba.org/#about-rroonga
370
370
  licenses:
371
371
  - LGPL-2.1
372
372
  metadata:
373
- msys2_mingw_dependencies: groonga>=11.0.0
373
+ msys2_mingw_dependencies: groonga>=12.0.2
374
374
  post_install_message:
375
375
  rdoc_options: []
376
376
  require_paths:
@@ -387,80 +387,80 @@ required_rubygems_version: !ruby/object:Gem::Requirement
387
387
  - !ruby/object:Gem::Version
388
388
  version: '0'
389
389
  requirements: []
390
- rubygems_version: 3.1.6
390
+ rubygems_version: 3.4.0.dev
391
391
  signing_key:
392
392
  specification_version: 4
393
393
  summary: Ruby bindings for Groonga that provide full text search and column store
394
394
  features.
395
395
  test_files:
396
- - test/test-table-dumper.rb
397
- - test/test-query-logger.rb
398
- - test/test-variable-size-column.rb
399
- - test/test-schema-dumper.rb
400
- - test/test-double-array-trie.rb
401
- - test/test-expression-builder.rb
396
+ - test/groonga-test-utils.rb
397
+ - test/run-test.rb
398
+ - test/test-accessor.rb
402
399
  - test/test-array.rb
403
- - test/test-id.rb
404
- - test/test-table-key-support.rb
400
+ - test/test-column-cache.rb
401
+ - test/test-column.rb
402
+ - test/test-command-select.rb
403
+ - test/test-config.rb
404
+ - test/test-context.rb
405
+ - test/test-convert.rb
406
+ - test/test-data-column.rb
405
407
  - test/test-database-dumper.rb
408
+ - test/test-database-inspector.rb
409
+ - test/test-database.rb
410
+ - test/test-default-cache.rb
411
+ - test/test-double-array-trie.rb
412
+ - test/test-encoding.rb
413
+ - test/test-error-message.rb
414
+ - test/test-exception.rb
415
+ - test/test-expression-builder.rb
406
416
  - test/test-expression.rb
417
+ - test/test-fix-size-column.rb
418
+ - test/test-flushable.rb
419
+ - test/test-geo-point.rb
420
+ - test/test-gqtp.rb
421
+ - test/test-hash.rb
422
+ - test/test-id.rb
423
+ - test/test-index-column.rb
424
+ - test/test-index-cursor.rb
425
+ - test/test-lock-timeout.rb
407
426
  - test/test-logger.rb
408
- - test/run-test.rb
409
- - test/test-windows-event-logger.rb
410
- - test/test-vector-column.rb
427
+ - test/test-memory-pool.rb
428
+ - test/test-name.rb
429
+ - test/test-normalizer.rb
411
430
  - test/test-operator.rb
412
- - test/test-table.rb
413
- - test/test-table-group.rb
414
- - test/test-column.rb
431
+ - test/test-package-label.rb
415
432
  - test/test-pagination.rb
416
- - test/test-error-message.rb
417
- - test/test-fix-size-column.rb
418
- - test/test-table-arrow.rb
419
- - test/test-sub-records.rb
420
- - test/test-table-select-normalize.rb
421
- - test/test-config.rb
422
433
  - test/test-patricia-trie.rb
423
- - test/test-gqtp.rb
424
- - test/test-memory-pool.rb
434
+ - test/test-plugin.rb
435
+ - test/test-procedure.rb
436
+ - test/test-query-logger.rb
437
+ - test/test-ractor.rb
438
+ - test/test-record.rb
439
+ - test/test-remote.rb
440
+ - test/test-request-canceler.rb
441
+ - test/test-request-timer.rb
425
442
  - test/test-schema-create-table.rb
443
+ - test/test-schema-dumper.rb
444
+ - test/test-schema-type.rb
426
445
  - test/test-schema.rb
427
- - test/test-column-cache.rb
428
- - test/test-command-select.rb
429
- - test/test-lock-timeout.rb
430
- - test/test-request-canceler.rb
431
- - test/test-default-cache.rb
432
- - test/test-database.rb
433
- - test/test-token-regexp.rb
446
+ - test/test-snippet.rb
447
+ - test/test-sub-records.rb
448
+ - test/test-table-arrow.rb
449
+ - test/test-table-dumper.rb
450
+ - test/test-table-group.rb
451
+ - test/test-table-key-support.rb
452
+ - test/test-table-offset-and-limit.rb
453
+ - test/test-table-select-mecab.rb
454
+ - test/test-table-select-normalize.rb
434
455
  - test/test-table-select-weight.rb
435
- - test/test-database-inspector.rb
436
- - test/test-encoding.rb
437
- - test/test-hash.rb
438
- - test/test-schema-type.rb
439
- - test/test-type.rb
440
- - test/test-context.rb
441
- - test/test-flushable.rb
442
- - test/test-normalizer.rb
443
456
  - test/test-table-select.rb
444
- - test/test-index-cursor.rb
445
- - test/test-remote.rb
446
- - test/test-snippet.rb
447
- - test/test-exception.rb
448
- - test/groonga-test-utils.rb
449
457
  - test/test-table-traverse.rb
450
- - test/test-convert.rb
458
+ - test/test-table.rb
451
459
  - test/test-thread.rb
452
- - test/test-plugin.rb
453
- - test/test-accessor.rb
454
- - test/test-index-column.rb
455
- - test/test-data-column.rb
456
- - test/test-ractor.rb
457
- - test/test-geo-point.rb
458
- - test/test-request-timer.rb
459
- - test/test-table-select-mecab.rb
460
- - test/test-version.rb
461
- - test/test-package-label.rb
460
+ - test/test-token-regexp.rb
461
+ - test/test-type.rb
462
+ - test/test-variable-size-column.rb
462
463
  - test/test-variable.rb
463
- - test/test-record.rb
464
- - test/test-table-offset-and-limit.rb
465
- - test/test-procedure.rb
466
- - test/test-name.rb
464
+ - test/test-vector-column.rb
465
+ - test/test-version.rb
466
+ - test/test-windows-event-logger.rb