data: split off inner classes of SearchIndex

This commit is contained in:
Eberhard Graether
2014-10-28 22:06:22 +01:00
parent 86f4629b0d
commit 2c84bf20ed
32 changed files with 723 additions and 670 deletions
+55
View File
@@ -0,0 +1,55 @@
#include "data/search/SearchMatch.h"
#include <sstream>
#include "utility/logging/logging.h"
#include "data/query/QueryCommand.h"
#include "data/query/QueryToken.h"
void SearchMatch::log(const std::vector<SearchMatch>& matches, const std::string& query)
{
std::stringstream ss;
ss << std::endl << matches.size() << " matches for \"" << query << "\":" << std::endl;
for (const SearchMatch& match : matches)
{
match.print(ss);
}
LOG_INFO(ss.str());
}
void SearchMatch::print(std::ostream& ostream) const
{
ostream << weight << '\t' << fullName << std::endl << '\t';
size_t i = 0;
for (size_t index : indices)
{
while (i < index)
{
i++;
ostream << ' ';
}
ostream << '^';
i++;
}
ostream << std::endl;
}
std::string SearchMatch::encodeForQuery() const
{
if (!tokenIds.size())
{
return QueryCommand::BOUNDARY + fullName + QueryCommand::BOUNDARY;
}
std::stringstream ss;
ss << QueryToken::BOUNDARY << fullName;
for (Id tokenId : tokenIds)
{
ss << QueryToken::DELIMITER << tokenId;
}
ss << QueryToken::BOUNDARY;
return ss.str();
}