17 #include <thrift/Thrift.h>
19 #include <boost/filesystem.hpp>
20 #include <boost/program_options.hpp>
32 #define CALCITEPORT 3279
38 "heavyai_us_counties",
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{};
54 std::string torch_lib_path{};
56 std::vector<LeafHostInfo> db_leaves{};
57 std::vector<LeafHostInfo> string_leaves{};
64 const bool allow_multifrag{
true};
65 const bool jit_debug{
false};
66 const bool intel_jit_profile{
false};
67 const bool read_only{
false};
68 const bool allow_loop_joins{
false};
69 const bool enable_rendering{
false};
70 const bool renderer_prefer_igpu{
false};
71 const unsigned renderer_vulkan_timeout_ms{300000};
72 const bool renderer_use_parallel_executors{
false};
73 const bool enable_auto_clear_render_mem{
false};
74 const int render_oom_retry_threshold{0};
75 const size_t render_mem_bytes{500000000};
76 const size_t max_concurrent_render_sessions{500};
77 const bool render_compositor_use_last_gpu{
false};
78 const bool renderer_enable_slab_allocation{
true};
79 const size_t reserved_gpu_mem{134217728};
80 const size_t num_reader_threads{0};
81 const bool legacy_syntax{
true};
82 const int idle_session_duration{60};
83 const int max_session_duration{43200};
84 system_parameters.runtime_udf_registration_policy =
86 system_parameters.omnisci_server_port = -1;
87 system_parameters.calcite_port = 3280;
89 system_parameters.aggregator =
false;
98 auto db_handler = std::make_unique<DBHandler>(db_leaves,
107 renderer_prefer_igpu,
108 renderer_vulkan_timeout_ms,
109 renderer_use_parallel_executors,
110 enable_auto_clear_render_mem,
111 render_oom_retry_threshold,
113 max_concurrent_render_sessions,
115 render_compositor_use_last_gpu,
116 renderer_enable_slab_allocation,
121 idle_session_duration,
122 max_session_duration,
125 udf_compiler_options,
129 #ifdef HAVE_TORCH_TFS
137 db_handler->set_execution_mode(session_id, TExecuteMode::CPU);
141 for (
size_t i = 0; i < num_samples; i++) {
146 "ThirdParty" /
"geo_samples" / file_name;
148 if (!boost::filesystem::exists(file_path)) {
149 throw std::runtime_error(
150 "Unable to populate geo sample data. File does not exist: " +
154 std::string sql_string =
"COPY " + table_name +
" FROM '" +
155 file_path.generic_string() +
"' WITH (GEO='true');";
157 std::string sql_string =
158 "COPY " + table_name +
" FROM '" + file_path.string() +
"' WITH (GEO='true');";
160 db_handler->sql_execute(res, session_id, sql_string,
true,
"", -1, -1);
164 int main(
int argc,
char* argv[]) {
165 std::string base_path;
167 bool skip_geo =
false;
168 namespace po = boost::program_options;
170 po::options_description desc(
"Options");
171 desc.add_options()(
"help,h",
"Print help messages ")(
173 po::value<std::string>(&base_path)->required(),
174 "Directory path to HeavyDB catalogs")(
"force,f",
175 "Force overwriting of existing HeavyDB "
176 "instance")(
"skip-geo",
177 "Skip inserting sample geo data");
179 desc.add_options()(
"enable-thrift-logs",
182 ->implicit_value(
true),
183 "Enable writing messages directly from thrift to stdout/stderr.");
188 po::positional_options_description positionalOptions;
189 positionalOptions.add(
"data", 1);
191 po::variables_map vm;
194 po::store(po::command_line_parser(argc, argv)
196 .positional(positionalOptions)
199 if (vm.count(
"help")) {
203 if (vm.count(
"force")) {
206 if (vm.count(
"skip-geo")) {
210 }
catch (boost::program_options::error& e) {
211 std::cerr <<
"Usage Error: " << e.what() << std::endl;
216 apache::thrift::GlobalOutput.setOutputFunction([](
const char* msg) {});
219 if (!boost::filesystem::exists(base_path)) {
220 std::cerr <<
"Catalog basepath " + base_path +
" does not exist.\n";
224 if (boost::filesystem::exists(catalogs_path)) {
226 boost::filesystem::remove_all(catalogs_path);
228 std::cerr <<
"HeavyDB catalogs directory already exists at " + catalogs_path +
229 ". Use -f to force reinitialization.\n";
234 if (boost::filesystem::exists(data_path)) {
236 boost::filesystem::remove_all(data_path);
238 std::cerr <<
"HeavyDB data directory already exists at " + data_path +
239 ". Use -f to force reinitialization.\n";
244 if (boost::filesystem::exists(lockfiles_path)) {
246 boost::filesystem::remove_all(lockfiles_path);
248 std::cerr <<
"HeavyDB lockfiles directory already exists at " + lockfiles_path +
249 ". Use -f to force reinitialization.\n";
254 if (boost::filesystem::exists(lockfiles_path2)) {
256 boost::filesystem::remove_all(lockfiles_path2);
258 std::cerr <<
"HeavyDB lockfiles catalogs directory already exists at " +
259 lockfiles_path2 +
". Use -f to force reinitialization.\n";
264 if (boost::filesystem::exists(lockfiles_path3)) {
266 boost::filesystem::remove_all(lockfiles_path3);
268 std::cerr <<
"HeavyDB lockfiles data directory already exists at " +
269 lockfiles_path3 +
". Use -f to force reinitialization.\n";
274 if (boost::filesystem::exists(export_path)) {
276 boost::filesystem::remove_all(export_path);
278 std::cerr <<
"HeavyDB export directory already exists at " + export_path +
279 ". Use -f to force reinitialization.\n";
284 if (boost::filesystem::exists(disk_cache_path)) {
286 boost::filesystem::remove_all(disk_cache_path);
288 std::cerr <<
"HeavyDB disk cache already exists at " + disk_cache_path +
289 ". Use -f to force reinitialization.\n";
294 if (!boost::filesystem::create_directory(catalogs_path)) {
295 std::cerr <<
"Cannot create " + shared::kCatalogDirectoryName +
" subdirectory under "
296 << base_path << std::endl;
298 if (!boost::filesystem::create_directory(lockfiles_path)) {
299 std::cerr <<
"Cannot create " + shared::kLockfilesDirectoryName +
300 " subdirectory under "
301 << base_path << std::endl;
303 if (!boost::filesystem::create_directory(lockfiles_path2)) {
304 std::cerr <<
"Cannot create " + shared::kLockfilesDirectoryName +
"/" +
305 shared::kCatalogDirectoryName +
" subdirectory under "
306 << base_path << std::endl;
308 if (!boost::filesystem::create_directory(lockfiles_path3)) {
309 std::cerr <<
"Cannot create " + shared::kLockfilesDirectoryName +
"/" +
310 shared::kDataDirectoryName +
" subdirectory under "
311 << base_path << std::endl;
313 if (!boost::filesystem::create_directory(export_path)) {
314 std::cerr <<
"Cannot create " + shared::kDefaultExportDirName +
" subdirectory under "
315 << base_path << std::endl;
323 auto dummy = std::make_shared<Data_Namespace::DataMgr>(
324 data_path, sys_parms,
nullptr,
false, 0);
326 std::make_shared<Calcite>(-1,
CALCITEPORT, base_path, 1024, 5000,
true,
"");
329 sys_cat.init(base_path, dummy, {}, calcite,
true,
false, {});
331 }
catch (std::exception& e) {
332 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)
const std::string kLockfilesDirectoryName
static std::string getDefaultPath(const std::string &base_path)
bool g_enable_thrift_logs