[Groonga-commit] groonga/groonga at f2ed038 [master] index: use column cache for fallback static index construction

Back to archive index

Kouhei Sutou null+****@clear*****
Tue Jul 31 13:06:18 JST 2018


Kouhei Sutou	2018-07-31 13:06:18 +0900 (Tue, 31 Jul 2018)

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

  Message:
    index: use column cache for fallback static index construction
    
    It'll improve performance but I didn't measure it...

  Modified files:
    lib/index_column.c

  Modified: lib/index_column.c (+27 -9)
===================================================================
--- lib/index_column.c    2018-07-31 12:47:59 +0900 (ffc504aaa)
+++ lib/index_column.c    2018-07-31 13:06:18 +0900 (f1dad536d)
@@ -121,15 +121,33 @@ grn_index_column_build_column(grn_ctx *ctx,
       grn_index_column_build_call_hook(ctx, column, id, &old_value, &value, 0);
     } GRN_TABLE_EACH_END(ctx, cursor);
   } else {
-    GRN_TABLE_EACH_BEGIN_FLAGS(ctx,
-                               table,
-                               cursor,
-                               id,
-                               cursor_flags) {
-      GRN_BULK_REWIND(&value);
-      grn_obj_get_value(ctx, column, id, &value);
-      grn_index_column_build_call_hook(ctx, column, id, &old_value, &value, 0);
-    } GRN_TABLE_EACH_END(ctx, cursor);
+    grn_column_cache *cache;
+    cache = grn_column_cache_open(ctx, column);
+    if (cache) {
+      GRN_TABLE_EACH_BEGIN_FLAGS(ctx,
+                                 table,
+                                 cursor,
+                                 id,
+                                 cursor_flags) {
+        void *raw_value;
+        size_t value_size;
+        GRN_BULK_REWIND(&value);
+        raw_value = grn_column_cache_ref(ctx, cache, id, &value_size);
+        grn_bulk_write(ctx, &value, raw_value, value_size);
+        grn_index_column_build_call_hook(ctx, column, id, &old_value, &value, 0);
+      } GRN_TABLE_EACH_END(ctx, cursor);
+      grn_column_cache_close(ctx, cache);
+    } else {
+      GRN_TABLE_EACH_BEGIN_FLAGS(ctx,
+                                 table,
+                                 cursor,
+                                 id,
+                                 cursor_flags) {
+        GRN_BULK_REWIND(&value);
+        grn_obj_get_value(ctx, column, id, &value);
+        grn_index_column_build_call_hook(ctx, column, id, &old_value, &value, 0);
+      } GRN_TABLE_EACH_END(ctx, cursor);
+    }
   }
   GRN_OBJ_FIN(ctx, &old_value);
   GRN_OBJ_FIN(ctx, &value);
-------------- next part --------------
HTML����������������������������...
URL: https://lists.osdn.me/mailman/archives/groonga-commit/attachments/20180731/43ae5ede/attachment-0001.htm 



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