OmniSciDB  72c90bc290
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
import_export::QueryExporter Class Referenceabstract

#include <QueryExporter.h>

+ Inheritance diagram for import_export::QueryExporter:

Public Types

enum  FileType {
  FileType::kCSV, FileType::kGeoJSON, FileType::kGeoJSONL, FileType::kShapefile,
  FileType::kFlatGeobuf
}
 
enum  FileCompression { FileCompression::kNone, FileCompression::kGZip, FileCompression::kZip }
 
enum  ArrayNullHandling { ArrayNullHandling::kAbortWithWarning, ArrayNullHandling::kExportSentinels, ArrayNullHandling::kExportZeros, ArrayNullHandling::kNullEntireField }
 

Public Member Functions

 QueryExporter (const FileType file_type)
 
 QueryExporter ()=delete
 
virtual ~QueryExporter ()
 
virtual void beginExport (const std::string &file_path, const std::string &layer_name, const CopyParams &copy_params, const std::vector< TargetMetaInfo > &column_info, const FileCompression file_compression, const ArrayNullHandling array_null_handling)=0
 
virtual void exportResults (const std::vector< AggregatedResult > &query_results)=0
 
virtual void endExport ()=0
 

Static Public Member Functions

static std::unique_ptr
< QueryExporter
create (const FileType file_type)
 

Protected Member Functions

void validateFileExtensions (const std::string &file_path, const std::string &file_type, const std::unordered_set< std::string > &valid_extensions) const
 
std::string safeColumnName (const std::string &resname, const int column_index)
 

Protected Attributes

const FileType file_type_
 

Detailed Description

Definition at line 27 of file QueryExporter.h.

Member Enumeration Documentation

Enumerator
kAbortWithWarning 
kExportSentinels 
kExportZeros 
kNullEntireField 

Definition at line 31 of file QueryExporter.h.

31  {
32  kAbortWithWarning,
33  kExportSentinels,
34  kExportZeros,
35  kNullEntireField
36  };
Enumerator
kNone 
kGZip 
kZip 

Definition at line 30 of file QueryExporter.h.

Enumerator
kCSV 
kGeoJSON 
kGeoJSONL 
kShapefile 
kFlatGeobuf 

Definition at line 29 of file QueryExporter.h.

29 { kCSV, kGeoJSON, kGeoJSONL, kShapefile, kFlatGeobuf };

Constructor & Destructor Documentation

import_export::QueryExporter::QueryExporter ( const FileType  file_type)
explicit

Definition at line 27 of file QueryExporter.cpp.

27 : file_type_{file_type} {}
import_export::QueryExporter::QueryExporter ( )
delete
virtual import_export::QueryExporter::~QueryExporter ( )
inlinevirtual

Definition at line 40 of file QueryExporter.h.

40 {}

Member Function Documentation

virtual void import_export::QueryExporter::beginExport ( const std::string &  file_path,
const std::string &  layer_name,
const CopyParams copy_params,
const std::vector< TargetMetaInfo > &  column_info,
const FileCompression  file_compression,
const ArrayNullHandling  array_null_handling 
)
pure virtual
std::unique_ptr< QueryExporter > import_export::QueryExporter::create ( const FileType  file_type)
static

Definition at line 29 of file QueryExporter.cpp.

References CHECK, kCSV, kFlatGeobuf, kGeoJSON, kGeoJSONL, and kShapefile.

Referenced by Parser::ExportQueryStmt::execute().

29  {
30  switch (file_type) {
31  case FileType::kCSV:
32  return std::make_unique<QueryExporterCSV>();
33  case FileType::kGeoJSON:
37  return std::make_unique<QueryExporterGDAL>(file_type);
38  }
39  CHECK(false);
40  return nullptr;
41 }
#define CHECK(condition)
Definition: Logger.h:291

+ Here is the caller graph for this function:

virtual void import_export::QueryExporter::endExport ( )
pure virtual
virtual void import_export::QueryExporter::exportResults ( const std::vector< AggregatedResult > &  query_results)
pure virtual
std::string import_export::QueryExporter::safeColumnName ( const std::string &  resname,
const int  column_index 
)
protected

Definition at line 55 of file QueryExporter.cpp.

References to_string().

Referenced by import_export::QueryExporterCSV::beginExport(), import_export::QueryExporterGDAL::beginExport(), and import_export::QueryExporterGDAL::exportResults().

56  {
57  if (resname.size() == 0) {
58  return "result_" + std::to_string(column_index);
59  }
60  return resname;
61 }
std::string to_string(char const *&&v)

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void import_export::QueryExporter::validateFileExtensions ( const std::string &  file_path,
const std::string &  file_type,
const std::unordered_set< std::string > &  valid_extensions 
) const
protected

Definition at line 43 of file QueryExporter.cpp.

Referenced by import_export::QueryExporterCSV::beginExport(), and import_export::QueryExporterGDAL::beginExport().

46  {
47  auto extension = boost::algorithm::to_lower_copy(
48  boost::filesystem::path(file_path).extension().string());
49  if (valid_extensions.find(extension) == valid_extensions.end()) {
50  throw std::runtime_error("Invalid file extension '" + extension +
51  "' for file type '" + file_type + "'");
52  }
53 }

+ Here is the caller graph for this function:

Member Data Documentation

const FileType import_export::QueryExporter::file_type_
protected

Definition at line 54 of file QueryExporter.h.

Referenced by import_export::QueryExporterGDAL::beginExport().


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