memgraph/tests/manual/query_hash.cpp
antonio2368 28413fd626 Change log library to spdlog, expose log levels to user (#72)
* Change from glog to spdlog

* Remove HA tests

* Remove logrotate log configuration

* Define custom main for unit gtests
2021-01-21 16:30:55 +01:00

37 lines
1017 B
C++

#include <iostream>
#include <vector>
#include <gflags/gflags.h>
#include "query/frontend/stripped.hpp"
DEFINE_string(q, "CREATE (n) RETURN n", "Query");
/**
* Useful when somebody wants to get a hash for some query.
*
* Usage:
* ./query_hash -q "CREATE (n {name: \"test\n"}) RETURN n"
*/
int main(int argc, char **argv) {
gflags::ParseCommandLineFlags(&argc, &argv, true);
// take query from input args
auto query = FLAGS_q;
// run preprocessing
query::frontend::StrippedQuery preprocessed(query);
// print query, stripped query, hash and variable values (propertie values)
std::cout << fmt::format("Query: {}\n", query);
std::cout << fmt::format("Stripped query: {}\n", preprocessed.query());
std::cout << fmt::format("Query hash: {}\n", preprocessed.hash());
std::cout << fmt::format("Property values:\n");
for (int i = 0; i < preprocessed.literals().size(); ++i) {
fmt::format(" {}", preprocessed.literals().At(i).second);
}
std::cout << std::endl;
return 0;
}