[Groonga-commit] groonga/groonga [master] load: set domain to vector elements

Back to archive index

Kouhei Sutou null+****@clear*****
Mon Sep 3 18:23:41 JST 2012


Kouhei Sutou	2012-09-03 18:23:41 +0900 (Mon, 03 Sep 2012)

  New Revision: 56d815f2be1dc192e39c2cfdde2873f02417b303
  https://github.com/groonga/groonga/commit/56d815f2be1dc192e39c2cfdde2873f02417b303

  Merged a271473: Merge pull request #30 from groonga/load-set-domain-to-vector-elements

  Log:
    load: set domain to vector elements

  Modified files:
    lib/db.c
    test/unit/core/test-command-load.c

  Modified: lib/db.c (+2 -1)
===================================================================
--- lib/db.c    2012-09-03 16:03:16 +0900 (1b3d051)
+++ lib/db.c    2012-09-03 18:23:41 +0900 (81b7df1)
@@ -8666,7 +8666,8 @@ set_vector(grn_ctx *ctx, grn_obj *column, grn_id id, grn_obj *vector)
           if (!cast_failed) {
             grn_vector_add_element(ctx, &buf,
                                    GRN_TEXT_VALUE(element),
-                                   GRN_TEXT_LEN(element), 0, GRN_ID_NIL);
+                                   GRN_TEXT_LEN(element), 0,
+                                   element->header.domain);
           }
           if (element == &casted_element) { GRN_OBJ_FIN(ctx, element); }
         } else {

  Modified: test/unit/core/test-command-load.c (+31 -0)
===================================================================
--- test/unit/core/test-command-load.c    2012-09-03 16:03:16 +0900 (0276e32)
+++ test/unit/core/test-command-load.c    2012-09-03 18:23:41 +0900 (ccad180)
@@ -41,6 +41,7 @@ void test_invalid_table_name(void);
 void data_each(void);
 void test_each(gconstpointer data);
 void test_vector_reference_column(void);
+void test_vector_domain(void);
 
 static gchar *tmp_directory;
 static const gchar *database_path;
@@ -459,3 +460,33 @@ test_vector_reference_column(void)
      "[1,\"mori\",[\"groonga\",\"search\",\"engine\"]]]]",
     send_command("select Users"));
 }
+
+void
+test_vector_domain(void)
+{
+  assert_send_command("table_create Posts TABLE_NO_KEY");
+  assert_send_command("column_create Posts tags COLUMN_VECTOR ShortText");
+  cut_assert_equal_string(
+    "1",
+    send_command(
+      "load "
+      "--table Posts "
+      "--values '[{\"tags\": [\"groonga\", \"search engine\"]}]'"));
+
+  {
+    grn_obj *tags_column;
+    grn_obj tags;
+    const char *tag;
+    grn_id domain;
+
+    tags_column = grn_ctx_get(context, "Posts.tags", strlen("Posts.tags"));
+    GRN_SHORT_TEXT_INIT(&tags, GRN_OBJ_VECTOR);
+    grn_obj_get_value(context, tags_column, 1, &tags);
+    cut_assert_equal_int(2, grn_vector_size(context, &tags));
+    grn_vector_get_element(context, &tags, 0, &tag, NULL, &domain);
+    GRN_OBJ_FIN(context, &tags);
+    grn_obj_unlink(context, tags_column);
+
+    grn_test_assert_equal_id(context, GRN_DB_SHORT_TEXT, domain);
+  }
+}
-------------- next part --------------
HTML����������������������������...
Descargar 



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