Lines Matching refs:agent
54 bool LoudsTrie::lookup(Agent &agent) const { in lookup()
55 MARISA_DEBUG_IF(!agent.has_state(), MARISA_STATE_ERROR); in lookup()
57 State &state = agent.state(); in lookup()
59 while (state.query_pos() < agent.query().length()) { in lookup()
60 if (!find_child(agent)) { in lookup()
67 agent.set_key(agent.query().ptr(), agent.query().length()); in lookup()
68 agent.set_key(terminal_flags_.rank1(state.node_id())); in lookup()
72 void LoudsTrie::reverse_lookup(Agent &agent) const { in reverse_lookup()
73 MARISA_DEBUG_IF(!agent.has_state(), MARISA_STATE_ERROR); in reverse_lookup()
74 MARISA_THROW_IF(agent.query().id() >= size(), MARISA_BOUND_ERROR); in reverse_lookup()
76 State &state = agent.state(); in reverse_lookup()
79 state.set_node_id(terminal_flags_.select1(agent.query().id())); in reverse_lookup()
81 agent.set_key(state.key_buf().begin(), state.key_buf().size()); in reverse_lookup()
82 agent.set_key(agent.query().id()); in reverse_lookup()
88 restore(agent, get_link(state.node_id())); in reverse_lookup()
97 agent.set_key(state.key_buf().begin(), state.key_buf().size()); in reverse_lookup()
98 agent.set_key(agent.query().id()); in reverse_lookup()
105 bool LoudsTrie::common_prefix_search(Agent &agent) const { in common_prefix_search()
106 MARISA_DEBUG_IF(!agent.has_state(), MARISA_STATE_ERROR); in common_prefix_search()
108 State &state = agent.state(); in common_prefix_search()
116 agent.set_key(agent.query().ptr(), state.query_pos()); in common_prefix_search()
117 agent.set_key(terminal_flags_.rank1(state.node_id())); in common_prefix_search()
122 while (state.query_pos() < agent.query().length()) { in common_prefix_search()
123 if (!find_child(agent)) { in common_prefix_search()
127 agent.set_key(agent.query().ptr(), state.query_pos()); in common_prefix_search()
128 agent.set_key(terminal_flags_.rank1(state.node_id())); in common_prefix_search()
136 bool LoudsTrie::predictive_search(Agent &agent) const { in predictive_search()
137 MARISA_DEBUG_IF(!agent.has_state(), MARISA_STATE_ERROR); in predictive_search()
139 State &state = agent.state(); in predictive_search()
146 while (state.query_pos() < agent.query().length()) { in predictive_search()
147 if (!predictive_find_child(agent)) { in predictive_search()
160 agent.set_key(state.key_buf().begin(), state.key_buf().size()); in predictive_search()
161 agent.set_key(terminal_flags_.rank1(state.node_id())); in predictive_search()
182 restore(agent, get_link(next.node_id(), next.link_id())); in predictive_search()
194 agent.set_key(state.key_buf().begin(), state.key_buf().size()); in predictive_search()
195 agent.set_key(next.key_id()); in predictive_search()
602 bool LoudsTrie::find_child(Agent &agent) const { in find_child()
603 MARISA_DEBUG_IF(agent.state().query_pos() >= agent.query().length(), in find_child()
606 State &state = agent.state(); in find_child()
608 agent.query()[state.query_pos()]); in find_child()
611 if (!match(agent, cache_[cache_id].link())) { in find_child()
631 if (match(agent, get_link(state.node_id(), link_id))) { in find_child()
637 (UInt8)agent.query()[state.query_pos()]) { in find_child()
647 bool LoudsTrie::predictive_find_child(Agent &agent) const { in predictive_find_child()
648 MARISA_DEBUG_IF(agent.state().query_pos() >= agent.query().length(), in predictive_find_child()
651 State &state = agent.state(); in predictive_find_child()
653 agent.query()[state.query_pos()]); in predictive_find_child()
656 if (!prefix_match(agent, cache_[cache_id].link())) { in predictive_find_child()
677 if (prefix_match(agent, get_link(state.node_id(), link_id))) { in predictive_find_child()
683 (UInt8)agent.query()[state.query_pos()]) { in predictive_find_child()
694 void LoudsTrie::restore(Agent &agent, std::size_t link) const { in restore() argument
696 next_trie_->restore_(agent, link); in restore()
698 tail_.restore(agent, link); in restore()
702 bool LoudsTrie::match(Agent &agent, std::size_t link) const { in match() argument
704 return next_trie_->match_(agent, link); in match()
706 return tail_.match(agent, link); in match()
710 bool LoudsTrie::prefix_match(Agent &agent, std::size_t link) const { in prefix_match() argument
712 return next_trie_->prefix_match_(agent, link); in prefix_match()
714 return tail_.prefix_match(agent, link); in prefix_match()
718 void LoudsTrie::restore_(Agent &agent, std::size_t node_id) const { in restore_() argument
721 State &state = agent.state(); in restore_()
726 restore(agent, cache_[cache_id].link()); in restore_()
739 restore(agent, get_link(node_id)); in restore_()
751 bool LoudsTrie::match_(Agent &agent, std::size_t node_id) const { in match_() argument
752 MARISA_DEBUG_IF(agent.state().query_pos() >= agent.query().length(), in match_()
756 State &state = agent.state(); in match_()
761 if (!match(agent, cache_[cache_id].link())) { in match_()
765 agent.query()[state.query_pos()]) { in match_()
774 } else if (state.query_pos() >= agent.query().length()) { in match_()
782 if (!match(agent, get_link(node_id))) { in match_()
785 } else if (!tail_.match(agent, get_link(node_id))) { in match_()
788 } else if (bases_[node_id] == (UInt8)agent.query()[state.query_pos()]) { in match_()
796 } else if (state.query_pos() >= agent.query().length()) { in match_()
803 bool LoudsTrie::prefix_match_(Agent &agent, std::size_t node_id) const { in prefix_match_() argument
804 MARISA_DEBUG_IF(agent.state().query_pos() >= agent.query().length(), in prefix_match_()
808 State &state = agent.state(); in prefix_match_()
813 if (!prefix_match(agent, cache_[cache_id].link())) { in prefix_match_()
817 agent.query()[state.query_pos()]) { in prefix_match_()
830 if (!prefix_match(agent, get_link(node_id))) { in prefix_match_()
833 } else if (bases_[node_id] == (UInt8)agent.query()[state.query_pos()]) { in prefix_match_()
846 if (state.query_pos() >= agent.query().length()) { in prefix_match_()
847 restore_(agent, node_id); in prefix_match_()