OmniSciDB  471d68cefb
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
anonymous_namespace{DBHandler.cpp} Namespace Reference

Classes

struct  ForceDisconnect
 
struct  ProjectionTokensForCompletion
 

Functions

SessionMap::iterator get_session_from_map (const TSessionId &session, SessionMap &session_map)
 
ProjectionTokensForCompletion extract_projection_tokens_for_completion (const std::string &sql)
 
std::string dump_table_col_names (const std::map< std::string, std::vector< std::string >> &table_col_names)
 
void check_table_not_sharded (const TableDescriptor *td)
 
void check_valid_column_names (const std::list< const ColumnDescriptor * > &descs, const std::vector< std::string > &column_names)
 
std::vector< int > column_ids_by_names (const std::list< const ColumnDescriptor * > &descs, const std::vector< std::string > &column_names)
 
size_t get_column_size (const TColumn &column)
 
RecordBatchVector loadArrowStream (const std::string &stream)
 
void add_vsi_network_prefix (std::string &path)
 
void add_vsi_geo_prefix (std::string &path)
 
void add_vsi_archive_prefix (std::string &path)
 
std::string remove_vsi_prefixes (const std::string &path_in)
 
bool path_is_relative (const std::string &path)
 
bool path_has_valid_filename (const std::string &path)
 
bool is_a_supported_geo_file (const std::string &path, bool include_gz)
 
bool is_a_supported_archive_file (const std::string &path)
 
std::string find_first_geo_file_in_archive (const std::string &archive_path, const import_export::CopyParams &copy_params)
 
bool is_local_file (const std::string &file_path)
 
void validate_import_file_path_if_local (const std::string &file_path)
 
std::unique_ptr
< Catalog_Namespace::CustomExpression
create_custom_expr_from_thrift_obj (const TCustomExpression &t_custom_expr, const Catalog &catalog)
 
TCustomExpression create_thrift_obj_from_custom_expr (const CustomExpression &custom_expr, const Catalog &catalog)
 
bool is_info_schema_db (const std::string &db_name)
 
void check_not_info_schema_db (const std::string &db_name, bool throw_mapd_exception=false)
 
bool TTypeInfo_IsGeo (const TDatumType::type &t)
 

Function Documentation

void anonymous_namespace{DBHandler.cpp}::add_vsi_archive_prefix ( std::string &  path)

Definition at line 3774 of file DBHandler.cpp.

Referenced by DBHandler::detect_column_types(), DBHandler::get_all_files_in_archive(), DBHandler::get_first_geo_file_in_archive(), DBHandler::get_layers_in_geo_file(), and DBHandler::import_geo_table().

3774  {
3775  // check for compressed file or file bundle
3776  if (boost::iends_with(path, ".zip")) {
3777  // zip archive
3778  path = "/vsizip/" + path;
3779  } else if (boost::iends_with(path, ".tar") || boost::iends_with(path, ".tgz") ||
3780  boost::iends_with(path, ".tar.gz")) {
3781  // tar archive (compressed or uncompressed)
3782  path = "/vsitar/" + path;
3783  }
3784 }

+ Here is the caller graph for this function:

void anonymous_namespace{DBHandler.cpp}::add_vsi_geo_prefix ( std::string &  path)

Definition at line 3767 of file DBHandler.cpp.

Referenced by DBHandler::detect_column_types(), DBHandler::get_layers_in_geo_file(), and DBHandler::import_geo_table().

3767  {
3768  // single gzip'd file (not an archive)?
3769  if (boost::iends_with(path, ".gz") && !boost::iends_with(path, ".tar.gz")) {
3770  path = "/vsigzip/" + path;
3771  }
3772 }

+ Here is the caller graph for this function:

void anonymous_namespace{DBHandler.cpp}::add_vsi_network_prefix ( std::string &  path)

Definition at line 3745 of file DBHandler.cpp.

References Geospatial::GDAL::supportsNetworkFileAccess(), and THROW_MAPD_EXCEPTION.

Referenced by DBHandler::detect_column_types(), DBHandler::get_all_files_in_archive(), DBHandler::get_first_geo_file_in_archive(), DBHandler::get_layers_in_geo_file(), and DBHandler::import_geo_table().

3745  {
3746  // do we support network file access?
3747  bool gdal_network = Geospatial::GDAL::supportsNetworkFileAccess();
3748 
3749  // modify head of filename based on source location
3750  if (boost::istarts_with(path, "http://") || boost::istarts_with(path, "https://")) {
3751  if (!gdal_network) {
3753  "HTTP geo file import not supported! Update to GDAL 2.2 or later!");
3754  }
3755  // invoke GDAL CURL virtual file reader
3756  path = "/vsicurl/" + path;
3757  } else if (boost::istarts_with(path, "s3://")) {
3758  if (!gdal_network) {
3760  "S3 geo file import not supported! Update to GDAL 2.2 or later!");
3761  }
3762  // invoke GDAL S3 virtual file reader
3763  boost::replace_first(path, "s3://", "/vsis3/");
3764  }
3765 }
#define THROW_MAPD_EXCEPTION(errstr)
Definition: DBHandler.cpp:126
static bool supportsNetworkFileAccess()
Definition: GDAL.cpp:118

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void anonymous_namespace{DBHandler.cpp}::check_not_info_schema_db ( const std::string &  db_name,
bool  throw_mapd_exception = false 
)

Definition at line 4330 of file DBHandler.cpp.

References INFORMATION_SCHEMA_DB, is_info_schema_db(), and THROW_MAPD_EXCEPTION.

Referenced by DBHandler::create_dashboard(), and DBHandler::sql_execute_impl().

4331  {
4332  if (is_info_schema_db(db_name)) {
4333  std::string error_message{"Write requests/queries are not allowed in the " +
4334  INFORMATION_SCHEMA_DB + " database."};
4335  if (throw_mapd_exception) {
4336  THROW_MAPD_EXCEPTION(error_message)
4337  } else {
4338  throw std::runtime_error(error_message);
4339  }
4340  }
4341 }
#define THROW_MAPD_EXCEPTION(errstr)
Definition: DBHandler.cpp:126
const std::string INFORMATION_SCHEMA_DB
Definition: SysCatalog.h:65
bool is_info_schema_db(const std::string &db_name)
Definition: DBHandler.cpp:4325

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void anonymous_namespace{DBHandler.cpp}::check_table_not_sharded ( const TableDescriptor td)

Definition at line 2815 of file DBHandler.cpp.

References TableDescriptor::nShards.

Referenced by DBHandler::prepare_loader_generic().

2815  {
2816  if (td && td->nShards) {
2817  throw std::runtime_error("Cannot import a sharded table directly to a leaf");
2818  }
2819 }

+ Here is the caller graph for this function:

void anonymous_namespace{DBHandler.cpp}::check_valid_column_names ( const std::list< const ColumnDescriptor * > &  descs,
const std::vector< std::string > &  column_names 
)

Definition at line 2821 of file DBHandler.cpp.

References setup::name, THROW_MAPD_EXCEPTION, and to_lower().

Referenced by DBHandler::prepare_loader_generic().

2822  {
2823  std::unordered_set<std::string> unique_names;
2824  for (const auto& name : column_names) {
2825  auto lower_name = to_lower(name);
2826  if (unique_names.find(lower_name) != unique_names.end()) {
2827  THROW_MAPD_EXCEPTION("Column " + name + " is mentioned multiple times");
2828  } else {
2829  unique_names.insert(lower_name);
2830  }
2831  }
2832  for (const auto& cd : descs) {
2833  auto iter = unique_names.find(to_lower(cd->columnName));
2834  if (iter != unique_names.end()) {
2835  unique_names.erase(iter);
2836  }
2837  }
2838  if (!unique_names.empty()) {
2839  THROW_MAPD_EXCEPTION("Column " + *unique_names.begin() + " does not exist");
2840  }
2841 }
std::string to_lower(const std::string &str)
string name
Definition: setup.in.py:72
#define THROW_MAPD_EXCEPTION(errstr)
Definition: DBHandler.cpp:126

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

std::vector<int> anonymous_namespace{DBHandler.cpp}::column_ids_by_names ( const std::list< const ColumnDescriptor * > &  descs,
const std::vector< std::string > &  column_names 
)

Definition at line 2847 of file DBHandler.cpp.

References THROW_MAPD_EXCEPTION, and to_lower().

Referenced by DBHandler::load_table(), DBHandler::load_table_binary(), DBHandler::load_table_binary_arrow(), and DBHandler::load_table_binary_columnar_internal().

2848  {
2849  std::vector<int> desc_to_column_ids;
2850  if (column_names.empty()) {
2851  int col_idx = 0;
2852  for (const auto& cd : descs) {
2853  if (!cd->isGeoPhyCol) {
2854  desc_to_column_ids.push_back(col_idx);
2855  ++col_idx;
2856  }
2857  }
2858  } else {
2859  for (const auto& cd : descs) {
2860  if (!cd->isGeoPhyCol) {
2861  bool found = false;
2862  for (size_t j = 0; j < column_names.size(); ++j) {
2863  if (to_lower(cd->columnName) == to_lower(column_names[j])) {
2864  found = true;
2865  desc_to_column_ids.push_back(j);
2866  break;
2867  }
2868  }
2869  if (!found) {
2870  if (!cd->columnType.get_notnull()) {
2871  desc_to_column_ids.push_back(-1);
2872  } else {
2873  THROW_MAPD_EXCEPTION("Column '" + cd->columnName +
2874  "' cannot be omitted due to NOT NULL constraint");
2875  }
2876  }
2877  }
2878  }
2879  }
2880  return desc_to_column_ids;
2881 }
std::string to_lower(const std::string &str)
#define THROW_MAPD_EXCEPTION(errstr)
Definition: DBHandler.cpp:126

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

std::unique_ptr<Catalog_Namespace::CustomExpression> anonymous_namespace{DBHandler.cpp}::create_custom_expr_from_thrift_obj ( const TCustomExpression &  t_custom_expr,
const Catalog catalog 
)

Definition at line 4113 of file DBHandler.cpp.

References CHECK, Catalog_Namespace::Catalog::getMetadataForTable(), and THROW_MAPD_EXCEPTION.

Referenced by DBHandler::create_custom_expression().

4115  {
4116  if (t_custom_expr.data_source_name.empty()) {
4117  THROW_MAPD_EXCEPTION("Custom expression data source name cannot be empty.")
4118  }
4119  CHECK(t_custom_expr.data_source_type == TDataSourceType::type::TABLE)
4120  << "Unexpected data source type: "
4121  << static_cast<int>(t_custom_expr.data_source_type);
4122  auto td = catalog.getMetadataForTable(t_custom_expr.data_source_name, false);
4123  if (!td) {
4124  THROW_MAPD_EXCEPTION("Custom expression references a table \"" +
4125  t_custom_expr.data_source_name + "\" that does not exist.")
4126  }
4127  DataSourceType data_source_type = DataSourceType::TABLE;
4128  return std::make_unique<CustomExpression>(
4129  t_custom_expr.name, t_custom_expr.expression_json, data_source_type, td->tableId);
4130 }
#define THROW_MAPD_EXCEPTION(errstr)
Definition: DBHandler.cpp:126
#define CHECK(condition)
Definition: Logger.h:209
const TableDescriptor * getMetadataForTable(const std::string &tableName, const bool populateFragmenter=true) const
Returns a pointer to a const TableDescriptor struct matching the provided tableName.

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

TCustomExpression anonymous_namespace{DBHandler.cpp}::create_thrift_obj_from_custom_expr ( const CustomExpression &  custom_expr,
const Catalog catalog 
)

Definition at line 4132 of file DBHandler.cpp.

References CHECK, Catalog_Namespace::CustomExpression::data_source_id, Catalog_Namespace::CustomExpression::data_source_type, Catalog_Namespace::CustomExpression::expression_json, Catalog_Namespace::Catalog::getMetadataForTable(), Catalog_Namespace::CustomExpression::id, Catalog_Namespace::CustomExpression::is_deleted, LOG, Catalog_Namespace::CustomExpression::name, TableDescriptor::tableName, and logger::WARNING.

Referenced by DBHandler::get_custom_expressions().

4133  {
4134  TCustomExpression t_custom_expr;
4135  t_custom_expr.id = custom_expr.id;
4136  t_custom_expr.name = custom_expr.name;
4137  t_custom_expr.expression_json = custom_expr.expression_json;
4138  t_custom_expr.data_source_id = custom_expr.data_source_id;
4139  t_custom_expr.is_deleted = custom_expr.is_deleted;
4140  CHECK(custom_expr.data_source_type == DataSourceType::TABLE)
4141  << "Unexpected data source type: "
4142  << static_cast<int>(custom_expr.data_source_type);
4143  t_custom_expr.data_source_type = TDataSourceType::type::TABLE;
4144  auto td = catalog.getMetadataForTable(custom_expr.data_source_id, false);
4145  if (td) {
4146  t_custom_expr.data_source_name = td->tableName;
4147  } else {
4148  LOG(WARNING)
4149  << "Custom expression references a deleted data source. Custom expression id: "
4150  << custom_expr.id << ", name: " << custom_expr.name;
4151  }
4152  return t_custom_expr;
4153 }
std::string tableName
#define LOG(tag)
Definition: Logger.h:203
#define CHECK(condition)
Definition: Logger.h:209
const TableDescriptor * getMetadataForTable(const std::string &tableName, const bool populateFragmenter=true) const
Returns a pointer to a const TableDescriptor struct matching the provided tableName.

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

std::string anonymous_namespace{DBHandler.cpp}::dump_table_col_names ( const std::map< std::string, std::vector< std::string >> &  table_col_names)

Definition at line 2194 of file DBHandler.cpp.

Referenced by DBHandler::get_result_row_for_pixel().

2195  {
2196  std::ostringstream oss;
2197  for (const auto& [table_name, col_names] : table_col_names) {
2198  oss << ":" << table_name;
2199  for (const auto& col_name : col_names) {
2200  oss << "," << col_name;
2201  }
2202  }
2203  return oss.str();
2204 }

+ Here is the caller graph for this function:

ProjectionTokensForCompletion anonymous_namespace{DBHandler.cpp}::extract_projection_tokens_for_completion ( const std::string &  sql)

Definition at line 1593 of file DBHandler.cpp.

References split(), and to_upper().

Referenced by DBHandler::get_completion_hints().

1594  {
1595  boost::regex id_regex{R"(([[:alnum:]]|_|\.)+)",
1596  boost::regex::extended | boost::regex::icase};
1597  boost::sregex_token_iterator tok_it(sql.begin(), sql.end(), id_regex, 0);
1598  boost::sregex_token_iterator end;
1599  std::unordered_set<std::string> uc_column_names;
1600  std::unordered_set<std::string> uc_column_table_qualifiers;
1601  for (; tok_it != end; ++tok_it) {
1602  std::string column_name = *tok_it;
1603  std::vector<std::string> column_tokens;
1604  boost::split(column_tokens, column_name, boost::is_any_of("."));
1605  if (column_tokens.size() == 2) {
1606  // If the column name is qualified, take user's word.
1607  uc_column_table_qualifiers.insert(to_upper(column_tokens.front()));
1608  } else {
1609  uc_column_names.insert(to_upper(column_name));
1610  }
1611  }
1612  return {uc_column_names, uc_column_table_qualifiers};
1613 }
std::vector< std::string > split(std::string_view str, std::string_view delim, std::optional< size_t > maxsplit)
split apart a string into a vector of substrings
std::string to_upper(const std::string &str)

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

std::string anonymous_namespace{DBHandler.cpp}::find_first_geo_file_in_archive ( const std::string &  archive_path,
const import_export::CopyParams copy_params 
)

Definition at line 3855 of file DBHandler.cpp.

References import_export::Importer::gdalGetAllFilesInArchive(), logger::INFO, is_a_supported_geo_file(), LOG, and remove_vsi_prefixes().

Referenced by DBHandler::detect_column_types(), DBHandler::get_first_geo_file_in_archive(), DBHandler::get_layers_in_geo_file(), and DBHandler::import_geo_table().

3856  {
3857  // get the recursive list of all files in the archive
3858  std::vector<std::string> files =
3859  import_export::Importer::gdalGetAllFilesInArchive(archive_path, copy_params);
3860 
3861  // report the list
3862  LOG(INFO) << "Found " << files.size() << " files in Archive "
3863  << remove_vsi_prefixes(archive_path);
3864  for (const auto& file : files) {
3865  LOG(INFO) << " " << file;
3866  }
3867 
3868  // scan the list for the first candidate file
3869  bool found_suitable_file = false;
3870  std::string file_name;
3871  for (const auto& file : files) {
3872  if (is_a_supported_geo_file(file, false)) {
3873  file_name = file;
3874  found_suitable_file = true;
3875  break;
3876  }
3877  }
3878 
3879  // if we didn't find anything
3880  if (!found_suitable_file) {
3881  LOG(INFO) << "Failed to find any supported geo files in Archive: " +
3882  remove_vsi_prefixes(archive_path);
3883  file_name.clear();
3884  }
3885 
3886  // done
3887  return file_name;
3888 }
#define LOG(tag)
Definition: Logger.h:203
std::string remove_vsi_prefixes(const std::string &path_in)
Definition: DBHandler.cpp:3786
static std::vector< std::string > gdalGetAllFilesInArchive(const std::string &archive_path, const CopyParams &copy_params)
Definition: Importer.cpp:5035
bool is_a_supported_geo_file(const std::string &path, bool include_gz)
Definition: DBHandler.cpp:3824

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

size_t anonymous_namespace{DBHandler.cpp}::get_column_size ( const TColumn &  column)

Definition at line 3145 of file DBHandler.cpp.

Referenced by DBHandler::load_table_binary_columnar_internal().

3145  {
3146  if (!column.nulls.empty()) {
3147  return column.nulls.size();
3148  } else {
3149  // it is a very bold estimate but later we check it against REAL data
3150  // and if this function returns a wrong result (e.g. both int and string
3151  // vectors are filled with values), we get an error
3152  return column.data.int_col.size() + column.data.arr_col.size() +
3153  column.data.real_col.size() + column.data.str_col.size();
3154  }
3155 }

+ Here is the caller graph for this function:

SessionMap::iterator anonymous_namespace{DBHandler.cpp}::get_session_from_map ( const TSessionId &  session,
SessionMap session_map 
)

Definition at line 139 of file DBHandler.cpp.

References THROW_MAPD_EXCEPTION.

Referenced by DBHandler::expire_idle_sessions_unsafe(), and DBHandler::get_session_it_unsafe().

140  {
141  auto session_it = session_map.find(session);
142  if (session_it == session_map.end()) {
143  THROW_MAPD_EXCEPTION("Session not valid.");
144  }
145  return session_it;
146 }
#define THROW_MAPD_EXCEPTION(errstr)
Definition: DBHandler.cpp:126

+ Here is the caller graph for this function:

bool anonymous_namespace{DBHandler.cpp}::is_a_supported_archive_file ( const std::string &  path)

Definition at line 3842 of file DBHandler.cpp.

References path_has_valid_filename().

Referenced by DBHandler::detect_column_types(), DBHandler::get_all_files_in_archive(), DBHandler::get_first_geo_file_in_archive(), DBHandler::get_layers_in_geo_file(), and DBHandler::import_geo_table().

3842  {
3843  if (!path_has_valid_filename(path)) {
3844  return false;
3845  }
3846  if (boost::iends_with(path, ".zip") && !boost::iends_with(path, ".gdb.zip")) {
3847  return true;
3848  } else if (boost::iends_with(path, ".tar") || boost::iends_with(path, ".tgz") ||
3849  boost::iends_with(path, ".tar.gz")) {
3850  return true;
3851  }
3852  return false;
3853 }
bool path_has_valid_filename(const std::string &path)
Definition: DBHandler.cpp:3816

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

bool anonymous_namespace{DBHandler.cpp}::is_a_supported_geo_file ( const std::string &  path,
bool  include_gz 
)

Definition at line 3824 of file DBHandler.cpp.

References path_has_valid_filename().

Referenced by DBHandler::detect_column_types(), find_first_geo_file_in_archive(), DBHandler::get_layers_in_geo_file(), and DBHandler::import_geo_table().

3824  {
3825  if (!path_has_valid_filename(path)) {
3826  return false;
3827  }
3828  if (include_gz) {
3829  if (boost::iends_with(path, ".geojson.gz") || boost::iends_with(path, ".json.gz")) {
3830  return true;
3831  }
3832  }
3833  if (boost::iends_with(path, ".shp") || boost::iends_with(path, ".geojson") ||
3834  boost::iends_with(path, ".json") || boost::iends_with(path, ".kml") ||
3835  boost::iends_with(path, ".kmz") || boost::iends_with(path, ".gdb") ||
3836  boost::iends_with(path, ".gdb.zip") || boost::iends_with(path, ".fgb")) {
3837  return true;
3838  }
3839  return false;
3840 }
bool path_has_valid_filename(const std::string &path)
Definition: DBHandler.cpp:3816

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

bool anonymous_namespace{DBHandler.cpp}::is_info_schema_db ( const std::string &  db_name)

Definition at line 4325 of file DBHandler.cpp.

References INFORMATION_SCHEMA_DB, and INFORMATION_SCHEMA_MIGRATION.

Referenced by check_not_info_schema_db().

4325  {
4326  return (db_name == INFORMATION_SCHEMA_DB &&
4327  SysCatalog::instance().hasExecutedMigration(INFORMATION_SCHEMA_MIGRATION));
4328 }
const std::string INFORMATION_SCHEMA_MIGRATION
Definition: SysCatalog.h:66
const std::string INFORMATION_SCHEMA_DB
Definition: SysCatalog.h:65

+ Here is the caller graph for this function:

bool anonymous_namespace{DBHandler.cpp}::is_local_file ( const std::string &  file_path)

Definition at line 3890 of file DBHandler.cpp.

Referenced by validate_import_file_path_if_local().

3890  {
3891  return (!boost::istarts_with(file_path, "s3://") &&
3892  !boost::istarts_with(file_path, "http://") &&
3893  !boost::istarts_with(file_path, "https://"));
3894 }

+ Here is the caller graph for this function:

RecordBatchVector anonymous_namespace{DBHandler.cpp}::loadArrowStream ( const std::string &  stream)

Definition at line 3310 of file DBHandler.cpp.

References ARROW_ASSIGN_OR_THROW, ARROW_THRIFT_THROW_NOT_OK, logger::ERROR, and LOG.

Referenced by DBHandler::load_table_binary_arrow().

3310  {
3311  RecordBatchVector batches;
3312  try {
3313  // TODO(wesm): Make this simpler in general, see ARROW-1600
3314  auto stream_buffer =
3315  std::make_shared<arrow::Buffer>(reinterpret_cast<const uint8_t*>(stream.c_str()),
3316  static_cast<int64_t>(stream.size()));
3317 
3318  arrow::io::BufferReader buf_reader(stream_buffer);
3319  std::shared_ptr<arrow::RecordBatchReader> batch_reader;
3320  ARROW_ASSIGN_OR_THROW(batch_reader,
3321  arrow::ipc::RecordBatchStreamReader::Open(&buf_reader));
3322 
3323  while (true) {
3324  std::shared_ptr<arrow::RecordBatch> batch;
3325  // Read batch (zero-copy) from the stream
3326  ARROW_THRIFT_THROW_NOT_OK(batch_reader->ReadNext(&batch));
3327  if (batch == nullptr) {
3328  break;
3329  }
3330  batches.emplace_back(std::move(batch));
3331  }
3332  } catch (const std::exception& e) {
3333  LOG(ERROR) << "Error parsing Arrow stream: " << e.what() << ". Import aborted";
3334  }
3335  return batches;
3336 }
#define LOG(tag)
Definition: Logger.h:203
#define ARROW_ASSIGN_OR_THROW(lhs, rexpr)
Definition: ArrowUtil.h:60
std::vector< std::shared_ptr< arrow::RecordBatch >> RecordBatchVector
Definition: DBHandler.cpp:3295
#define ARROW_THRIFT_THROW_NOT_OK(s)
Definition: DBHandler.cpp:3297

+ Here is the caller graph for this function:

bool anonymous_namespace{DBHandler.cpp}::path_has_valid_filename ( const std::string &  path)

Definition at line 3816 of file DBHandler.cpp.

References nvtx_helpers::anonymous_namespace{nvtx_helpers.cpp}::filename().

Referenced by is_a_supported_archive_file(), and is_a_supported_geo_file().

3816  {
3817  auto filename = boost::filesystem::path(path).filename().string();
3818  if (filename.size() == 0 || filename[0] == '.' || filename[0] == '/') {
3819  return false;
3820  }
3821  return true;
3822 }

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

bool anonymous_namespace{DBHandler.cpp}::path_is_relative ( const std::string &  path)

Definition at line 3808 of file DBHandler.cpp.

Referenced by DBHandler::detect_column_types(), DBHandler::get_all_files_in_archive(), DBHandler::get_first_geo_file_in_archive(), DBHandler::get_layers_in_geo_file(), and DBHandler::import_geo_table().

3808  {
3809  if (boost::istarts_with(path, "s3://") || boost::istarts_with(path, "http://") ||
3810  boost::istarts_with(path, "https://")) {
3811  return false;
3812  }
3813  return !boost::filesystem::path(path).is_absolute();
3814 }

+ Here is the caller graph for this function:

std::string anonymous_namespace{DBHandler.cpp}::remove_vsi_prefixes ( const std::string &  path_in)

Definition at line 3786 of file DBHandler.cpp.

Referenced by find_first_geo_file_in_archive().

3786  {
3787  std::string path(path_in);
3788 
3789  // these will be first
3790  if (boost::istarts_with(path, "/vsizip/")) {
3791  boost::replace_first(path, "/vsizip/", "");
3792  } else if (boost::istarts_with(path, "/vsitar/")) {
3793  boost::replace_first(path, "/vsitar/", "");
3794  } else if (boost::istarts_with(path, "/vsigzip/")) {
3795  boost::replace_first(path, "/vsigzip/", "");
3796  }
3797 
3798  // then these
3799  if (boost::istarts_with(path, "/vsicurl/")) {
3800  boost::replace_first(path, "/vsicurl/", "");
3801  } else if (boost::istarts_with(path, "/vsis3/")) {
3802  boost::replace_first(path, "/vsis3/", "s3://");
3803  }
3804 
3805  return path;
3806 }

+ Here is the caller graph for this function:

bool anonymous_namespace{DBHandler.cpp}::TTypeInfo_IsGeo ( const TDatumType::type &  t)

Definition at line 4849 of file DBHandler.cpp.

References LINESTRING, MULTIPOLYGON, POINT, and POLYGON.

Referenced by DBHandler::import_geo_table().

4849  {
4850  return (t == TDatumType::POLYGON || t == TDatumType::MULTIPOLYGON ||
4852 }
#define LINESTRING
#define MULTIPOLYGON
#define POINT
char * t
#define POLYGON

+ Here is the caller graph for this function:

void anonymous_namespace{DBHandler.cpp}::validate_import_file_path_if_local ( const std::string &  file_path)

Definition at line 3896 of file DBHandler.cpp.

References ddl_utils::IMPORT, is_local_file(), and ddl_utils::validate_allowed_file_path().

Referenced by DBHandler::detect_column_types(), DBHandler::get_all_files_in_archive(), DBHandler::get_first_geo_file_in_archive(), DBHandler::get_layers_in_geo_file(), DBHandler::import_geo_table(), and DBHandler::import_table().

3896  {
3897  if (is_local_file(file_path)) {
3899  }
3900 }
void validate_allowed_file_path(const std::string &file_path, const DataTransferType data_transfer_type, const bool allow_wildcards)
Definition: DdlUtils.cpp:770
bool is_local_file(const std::string &file_path)
Definition: DBHandler.cpp:3890

+ Here is the call graph for this function:

+ Here is the caller graph for this function: