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