[Groonga-commit] groonga/groonga at 50e24c8 [master] dat: limit the number of nodes per key

Back to archive index

Susumu Yata null+****@clear*****
Thu Sep 28 14:59:50 JST 2017


Susumu Yata	2017-09-28 14:59:50 +0900 (Thu, 28 Sep 2017)

  New Revision: 50e24c86e2dc4b802e32b56c3ac390bff1587e91
  https://github.com/groonga/groonga/commit/50e24c86e2dc4b802e32b56c3ac390bff1587e91

  Merged 15ee139: Merge pull request #763 from groonga/dat-limit-num-nodes-per-key

  Message:
    dat: limit the number of nodes per key

  Modified files:
    lib/dat/dat.hpp
    lib/dat/trie.cpp

  Modified: lib/dat/dat.hpp (+1 -0)
===================================================================
--- lib/dat/dat.hpp    2017-09-28 10:57:07 +0900 (f2e78b4c6)
+++ lib/dat/dat.hpp    2017-09-28 14:59:50 +0900 (a454ae7ca)
@@ -126,6 +126,7 @@ const UInt64 MIN_FILE_SIZE              = 1 << 16;
 const UInt64 DEFAULT_FILE_SIZE          = 1 << 20;
 const UInt64 MAX_FILE_SIZE              = (UInt64)1 << 40;
 const double DEFAULT_NUM_NODES_PER_KEY  = 4.0;
+const double MAX_NUM_NODES_PER_KEY      = 16.0;
 const double DEFAULT_AVERAGE_KEY_LENGTH = 16.0;
 const UInt32 MAX_KEY_BUF_SIZE           = 0x80000000U;
 const UInt32 MAX_TOTAL_KEY_LENGTH       = 0xFFFFFFFFU;

  Modified: lib/dat/trie.cpp (+8 -0)
===================================================================
--- lib/dat/trie.cpp    2017-09-28 10:57:07 +0900 (2f9e79bac)
+++ lib/dat/trie.cpp    2017-09-28 14:59:50 +0900 (1022c2da0)
@@ -67,7 +67,11 @@ void Trie::create(const char *file_name,
   if (num_nodes_per_key < 1.0) {
     num_nodes_per_key = DEFAULT_NUM_NODES_PER_KEY;
   }
+  if (num_nodes_per_key > MAX_NUM_NODES_PER_KEY) {
+    num_nodes_per_key = MAX_NUM_NODES_PER_KEY;
+  }
   GRN_DAT_THROW_IF(PARAM_ERROR, num_nodes_per_key < 1.0);
+  GRN_DAT_THROW_IF(PARAM_ERROR, num_nodes_per_key > MAX_NUM_NODES_PER_KEY);
 
   if (average_key_length < 1.0) {
     average_key_length = DEFAULT_AVERAGE_KEY_LENGTH;
@@ -105,9 +109,13 @@ void Trie::create(const Trie &trie,
       num_nodes_per_key = DEFAULT_NUM_NODES_PER_KEY;
     } else {
       num_nodes_per_key = 1.0 * trie.num_nodes() / trie.num_keys();
+      if (num_nodes_per_key > MAX_NUM_NODES_PER_KEY) {
+        num_nodes_per_key = MAX_NUM_NODES_PER_KEY;
+      }
     }
   }
   GRN_DAT_THROW_IF(PARAM_ERROR, num_nodes_per_key < 1.0);
+  GRN_DAT_THROW_IF(PARAM_ERROR, num_nodes_per_key > MAX_NUM_NODES_PER_KEY);
 
   if (average_key_length < 1.0) {
     if (trie.num_keys() == 0) {
-------------- next part --------------
HTML����������������������������...
URL: https://lists.osdn.me/mailman/archives/groonga-commit/attachments/20170928/a1c09453/attachment-0003.htm 



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