[Groonga-commit] groonga/groonga at 8173437 [master] dump: use '{"x": 1, "y": 2}' style for not referenced weight vector

Back to archive index

Kouhei Sutou null+****@clear*****
Thu Feb 16 11:31:44 JST 2017


Kouhei Sutou	2017-02-16 11:31:44 +0900 (Thu, 16 Feb 2017)

  New Revision: 8173437c9cfb91dea93bf173b4916ffaf85bd9a6
  https://github.com/groonga/groonga/commit/8173437c9cfb91dea93bf173b4916ffaf85bd9a6

  Message:
    dump: use '{"x": 1, "y": 2}' style for not referenced weight vector
    
    Old style: '[{"x": 1}, {"y": 2}]'
    
    The old style isn't supported until 7.0.1. The new style is supported by
    old Groonga. So the new style is useful.

  Modified files:
    lib/str.c
    test/command/suite/dump/record/weight_vector_type.expected
    test/command/suite/load/vector/add/weight/array/value_weight_type.expected
    test/command/suite/load/vector/add/weight/object/value_weight_type.expected

  Modified: lib/str.c (+10 -6)
===================================================================
--- lib/str.c    2017-02-16 10:56:16 +0900 (bc61099)
+++ lib/str.c    2017-02-16 11:31:44 +0900 (9b395c4)
@@ -3002,7 +3002,11 @@ grn_text_otoj(grn_ctx *ctx, grn_obj *bulk, grn_obj *obj, grn_obj_format *format)
       GRN_UINT32_INIT(&weight, 0);
       with_weight = (format && format->flags & GRN_OBJ_FORMAT_WITH_WEIGHT);
       n = grn_vector_size(ctx, obj);
-      GRN_TEXT_PUTC(ctx, bulk, '[');
+      if (with_weight) {
+        GRN_TEXT_PUTC(ctx, bulk, '{');
+      } else {
+        GRN_TEXT_PUTC(ctx, bulk, '[');
+      }
       for (i = 0; i < n; i++) {
         const char *_value;
         unsigned int _weight, length;
@@ -3016,19 +3020,19 @@ grn_text_otoj(grn_ctx *ctx, grn_obj *bulk, grn_obj *obj, grn_obj_format *format)
         } else {
           grn_obj_reinit(ctx, &value, obj->header.domain, 0);
         }
-        if (with_weight) {
-          GRN_TEXT_PUTC(ctx, bulk, '{');
-        }
         grn_bulk_write(ctx, &value, _value, length);
         grn_text_otoj(ctx, bulk, &value, NULL);
         if (with_weight) {
           GRN_TEXT_PUTC(ctx, bulk, ':');
           GRN_UINT32_SET(ctx, &weight, _weight);
           grn_text_otoj(ctx, bulk, &weight, NULL);
-          GRN_TEXT_PUTC(ctx, bulk, '}');
         }
       }
-      GRN_TEXT_PUTC(ctx, bulk, ']');
+      if (with_weight) {
+        GRN_TEXT_PUTC(ctx, bulk, '}');
+      } else {
+        GRN_TEXT_PUTC(ctx, bulk, ']');
+      }
       GRN_OBJ_FIN(ctx, &value);
       GRN_OBJ_FIN(ctx, &weight);
     }

  Modified: test/command/suite/dump/record/weight_vector_type.expected (+1 -1)
===================================================================
--- test/command/suite/dump/record/weight_vector_type.expected    2017-02-16 10:56:16 +0900 (193a608)
+++ test/command/suite/dump/record/weight_vector_type.expected    2017-02-16 11:31:44 +0900 (cad069e)
@@ -20,5 +20,5 @@ column_create Memos tags COLUMN_VECTOR|WITH_WEIGHT ShortText
 load --table Memos
 [
 ["_key","tags"],
-["Groonga is fast",[{"groonga":100},{"full text search":10}]]
+["Groonga is fast",{"groonga":100,"full text search":10}]
 ]

  Modified: test/command/suite/load/vector/add/weight/array/value_weight_type.expected (+1 -1)
===================================================================
--- test/command/suite/load/vector/add/weight/array/value_weight_type.expected    2017-02-16 10:56:16 +0900 (db59f0f)
+++ test/command/suite/load/vector/add/weight/array/value_weight_type.expected    2017-02-16 11:31:44 +0900 (9f9cc82)
@@ -18,5 +18,5 @@ dump   --dump_plugins no   --dump_schema no
 load --table Memos
 [
 ["_key","tags"],
-["Groonga is fast",[{"groonga":100},{"mroonga":200}]]
+["Groonga is fast",{"groonga":100,"mroonga":200}]
 ]

  Modified: test/command/suite/load/vector/add/weight/object/value_weight_type.expected (+1 -1)
===================================================================
--- test/command/suite/load/vector/add/weight/object/value_weight_type.expected    2017-02-16 10:56:16 +0900 (0be7b4d)
+++ test/command/suite/load/vector/add/weight/object/value_weight_type.expected    2017-02-16 11:31:44 +0900 (4d7074f)
@@ -17,5 +17,5 @@ dump   --dump_plugins no   --dump_schema no
 load --table Memos
 [
 ["_key","tags"],
-["Groonga is fast",[{"groonga":100},{"mroonga":200}]]
+["Groonga is fast",{"groonga":100,"mroonga":200}]
 ]
-------------- next part --------------
HTML����������������������������...
Download 



More information about the Groonga-commit mailing list
Back to archive index