OmniSciDB  ba1bac9284
 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 1387 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 1389 of file ParserNode.h.

References compression.

1393  : table(tab), path(path) {
1394  auto options_deleter = [](std::list<NameValueAssign*>* options) {
1395  for (auto option : *options) {
1396  delete option;
1397  }
1398  delete options;
1399  };
1400  std::unique_ptr<std::list<NameValueAssign*>, decltype(options_deleter)> options_ptr(
1401  options, options_deleter);
1402  std::vector<std::string> allowed_compression_programs{"lz4", "gzip", "none"};
1403  // specialize decompressor or break on osx bsdtar...
1404  if (options) {
1405  for (const auto option : *options) {
1406  if (boost::iequals(*option->get_name(), "compression")) {
1407  if (const auto str_literal =
1408  dynamic_cast<const StringLiteral*>(option->get_value())) {
1409  compression = *str_literal->get_stringval();
1410  const std::string lowercase_compression =
1411  boost::algorithm::to_lower_copy(compression);
1412  if (allowed_compression_programs.end() ==
1413  std::find(allowed_compression_programs.begin(),
1414  allowed_compression_programs.end(),
1415  lowercase_compression)) {
1416  throw std::runtime_error("Compression program " + compression +
1417  " is not supported.");
1418  }
1419  } else {
1420  throw std::runtime_error("Compression option must be a string.");
1421  }
1422  } else {
1423  throw std::runtime_error("Invalid WITH option: " + *option->get_name());
1424  }
1425  }
1426  }
1427  // default lz4 compression, next gzip, or none.
1428  if (compression.empty()) {
1429  if (boost::process::search_path(compression = "gzip").string().empty()) {
1430  if (boost::process::search_path(compression = "lz4").string().empty()) {
1431  compression = "none";
1432  }
1433  }
1434  }
1435  if (boost::iequals(compression, "none")) {
1436  compression.clear();
1437  } else {
1438  std::map<std::string, std::string> decompression{{"lz4", "unlz4"},
1439  {"gzip", "gunzip"}};
1440  const auto use_program = is_restore ? decompression[compression] : compression;
1441  const auto prog_path = boost::process::search_path(use_program);
1442  if (prog_path.string().empty()) {
1443  throw std::runtime_error("Compression program " + use_program + " is not found.");
1444  }
1445  compression = "--use-compress-program=" + use_program;
1446  }
1447  }
std::unique_ptr< std::string > path
Definition: ParserNode.h:1454
std::unique_ptr< std::string > table
Definition: ParserNode.h:1453

Member Function Documentation

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

Definition at line 1450 of file ParserNode.h.

References compression.

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

Definition at line 1449 of file ParserNode.h.

References path.

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

Definition at line 1448 of file ParserNode.h.

References table.

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

Member Data Documentation

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

Definition at line 1455 of file ParserNode.h.

Referenced by DumpRestoreTableStmtBase(), and getCompression().

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

Definition at line 1454 of file ParserNode.h.

Referenced by getPath().

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

Definition at line 1453 of file ParserNode.h.

Referenced by getTable().


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