[Groonga-commit] groonga/groonga [master] updated to rebuild child-sibling links in grn::dat::Trie::repair().

Back to archive index

null+****@clear***** null+****@clear*****
2012年 1月 26日 (木) 10:08:38 JST


Susumu Yata	2012-01-26 10:08:38 +0900 (Thu, 26 Jan 2012)

  New Revision: dfcea424948ff62f8ec4fe9d293eef2f2c33435b

  Log:
    updated to rebuild child-sibling links in grn::dat::Trie::repair().

  Modified files:
    lib/dat/trie.cpp

  Modified: lib/dat/trie.cpp (+4 -1)
===================================================================
--- lib/dat/trie.cpp    2012-01-25 16:41:33 +0900 (6cfe884)
+++ lib/dat/trie.cpp    2012-01-26 10:08:38 +0900 (6858e7f)
@@ -393,7 +393,7 @@ void Trie::build_from_keys(const UInt32 *begin, const UInt32 *end,
 
   UInt32 offset;
   {
-    UInt16 labels[MAX_LABEL + 1];
+    UInt16 labels[MAX_LABEL + 2];
     UInt32 num_labels = 0;
 
     const UInt32 *it = begin;
@@ -409,12 +409,15 @@ void Trie::build_from_keys(const UInt32 *begin, const UInt32 *end,
         labels[num_labels++] = (UInt8)key[depth];
       }
     }
+    labels[num_labels] = INVALID_LABEL;
 
     offset = find_offset(labels, num_labels);
+    ith_node(node_id).set_child(labels[0]);
     for (UInt32 i = 0; i < num_labels; ++i) {
       const UInt32 next = offset ^ labels[i];
       reserve_node(next);
       ith_node(next).set_label(labels[i]);
+      ith_node(next).set_sibling(labels[i + 1]);
     }
 
     if (offset >= num_nodes()) {




Groonga-commit メーリングリストの案内
Back to archive index