OmniSciDB  0fdbebe030
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
Parser::DumpRestoreTableStmtBase Class Reference

#include <ParserNode.h>

+ Inheritance diagram for Parser::DumpRestoreTableStmtBase:
+ Collaboration diagram for Parser::DumpRestoreTableStmtBase:

Public Member Functions

 DumpRestoreTableStmtBase (std::string *tab, std::string *path, std::list< NameValueAssign * > *options, const bool is_restore)
 
const std::string * getTable () const
 
const std::string * getPath () const
 
const std::string getCompression () const
 
- Public Member Functions inherited from Parser::DDLStmt
virtual void execute (const Catalog_Namespace::SessionInfo &session)=0
 
void setColumnDescriptor (ColumnDescriptor &cd, const ColumnDef *coldef)
 
- Public Member Functions inherited from Parser::Node
virtual ~Node ()
 

Protected Attributes

std::unique_ptr< std::string > table
 
std::unique_ptr< std::string > path
 
std::string compression
 

Detailed Description

Definition at line 1331 of file ParserNode.h.

Constructor & Destructor Documentation

Parser::DumpRestoreTableStmtBase::DumpRestoreTableStmtBase ( std::string *  tab,
std::string *  path,
std::list< NameValueAssign * > *  options,
const bool  is_restore 
)
inline

Definition at line 1333 of file ParserNode.h.

References compression.

1337  : table(tab), path(path) {
1338  auto options_deleter = [](std::list<NameValueAssign*>* options) {
1339  for (auto option : *options) {
1340  delete option;
1341  }
1342  delete options;
1343  };
1344  std::unique_ptr<std::list<NameValueAssign*>, decltype(options_deleter)> options_ptr(
1345  options, options_deleter);
1346  std::vector<std::string> allowed_compression_programs{"lz4", "gzip", "none"};
1347  // specialize decompressor or break on osx bsdtar...
1348  if (options) {
1349  for (const auto option : *options) {
1350  if (boost::iequals(*option->get_name(), "compression")) {
1351  if (const auto str_literal =
1352  dynamic_cast<const StringLiteral*>(option->get_value())) {
1353  compression = *str_literal->get_stringval();
1354  const std::string lowercase_compression =
1355  boost::algorithm::to_lower_copy(compression);
1356  if (allowed_compression_programs.end() ==
1357  std::find(allowed_compression_programs.begin(),
1358  allowed_compression_programs.end(),
1359  lowercase_compression)) {
1360  throw std::runtime_error("Compression program " + compression +
1361  " is not supported.");
1362  }
1363  } else {
1364  throw std::runtime_error("Compression option must be a string.");
1365  }
1366  } else {
1367  throw std::runtime_error("Invalid WITH option: " + *option->get_name());
1368  }
1369  }
1370  }
1371  // default lz4 compression, next gzip, or none.
1372  if (compression.empty()) {
1373  if (boost::process::search_path(compression = "gzip").string().empty()) {
1374  if (boost::process::search_path(compression = "lz4").string().empty()) {
1375  compression = "none";
1376  }
1377  }
1378  }
1379  if (boost::iequals(compression, "none")) {
1380  compression.clear();
1381  } else {
1382  std::map<std::string, std::string> decompression{{"lz4", "unlz4"},
1383  {"gzip", "gunzip"}};
1384  const auto use_program = is_restore ? decompression[compression] : compression;
1385  const auto prog_path = boost::process::search_path(use_program);
1386  if (prog_path.string().empty()) {
1387  throw std::runtime_error("Compression program " + use_program + " is not found.");
1388  }
1389  compression = "--use-compress-program=" + use_program;
1390  }
1391  }
std::unique_ptr< std::string > path
Definition: ParserNode.h:1398
std::unique_ptr< std::string > table
Definition: ParserNode.h:1397

Member Function Documentation

const std::string Parser::DumpRestoreTableStmtBase::getCompression ( ) const
inline

Definition at line 1394 of file ParserNode.h.

References compression.

1394 { return compression; }
const std::string* Parser::DumpRestoreTableStmtBase::getPath ( ) const
inline

Definition at line 1393 of file ParserNode.h.

References path.

1393 { return path.get(); }
std::unique_ptr< std::string > path
Definition: ParserNode.h:1398
const std::string* Parser::DumpRestoreTableStmtBase::getTable ( ) const
inline

Definition at line 1392 of file ParserNode.h.

References table.

1392 { return table.get(); }
std::unique_ptr< std::string > table
Definition: ParserNode.h:1397

Member Data Documentation

std::string Parser::DumpRestoreTableStmtBase::compression
protected

Definition at line 1399 of file ParserNode.h.

Referenced by DumpRestoreTableStmtBase(), and getCompression().

std::unique_ptr<std::string> Parser::DumpRestoreTableStmtBase::path
protected

Definition at line 1398 of file ParserNode.h.

Referenced by getPath().

std::unique_ptr<std::string> Parser::DumpRestoreTableStmtBase::table
protected

Definition at line 1397 of file ParserNode.h.

Referenced by getTable().


The documentation for this class was generated from the following file: