OmniSciDB  29e35f4d58
MapDHandler.cpp File Reference
#include "MapDHandler.h"
#include "DistributedLoader.h"
#include "MapDServer.h"
#include "QueryEngine/UDFCompiler.h"
#include "TokenCompletionHints.h"
#include "MapDRelease.h"
#include "Calcite/Calcite.h"
#include "gen-cpp/CalciteServer.h"
#include "QueryEngine/RelAlgExecutor.h"
#include "Catalog/Catalog.h"
#include "Fragmenter/InsertOrderFragmenter.h"
#include "Import/Importer.h"
#include "LockMgr/TableLockMgr.h"
#include "MapDDistributedHandler.h"
#include "Parser/ParserWrapper.h"
#include "Parser/ReservedKeywords.h"
#include "Parser/parser.h"
#include "Planner/Planner.h"
#include "QueryEngine/ArrowResultSet.h"
#include "QueryEngine/CalciteAdapter.h"
#include "QueryEngine/Execute.h"
#include "QueryEngine/ExtensionFunctionsWhitelist.h"
#include "QueryEngine/GpuMemUtils.h"
#include "QueryEngine/JoinFilterPushDown.h"
#include "QueryEngine/JsonAccessors.h"
#include "QueryEngine/TableFunctions/TableFunctionsFactory.h"
#include "QueryEngine/TableOptimizer.h"
#include "QueryEngine/ThriftSerializers.h"
#include "Shared/SQLTypeUtilities.h"
#include "Shared/StringTransform.h"
#include "Shared/SysInfo.h"
#include "Shared/geo_types.h"
#include "Shared/geosupport.h"
#include "Shared/import_helpers.h"
#include "Shared/mapd_shared_mutex.h"
#include "Shared/measure.h"
#include "Shared/scope.h"
#include <fcntl.h>
#include <picosha2.h>
#include <sys/time.h>
#include <sys/types.h>
#include <sys/wait.h>
#include <unistd.h>
#include <algorithm>
#include <boost/algorithm/string.hpp>
#include <boost/filesystem.hpp>
#include <boost/make_shared.hpp>
#include <boost/process/search_path.hpp>
#include <boost/program_options.hpp>
#include <boost/regex.hpp>
#include <boost/tokenizer.hpp>
#include <cmath>
#include <csignal>
#include <fstream>
#include <future>
#include <map>
#include <memory>
#include <random>
#include <regex>
#include <string>
#include <thread>
#include <typeinfo>
#include <arrow/api.h>
#include <arrow/io/api.h>
#include <arrow/ipc/api.h>
#include "QueryEngine/ArrowUtil.h"

Go to the source code of this file.

Classes

struct  anonymous_namespace{MapDHandler.cpp}::ForceDisconnect
 
struct  anonymous_namespace{MapDHandler.cpp}::ProjectionTokensForCompletion
 

Namespaces

 anonymous_namespace{MapDHandler.cpp}
 

Macros

#define ENABLE_GEO_IMPORT_COLUMN_MATCHING   0
 
#define INVALID_SESSION_ID   ""
 
#define THROW_MAPD_EXCEPTION(errstr)
 
#define ARROW_THRIFT_THROW_NOT_OK(s)
 
#define THROW_COLUMN_ATTR_MISMATCH_EXCEPTION(attr, got, expected)
 

Typedefs

using RecordBatchVector = std::vector< std::shared_ptr< arrow::RecordBatch > >
 

Functions

SessionMap::iterator anonymous_namespace{MapDHandler.cpp}::get_session_from_map (const TSessionId &session, SessionMap &session_map)
 
ProjectionTokensForCompletion anonymous_namespace{MapDHandler.cpp}::extract_projection_tokens_for_completion (const std::string &sql)
 
static TDBObject serialize_db_object (const std::string &roleName, const DBObject &inObject)
 
std::string anonymous_namespace{MapDHandler.cpp}::dump_table_col_names (const std::map< std::string, std::vector< std::string >> &table_col_names)
 
void anonymous_namespace{MapDHandler.cpp}::fixup_geo_column_descriptor (TColumnType &col_type, const SQLTypes subtype, const int output_srid)
 
void anonymous_namespace{MapDHandler.cpp}::check_table_not_sharded (const Catalog &cat, const std::string &table_name)
 
RecordBatchVector anonymous_namespace{MapDHandler.cpp}::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 Importer_NS::CopyParams &copy_params)
 
static bool is_allowed_on_dashboard (const Catalog_Namespace::SessionInfo &session_info, int32_t dashboard_id, AccessPrivileges requestedPermissions)
 
bool anonymous_namespace{MapDHandler.cpp}::TTypeInfo_IsGeo (const TDatumType::type &t)
 
std::map< std::string, std::string > get_device_parameters ()
 
ExtArgumentType mapfrom (const TExtArgumentType::type &t)
 
table_functions::OutputBufferSizeType mapfrom (const TOutputBufferSizeType::type &t)
 
std::vector< ExtArgumentTypemapfrom (const std::vector< TExtArgumentType::type > &v)
 

Macro Definition Documentation

◆ ARROW_THRIFT_THROW_NOT_OK

#define ARROW_THRIFT_THROW_NOT_OK (   s)
Value:
do { \
::arrow::Status _s = (s); \
if (UNLIKELY(!_s.ok())) { \
TMapDException ex; \
ex.error_msg = _s.ToString(); \
LOG(ERROR) << s.ToString(); \
throw ex; \
} \
} while (0)
#define UNLIKELY(x)
Definition: likely.h:20

Definition at line 2389 of file MapDHandler.cpp.

Referenced by anonymous_namespace{MapDHandler.cpp}::loadArrowStream().

◆ ENABLE_GEO_IMPORT_COLUMN_MATCHING

#define ENABLE_GEO_IMPORT_COLUMN_MATCHING   0

Definition at line 102 of file MapDHandler.cpp.

◆ INVALID_SESSION_ID

#define INVALID_SESSION_ID   ""

Definition at line 108 of file MapDHandler.cpp.

Referenced by MapDHandler::getInvalidSessionId().

◆ THROW_COLUMN_ATTR_MISMATCH_EXCEPTION

#define THROW_COLUMN_ATTR_MISMATCH_EXCEPTION (   attr,
  got,
  expected 
)
Value:
THROW_MAPD_EXCEPTION("Could not append geo file '" + file_path.filename().string() + \
"' to table '" + table_name + "'. Column '" + cd->columnName + \
"' " + attr + " mismatch (got '" + got + "', expected '" + \
expected + "')");
#define THROW_MAPD_EXCEPTION(errstr)

Definition at line 3742 of file MapDHandler.cpp.

Referenced by MapDHandler::import_geo_table().

◆ THROW_MAPD_EXCEPTION

#define THROW_MAPD_EXCEPTION (   errstr)
Value:
{ \
TMapDException ex; \
ex.error_msg = errstr; \
LOG(ERROR) << ex.error_msg; \
throw ex; \
}

Definition at line 110 of file MapDHandler.cpp.

Referenced by add_vsi_network_prefix(), MapDHandler::broadcast_serialized_rows(), MapDHandler::check_read_only(), MapDHandler::check_table_consistency(), MapDHandler::check_table_load_privileges(), MapDHandler::clear_cpu_memory(), MapDHandler::clear_gpu_memory(), MapDHandler::connect(), MapDHandler::convert_rows(), MapDHandler::create_dashboard(), MapDHandler::create_link(), MapDHandler::create_table(), MapDHandler::delete_dashboard(), MapDHandler::detect_column_types(), MapDHandler::execute_next_render_step(), MapDHandler::execute_query_step(), MapDHandler::get_all_files_in_archive(), MapDHandler::get_all_roles_for_user(), MapDHandler::get_dashboard(), MapDHandler::get_dashboard_grantees(), MapDHandler::get_db_object_privs(), MapDHandler::get_db_objects_for_grantee(), MapDHandler::get_first_geo_file_in_archive(), MapDHandler::get_heap_profile(), MapDHandler::get_layers_in_geo_file(), MapDHandler::get_link_view(), MapDHandler::get_result_row_for_pixel(), anonymous_namespace{MapDHandler.cpp}::get_session_from_map(), MapDHandler::get_session_it_unsafe(), MapDHandler::get_table_details_impl(), MapDHandler::get_tables_meta(), MapDHandler::get_valid_groups(), MapDHandler::has_dashboard_permission(), MapDHandler::has_database_permission(), MapDHandler::has_object_privilege(), MapDHandler::has_role(), MapDHandler::has_table_permission(), MapDHandler::has_view_permission(), MapDHandler::import_geo_table(), MapDHandler::import_table(), MapDHandler::insert_data(), MapDHandler::internal_connect(), MapDHandler::krb5_connect(), MapDHandler::load_table(), MapDHandler::load_table_binary(), MapDHandler::load_table_binary_arrow(), MapDHandler::load_table_binary_columnar(), MapDHandler::parse_to_plan_legacy(), MapDHandler::populateThriftColumnType(), MapDHandler::prepare_columnar_loader(), MapDHandler::register_runtime_extension_functions(), MapDHandler::render_vega(), MapDHandler::replace_dashboard(), MapDHandler::set_license_key(), MapDHandler::share_dashboard(), MapDHandler::sql_execute(), MapDHandler::sql_execute_df(), MapDHandler::sql_execute_impl(), MapDHandler::sql_validate(), MapDHandler::start_heap_profile(), MapDHandler::start_query(), MapDHandler::start_render_query(), MapDHandler::stop_heap_profile(), MapDHandler::switch_database(), MapDHandler::thrift_to_copyparams(), MapDHandler::unshare_dashboard(), and MapDHandler::validate_rel_alg().

Typedef Documentation

◆ RecordBatchVector

using RecordBatchVector = std::vector<std::shared_ptr<arrow::RecordBatch> >

Definition at line 2387 of file MapDHandler.cpp.

Function Documentation

◆ add_vsi_archive_prefix()

void add_vsi_archive_prefix ( std::string &  path)

Definition at line 2819 of file MapDHandler.cpp.

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

2819  {
2820  // check for compressed file or file bundle
2821  if (boost::iends_with(path, ".zip")) {
2822  // zip archive
2823  path = "/vsizip/" + path;
2824  } else if (boost::iends_with(path, ".tar") || boost::iends_with(path, ".tgz") ||
2825  boost::iends_with(path, ".tar.gz")) {
2826  // tar archive (compressed or uncompressed)
2827  path = "/vsitar/" + path;
2828  }
2829 }
+ Here is the caller graph for this function:

◆ add_vsi_geo_prefix()

void add_vsi_geo_prefix ( std::string &  path)

Definition at line 2812 of file MapDHandler.cpp.

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

2812  {
2813  // single gzip'd file (not an archive)?
2814  if (boost::iends_with(path, ".gz") && !boost::iends_with(path, ".tar.gz")) {
2815  path = "/vsigzip/" + path;
2816  }
2817 }
+ Here is the caller graph for this function:

◆ add_vsi_network_prefix()

void add_vsi_network_prefix ( std::string &  path)

Definition at line 2790 of file MapDHandler.cpp.

References Importer_NS::Importer::gdalSupportsNetworkFileAccess(), and THROW_MAPD_EXCEPTION.

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

2790  {
2791  // do we support network file access?
2793 
2794  // modify head of filename based on source location
2795  if (boost::istarts_with(path, "http://") || boost::istarts_with(path, "https://")) {
2796  if (!gdal_network) {
2798  "HTTP geo file import not supported! Update to GDAL 2.2 or later!");
2799  }
2800  // invoke GDAL CURL virtual file reader
2801  path = "/vsicurl/" + path;
2802  } else if (boost::istarts_with(path, "s3://")) {
2803  if (!gdal_network) {
2805  "S3 geo file import not supported! Update to GDAL 2.2 or later!");
2806  }
2807  // invoke GDAL S3 virtual file reader
2808  boost::replace_first(path, "s3://", "/vsis3/");
2809  }
2810 }
#define THROW_MAPD_EXCEPTION(errstr)
static bool gdalSupportsNetworkFileAccess()
Definition: Importer.cpp:4624
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ find_first_geo_file_in_archive()

std::string find_first_geo_file_in_archive ( const std::string &  archive_path,
const Importer_NS::CopyParams copy_params 
)

Definition at line 2900 of file MapDHandler.cpp.

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

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

2901  {
2902  // get the recursive list of all files in the archive
2903  std::vector<std::string> files =
2904  Importer_NS::Importer::gdalGetAllFilesInArchive(archive_path, copy_params);
2905 
2906  // report the list
2907  LOG(INFO) << "Found " << files.size() << " files in Archive "
2908  << remove_vsi_prefixes(archive_path);
2909  for (const auto& file : files) {
2910  LOG(INFO) << " " << file;
2911  }
2912 
2913  // scan the list for the first candidate file
2914  bool found_suitable_file = false;
2915  std::string file_name;
2916  for (const auto& file : files) {
2917  if (is_a_supported_geo_file(file, false)) {
2918  file_name = file;
2919  found_suitable_file = true;
2920  break;
2921  }
2922  }
2923 
2924  // if we didn't find anything
2925  if (!found_suitable_file) {
2926  LOG(INFO) << "Failed to find any supported geo files in Archive: " +
2927  remove_vsi_prefixes(archive_path);
2928  file_name.clear();
2929  }
2930 
2931  // done
2932  return file_name;
2933 }
std::string remove_vsi_prefixes(const std::string &path_in)
#define LOG(tag)
Definition: Logger.h:188
bool is_a_supported_geo_file(const std::string &path, bool include_gz)
static std::vector< std::string > gdalGetAllFilesInArchive(const std::string &archive_path, const CopyParams &copy_params)
Definition: Importer.cpp:4538
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ get_device_parameters()

std::map<std::string, std::string> get_device_parameters ( )

Definition at line 613 of file NativeCodegen.cpp.

References checkCudaErrors(), cpu_threads(), get_gpu_data_layout(), get_gpu_target_triple_string(), run_benchmark_import::result, and to_string().

Referenced by MapDHandler::max_bytes_for_thrift().

613  {
614  std::map<std::string, std::string> result;
615 
616  result.insert(std::make_pair("cpu_name", llvm::sys::getHostCPUName()));
617  result.insert(std::make_pair("cpu_triple", llvm::sys::getProcessTriple()));
618  result.insert(
619  std::make_pair("cpu_cores", std::to_string(llvm::sys::getHostNumPhysicalCores())));
620  result.insert(std::make_pair("cpu_threads", std::to_string(cpu_threads())));
621 
622  llvm::StringMap<bool> cpu_features;
623  if (llvm::sys::getHostCPUFeatures(cpu_features)) {
624  std::string features_str = "";
625  for (auto it = cpu_features.begin(); it != cpu_features.end(); ++it) {
626  features_str += (it->getValue() ? " +" : " -");
627  features_str += it->getKey().str();
628  }
629  result.insert(std::make_pair("cpu_features", features_str));
630  }
631 
632 #ifdef HAVE_CUDA
633  int device_count = 0;
634  checkCudaErrors(cuDeviceGetCount(&device_count));
635  if (device_count) {
636  CUdevice device{};
637  char device_name[256];
638  int major = 0, minor = 0;
639  checkCudaErrors(cuDeviceGet(&device, 0)); // assuming homogeneous multi-GPU system
640  checkCudaErrors(cuDeviceGetName(device_name, 256, device));
641  checkCudaErrors(cuDeviceGetAttribute(
642  &major, CU_DEVICE_ATTRIBUTE_COMPUTE_CAPABILITY_MAJOR, device));
643  checkCudaErrors(cuDeviceGetAttribute(
644  &minor, CU_DEVICE_ATTRIBUTE_COMPUTE_CAPABILITY_MINOR, device));
645 
646  result.insert(std::make_pair("gpu_name", device_name));
647  result.insert(std::make_pair("gpu_count", std::to_string(device_count)));
648  result.insert(std::make_pair("gpu_compute_capability",
649  std::to_string(major) + "." + std::to_string(minor)));
650  result.insert(std::make_pair("gpu_triple", get_gpu_target_triple_string()));
651  result.insert(std::make_pair("gpu_datalayout", get_gpu_data_layout()));
652  }
653 #endif
654 
655  return result;
656 }
void checkCudaErrors(CUresult err)
Definition: sample.cpp:38
llvm::StringRef get_gpu_data_layout()
std::string to_string(char const *&&v)
llvm::StringRef get_gpu_target_triple_string()
int CUdevice
Definition: nocuda.h:20
int cpu_threads()
Definition: thread_count.h:25
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ is_a_supported_archive_file()

bool is_a_supported_archive_file ( const std::string &  path)

Definition at line 2887 of file MapDHandler.cpp.

References path_has_valid_filename().

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

2887  {
2888  if (!path_has_valid_filename(path)) {
2889  return false;
2890  }
2891  if (boost::iends_with(path, ".zip") && !boost::iends_with(path, ".gdb.zip")) {
2892  return true;
2893  } else if (boost::iends_with(path, ".tar") || boost::iends_with(path, ".tgz") ||
2894  boost::iends_with(path, ".tar.gz")) {
2895  return true;
2896  }
2897  return false;
2898 }
bool path_has_valid_filename(const std::string &path)
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ is_a_supported_geo_file()

bool is_a_supported_geo_file ( const std::string &  path,
bool  include_gz 
)

Definition at line 2869 of file MapDHandler.cpp.

References path_has_valid_filename().

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

2869  {
2870  if (!path_has_valid_filename(path)) {
2871  return false;
2872  }
2873  if (include_gz) {
2874  if (boost::iends_with(path, ".geojson.gz") || boost::iends_with(path, ".json.gz")) {
2875  return true;
2876  }
2877  }
2878  if (boost::iends_with(path, ".shp") || boost::iends_with(path, ".geojson") ||
2879  boost::iends_with(path, ".json") || boost::iends_with(path, ".kml") ||
2880  boost::iends_with(path, ".kmz") || boost::iends_with(path, ".gdb") ||
2881  boost::iends_with(path, ".gdb.zip")) {
2882  return true;
2883  }
2884  return false;
2885 }
bool path_has_valid_filename(const std::string &path)
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ is_allowed_on_dashboard()

static bool is_allowed_on_dashboard ( const Catalog_Namespace::SessionInfo session_info,
int32_t  dashboard_id,
AccessPrivileges  requestedPermissions 
)
static

Definition at line 3153 of file MapDHandler.cpp.

References DashboardDBObjectType, Catalog_Namespace::SessionInfo::get_currentUser(), and Catalog_Namespace::SessionInfo::getCatalog().

Referenced by MapDHandler::delete_dashboard(), MapDHandler::get_dashboard(), MapDHandler::get_dashboards(), and MapDHandler::replace_dashboard().

3155  {
3156  DBObject object(dashboard_id, DashboardDBObjectType);
3157  auto& catalog = session_info.getCatalog();
3158  auto& user = session_info.get_currentUser();
3159  object.loadKey(catalog);
3160  object.setPrivileges(requestedPermissions);
3161  std::vector<DBObject> privs = {object};
3162  return SysCatalog::instance().checkPrivileges(user, privs);
3163 }
const UserMetadata & get_currentUser() const
Definition: SessionInfo.h:93
Catalog & getCatalog() const
Definition: SessionInfo.h:90
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ mapfrom() [1/3]

ExtArgumentType mapfrom ( const TExtArgumentType::type &  t)

Definition at line 5742 of file MapDHandler.cpp.

References ArrayDouble, ArrayFloat, ArrayInt16, ArrayInt32, ArrayInt64, ArrayInt8, Bool, Cursor, Double, Float, GeoPoint, Int16, Int32, Int64, Int8, PDouble, PFloat, PInt16, PInt32, PInt64, PInt8, UNREACHABLE, and Void.

Referenced by mapfrom(), and MapDHandler::register_runtime_extension_functions().

5742  {
5743  switch (t) {
5744  case TExtArgumentType::Int8:
5745  return ExtArgumentType::Int8;
5746  case TExtArgumentType::Int16:
5747  return ExtArgumentType::Int16;
5748  case TExtArgumentType::Int32:
5749  return ExtArgumentType::Int32;
5750  case TExtArgumentType::Int64:
5751  return ExtArgumentType::Int64;
5752  case TExtArgumentType::Float:
5753  return ExtArgumentType::Float;
5754  case TExtArgumentType::Double:
5755  return ExtArgumentType::Double;
5756  case TExtArgumentType::Void:
5757  return ExtArgumentType::Void;
5758  case TExtArgumentType::PInt8:
5759  return ExtArgumentType::PInt8;
5760  case TExtArgumentType::PInt16:
5761  return ExtArgumentType::PInt16;
5762  case TExtArgumentType::PInt32:
5763  return ExtArgumentType::PInt32;
5764  case TExtArgumentType::PInt64:
5765  return ExtArgumentType::PInt64;
5766  case TExtArgumentType::PFloat:
5767  return ExtArgumentType::PFloat;
5768  case TExtArgumentType::PDouble:
5769  return ExtArgumentType::PDouble;
5770  case TExtArgumentType::Bool:
5771  return ExtArgumentType::Bool;
5772  case TExtArgumentType::ArrayInt8:
5774  case TExtArgumentType::ArrayInt16:
5776  case TExtArgumentType::ArrayInt32:
5778  case TExtArgumentType::ArrayInt64:
5780  case TExtArgumentType::ArrayFloat:
5782  case TExtArgumentType::ArrayDouble:
5784  case TExtArgumentType::GeoPoint:
5786  case TExtArgumentType::Cursor:
5787  return ExtArgumentType::Cursor;
5788  }
5789  UNREACHABLE();
5790  return ExtArgumentType{};
5791 }
#define UNREACHABLE()
Definition: Logger.h:237
+ Here is the caller graph for this function:

◆ mapfrom() [2/3]

table_functions::OutputBufferSizeType mapfrom ( const TOutputBufferSizeType::type &  t)

◆ mapfrom() [3/3]

std::vector<ExtArgumentType> mapfrom ( const std::vector< TExtArgumentType::type > &  v)

Definition at line 5806 of file MapDHandler.cpp.

References mapfrom(), run_benchmark_import::result, and run_benchmark_import::type.

5806  {
5807  std::vector<ExtArgumentType> result;
5808  std::transform(v.begin(),
5809  v.end(),
5810  std::back_inserter(result),
5811  [](TExtArgumentType::type c) -> ExtArgumentType { return mapfrom(c); });
5812  return result;
5813 }
ExtArgumentType mapfrom(const TExtArgumentType::type &t)
+ Here is the call graph for this function:

◆ path_has_valid_filename()

bool path_has_valid_filename ( const std::string &  path)

Definition at line 2861 of file MapDHandler.cpp.

References logger::filename().

Referenced by is_a_supported_archive_file(), and is_a_supported_geo_file().

2861  {
2862  auto filename = boost::filesystem::path(path).filename().string();
2863  if (filename.size() == 0 || filename[0] == '.' || filename[0] == '/') {
2864  return false;
2865  }
2866  return true;
2867 }
std::string filename(char const *path)
Definition: Logger.cpp:58
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ path_is_relative()

bool path_is_relative ( const std::string &  path)

Definition at line 2853 of file MapDHandler.cpp.

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

2853  {
2854  if (boost::istarts_with(path, "s3://") || boost::istarts_with(path, "http://") ||
2855  boost::istarts_with(path, "https://")) {
2856  return false;
2857  }
2858  return !boost::filesystem::path(path).is_absolute();
2859 }
+ Here is the caller graph for this function:

◆ remove_vsi_prefixes()

std::string remove_vsi_prefixes ( const std::string &  path_in)

Definition at line 2831 of file MapDHandler.cpp.

Referenced by find_first_geo_file_in_archive().

2831  {
2832  std::string path(path_in);
2833 
2834  // these will be first
2835  if (boost::istarts_with(path, "/vsizip/")) {
2836  boost::replace_first(path, "/vsizip/", "");
2837  } else if (boost::istarts_with(path, "/vsitar/")) {
2838  boost::replace_first(path, "/vsitar/", "");
2839  } else if (boost::istarts_with(path, "/vsigzip/")) {
2840  boost::replace_first(path, "/vsigzip/", "");
2841  }
2842 
2843  // then these
2844  if (boost::istarts_with(path, "/vsicurl/")) {
2845  boost::replace_first(path, "/vsicurl/", "");
2846  } else if (boost::istarts_with(path, "/vsis3/")) {
2847  boost::replace_first(path, "/vsis3/", "s3://");
2848  }
2849 
2850  return path;
2851 }
+ Here is the caller graph for this function:

◆ serialize_db_object()

static TDBObject serialize_db_object ( const std::string &  roleName,
const DBObject inObject 
)
static

Definition at line 1342 of file MapDHandler.cpp.

References DatabasePrivileges::ACCESS, TablePrivileges::ALTER_TABLE, CHECK, DashboardPrivileges::CREATE_DASHBOARD, DatabasePrivileges::CREATE_DATABASE, TablePrivileges::CREATE_TABLE, ViewPrivileges::CREATE_VIEW, DashboardDBObjectType, DatabaseDBObjectType, DashboardPrivileges::DELETE_DASHBOARD, TablePrivileges::DELETE_FROM_TABLE, ViewPrivileges::DELETE_FROM_VIEW, DatabasePrivileges::DROP_DATABASE, TablePrivileges::DROP_TABLE, ViewPrivileges::DROP_VIEW, DashboardPrivileges::EDIT_DASHBOARD, DBObject::getName(), DBObject::getObjectKey(), DBObject::getPrivileges(), DBObject::getType(), TablePrivileges::INSERT_INTO_TABLE, ViewPrivileges::INSERT_INTO_VIEW, DBObjectKey::permissionType, TablePrivileges::SELECT_FROM_TABLE, ViewPrivileges::SELECT_FROM_VIEW, TableDBObjectType, TablePrivileges::TRUNCATE_TABLE, run_benchmark_import::type, TablePrivileges::UPDATE_IN_TABLE, ViewPrivileges::UPDATE_IN_VIEW, DashboardPrivileges::VIEW_DASHBOARD, DatabasePrivileges::VIEW_SQL_EDITOR, and ViewDBObjectType.

Referenced by MapDHandler::get_db_object_privs(), and MapDHandler::get_db_objects_for_grantee().

1343  {
1344  TDBObject outObject;
1345  outObject.objectName = inObject.getName();
1346  outObject.grantee = roleName;
1347  const auto ap = inObject.getPrivileges();
1348  switch (inObject.getObjectKey().permissionType) {
1349  case DatabaseDBObjectType:
1350  outObject.privilegeObjectType = TDBObjectType::DatabaseDBObjectType;
1351  outObject.privs.push_back(ap.hasPermission(DatabasePrivileges::CREATE_DATABASE));
1352  outObject.privs.push_back(ap.hasPermission(DatabasePrivileges::DROP_DATABASE));
1353  outObject.privs.push_back(ap.hasPermission(DatabasePrivileges::VIEW_SQL_EDITOR));
1354  outObject.privs.push_back(ap.hasPermission(DatabasePrivileges::ACCESS));
1355 
1356  break;
1357  case TableDBObjectType:
1358  outObject.privilegeObjectType = TDBObjectType::TableDBObjectType;
1359  outObject.privs.push_back(ap.hasPermission(TablePrivileges::CREATE_TABLE));
1360  outObject.privs.push_back(ap.hasPermission(TablePrivileges::DROP_TABLE));
1361  outObject.privs.push_back(ap.hasPermission(TablePrivileges::SELECT_FROM_TABLE));
1362  outObject.privs.push_back(ap.hasPermission(TablePrivileges::INSERT_INTO_TABLE));
1363  outObject.privs.push_back(ap.hasPermission(TablePrivileges::UPDATE_IN_TABLE));
1364  outObject.privs.push_back(ap.hasPermission(TablePrivileges::DELETE_FROM_TABLE));
1365  outObject.privs.push_back(ap.hasPermission(TablePrivileges::TRUNCATE_TABLE));
1366  outObject.privs.push_back(ap.hasPermission(TablePrivileges::ALTER_TABLE));
1367 
1368  break;
1369  case DashboardDBObjectType:
1370  outObject.privilegeObjectType = TDBObjectType::DashboardDBObjectType;
1371  outObject.privs.push_back(ap.hasPermission(DashboardPrivileges::CREATE_DASHBOARD));
1372  outObject.privs.push_back(ap.hasPermission(DashboardPrivileges::DELETE_DASHBOARD));
1373  outObject.privs.push_back(ap.hasPermission(DashboardPrivileges::VIEW_DASHBOARD));
1374  outObject.privs.push_back(ap.hasPermission(DashboardPrivileges::EDIT_DASHBOARD));
1375 
1376  break;
1377  case ViewDBObjectType:
1378  outObject.privilegeObjectType = TDBObjectType::ViewDBObjectType;
1379  outObject.privs.push_back(ap.hasPermission(ViewPrivileges::CREATE_VIEW));
1380  outObject.privs.push_back(ap.hasPermission(ViewPrivileges::DROP_VIEW));
1381  outObject.privs.push_back(ap.hasPermission(ViewPrivileges::SELECT_FROM_VIEW));
1382  outObject.privs.push_back(ap.hasPermission(ViewPrivileges::INSERT_INTO_VIEW));
1383  outObject.privs.push_back(ap.hasPermission(ViewPrivileges::UPDATE_IN_VIEW));
1384  outObject.privs.push_back(ap.hasPermission(ViewPrivileges::DELETE_FROM_VIEW));
1385 
1386  break;
1387  default:
1388  CHECK(false);
1389  }
1390  const int type_val = static_cast<int>(inObject.getType());
1391  CHECK(type_val >= 0 && type_val < 5);
1392  outObject.objectType = static_cast<TDBObjectType::type>(type_val);
1393  return outObject;
1394 }
static const int32_t DROP_VIEW
Definition: DBObject.h:114
static const int32_t SELECT_FROM_VIEW
Definition: DBObject.h:115
static const int32_t UPDATE_IN_VIEW
Definition: DBObject.h:117
static const int32_t CREATE_VIEW
Definition: DBObject.h:113
static const int32_t ALTER_TABLE
Definition: DBObject.h:94
DBObjectType getType() const
Definition: DBObject.h:196
DBObjectKey getObjectKey() const
Definition: DBObject.h:197
std::string getName() const
Definition: DBObject.h:195
static const int32_t DROP_DATABASE
Definition: DBObject.h:80
static const int32_t DELETE_FROM_TABLE
Definition: DBObject.h:92
static const int32_t TRUNCATE_TABLE
Definition: DBObject.h:93
static const int32_t EDIT_DASHBOARD
Definition: DBObject.h:105
static const int32_t DELETE_DASHBOARD
Definition: DBObject.h:103
static const int32_t INSERT_INTO_TABLE
Definition: DBObject.h:90
const AccessPrivileges & getPrivileges() const
Definition: DBObject.h:202
static const int32_t ACCESS
Definition: DBObject.h:82
static const int32_t CREATE_DATABASE
Definition: DBObject.h:79
static const int32_t VIEW_DASHBOARD
Definition: DBObject.h:104
static const int32_t VIEW_SQL_EDITOR
Definition: DBObject.h:81
static const int32_t DROP_TABLE
Definition: DBObject.h:88
static const int32_t INSERT_INTO_VIEW
Definition: DBObject.h:116
#define CHECK(condition)
Definition: Logger.h:193
static const int32_t DELETE_FROM_VIEW
Definition: DBObject.h:118
static const int32_t CREATE_TABLE
Definition: DBObject.h:87
static const int32_t CREATE_DASHBOARD
Definition: DBObject.h:102
int32_t permissionType
Definition: DBObject.h:54
static const int32_t SELECT_FROM_TABLE
Definition: DBObject.h:89
static const int32_t UPDATE_IN_TABLE
Definition: DBObject.h:91
+ Here is the call graph for this function:
+ Here is the caller graph for this function: