OmniSciDB  1dac507f6e
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
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 "MapDRenderHandler.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)
 
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

#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 LOG(tag)
Definition: Logger.h:185
#define UNLIKELY(x)
Definition: likely.h:20

Definition at line 2363 of file MapDHandler.cpp.

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

#define ENABLE_GEO_IMPORT_COLUMN_MATCHING   0

Definition at line 103 of file MapDHandler.cpp.

#define INVALID_SESSION_ID   ""

Definition at line 109 of file MapDHandler.cpp.

Referenced by MapDHandler::getInvalidSessionId().

#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 3716 of file MapDHandler.cpp.

Referenced by MapDHandler::import_geo_table().

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

Definition at line 111 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

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

Definition at line 2361 of file MapDHandler.cpp.

Function Documentation

void add_vsi_archive_prefix ( std::string &  path)

Definition at line 2793 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().

2793  {
2794  // check for compressed file or file bundle
2795  if (boost::iends_with(path, ".zip")) {
2796  // zip archive
2797  path = "/vsizip/" + path;
2798  } else if (boost::iends_with(path, ".tar") || boost::iends_with(path, ".tgz") ||
2799  boost::iends_with(path, ".tar.gz")) {
2800  // tar archive (compressed or uncompressed)
2801  path = "/vsitar/" + path;
2802  }
2803 }

+ Here is the caller graph for this function:

void add_vsi_geo_prefix ( std::string &  path)

Definition at line 2786 of file MapDHandler.cpp.

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

2786  {
2787  // single gzip'd file (not an archive)?
2788  if (boost::iends_with(path, ".gz") && !boost::iends_with(path, ".tar.gz")) {
2789  path = "/vsigzip/" + path;
2790  }
2791 }

+ Here is the caller graph for this function:

void add_vsi_network_prefix ( std::string &  path)

Definition at line 2764 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().

2764  {
2765  // do we support network file access?
2767 
2768  // modify head of filename based on source location
2769  if (boost::istarts_with(path, "http://") || boost::istarts_with(path, "https://")) {
2770  if (!gdal_network) {
2772  "HTTP geo file import not supported! Update to GDAL 2.2 or later!");
2773  }
2774  // invoke GDAL CURL virtual file reader
2775  path = "/vsicurl/" + path;
2776  } else if (boost::istarts_with(path, "s3://")) {
2777  if (!gdal_network) {
2779  "S3 geo file import not supported! Update to GDAL 2.2 or later!");
2780  }
2781  // invoke GDAL S3 virtual file reader
2782  boost::replace_first(path, "s3://", "/vsis3/");
2783  }
2784 }
#define THROW_MAPD_EXCEPTION(errstr)
static bool gdalSupportsNetworkFileAccess()
Definition: Importer.cpp:4620

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

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

Definition at line 2874 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().

2875  {
2876  // get the recursive list of all files in the archive
2877  std::vector<std::string> files =
2878  Importer_NS::Importer::gdalGetAllFilesInArchive(archive_path, copy_params);
2879 
2880  // report the list
2881  LOG(INFO) << "Found " << files.size() << " files in Archive "
2882  << remove_vsi_prefixes(archive_path);
2883  for (const auto& file : files) {
2884  LOG(INFO) << " " << file;
2885  }
2886 
2887  // scan the list for the first candidate file
2888  bool found_suitable_file = false;
2889  std::string file_name;
2890  for (const auto& file : files) {
2891  if (is_a_supported_geo_file(file, false)) {
2892  file_name = file;
2893  found_suitable_file = true;
2894  break;
2895  }
2896  }
2897 
2898  // if we didn't find anything
2899  if (!found_suitable_file) {
2900  LOG(INFO) << "Failed to find any supported geo files in Archive: " +
2901  remove_vsi_prefixes(archive_path);
2902  file_name.clear();
2903  }
2904 
2905  // done
2906  return file_name;
2907 }
std::string remove_vsi_prefixes(const std::string &path_in)
#define LOG(tag)
Definition: Logger.h:185
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:4534

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

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

Definition at line 613 of file NativeCodegen.cpp.

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
bool is_a_supported_archive_file ( const std::string &  path)

Definition at line 2861 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().

2861  {
2862  if (!path_has_valid_filename(path)) {
2863  return false;
2864  }
2865  if (boost::iends_with(path, ".zip") && !boost::iends_with(path, ".gdb.zip")) {
2866  return true;
2867  } else if (boost::iends_with(path, ".tar") || boost::iends_with(path, ".tgz") ||
2868  boost::iends_with(path, ".tar.gz")) {
2869  return true;
2870  }
2871  return false;
2872 }
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:

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

Definition at line 2843 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().

2843  {
2844  if (!path_has_valid_filename(path)) {
2845  return false;
2846  }
2847  if (include_gz) {
2848  if (boost::iends_with(path, ".geojson.gz") || boost::iends_with(path, ".json.gz")) {
2849  return true;
2850  }
2851  }
2852  if (boost::iends_with(path, ".shp") || boost::iends_with(path, ".geojson") ||
2853  boost::iends_with(path, ".json") || boost::iends_with(path, ".kml") ||
2854  boost::iends_with(path, ".kmz") || boost::iends_with(path, ".gdb") ||
2855  boost::iends_with(path, ".gdb.zip")) {
2856  return true;
2857  }
2858  return false;
2859 }
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:

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

Definition at line 3127 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().

3129  {
3130  DBObject object(dashboard_id, DashboardDBObjectType);
3131  auto& catalog = session_info.getCatalog();
3132  auto& user = session_info.get_currentUser();
3133  object.loadKey(catalog);
3134  object.setPrivileges(requestedPermissions);
3135  std::vector<DBObject> privs = {object};
3136  return SysCatalog::instance().checkPrivileges(user, privs);
3137 }
Catalog & getCatalog() const
Definition: SessionInfo.h:90
const UserMetadata & get_currentUser() const
Definition: SessionInfo.h:93

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

ExtArgumentType mapfrom ( const TExtArgumentType::type &  t)

Definition at line 5713 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().

5713  {
5714  switch (t) {
5715  case TExtArgumentType::Int8:
5716  return ExtArgumentType::Int8;
5717  case TExtArgumentType::Int16:
5718  return ExtArgumentType::Int16;
5719  case TExtArgumentType::Int32:
5720  return ExtArgumentType::Int32;
5721  case TExtArgumentType::Int64:
5722  return ExtArgumentType::Int64;
5723  case TExtArgumentType::Float:
5724  return ExtArgumentType::Float;
5725  case TExtArgumentType::Double:
5726  return ExtArgumentType::Double;
5727  case TExtArgumentType::Void:
5728  return ExtArgumentType::Void;
5729  case TExtArgumentType::PInt8:
5730  return ExtArgumentType::PInt8;
5731  case TExtArgumentType::PInt16:
5732  return ExtArgumentType::PInt16;
5733  case TExtArgumentType::PInt32:
5734  return ExtArgumentType::PInt32;
5735  case TExtArgumentType::PInt64:
5736  return ExtArgumentType::PInt64;
5737  case TExtArgumentType::PFloat:
5738  return ExtArgumentType::PFloat;
5739  case TExtArgumentType::PDouble:
5740  return ExtArgumentType::PDouble;
5741  case TExtArgumentType::Bool:
5742  return ExtArgumentType::Bool;
5743  case TExtArgumentType::ArrayInt8:
5745  case TExtArgumentType::ArrayInt16:
5747  case TExtArgumentType::ArrayInt32:
5749  case TExtArgumentType::ArrayInt64:
5751  case TExtArgumentType::ArrayFloat:
5753  case TExtArgumentType::ArrayDouble:
5755  case TExtArgumentType::GeoPoint:
5757  case TExtArgumentType::Cursor:
5758  return ExtArgumentType::Cursor;
5759  }
5760  UNREACHABLE();
5761  return ExtArgumentType{};
5762 }
#define UNREACHABLE()
Definition: Logger.h:234

+ Here is the caller graph for this function:

table_functions::OutputBufferSizeType mapfrom ( const TOutputBufferSizeType::type &  t)
std::vector<ExtArgumentType> mapfrom ( const std::vector< TExtArgumentType::type > &  v)

Definition at line 5777 of file MapDHandler.cpp.

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

5777  {
5778  std::vector<ExtArgumentType> result;
5779  std::transform(v.begin(),
5780  v.end(),
5781  std::back_inserter(result),
5782  [](TExtArgumentType::type c) -> ExtArgumentType { return mapfrom(c); });
5783  return result;
5784 }
ExtArgumentType mapfrom(const TExtArgumentType::type &t)

+ Here is the call graph for this function:

bool path_has_valid_filename ( const std::string &  path)

Definition at line 2835 of file MapDHandler.cpp.

References logger::filename().

Referenced by is_a_supported_archive_file(), and is_a_supported_geo_file().

2835  {
2836  auto filename = boost::filesystem::path(path).filename().string();
2837  if (filename.size() == 0 || filename[0] == '.' || filename[0] == '/') {
2838  return false;
2839  }
2840  return true;
2841 }
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:

bool path_is_relative ( const std::string &  path)

Definition at line 2827 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().

2827  {
2828  if (boost::istarts_with(path, "s3://") || boost::istarts_with(path, "http://") ||
2829  boost::istarts_with(path, "https://")) {
2830  return false;
2831  }
2832  return !boost::filesystem::path(path).is_absolute();
2833 }

+ Here is the caller graph for this function:

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

Definition at line 2805 of file MapDHandler.cpp.

Referenced by find_first_geo_file_in_archive().

2805  {
2806  std::string path(path_in);
2807 
2808  // these will be first
2809  if (boost::istarts_with(path, "/vsizip/")) {
2810  boost::replace_first(path, "/vsizip/", "");
2811  } else if (boost::istarts_with(path, "/vsitar/")) {
2812  boost::replace_first(path, "/vsitar/", "");
2813  } else if (boost::istarts_with(path, "/vsigzip/")) {
2814  boost::replace_first(path, "/vsigzip/", "");
2815  }
2816 
2817  // then these
2818  if (boost::istarts_with(path, "/vsicurl/")) {
2819  boost::replace_first(path, "/vsicurl/", "");
2820  } else if (boost::istarts_with(path, "/vsis3/")) {
2821  boost::replace_first(path, "/vsis3/", "s3://");
2822  }
2823 
2824  return path;
2825 }

+ Here is the caller graph for this function:

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

Definition at line 1328 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().

1329  {
1330  TDBObject outObject;
1331  outObject.objectName = inObject.getName();
1332  outObject.grantee = roleName;
1333  const auto ap = inObject.getPrivileges();
1334  switch (inObject.getObjectKey().permissionType) {
1335  case DatabaseDBObjectType:
1336  outObject.privilegeObjectType = TDBObjectType::DatabaseDBObjectType;
1337  outObject.privs.push_back(ap.hasPermission(DatabasePrivileges::CREATE_DATABASE));
1338  outObject.privs.push_back(ap.hasPermission(DatabasePrivileges::DROP_DATABASE));
1339  outObject.privs.push_back(ap.hasPermission(DatabasePrivileges::VIEW_SQL_EDITOR));
1340  outObject.privs.push_back(ap.hasPermission(DatabasePrivileges::ACCESS));
1341 
1342  break;
1343  case TableDBObjectType:
1344  outObject.privilegeObjectType = TDBObjectType::TableDBObjectType;
1345  outObject.privs.push_back(ap.hasPermission(TablePrivileges::CREATE_TABLE));
1346  outObject.privs.push_back(ap.hasPermission(TablePrivileges::DROP_TABLE));
1347  outObject.privs.push_back(ap.hasPermission(TablePrivileges::SELECT_FROM_TABLE));
1348  outObject.privs.push_back(ap.hasPermission(TablePrivileges::INSERT_INTO_TABLE));
1349  outObject.privs.push_back(ap.hasPermission(TablePrivileges::UPDATE_IN_TABLE));
1350  outObject.privs.push_back(ap.hasPermission(TablePrivileges::DELETE_FROM_TABLE));
1351  outObject.privs.push_back(ap.hasPermission(TablePrivileges::TRUNCATE_TABLE));
1352  outObject.privs.push_back(ap.hasPermission(TablePrivileges::ALTER_TABLE));
1353 
1354  break;
1355  case DashboardDBObjectType:
1356  outObject.privilegeObjectType = TDBObjectType::DashboardDBObjectType;
1357  outObject.privs.push_back(ap.hasPermission(DashboardPrivileges::CREATE_DASHBOARD));
1358  outObject.privs.push_back(ap.hasPermission(DashboardPrivileges::DELETE_DASHBOARD));
1359  outObject.privs.push_back(ap.hasPermission(DashboardPrivileges::VIEW_DASHBOARD));
1360  outObject.privs.push_back(ap.hasPermission(DashboardPrivileges::EDIT_DASHBOARD));
1361 
1362  break;
1363  case ViewDBObjectType:
1364  outObject.privilegeObjectType = TDBObjectType::ViewDBObjectType;
1365  outObject.privs.push_back(ap.hasPermission(ViewPrivileges::CREATE_VIEW));
1366  outObject.privs.push_back(ap.hasPermission(ViewPrivileges::DROP_VIEW));
1367  outObject.privs.push_back(ap.hasPermission(ViewPrivileges::SELECT_FROM_VIEW));
1368  outObject.privs.push_back(ap.hasPermission(ViewPrivileges::INSERT_INTO_VIEW));
1369  outObject.privs.push_back(ap.hasPermission(ViewPrivileges::UPDATE_IN_VIEW));
1370  outObject.privs.push_back(ap.hasPermission(ViewPrivileges::DELETE_FROM_VIEW));
1371 
1372  break;
1373  default:
1374  CHECK(false);
1375  }
1376  const int type_val = static_cast<int>(inObject.getType());
1377  CHECK(type_val >= 0 && type_val < 5);
1378  outObject.objectType = static_cast<TDBObjectType::type>(type_val);
1379  return outObject;
1380 }
static const int32_t DROP_VIEW
Definition: DBObject.h:114
DBObjectKey getObjectKey() const
Definition: DBObject.h:197
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
CHECK(cgen_state)
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
std::string getName() const
Definition: DBObject.h:195
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
DBObjectType getType() const
Definition: DBObject.h:196
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
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: