OmniSciDB  b24e664e58
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
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)
 
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 2173 of file MapDHandler.cpp.

References Catalog_Namespace::Catalog::getMetadataForTable().

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

2173  {
2174  const auto td = cat.getMetadataForTable(table_name);
2175  if (td && td->nShards) {
2176  throw std::runtime_error("Cannot import a sharded table directly to a leaf");
2177  }
2178 }
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 1100 of file MapDHandler.cpp.

References split(), and to_upper().

Referenced by MapDHandler::get_completion_hints().

1101  {
1102  boost::regex id_regex{R"(([[:alnum:]]|_|\.)+)",
1103  boost::regex::extended | boost::regex::icase};
1104  boost::sregex_token_iterator tok_it(sql.begin(), sql.end(), id_regex, 0);
1105  boost::sregex_token_iterator end;
1106  std::unordered_set<std::string> uc_column_names;
1107  std::unordered_set<std::string> uc_column_table_qualifiers;
1108  for (; tok_it != end; ++tok_it) {
1109  std::string column_name = *tok_it;
1110  std::vector<std::string> column_tokens;
1111  boost::split(column_tokens, column_name, boost::is_any_of("."));
1112  if (column_tokens.size() == 2) {
1113  // If the column name is qualified, take user's word.
1114  uc_column_table_qualifiers.insert(to_upper(column_tokens.front()));
1115  } else {
1116  uc_column_names.insert(to_upper(column_name));
1117  }
1118  }
1119  return {uc_column_names, uc_column_table_qualifiers};
1120 }
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 1700 of file MapDHandler.cpp.

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

1702  {
1703  col_type.col_type.precision = static_cast<int>(subtype);
1704  col_type.col_type.scale = output_srid;
1705 }

+ 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 121 of file MapDHandler.cpp.

References THROW_MAPD_EXCEPTION.

Referenced by MapDHandler::get_session_it_unsafe().

122  {
123  auto session_it = session_map.find(session);
124  if (session_it == session_map.end()) {
125  THROW_MAPD_EXCEPTION("Session not valid.");
126  }
127  return session_it;
128 }
#define THROW_MAPD_EXCEPTION(errstr)

+ Here is the caller graph for this function:

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

Definition at line 2379 of file MapDHandler.cpp.

References ARROW_THRIFT_THROW_NOT_OK, logger::ERROR, and LOG.

Referenced by MapDHandler::load_table_binary_arrow().

2379  {
2380  RecordBatchVector batches;
2381  try {
2382  // TODO(wesm): Make this simpler in general, see ARROW-1600
2383  auto stream_buffer =
2384  std::make_shared<arrow::Buffer>(reinterpret_cast<const uint8_t*>(stream.c_str()),
2385  static_cast<int64_t>(stream.size()));
2386 
2387  arrow::io::BufferReader buf_reader(stream_buffer);
2388  std::shared_ptr<arrow::RecordBatchReader> batch_reader;
2390  arrow::ipc::RecordBatchStreamReader::Open(&buf_reader, &batch_reader));
2391 
2392  while (true) {
2393  std::shared_ptr<arrow::RecordBatch> batch;
2394  // Read batch (zero-copy) from the stream
2395  ARROW_THRIFT_THROW_NOT_OK(batch_reader->ReadNext(&batch));
2396  if (batch == nullptr) {
2397  break;
2398  }
2399  batches.emplace_back(std::move(batch));
2400  }
2401  } catch (const std::exception& e) {
2402  LOG(ERROR) << "Error parsing Arrow stream: " << e.what() << ". Import aborted";
2403  }
2404  return batches;
2405 }
#define LOG(tag)
Definition: Logger.h:185
#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 3680 of file MapDHandler.cpp.

Referenced by MapDHandler::import_geo_table().

3680  {
3681  return (t == TDatumType::POLYGON || t == TDatumType::MULTIPOLYGON ||
3682  t == TDatumType::LINESTRING || t == TDatumType::POINT);
3683 }

+ Here is the caller graph for this function: