[Groonga-commit] groonga/groonga at ab3ae3c [master] db: avoid setoperation if there are no records and operator is OP_OR

Back to archive index

naoa null+****@clear*****
Tue Feb 16 16:25:51 JST 2016


naoa	2016-02-16 16:25:51 +0900 (Tue, 16 Feb 2016)

  New Revision: ab3ae3cce44088767e9c3b62360cedea2ccca88b
  https://github.com/groonga/groonga/commit/ab3ae3cce44088767e9c3b62360cedea2ccca88b

  Merged 167aa02: Merge pull request #478 from naoa/table-fuzzy-support-op

  Message:
    db: avoid setoperation if there are no records and operator is OP_OR
    
    In using index case, it doesn't need set operation

  Modified files:
    lib/db.c

  Modified: lib/db.c (+18 -11)
===================================================================
--- lib/db.c    2016-02-16 04:38:29 +0900 (aa0246c)
+++ lib/db.c    2016-02-16 16:25:51 +0900 (2abf09f)
@@ -2923,18 +2923,25 @@ grn_table_fuzzy_search(grn_ctx *ctx, grn_obj *table, const void *key, uint32_t k
   case GRN_TABLE_PAT_KEY :
     {
       grn_pat *pat = (grn_pat *)table;
-      grn_obj *hash;
-      hash = grn_table_create(ctx, NULL, 0, NULL,
-                              GRN_OBJ_TABLE_HASH_KEY|GRN_OBJ_WITH_SUBREC,
-                              table, NULL);
-      WITH_NORMALIZE(pat, key, key_size, {
-        rc = grn_pat_fuzzy_search(ctx, pat, key, key_size,
-                                  args, (grn_hash *)hash);
-      });
-      if (rc == GRN_SUCCESS) {
-        rc = grn_table_setoperation(ctx, res, hash, res, op);
+      if (!grn_table_size(ctx, res) && op == GRN_OP_OR) {
+        WITH_NORMALIZE(pat, key, key_size, {
+          rc = grn_pat_fuzzy_search(ctx, pat, key, key_size,
+                                    args, (grn_hash *)res);
+        });
+      } else {
+        grn_obj *hash;
+        hash = grn_table_create(ctx, NULL, 0, NULL,
+                                GRN_OBJ_TABLE_HASH_KEY|GRN_OBJ_WITH_SUBREC,
+                                table, NULL);
+        WITH_NORMALIZE(pat, key, key_size, {
+          rc = grn_pat_fuzzy_search(ctx, pat, key, key_size,
+                                    args, (grn_hash *)hash);
+        });
+        if (rc == GRN_SUCCESS) {
+          rc = grn_table_setoperation(ctx, res, hash, res, op);
+        }
+        grn_obj_unlink(ctx, hash);
       }
-      grn_obj_unlink(ctx, hash);
     }
     break;
   default :
-------------- next part --------------
HTML����������������������������...
Download 



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