OmniSciDB  1dac507f6e
 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 1276 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 1278 of file ParserNode.h.

References compression.

1282  : table(tab), path(path) {
1283  auto options_deleter = [](std::list<NameValueAssign*>* options) {
1284  for (auto option : *options) {
1285  delete option;
1286  }
1287  delete options;
1288  };
1289  std::unique_ptr<std::list<NameValueAssign*>, decltype(options_deleter)> options_ptr(
1290  options, options_deleter);
1291  std::vector<std::string> allowed_compression_programs{"lz4", "gzip", "none"};
1292  // specialize decompressor or break on osx bsdtar...
1293  if (options) {
1294  for (const auto option : *options) {
1295  if (boost::iequals(*option->get_name(), "compression")) {
1296  if (const auto str_literal =
1297  dynamic_cast<const StringLiteral*>(option->get_value())) {
1298  compression = *str_literal->get_stringval();
1299  const std::string lowercase_compression =
1300  boost::algorithm::to_lower_copy(compression);
1301  if (allowed_compression_programs.end() ==
1302  std::find(allowed_compression_programs.begin(),
1303  allowed_compression_programs.end(),
1304  lowercase_compression)) {
1305  throw std::runtime_error("Compression program " + compression +
1306  " is not supported.");
1307  }
1308  } else {
1309  throw std::runtime_error("Compression option must be a string.");
1310  }
1311  } else {
1312  throw std::runtime_error("Invalid WITH option: " + *option->get_name());
1313  }
1314  }
1315  }
1316  // default lz4 compression, next gzip, or none.
1317  if (compression.empty()) {
1318  if (boost::process::search_path(compression = "gzip").string().empty()) {
1319  if (boost::process::search_path(compression = "lz4").string().empty()) {
1320  compression = "none";
1321  }
1322  }
1323  }
1324  if (boost::iequals(compression, "none")) {
1325  compression.clear();
1326  } else {
1327  std::map<std::string, std::string> decompression{{"lz4", "unlz4"},
1328  {"gzip", "gunzip"}};
1329  const auto use_program = is_restore ? decompression[compression] : compression;
1330  const auto prog_path = boost::process::search_path(use_program);
1331  if (prog_path.string().empty()) {
1332  throw std::runtime_error("Compression program " + use_program + " is not found.");
1333  }
1334  compression = "--use-compress-program=" + use_program;
1335  }
1336  }
std::unique_ptr< std::string > path
Definition: ParserNode.h:1343
std::unique_ptr< std::string > table
Definition: ParserNode.h:1342

Member Function Documentation

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

Definition at line 1339 of file ParserNode.h.

References compression.

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

Definition at line 1338 of file ParserNode.h.

References path.

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

Definition at line 1337 of file ParserNode.h.

References table.

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

Member Data Documentation

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

Definition at line 1344 of file ParserNode.h.

Referenced by DumpRestoreTableStmtBase(), and getCompression().

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

Definition at line 1343 of file ParserNode.h.

Referenced by getPath().

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

Definition at line 1342 of file ParserNode.h.

Referenced by getTable().


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