2017-11-23 21:26:53 +08:00
|
|
|
#include "communication/result_stream_faker.hpp"
|
2021-06-30 17:19:13 +08:00
|
|
|
#include "query/config.hpp"
|
2017-11-23 21:26:53 +08:00
|
|
|
#include "query/interpreter.hpp"
|
2021-06-14 21:47:57 +08:00
|
|
|
#include "storage/v2/isolation_level.hpp"
|
2019-11-22 00:24:01 +08:00
|
|
|
#include "storage/v2/storage.hpp"
|
2021-09-30 01:14:39 +08:00
|
|
|
#include "utils/license.hpp"
|
2021-05-14 21:38:59 +08:00
|
|
|
#include "utils/on_scope_exit.hpp"
|
2017-11-23 21:26:53 +08:00
|
|
|
|
|
|
|
int main(int argc, char *argv[]) {
|
|
|
|
gflags::ParseCommandLineFlags(&argc, &argv, true);
|
|
|
|
|
|
|
|
// parse the first cmd line argument as the query
|
|
|
|
if (argc < 2) {
|
|
|
|
std::cout << "Usage: ./single_query 'RETURN \"query here\"'" << std::endl;
|
|
|
|
exit(1);
|
|
|
|
}
|
2019-10-10 17:23:33 +08:00
|
|
|
|
2019-11-22 00:24:01 +08:00
|
|
|
storage::Storage db;
|
2021-05-14 21:38:59 +08:00
|
|
|
auto data_directory = std::filesystem::temp_directory_path() / "single_query_test";
|
|
|
|
utils::OnScopeExit([&data_directory] { std::filesystem::remove_all(data_directory); });
|
2021-09-30 01:14:39 +08:00
|
|
|
|
|
|
|
utils::license::global_license_checker.EnableTesting();
|
2021-06-22 14:43:19 +08:00
|
|
|
query::InterpreterContext interpreter_context{&db, query::InterpreterConfig{}, data_directory,
|
|
|
|
"non existing bootstrap servers"};
|
2019-10-10 17:23:33 +08:00
|
|
|
query::Interpreter interpreter{&interpreter_context};
|
|
|
|
|
2019-11-22 00:24:01 +08:00
|
|
|
ResultStreamFaker stream(&db);
|
2021-07-22 22:22:08 +08:00
|
|
|
auto [header, _, qid] = interpreter.Prepare(argv[1], {}, nullptr);
|
2019-10-10 17:23:33 +08:00
|
|
|
stream.Header(header);
|
|
|
|
auto summary = interpreter.PullAll(&stream);
|
|
|
|
stream.Summary(summary);
|
2018-07-20 18:31:22 +08:00
|
|
|
std::cout << stream;
|
2019-10-10 17:23:33 +08:00
|
|
|
|
2017-11-23 21:26:53 +08:00
|
|
|
return 0;
|
|
|
|
}
|