forked from heavyai/heavydb
-
Notifications
You must be signed in to change notification settings - Fork 0
/
RunQueryLoop.cpp
70 lines (58 loc) · 2.22 KB
/
RunQueryLoop.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
/*
* Copyright 2017 MapD Technologies, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#include "../Catalog/Catalog.h"
#include "../QueryRunner/QueryRunner.h"
#include <boost/program_options.hpp>
using QR = QueryRunner::QueryRunner;
int main(int argc, char** argv) {
std::string db_path;
std::string query;
size_t iter;
ExecutorDeviceType device_type{ExecutorDeviceType::GPU};
boost::program_options::options_description desc("Options");
desc.add_options()("path",
boost::program_options::value<std::string>(&db_path)->required(),
"Directory path to Mapd catalogs")(
"query", boost::program_options::value<std::string>(&query)->required(), "Query")(
"iter", boost::program_options::value<size_t>(&iter), "Number of iterations")(
"cpu", "Run on CPU (run on GPU by default)");
boost::program_options::positional_options_description positionalOptions;
positionalOptions.add("path", 1);
positionalOptions.add("query", 1);
boost::program_options::variables_map vm;
try {
boost::program_options::store(boost::program_options::command_line_parser(argc, argv)
.options(desc)
.positional(positionalOptions)
.run(),
vm);
boost::program_options::notify(vm);
} catch (boost::program_options::error& err) {
LOG(ERROR) << err.what();
return 1;
}
if (!vm.count("iter")) {
iter = 100;
}
if (vm.count("cpu")) {
device_type = ExecutorDeviceType::CPU;
}
QR::init(db_path.c_str());
for (size_t i = 0; i < iter; ++i) {
QR::get()->runSQL(query, device_type, true, true);
}
return 0;
}