2017-02-14 16:37:32 +08:00
|
|
|
#include <iostream>
|
|
|
|
#include <vector>
|
|
|
|
|
2017-06-21 17:29:13 +08:00
|
|
|
#include <glog/logging.h>
|
|
|
|
|
2017-06-13 22:25:08 +08:00
|
|
|
#include "query/frontend/stripped.hpp"
|
2017-02-14 16:37:32 +08:00
|
|
|
|
2017-07-06 19:53:39 +08:00
|
|
|
DEFINE_string(q, "CREATE (n) RETURN n", "Query");
|
|
|
|
|
2017-02-14 16:37:32 +08:00
|
|
|
/**
|
|
|
|
* Useful when somebody wants to get a hash for some query.
|
|
|
|
*
|
|
|
|
* Usage:
|
|
|
|
* ./query_hash -q "CREATE (n {name: \"test\n"}) RETURN n"
|
|
|
|
*/
|
2017-02-18 18:54:37 +08:00
|
|
|
int main(int argc, char **argv) {
|
2017-07-06 19:53:39 +08:00
|
|
|
gflags::ParseCommandLineFlags(&argc, &argv, true);
|
2017-06-21 17:29:13 +08:00
|
|
|
google::InitGoogleLogging(argv[0]);
|
2017-02-18 18:54:37 +08:00
|
|
|
|
|
|
|
// take query from input args
|
2017-07-06 19:53:39 +08:00
|
|
|
auto query = FLAGS_q;
|
2017-02-18 18:54:37 +08:00
|
|
|
|
|
|
|
// run preprocessing
|
2019-07-10 20:30:11 +08:00
|
|
|
query::frontend::StrippedQuery preprocessed(query);
|
2017-02-18 18:54:37 +08:00
|
|
|
|
|
|
|
// print query, stripped query, hash and variable values (propertie values)
|
2017-04-18 18:11:25 +08:00
|
|
|
std::cout << fmt::format("Query: {}\n", query);
|
2017-06-08 00:28:31 +08:00
|
|
|
std::cout << fmt::format("Stripped query: {}\n", preprocessed.query());
|
|
|
|
std::cout << fmt::format("Query hash: {}\n", preprocessed.hash());
|
2017-04-18 18:11:25 +08:00
|
|
|
std::cout << fmt::format("Property values:\n");
|
2017-06-15 00:53:02 +08:00
|
|
|
for (int i = 0; i < preprocessed.literals().size(); ++i) {
|
|
|
|
fmt::format(" {}", preprocessed.literals().At(i).second);
|
2017-04-18 18:11:25 +08:00
|
|
|
}
|
|
|
|
std::cout << std::endl;
|
2017-02-18 18:54:37 +08:00
|
|
|
|
|
|
|
return 0;
|
2017-02-14 16:37:32 +08:00
|
|
|
}
|