OmniSciDB  04ee39c94c
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

◆ check_table_not_sharded()

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

Definition at line 2014 of file MapDHandler.cpp.

References Catalog_Namespace::Catalog::getMetadataForTable().

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

2014  {
2015  const auto td = cat.getMetadataForTable(table_name);
2016  if (td && td->nShards) {
2017  throw std::runtime_error("Cannot import a sharded table directly to a leaf");
2018  }
2019 }
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:

◆ extract_projection_tokens_for_completion()

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

Definition at line 981 of file MapDHandler.cpp.

References split(), and to_upper().

Referenced by MapDHandler::get_completion_hints().

982  {
983  boost::regex id_regex{R"(([[:alnum:]]|_|\.)+)",
984  boost::regex::extended | boost::regex::icase};
985  boost::sregex_token_iterator tok_it(sql.begin(), sql.end(), id_regex, 0);
986  boost::sregex_token_iterator end;
987  std::unordered_set<std::string> uc_column_names;
988  std::unordered_set<std::string> uc_column_table_qualifiers;
989  for (; tok_it != end; ++tok_it) {
990  std::string column_name = *tok_it;
991  std::vector<std::string> column_tokens;
992  boost::split(column_tokens, column_name, boost::is_any_of("."));
993  if (column_tokens.size() == 2) {
994  // If the column name is qualified, take user's word.
995  uc_column_table_qualifiers.insert(to_upper(column_tokens.front()));
996  } else {
997  uc_column_names.insert(to_upper(column_name));
998  }
999  }
1000  return {uc_column_names, uc_column_table_qualifiers};
1001 }
auto sql(const std::string &sql_stmts)
std::string to_upper(const std::string &str)
std::vector< std::string > split(const std::string &str, const std::string &delim)
+ 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 1553 of file MapDHandler.cpp.

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

1555  {
1556  col_type.col_type.precision = static_cast<int>(subtype);
1557  col_type.col_type.scale = output_srid;
1558 }
+ 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 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:

◆ loadArrowStream()

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

Definition at line 2220 of file MapDHandler.cpp.

References ARROW_THRIFT_THROW_NOT_OK, logger::ERROR, and LOG.

Referenced by MapDHandler::load_table_binary_arrow().

2220  {
2221  RecordBatchVector batches;
2222  try {
2223  // TODO(wesm): Make this simpler in general, see ARROW-1600
2224  auto stream_buffer =
2225  std::make_shared<arrow::Buffer>(reinterpret_cast<const uint8_t*>(stream.c_str()),
2226  static_cast<int64_t>(stream.size()));
2227 
2228  arrow::io::BufferReader buf_reader(stream_buffer);
2229  std::shared_ptr<arrow::RecordBatchReader> batch_reader;
2231  arrow::ipc::RecordBatchStreamReader::Open(&buf_reader, &batch_reader));
2232 
2233  while (true) {
2234  std::shared_ptr<arrow::RecordBatch> batch;
2235  // Read batch (zero-copy) from the stream
2236  ARROW_THRIFT_THROW_NOT_OK(batch_reader->ReadNext(&batch));
2237  if (batch == nullptr) {
2238  break;
2239  }
2240  batches.emplace_back(std::move(batch));
2241  }
2242  } catch (const std::exception& e) {
2243  LOG(ERROR) << "Error parsing Arrow stream: " << e.what() << ". Import aborted";
2244  }
2245  return batches;
2246 }
#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:

◆ TTypeInfo_IsGeo()

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

Definition at line 3514 of file MapDHandler.cpp.

References kGEOGRAPHY, kGEOMETRY, run-benchmark-import::result, and run-benchmark-import::type.

Referenced by MapDHandler::import_geo_table().

3514  {
3515  return (t == TDatumType::POLYGON || t == TDatumType::MULTIPOLYGON ||
3516  t == TDatumType::LINESTRING || t == TDatumType::POINT);
3517 }
+ Here is the caller graph for this function: