[Groonga-commit] groonga/groonga at 6e67101 [master] Fix a bug that "--match_columns 'index[0] || index[9]'" uses wrong section

アーカイブの一覧に戻る

Kouhei Sutou null+****@clear*****
Wed Aug 1 11:33:20 JST 2018


Kouhei Sutou	2018-08-01 11:33:20 +0900 (Wed, 01 Aug 2018)

  New Revision: 6e67101cabfe6d9f66c675667716598d5f7fb9a6
  https://github.com/groonga/groonga/commit/6e67101cabfe6d9f66c675667716598d5f7fb9a6

  Message:
    Fix a bug that "--match_columns 'index[0] || index[9]'" uses wrong section

  Added files:
    test/command/suite/select/match_columns/section/by_index/16_items/no_weight.expected
    test/command/suite/select/match_columns/section/by_index/16_items/no_weight.test
  Modified files:
    lib/str.c

  Modified: lib/str.c (+3 -2)
===================================================================
--- lib/str.c    2018-08-01 11:02:17 +0900 (2c52c7215)
+++ lib/str.c    2018-08-01 11:33:20 +0900 (b40489df6)
@@ -1,6 +1,7 @@
 /* -*- c-basic-offset: 2 -*- */
 /*
   Copyright(C) 2009-2017 Brazil
+  Copyright(C) 2018 Kouhei Sutou <kou �� clear-code.com>
 
   This library is free software; you can redistribute it and/or
   modify it under the terms of the GNU Lesser General Public
@@ -2029,13 +2030,13 @@ grn_bulk_truncate(grn_ctx *ctx, grn_obj *bulk, unsigned int len)
 {
   if (GRN_BULK_OUTP(bulk)) {
     if ((bulk->u.b.tail - bulk->u.b.head) < len) {
-      return grn_bulk_space_clear(ctx, bulk, len);
+      return grn_bulk_space_clear(ctx, bulk, len - GRN_BULK_VSIZE(bulk));
     } else {
       bulk->u.b.curr = bulk->u.b.head + len;
     }
   } else {
     if (GRN_BULK_BUFSIZE < len) {
-      return grn_bulk_space_clear(ctx, bulk, len);
+      return grn_bulk_space_clear(ctx, bulk, len - GRN_BULK_VSIZE(bulk));
     } else {
       bulk->header.flags &= ~GRN_BULK_BUFSIZE_MAX;
       bulk->header.flags += len;

  Added: test/command/suite/select/match_columns/section/by_index/16_items/no_weight.expected (+75 -0) 100644
===================================================================
--- /dev/null
+++ test/command/suite/select/match_columns/section/by_index/16_items/no_weight.expected    2018-08-01 11:33:20 +0900 (f000dac42)
@@ -0,0 +1,75 @@
+table_create Memos TABLE_NO_KEY
+[[0,0.0,0.0],true]
+column_create Memos contents COLUMN_VECTOR ShortText
+[[0,0.0,0.0],true]
+table_create Lexicon TABLE_PAT_KEY ShortText --default_tokenizer TokenBigram
+[[0,0.0,0.0],true]
+column_create Lexicon memo_index COLUMN_INDEX|WITH_POSITION|WITH_SECTION   Memos contents
+[[0,0.0,0.0],true]
+load --table Memos
+[
+["contents"],
+[["a",
+  "a a",
+  "a a a",
+  "a a a a",
+  "a a a a a",
+  "a a a a a a",
+  "a a a a a a a",
+  "a a a a a a a a",
+  "a a a a a a a a a",
+  "a a a a a a a a a a",
+  "a a a a a a a a a a a",
+  "a a a a a a a a a a a a",
+  "a a a a a a a a a a a a a",
+  "a a a a a a a a a a a a a a",
+  "a a a a a a a a a a a a a a a",
+  "a a a a a a a a a a a a a a a a"]]
+]
+[[0,0.0,0.0],1]
+select Memos   --match_columns "Lexicon.memo_index[0] || Lexicon.memo_index[15]"   --query a   --output_columns "contents, _score"
+[
+  [
+    0,
+    0.0,
+    0.0
+  ],
+  [
+    [
+      [
+        1
+      ],
+      [
+        [
+          "contents",
+          "ShortText"
+        ],
+        [
+          "_score",
+          "Int32"
+        ]
+      ],
+      [
+        [
+          "a",
+          "a a",
+          "a a a",
+          "a a a a",
+          "a a a a a",
+          "a a a a a a",
+          "a a a a a a a",
+          "a a a a a a a a",
+          "a a a a a a a a a",
+          "a a a a a a a a a a",
+          "a a a a a a a a a a a",
+          "a a a a a a a a a a a a",
+          "a a a a a a a a a a a a a",
+          "a a a a a a a a a a a a a a",
+          "a a a a a a a a a a a a a a a",
+          "a a a a a a a a a a a a a a a a"
+        ],
+        16
+      ]
+    ]
+  ]
+]

  Added: test/command/suite/select/match_columns/section/by_index/16_items/no_weight.test (+32 -0) 100644
===================================================================
--- /dev/null
+++ test/command/suite/select/match_columns/section/by_index/16_items/no_weight.test    2018-08-01 11:33:20 +0900 (6ef8ffaca)
@@ -0,0 +1,32 @@
+table_create Memos TABLE_NO_KEY
+column_create Memos contents COLUMN_VECTOR ShortText
+
+table_create Lexicon TABLE_PAT_KEY ShortText --default_tokenizer TokenBigram
+column_create Lexicon memo_index COLUMN_INDEX|WITH_POSITION|WITH_SECTION \
+  Memos contents
+
+load --table Memos
+[
+["contents"],
+[["a",
+  "a a",
+  "a a a",
+  "a a a a",
+  "a a a a a",
+  "a a a a a a",
+  "a a a a a a a",
+  "a a a a a a a a",
+  "a a a a a a a a a",
+  "a a a a a a a a a a",
+  "a a a a a a a a a a a",
+  "a a a a a a a a a a a a",
+  "a a a a a a a a a a a a a",
+  "a a a a a a a a a a a a a a",
+  "a a a a a a a a a a a a a a a",
+  "a a a a a a a a a a a a a a a a"]]
+]
+
+select Memos \
+  --match_columns "Lexicon.memo_index[0] || Lexicon.memo_index[15]" \
+  --query a \
+  --output_columns "contents, _score"
-------------- next part --------------
HTML����������������������������...
URL: https://lists.osdn.me/mailman/archives/groonga-commit/attachments/20180801/2d81e708/attachment-0001.htm 



More information about the Groonga-commit mailing list
アーカイブの一覧に戻る