OmniSciDB  a667adc9c8
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
EmbeddedDbFSITest.cpp File Reference
#include <boost/filesystem.hpp>
#include <boost/program_options.hpp>
#include <exception>
#include <iostream>
#include "DBEngine.h"
#include <arrow/api.h>
#include <arrow/csv/reader.h>
#include <arrow/io/file.h>
#include "Shared/ArrowUtil.h"
+ Include dependency graph for EmbeddedDbFSITest.cpp:

Go to the source code of this file.

Functions

int main (int argc, char *argv[])
 

Function Documentation

int main ( int  argc,
char *  argv[] 
)

Definition at line 30 of file EmbeddedDbFSITest.cpp.

References EmbeddedDatabase::DBEngine::create(), setup::dbe, run, and to_string().

30  {
31  std::string base_path, csv_path;
32  int calcite_port = 5555;
33  bool columnar_output = true;
34  namespace po = boost::program_options;
35 
36  po::options_description desc("Options");
37  desc.add_options()("help,h", "Print help messages ")(
38  "data",
39  po::value<std::string>(&base_path)->required(),
40  "Directory path to OmniSci catalogs")(
41  "csv", po::value<std::string>(&csv_path)->required(), "Directory path to CSV file")(
42  "calcite-port",
43  po::value<int>(&calcite_port)->default_value(calcite_port),
44  "Calcite port")("columnar-output",
45  po::value<bool>(&columnar_output)->default_value(columnar_output),
46  "Enable columnar_output");
47 
48  po::positional_options_description positionalOptions;
49  positionalOptions.add("data", 1);
50 
51  po::variables_map vm;
52 
53  try {
54  po::store(po::command_line_parser(argc, argv)
55  .options(desc)
56  .positional(positionalOptions)
57  .run(),
58  vm);
59  if (vm.count("help")) {
60  std::cout << desc;
61  return 0;
62  }
63  po::notify(vm);
64  } catch (boost::program_options::error& e) {
65  std::cerr << "Usage Error: " << e.what() << std::endl;
66  return 1;
67  }
68 
69  try {
70  auto opt_str = base_path + " --calcite-port " + std::to_string(calcite_port);
71  if (columnar_output) {
72  opt_str += "--columnar-output";
73  }
74  auto dbe = DBEngine::create(opt_str);
75  if (dbe) {
76  dbe->executeDDL(std::string(R"( CREATE TEMPORARY TABLE test ( trip_id BIGINT, vendor_id TEXT ENCODING NONE, pickup_datetime TIMESTAMP, dropoff_datetime TIMESTAMP, store_and_fwd_flag TEXT ENCODING DICT, rate_code_id BIGINT, pickup_longitude DOUBLE, pickup_latitude DOUBLE, dropoff_longitude DOUBLE, dropoff_latitude DOUBLE, passenger_count BIGINT, trip_distance DOUBLE, fare_amount DOUBLE, extra DOUBLE, mta_tax DOUBLE, tip_amount DOUBLE, tolls_amount DOUBLE, ehail_fee DOUBLE, improvement_surcharge DOUBLE, total_amount DOUBLE, payment_type TEXT ENCODING DICT, trip_type BIGINT, pickup TEXT ENCODING DICT, dropoff TEXT ENCODING NONE, cab_type TEXT ENCODING DICT, precipitation DOUBLE, snow_depth BIGINT, snowfall DOUBLE, max_temperature BIGINT, min_temperature BIGINT, average_wind_speed DOUBLE, pickup_nyct2010_gid BIGINT, pickup_ctlabel DOUBLE, pickup_borocode BIGINT, pickup_boroname TEXT ENCODING NONE, pickup_ct2010 BIGINT, pickup_boroct2010 BIGINT, pickup_cdeligibil TEXT ENCODING DICT, pickup_ntacode TEXT ENCODING DICT, pickup_ntaname TEXT ENCODING DICT, pickup_puma BIGINT, dropoff_nyct2010_gid BIGINT, dropoff_ctlabel DOUBLE, dropoff_borocode BIGINT, dropoff_boroname TEXT ENCODING NONE, dropoff_ct2010 BIGINT, dropoff_boroct2010 BIGINT, dropoff_cdeligibil TEXT ENCODING NONE, dropoff_ntacode TEXT ENCODING NONE, dropoff_ntaname TEXT ENCODING NONE, dropoff_puma BIGINT) WITH (storage_type='CSV:") + csv_path + std::string("', fragment_size=100);)"));
77  auto schema = dbe->getTableDetails("test");
78  for (auto& item : schema) {
79  std::cout << item.col_name << std::endl;
80  }
81  auto cursor = dbe->executeDML("select count(*) from test");
82  if (cursor) {
83  std::cout << cursor->getRowCount() << " rows selected" << std::endl;
84  std::shared_ptr<arrow::RecordBatch> rbatch = cursor->getArrowRecordBatch();
85  } else {
86  std::cerr << "Cursor is NULL" << std::endl;
87  }
88  }
89  } catch (std::exception& e) {
90  std::cerr << "Exception: " << e.what() << "\n";
91  }
92  return 0;
93 }
94 
std::string to_string(char const *&&v)
FILE * create(const std::string &basePath, const int fileId, const size_t pageSize, const size_t numPages)
Definition: File.cpp:49
tuple dbe
Definition: setup.in.py:14
static bool run

+ Here is the call graph for this function: