[Groonga-commit] groonga/groonga at 8f4cfaf [master] select: support sequential match (no index match) with match_columns

Back to archive index

Kouhei Sutou null+****@clear*****
Sun Nov 2 17:50:34 JST 2014


Kouhei Sutou	2014-11-02 17:50:34 +0900 (Sun, 02 Nov 2014)

  New Revision: 8f4cfaf156537d3b04fb0be1e3af3a2eded0e8d5
  https://github.com/groonga/groonga/commit/8f4cfaf156537d3b04fb0be1e3af3a2eded0e8d5

  Message:
    select: support sequential match (no index match) with match_columns
    
    Limitations:
    
      * Column must be one. "title || body" isn't supported.
      * Column must be value column. Index column isn't supported.
    
    [groonga-dev,02902]
    
    Reported by Atsushi Shinoda.

  Added files:
    test/command/suite/select/match_columns/no_index/one_column.expected
    test/command/suite/select/match_columns/no_index/one_column.test
    test/command/suite/select/match_columns/no_index/two_columns.expected
    test/command/suite/select/match_columns/no_index/two_columns.test
  Modified files:
    lib/db.c

  Modified: lib/db.c (+32 -0)
===================================================================
--- lib/db.c    2014-11-02 17:17:37 +0900 (1e2b838)
+++ lib/db.c    2014-11-02 17:50:34 +0900 (c7f09f0)
@@ -5952,6 +5952,35 @@ grn_obj_get_value_(grn_ctx *ctx, grn_obj *obj, grn_id id, uint32_t *size)
 }
 
 static void
+grn_obj_get_value_expr(grn_ctx *ctx, grn_obj *expr, grn_id id, grn_obj *value)
+{
+  grn_expr *e = (grn_expr *)expr;
+  grn_expr_code *code;
+
+  if (e->codes_curr != 1) {
+    return;
+  }
+
+  code = e->codes;
+  if (code->op != GRN_OP_GET_VALUE) {
+    return;
+  }
+
+  if (!code->value) {
+    return;
+  }
+
+  switch (code->value->header.type) {
+  case GRN_COLUMN_VAR_SIZE :
+  case GRN_COLUMN_FIX_SIZE :
+    grn_obj_get_value(ctx, code->value, id, value);
+    break;
+  default :
+    break;
+  }
+}
+
+static void
 grn_obj_get_value_column_index(grn_ctx *ctx, grn_obj *index_column,
                                grn_id id, grn_obj *value)
 {
@@ -6024,6 +6053,9 @@ grn_obj_get_value(grn_ctx *ctx, grn_obj *obj, grn_id id, grn_obj *value)
     value = grn_accessor_get_value(ctx, (grn_accessor *)obj, id, value);
     value->header.domain = grn_obj_get_range(ctx, obj);
     break;
+  case GRN_EXPR :
+    grn_obj_get_value_expr(ctx, obj, id, value);
+    break;
   case GRN_TABLE_PAT_KEY :
     {
       grn_pat *pat = (grn_pat *)obj;

  Added: test/command/suite/select/match_columns/no_index/one_column.expected (+11 -0) 100644
===================================================================
--- /dev/null
+++ test/command/suite/select/match_columns/no_index/one_column.expected    2014-11-02 17:50:34 +0900 (abb5d53)
@@ -0,0 +1,11 @@
+table_create Memos TABLE_NO_KEY
+[[0,0.0,0.0],true]
+column_create Memos content COLUMN_SCALAR ShortText
+[[0,0.0,0.0],true]
+load --table Memos
+[
+{"content": "Groonga"}
+]
+[[0,0.0,0.0],1]
+select Memos --match_columns content --query Groonga
+[[0,0.0,0.0],[[[1],[["_id","UInt32"],["content","ShortText"]],[1,"Groonga"]]]]

  Added: test/command/suite/select/match_columns/no_index/one_column.test (+9 -0) 100644
===================================================================
--- /dev/null
+++ test/command/suite/select/match_columns/no_index/one_column.test    2014-11-02 17:50:34 +0900 (4c49e96)
@@ -0,0 +1,9 @@
+table_create Memos TABLE_NO_KEY
+column_create Memos content COLUMN_SCALAR ShortText
+
+load --table Memos
+[
+{"content": "Groonga"}
+]
+
+select Memos --match_columns content --query Groonga

  Added: test/command/suite/select/match_columns/no_index/two_columns.expected (+40 -0) 100644
===================================================================
--- /dev/null
+++ test/command/suite/select/match_columns/no_index/two_columns.expected    2014-11-02 17:50:34 +0900 (1fa02e0)
@@ -0,0 +1,40 @@
+table_create Memos TABLE_NO_KEY
+[[0,0.0,0.0],true]
+column_create Memos title COLUMN_SCALAR ShortText
+[[0,0.0,0.0],true]
+column_create Memos content COLUMN_SCALAR ShortText
+[[0,0.0,0.0],true]
+load --table Memos
+[
+{"title": "Groonga", "content": "Try Groonga!"}
+]
+[[0,0.0,0.0],1]
+select Memos --match_columns title||content --query Groonga
+[
+  [
+    0,
+    0.0,
+    0.0
+  ],
+  [
+    [
+      [
+        0
+      ],
+      [
+        [
+          "_id",
+          "UInt32"
+        ],
+        [
+          "content",
+          "ShortText"
+        ],
+        [
+          "title",
+          "ShortText"
+        ]
+      ]
+    ]
+  ]
+]

  Added: test/command/suite/select/match_columns/no_index/two_columns.test (+10 -0) 100644
===================================================================
--- /dev/null
+++ test/command/suite/select/match_columns/no_index/two_columns.test    2014-11-02 17:50:34 +0900 (4d7f591)
@@ -0,0 +1,10 @@
+table_create Memos TABLE_NO_KEY
+column_create Memos title COLUMN_SCALAR ShortText
+column_create Memos content COLUMN_SCALAR ShortText
+
+load --table Memos
+[
+{"title": "Groonga", "content": "Try Groonga!"}
+]
+
+select Memos --match_columns title||content --query Groonga
-------------- next part --------------
HTML����������������������������...
下載 



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