OmniSciDB  29e35f4d58
anonymous_namespace{MapDHandler.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 fixup_geo_column_descriptor (TColumnType &col_type, const SQLTypes subtype, const int output_srid)
 
void check_table_not_sharded (const Catalog &cat, const std::string &table_name)
 
RecordBatchVector loadArrowStream (const std::string &stream)
 
bool TTypeInfo_IsGeo (const TDatumType::type &t)
 

Function Documentation

◆ check_table_not_sharded()

void anonymous_namespace{MapDHandler.cpp}::check_table_not_sharded ( const Catalog cat,
const std::string &  table_name 
)

Definition at line 2196 of file MapDHandler.cpp.

References Catalog_Namespace::Catalog::getMetadataForTable().

Referenced by MapDHandler::load_table(), MapDHandler::load_table_binary(), and MapDHandler::prepare_columnar_loader().

2196  {
2197  const auto td = cat.getMetadataForTable(table_name);
2198  if (td && td->nShards) {
2199  throw std::runtime_error("Cannot import a sharded table directly to a leaf");
2200  }
2201 }
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:

◆ dump_table_col_names()

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

Definition at line 1667 of file MapDHandler.cpp.

Referenced by MapDHandler::get_result_row_for_pixel().

1668  {
1669  std::ostringstream oss;
1670  for (const auto& [table_name, col_names] : table_col_names) {
1671  oss << ":" << table_name;
1672  for (const auto& col_name : col_names) {
1673  oss << "," << col_name;
1674  }
1675  }
1676  return oss.str();
1677 }
+ Here is the caller graph for this function:

◆ extract_projection_tokens_for_completion()

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

Definition at line 1099 of file MapDHandler.cpp.

References split(), and to_upper().

Referenced by MapDHandler::get_completion_hints().

1100  {
1101  boost::regex id_regex{R"(([[:alnum:]]|_|\.)+)",
1102  boost::regex::extended | boost::regex::icase};
1103  boost::sregex_token_iterator tok_it(sql.begin(), sql.end(), id_regex, 0);
1104  boost::sregex_token_iterator end;
1105  std::unordered_set<std::string> uc_column_names;
1106  std::unordered_set<std::string> uc_column_table_qualifiers;
1107  for (; tok_it != end; ++tok_it) {
1108  std::string column_name = *tok_it;
1109  std::vector<std::string> column_tokens;
1110  boost::split(column_tokens, column_name, boost::is_any_of("."));
1111  if (column_tokens.size() == 2) {
1112  // If the column name is qualified, take user's word.
1113  uc_column_table_qualifiers.insert(to_upper(column_tokens.front()));
1114  } else {
1115  uc_column_names.insert(to_upper(column_name));
1116  }
1117  }
1118  return {uc_column_names, uc_column_table_qualifiers};
1119 }
std::string to_upper(const std::string &str)
std::vector< std::string > split(const std::string &str, const std::string &delim)
split apart a string into a vector of substrings
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ fixup_geo_column_descriptor()

void anonymous_namespace{MapDHandler.cpp}::fixup_geo_column_descriptor ( TColumnType &  col_type,
const SQLTypes  subtype,
const int  output_srid 
)
inline

Definition at line 1725 of file MapDHandler.cpp.

Referenced by MapDHandler::convert_target_metainfo(), and MapDHandler::populateThriftColumnType().

1727  {
1728  col_type.col_type.precision = static_cast<int>(subtype);
1729  col_type.col_type.scale = output_srid;
1730 }
+ Here is the caller graph for this function:

◆ get_session_from_map()

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

Definition at line 120 of file MapDHandler.cpp.

References THROW_MAPD_EXCEPTION.

Referenced by MapDHandler::get_session_it_unsafe().

121  {
122  auto session_it = session_map.find(session);
123  if (session_it == session_map.end()) {
124  THROW_MAPD_EXCEPTION("Session not valid.");
125  }
126  return session_it;
127 }
#define THROW_MAPD_EXCEPTION(errstr)
+ Here is the caller graph for this function:

◆ loadArrowStream()

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

Definition at line 2402 of file MapDHandler.cpp.

References ARROW_THRIFT_THROW_NOT_OK, logger::ERROR, and LOG.

Referenced by MapDHandler::load_table_binary_arrow().

2402  {
2403  RecordBatchVector batches;
2404  try {
2405  // TODO(wesm): Make this simpler in general, see ARROW-1600
2406  auto stream_buffer =
2407  std::make_shared<arrow::Buffer>(reinterpret_cast<const uint8_t*>(stream.c_str()),
2408  static_cast<int64_t>(stream.size()));
2409 
2410  arrow::io::BufferReader buf_reader(stream_buffer);
2411  std::shared_ptr<arrow::RecordBatchReader> batch_reader;
2413  arrow::ipc::RecordBatchStreamReader::Open(&buf_reader, &batch_reader));
2414 
2415  while (true) {
2416  std::shared_ptr<arrow::RecordBatch> batch;
2417  // Read batch (zero-copy) from the stream
2418  ARROW_THRIFT_THROW_NOT_OK(batch_reader->ReadNext(&batch));
2419  if (batch == nullptr) {
2420  break;
2421  }
2422  batches.emplace_back(std::move(batch));
2423  }
2424  } catch (const std::exception& e) {
2425  LOG(ERROR) << "Error parsing Arrow stream: " << e.what() << ". Import aborted";
2426  }
2427  return batches;
2428 }
#define LOG(tag)
Definition: Logger.h:188
#define ARROW_THRIFT_THROW_NOT_OK(s)
std::vector< std::shared_ptr< arrow::RecordBatch > > RecordBatchVector
+ Here is the caller graph for this function:

◆ TTypeInfo_IsGeo()

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

Definition at line 3703 of file MapDHandler.cpp.

References kGEOGRAPHY, kGEOMETRY, run_benchmark_import::result, and run_benchmark_import::type.

Referenced by MapDHandler::import_geo_table().

3703  {
3704  return (t == TDatumType::POLYGON || t == TDatumType::MULTIPOLYGON ||
3705  t == TDatumType::LINESTRING || t == TDatumType::POINT);
3706 }
+ Here is the caller graph for this function: