OmniSciDB  dfae7c3b14
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 }
 
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< QueryExportercreate (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

◆ ArrayNullHandling

Enumerator
kAbortWithWarning 
kExportSentinels 
kExportZeros 
kNullEntireField 

Definition at line 31 of file QueryExporter.h.

31  {
32  kAbortWithWarning,
33  kExportSentinels,
34  kExportZeros,
35  kNullEntireField
36  };

◆ FileCompression

Enumerator
kNone 
kGZip 
kZip 

Definition at line 30 of file QueryExporter.h.

30 { kNone, kGZip, kZip };

◆ FileType

Enumerator
kCSV 
kGeoJSON 
kGeoJSONL 
kShapefile 

Definition at line 29 of file QueryExporter.h.

29 { kCSV, kGeoJSON, kGeoJSONL, kShapefile };

Constructor & Destructor Documentation

◆ QueryExporter() [1/2]

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

Definition at line 26 of file QueryExporter.cpp.

26 : file_type_{file_type} {}

◆ QueryExporter() [2/2]

import_export::QueryExporter::QueryExporter ( )
delete

◆ ~QueryExporter()

virtual import_export::QueryExporter::~QueryExporter ( )
inlinevirtual

Definition at line 40 of file QueryExporter.h.

References beginExport(), create(), endExport(), and exportResults().

40 {}
+ Here is the call graph for this function:

Member Function Documentation

◆ beginExport()

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

Implemented in import_export::QueryExporterGDAL, and import_export::QueryExporterCSV.

Referenced by ~QueryExporter().

+ Here is the caller graph for this function:

◆ create()

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

Definition at line 28 of file QueryExporter.cpp.

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

Referenced by Parser::ExportQueryStmt::execute(), and ~QueryExporter().

28  {
29  switch (file_type) {
30  case FileType::kCSV:
31  return std::make_unique<QueryExporterCSV>();
32  case FileType::kGeoJSON:
35  return std::make_unique<QueryExporterGDAL>(file_type);
36  }
37  CHECK(false);
38  return nullptr;
39 }
#define CHECK(condition)
Definition: Logger.h:197
+ Here is the caller graph for this function:

◆ endExport()

virtual void import_export::QueryExporter::endExport ( )
pure virtual

Implemented in import_export::QueryExporterGDAL, and import_export::QueryExporterCSV.

Referenced by ~QueryExporter().

+ Here is the caller graph for this function:

◆ exportResults()

virtual void import_export::QueryExporter::exportResults ( const std::vector< AggregatedResult > &  query_results)
pure virtual

Implemented in import_export::QueryExporterGDAL, and import_export::QueryExporterCSV.

Referenced by ~QueryExporter().

+ Here is the caller graph for this function:

◆ safeColumnName()

std::string import_export::QueryExporter::safeColumnName ( const std::string &  resname,
const int  column_index 
)
protected

Definition at line 53 of file QueryExporter.cpp.

References to_string().

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

54  {
55  if (resname.size() == 0) {
56  return "result_" + std::to_string(column_index);
57  }
58  return resname;
59 }
std::string to_string(char const *&&v)
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ validateFileExtensions()

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 41 of file QueryExporter.cpp.

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

44  {
45  auto extension = boost::algorithm::to_lower_copy(
46  boost::filesystem::path(file_path).extension().string());
47  if (valid_extensions.find(extension) == valid_extensions.end()) {
48  throw std::runtime_error("Invalid file extension '" + extension +
49  "' for file type '" + file_type + "'");
50  }
51 }
+ Here is the caller graph for this function:

Member Data Documentation

◆ file_type_

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: