17 #include <thrift/Thrift.h>
19 #include <boost/filesystem.hpp>
20 #include <boost/program_options.hpp>
32 #define CALCITEPORT 3279
43 static void loadGeo(std::string base_path) {
44 TSessionId session_id{};
47 std::string udf_filename{};
48 std::string udf_compiler_path{};
49 std::vector<std::string> udf_compiler_options{};
51 std::string libgeos_so_filename{};
53 std::vector<LeafHostInfo> db_leaves{};
54 std::vector<LeafHostInfo> string_leaves{};
61 const bool allow_multifrag{
true};
62 const bool jit_debug{
false};
63 const bool intel_jit_profile{
false};
64 const bool read_only{
false};
65 const bool allow_loop_joins{
false};
66 const bool enable_rendering{
false};
67 const bool renderer_use_ppll_polys{
false};
68 const bool renderer_prefer_igpu{
false};
69 const unsigned renderer_vulkan_timeout_ms{300000};
70 const bool enable_auto_clear_render_mem{
false};
71 const int render_oom_retry_threshold{0};
72 const size_t render_mem_bytes{500000000};
73 const size_t max_concurrent_render_sessions{500};
74 const bool render_compositor_use_last_gpu{
false};
75 const size_t reserved_gpu_mem{134217728};
76 const size_t num_reader_threads{0};
77 const bool legacy_syntax{
true};
78 const int idle_session_duration{60};
79 const int max_session_duration{43200};
80 system_parameters.runtime_udf_registration_policy =
82 system_parameters.omnisci_server_port = -1;
83 system_parameters.calcite_port = 3280;
85 system_parameters.aggregator =
false;
94 auto db_handler = std::make_unique<DBHandler>(db_leaves,
103 renderer_use_ppll_polys,
104 renderer_prefer_igpu,
105 renderer_vulkan_timeout_ms,
106 enable_auto_clear_render_mem,
107 render_oom_retry_threshold,
109 max_concurrent_render_sessions,
111 render_compositor_use_last_gpu,
116 idle_session_duration,
117 max_session_duration,
120 udf_compiler_options,
129 db_handler->set_execution_mode(session_id, TExecuteMode::CPU);
133 for (
size_t i = 0; i < num_samples; i++) {
138 "ThirdParty" /
"geo_samples" / file_name;
140 if (!boost::filesystem::exists(file_path)) {
141 throw std::runtime_error(
142 "Unable to populate geo sample data. File does not exist: " +
146 std::string sql_string =
"COPY " + table_name +
" FROM '" +
147 file_path.generic_string() +
"' WITH (GEO='true');";
149 std::string sql_string =
150 "COPY " + table_name +
" FROM '" + file_path.string() +
"' WITH (GEO='true');";
152 db_handler->sql_execute(res, session_id, sql_string,
true,
"", -1, -1);
156 int main(
int argc,
char* argv[]) {
157 std::string base_path;
159 bool skip_geo =
false;
160 namespace po = boost::program_options;
162 po::options_description desc(
"Options");
163 desc.add_options()(
"help,h",
"Print help messages ")(
165 po::value<std::string>(&base_path)->required(),
166 "Directory path to HeavyDB catalogs")(
"force,f",
167 "Force overwriting of existing HeavyDB "
168 "instance")(
"skip-geo",
169 "Skip inserting sample geo data");
171 desc.add_options()(
"enable-thrift-logs",
174 ->implicit_value(
true),
175 "Enable writing messages directly from thrift to stdout/stderr.");
180 po::positional_options_description positionalOptions;
181 positionalOptions.add(
"data", 1);
183 po::variables_map vm;
186 po::store(po::command_line_parser(argc, argv)
188 .positional(positionalOptions)
191 if (vm.count(
"help")) {
195 if (vm.count(
"force")) {
198 if (vm.count(
"skip-geo")) {
202 }
catch (boost::program_options::error& e) {
203 std::cerr <<
"Usage Error: " << e.what() << std::endl;
208 apache::thrift::GlobalOutput.setOutputFunction([](
const char* msg) {});
211 if (!boost::filesystem::exists(base_path)) {
212 std::cerr <<
"Catalog basepath " + base_path +
" does not exist.\n";
216 if (boost::filesystem::exists(catalogs_path)) {
218 boost::filesystem::remove_all(catalogs_path);
220 std::cerr <<
"HeavyDB catalogs already initialized at " + base_path +
221 ". Use -f to force reinitialization.\n";
226 if (boost::filesystem::exists(data_path)) {
228 boost::filesystem::remove_all(data_path);
230 std::cerr <<
"HeavyDB data directory already exists at " + base_path +
231 ". Use -f to force reinitialization.\n";
236 if (boost::filesystem::exists(export_path)) {
238 boost::filesystem::remove_all(export_path);
240 std::cerr <<
"HeavyDB export directory already exists at " + base_path +
241 ". Use -f to force reinitialization.\n";
246 if (boost::filesystem::exists(disk_cache_path)) {
248 boost::filesystem::remove_all(disk_cache_path);
250 std::cerr <<
"HeavyDB disk cache already exists at " + disk_cache_path +
251 ". Use -f to force reinitialization.\n";
255 if (!boost::filesystem::create_directory(catalogs_path)) {
256 std::cerr <<
"Cannot create " + shared::kCatalogDirectoryName +
" subdirectory under "
257 << base_path << std::endl;
259 if (!boost::filesystem::create_directory(export_path)) {
260 std::cerr <<
"Cannot create export subdirectory under " << base_path << std::endl;
268 auto dummy = std::make_shared<Data_Namespace::DataMgr>(
269 data_path, sys_parms,
nullptr,
false, 0);
271 std::make_shared<Calcite>(-1,
CALCITEPORT, base_path, 1024, 5000,
true,
"");
274 sys_cat.init(base_path, dummy, {}, calcite,
true,
false, {});
276 }
catch (std::exception& e) {
277 std::cerr <<
"Exception: " << e.what() <<
"\n";
const std::string kDataDirectoryName
static void initialize(const std::string &data_dir, const std::string &allowed_import_paths, const std::string &allowed_export_paths)
std::string get_root_abs_path()
const std::string kDefaultDiskCacheDirName
const std::string kDefaultExportDirName
This file contains the class specification and related data structures for Catalog.
static const std::array< std::string, 3 > SampleGeoFileNames
static SysCatalog & instance()
const std::string kDefaultDbName
void init(LogOptions const &log_opts)
static void loadGeo(std::string base_path)
static const std::array< std::string, 3 > SampleGeoTableNames
const std::string kRootUsername
const std::string kCatalogDirectoryName
boost::program_options::options_description const & get_options() const
void set_base_path(std::string const &base_path)
static std::string getDefaultPath(const std::string &base_path)
bool g_enable_thrift_logs