[Groonga-commit] groonga/groonga [master] [dump] dump records for tables that have default tokenizer

Back to archive index

null+****@clear***** null+****@clear*****
2012年 3月 6日 (火) 15:38:19 JST


Kouhei Sutou	2012-03-06 15:38:19 +0900 (Tue, 06 Mar 2012)

  New Revision: 276c38ee1cd43034c43b9e1118511a22262185b2

  Log:
    [dump] dump records for tables that have default tokenizer

  Added files:
    test/function/suite/dump/table-tokenizer-index-column.expected
    test/function/suite/dump/table-tokenizer-index-column.test
  Modified files:
    lib/proc.c

  Modified: lib/proc.c (+1 -32)
===================================================================
--- lib/proc.c    2012-03-06 09:49:33 +0900 (07292d9)
+++ lib/proc.c    2012-03-06 15:38:19 +0900 (2a9553f)
@@ -1985,35 +1985,6 @@ dump_column(grn_ctx *ctx, grn_obj *outbuf , grn_obj *table, grn_obj *column)
 }
 
 static int
-have_index_column(grn_ctx *ctx, grn_obj *table)
-{
-  int n_index_columns = 0;
-  grn_hash *columns;
-  columns = grn_hash_create(ctx, NULL, sizeof(grn_id), 0,
-                            GRN_OBJ_TABLE_HASH_KEY|GRN_HASH_TINY);
-  if (!columns) {
-    ERR(GRN_ERROR, "couldn't create a hash to hold columns");
-    return 0;
-  }
-
-  if (grn_table_columns(ctx, table, NULL, 0, (grn_obj *)columns) >= 0) {
-    grn_id *key;
-
-    GRN_HASH_EACH(ctx, columns, id, &key, NULL, NULL, {
-      grn_obj *column;
-      if ((column = grn_ctx_at(ctx, *key))) {
-        if (column->header.flags & GRN_OBJ_COLUMN_INDEX) {
-          n_index_columns++;
-        }
-        grn_obj_unlink(ctx, column);
-      }
-    });
-  }
-  grn_hash_close(ctx, columns);
-  return n_index_columns;
-}
-
-static int
 reference_column_p(grn_ctx *ctx, grn_obj *column)
 {
   grn_obj *range;
@@ -2110,9 +2081,7 @@ dump_records(grn_ctx *ctx, grn_obj *outbuf, grn_obj *table)
     return;
   }
 
-  if (grn_table_size(ctx, table) == 0 ||
-      (grn_obj_get_info(ctx, table, GRN_INFO_DEFAULT_TOKENIZER, NULL) &&
-       have_index_column(ctx, table))) {
+  if (grn_table_size(ctx, table) == 0) {
     return;
   }
 

  Added: test/function/suite/dump/table-tokenizer-index-column.expected (+58 -0) 100644
===================================================================
--- /dev/null
+++ test/function/suite/dump/table-tokenizer-index-column.expected    2012-03-06 15:38:19 +0900 (9032cd8)
@@ -0,0 +1,58 @@
+table_create  Queries           TABLE_HASH_KEY  UInt32
+[[0,0.0,0.0],true]
+table_create  Words             TABLE_HASH_KEY  ShortText     --default_tokenizer TokenDelimit
+[[0,0.0,0.0],true]
+column_create Queries   content COLUMN_SCALAR   ShortText
+[[0,0.0,0.0],true]
+column_create Words     index   COLUMN_INDEX    Queries  content
+[[0,0.0,0.0],true]
+column_create Words     boost   COLUMN_SCALAR   UInt32
+[[0,0.0,0.0],true]
+load --table Queries
+[
+{"_key":1, "content":"Sports Soccer"},
+{"_key":2, "content":"Variety Money"},
+{"_key":3, "content":"IT Server groonga"},
+{"_key":4, "content":"Sports Baseball"},
+{"_key":5, "content":"Variety Quiz"},
+{"_key":6, "content":"Animation Pikonyan"},
+{"_key":7, "content":"Animation Raccoon"},
+{"_key":8, "content":"Animation Music"}
+]
+[[0,0.0,0.0],8]
+dump
+table_create Queries TABLE_HASH_KEY UInt32
+column_create Queries content COLUMN_SCALAR ShortText
+table_create Words TABLE_HASH_KEY ShortText --default_tokenizer TokenDelimit
+column_create Words boost COLUMN_SCALAR UInt32
+column_create Words index COLUMN_INDEX Queries content
+load --table Queries
+[
+["_key","content"],
+[1,"Sports Soccer"],
+[2,"Variety Money"],
+[3,"IT Server groonga"],
+[4,"Sports Baseball"],
+[5,"Variety Quiz"],
+[6,"Animation Pikonyan"],
+[7,"Animation Raccoon"],
+[8,"Animation Music"]
+]
+load --table Words
+[
+["_key","boost"],
+["Sports",0],
+["Soccer",0],
+["Variety",0],
+["Money",0],
+["IT",0],
+["Server",0],
+["groonga",0],
+["Baseball",0],
+["Quiz",0],
+["Animation",0],
+["Pikonyan",0],
+["Raccoon",0],
+["Music",0]
+]
+

  Added: test/function/suite/dump/table-tokenizer-index-column.test (+21 -0) 100644
===================================================================
--- /dev/null
+++ test/function/suite/dump/table-tokenizer-index-column.test    2012-03-06 15:38:19 +0900 (fa8436d)
@@ -0,0 +1,21 @@
+table_create  Queries           TABLE_HASH_KEY  UInt32
+table_create  Words             TABLE_HASH_KEY  ShortText     --default_tokenizer TokenDelimit
+
+column_create Queries   content COLUMN_SCALAR   ShortText
+
+column_create Words     index   COLUMN_INDEX    Queries  content
+column_create Words     boost   COLUMN_SCALAR   UInt32
+
+load --table Queries
+[
+{"_key":1, "content":"Sports Soccer"},
+{"_key":2, "content":"Variety Money"},
+{"_key":3, "content":"IT Server groonga"},
+{"_key":4, "content":"Sports Baseball"},
+{"_key":5, "content":"Variety Quiz"},
+{"_key":6, "content":"Animation Pikonyan"},
+{"_key":7, "content":"Animation Raccoon"},
+{"_key":8, "content":"Animation Music"}
+]
+
+dump




Groonga-commit メーリングリストの案内
Back to archive index