| 74 | TrieBuilder::TrieBuilder() { trie_.nodes_.push_back(Trie::Node{-1, -1, ""}); } |
| 75 | |
| 76 | Status TrieBuilder::AppendChildNode(Trie::Node* parent, uint8_t ch, Trie::Node&& node) { |
| 77 | if (parent->child_lookup_ == -1) { |
| 78 | RETURN_NOT_OK(ExtendLookupTable(&parent->child_lookup_)); |
| 79 | } |
| 80 | auto parent_lookup = parent->child_lookup_ * 256 + ch; |
| 81 | |
| 82 | DCHECK_EQ(trie_.lookup_table_[parent_lookup], -1); |
| 83 | if (trie_.nodes_.size() >= static_cast<size_t>(kMaxIndex)) { |
| 84 | auto max_capacity = kMaxIndex; |
| 85 | return Status::CapacityError("TrieBuilder cannot contain more than ", max_capacity, |
| 86 | " child nodes"); |
| 87 | } |
| 88 | trie_.nodes_.push_back(std::move(node)); |
| 89 | trie_.lookup_table_[parent_lookup] = static_cast<index_type>(trie_.nodes_.size() - 1); |
| 90 | return Status::OK(); |
| 91 | } |
| 92 | |
| 93 | Status TrieBuilder::CreateChildNode(Trie::Node* parent, uint8_t ch, |
| 94 | std::string_view substring) { |
nothing calls this directly
no test coverage detected