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
|
|
|
#include "utils/command_line/arguments.hpp"
|
|
|
|
#include "utils/type_discovery.hpp"
|
|
|
|
|
|
|
|
/**
|
|
|
|
* 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-06-21 17:29:13 +08:00
|
|
|
google::InitGoogleLogging(argv[0]);
|
2017-02-18 18:54:37 +08:00
|
|
|
|
|
|
|
// init args
|
|
|
|
REGISTER_ARGS(argc, argv);
|
|
|
|
|
|
|
|
// take query from input args
|
|
|
|
auto query = GET_ARG("-q", "CREATE (n) RETURN n").get_string();
|
|
|
|
|
|
|
|
// run preprocessing
|
2017-06-08 00:28:31 +08:00
|
|
|
query::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
|
|
|
}
|