[Groonga-commit] groonga/groonga at 705d347 [custom-segment-size] pat: support custom segment size by environment variable

Back to archive index

Kouhei Sutou null+****@clear*****
Thu Apr 23 18:06:39 JST 2015


Kouhei Sutou	2015-04-23 18:06:39 +0900 (Thu, 23 Apr 2015)

  New Revision: 705d347cbec47d2c29752801e481e439e50948e6
  https://github.com/groonga/groonga/commit/705d347cbec47d2c29752801e481e439e50948e6

  Message:
    pat: support custom segment size by environment variable
    
    Environment variable name is GRN_PAT_SEGMENT_SIZE.

  Modified files:
    lib/pat.c

  Modified: lib/pat.c (+13 -2)
===================================================================
--- lib/pat.c    2015-04-23 15:01:00 +0900 (e24dbe7)
+++ lib/pat.c    2015-04-23 18:06:39 +0900 (533c16f)
@@ -405,8 +405,19 @@ _grn_pat_create(grn_ctx *ctx, grn_pat *pat,
     array_spec[segment_pat].max_n_segments = 1 << (30 - (22 - 4));
     array_spec[segment_sis].w_of_element = w_of_element;
     array_spec[segment_sis].max_n_segments = 1 << (30 - (22 - w_of_element));
-    io = grn_io_create_with_array(ctx, path, sizeof(struct grn_pat_header),
-                                  GRN_PAT_SEGMENT_SIZE, grn_io_auto, 3, array_spec);
+    {
+      uint32_t segment_size = GRN_PAT_SEGMENT_SIZE;
+      char segment_size_env[GRN_ENV_BUFFER_SIZE];
+      grn_getenv("GRN_PAT_SEGMENT_SIZE", segment_size_env, GRN_ENV_BUFFER_SIZE);
+      if (segment_size_env[0]) {
+        segment_size = grn_atoui(segment_size_env,
+                                 segment_size_env + strlen(segment_size_env),
+                                 NULL);
+      }
+      io = grn_io_create_with_array(ctx, path, sizeof(struct grn_pat_header),
+                                    segment_size,
+                                    grn_io_auto, 3, array_spec);
+    }
   }
   if (!io) { return NULL; }
   if (encoding == GRN_ENC_DEFAULT) { encoding = grn_gctx.encoding; }
-------------- next part --------------
HTML����������������������������...
Download 



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