OmniSciDB  8a228a1076
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 1333 of file ParserNode.h.

Constructor & Destructor Documentation

◆ DumpRestoreTableStmtBase()

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

Definition at line 1335 of file ParserNode.h.

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

Member Function Documentation

◆ getCompression()

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

Definition at line 1396 of file ParserNode.h.

1396 { return compression; }

◆ getPath()

const std::string* Parser::DumpRestoreTableStmtBase::getPath ( ) const
inline

Definition at line 1395 of file ParserNode.h.

1395 { return path.get(); }
std::unique_ptr< std::string > path
Definition: ParserNode.h:1400

◆ getTable()

const std::string* Parser::DumpRestoreTableStmtBase::getTable ( ) const
inline

Definition at line 1394 of file ParserNode.h.

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

Member Data Documentation

◆ compression

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

Definition at line 1401 of file ParserNode.h.

◆ path

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

Definition at line 1400 of file ParserNode.h.

◆ table

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

Definition at line 1399 of file ParserNode.h.


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