OmniSciDB  343343d194
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
anonymous_namespace{MapDHandler.cpp} Namespace Reference

Classes

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)
 
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

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

Definition at line 2099 of file MapDHandler.cpp.

References Catalog_Namespace::Catalog::getMetadataForTable().

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

2099  {
2100  const auto td = cat.getMetadataForTable(table_name);
2101  if (td && td->nShards) {
2102  throw std::runtime_error("Cannot import a sharded table directly to a leaf");
2103  }
2104 }
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:

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

Definition at line 1028 of file MapDHandler.cpp.

References split(), and to_upper().

Referenced by MapDHandler::get_completion_hints().

1029  {
1030  boost::regex id_regex{R"(([[:alnum:]]|_|\.)+)",
1031  boost::regex::extended | boost::regex::icase};
1032  boost::sregex_token_iterator tok_it(sql.begin(), sql.end(), id_regex, 0);
1033  boost::sregex_token_iterator end;
1034  std::unordered_set<std::string> uc_column_names;
1035  std::unordered_set<std::string> uc_column_table_qualifiers;
1036  for (; tok_it != end; ++tok_it) {
1037  std::string column_name = *tok_it;
1038  std::vector<std::string> column_tokens;
1039  boost::split(column_tokens, column_name, boost::is_any_of("."));
1040  if (column_tokens.size() == 2) {
1041  // If the column name is qualified, take user's word.
1042  uc_column_table_qualifiers.insert(to_upper(column_tokens.front()));
1043  } else {
1044  uc_column_names.insert(to_upper(column_name));
1045  }
1046  }
1047  return {uc_column_names, uc_column_table_qualifiers};
1048 }
auto sql(std::string_view sql_stmts)
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:

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

Definition at line 1628 of file MapDHandler.cpp.

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

1630  {
1631  col_type.col_type.precision = static_cast<int>(subtype);
1632  col_type.col_type.scale = output_srid;
1633 }

+ Here is the caller graph for this function:

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

Definition at line 125 of file MapDHandler.cpp.

References THROW_MAPD_EXCEPTION.

Referenced by MapDHandler::get_session_it_unsafe().

126  {
127  auto session_it = session_map.find(session);
128  if (session_it == session_map.end()) {
129  THROW_MAPD_EXCEPTION("Session not valid.");
130  }
131  return session_it;
132 }
#define THROW_MAPD_EXCEPTION(errstr)
TSessionId session

+ Here is the caller graph for this function:

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

Definition at line 2305 of file MapDHandler.cpp.

References ARROW_THRIFT_THROW_NOT_OK, logger::ERROR, and LOG.

Referenced by MapDHandler::load_table_binary_arrow().

2305  {
2306  RecordBatchVector batches;
2307  try {
2308  // TODO(wesm): Make this simpler in general, see ARROW-1600
2309  auto stream_buffer =
2310  std::make_shared<arrow::Buffer>(reinterpret_cast<const uint8_t*>(stream.c_str()),
2311  static_cast<int64_t>(stream.size()));
2312 
2313  arrow::io::BufferReader buf_reader(stream_buffer);
2314  std::shared_ptr<arrow::RecordBatchReader> batch_reader;
2316  arrow::ipc::RecordBatchStreamReader::Open(&buf_reader, &batch_reader));
2317 
2318  while (true) {
2319  std::shared_ptr<arrow::RecordBatch> batch;
2320  // Read batch (zero-copy) from the stream
2321  ARROW_THRIFT_THROW_NOT_OK(batch_reader->ReadNext(&batch));
2322  if (batch == nullptr) {
2323  break;
2324  }
2325  batches.emplace_back(std::move(batch));
2326  }
2327  } catch (const std::exception& e) {
2328  LOG(ERROR) << "Error parsing Arrow stream: " << e.what() << ". Import aborted";
2329  }
2330  return batches;
2331 }
#define LOG(tag)
Definition: Logger.h:182
#define ARROW_THRIFT_THROW_NOT_OK(s)
std::vector< std::shared_ptr< arrow::RecordBatch >> RecordBatchVector

+ Here is the caller graph for this function:

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

Definition at line 3602 of file MapDHandler.cpp.

Referenced by MapDHandler::import_geo_table().

3602  {
3603  return (t == TDatumType::POLYGON || t == TDatumType::MULTIPOLYGON ||
3604  t == TDatumType::LINESTRING || t == TDatumType::POINT);
3605 }

+ Here is the caller graph for this function: