17 #include <thrift/Thrift.h>
19 #include <boost/filesystem.hpp>
20 #include <boost/program_options.hpp>
33 #define CALCITEPORT 3279
44 int main(
int argc,
char* argv[]) {
45 std::string base_path;
47 bool skip_geo =
false;
48 namespace po = boost::program_options;
50 po::options_description desc(
"Options");
51 desc.add_options()(
"help,h",
"Print help messages ")(
53 po::value<std::string>(&base_path)->required(),
54 "Directory path to OmniSci catalogs")(
55 "force,f",
"Force overwriting of existing OmniSci instance")(
56 "skip-geo",
"Skip inserting sample geo data");
58 desc.add_options()(
"enable-thrift-logs",
61 ->implicit_value(
true),
62 "Enable writing messages directly from thrift to stdout/stderr.");
67 po::positional_options_description positionalOptions;
68 positionalOptions.add(
"data", 1);
73 po::store(po::command_line_parser(argc, argv)
75 .positional(positionalOptions)
78 if (vm.count(
"help")) {
82 if (vm.count(
"force")) {
85 if (vm.count(
"skip-geo")) {
89 }
catch (boost::program_options::error& e) {
90 std::cerr <<
"Usage Error: " << e.what() << std::endl;
95 apache::thrift::GlobalOutput.setOutputFunction([](
const char* msg) {});
98 if (!boost::filesystem::exists(base_path)) {
99 std::cerr <<
"Catalog basepath " + base_path +
" does not exist.\n";
102 std::string catalogs_path = base_path +
"/mapd_catalogs";
103 if (boost::filesystem::exists(catalogs_path)) {
105 boost::filesystem::remove_all(catalogs_path);
107 std::cerr <<
"OmniSci catalogs already initialized at " + base_path +
108 ". Use -f to force reinitialization.\n";
112 std::string
data_path = base_path +
"/mapd_data";
113 if (boost::filesystem::exists(data_path)) {
115 boost::filesystem::remove_all(data_path);
117 std::cerr <<
"OmniSci data directory already exists at " + base_path +
118 ". Use -f to force reinitialization.\n";
122 std::string export_path = base_path +
"/mapd_export";
123 if (boost::filesystem::exists(export_path)) {
125 boost::filesystem::remove_all(export_path);
127 std::cerr <<
"OmniSci export directory already exists at " + base_path +
128 ". Use -f to force reinitialization.\n";
132 if (!boost::filesystem::create_directory(catalogs_path)) {
133 std::cerr <<
"Cannot create mapd_catalogs subdirectory under " << base_path
136 if (!boost::filesystem::create_directory(export_path)) {
137 std::cerr <<
"Cannot create mapd_export subdirectory under " << base_path
146 auto dummy = std::make_shared<Data_Namespace::DataMgr>(
147 data_path, sys_parms,
nullptr,
false, 0);
149 std::make_shared<Calcite>(-1,
CALCITEPORT, base_path, 1024, 5000,
true,
"");
152 sys_cat.init(base_path, dummy, {}, calcite,
true,
false, {});
158 CHECK(sys_cat.getMetadataForDB(db_name, cur_db));
159 auto cat = sys_cat.getCatalog(cur_db,
false);
166 for (
size_t i = 0;
i < num_samples;
i++) {
170 const auto file_path = boost::filesystem::path(
172 if (!boost::filesystem::exists(file_path)) {
173 throw std::runtime_error(
174 "Unable to populate geo sample data. File does not exist: " +
178 import_driver.importGeoTable(file_path.string(), table_name,
true,
true,
false);
182 }
catch (std::exception& e) {
183 std::cerr <<
"Exception: " << e.what() <<
"\n";
boost::program_options::options_description const & get_options() const
This file contains the class specification and related data structures for Catalog.
static const std::array< std::string, 3 > SampleGeoFileNames
static SysCatalog & instance()
void init(LogOptions const &log_opts)
const std::string OMNISCI_DEFAULT_DB
static const std::array< std::string, 3 > SampleGeoTableNames
bool g_enable_thrift_logs
const std::string OMNISCI_ROOT_USER
std::string get_root_abs_path()
void set_base_path(std::string const &base_path)