2016-07-02 05:05:03 +08:00
|
|
|
#pragma once
|
|
|
|
|
|
|
|
#include "cypher/common.hpp"
|
|
|
|
#include "query_stripper.hpp"
|
|
|
|
#include "utils/hashing/fnv.hpp"
|
|
|
|
|
|
|
|
class QueryHasher
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
QueryHasher()
|
2016-07-24 10:47:48 +08:00
|
|
|
: stripper(make_query_stripper(TK_LONG, TK_FLOAT, TK_STR, TK_BOOL)) {}
|
2016-07-02 05:05:03 +08:00
|
|
|
|
|
|
|
std::string hash(std::string &query)
|
|
|
|
{
|
|
|
|
auto stripped = stripper.strip(query);
|
|
|
|
auto stripped_hash = fnv(stripped.query);
|
|
|
|
auto hash_string = std::to_string(stripped_hash);
|
|
|
|
return hash_string;
|
|
|
|
}
|
|
|
|
|
|
|
|
private:
|
|
|
|
QueryStripper<int, int, int, int> stripper;
|
|
|
|
};
|