OmniSciDB  c1a53651b2
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
S3FilePathUtil.h
Go to the documentation of this file.
1 #include <optional>
2 #include <string>
3 #include <vector>
4 
5 #include <aws/s3/model/Object.h>
6 
7 // #include "DataMgr/OmniSciAwsSdk.h"
10 
11 namespace foreign_storage {
12 std::vector<Aws::S3::Model::Object> s3_objects_filter_sort_files(
13  const std::vector<Aws::S3::Model::Object>& file_paths,
14  const shared::FilePathOptions& options);
15 
16 using S3ObjectComparator =
17  std::function<bool(const Aws::S3::Model::Object&, const Aws::S3::Model::Object&)>;
18 class FileOrderS3 : public shared::FileOrderBase<S3ObjectComparator> {
19  public:
21  : FileOrderBase<S3ObjectComparator>(options) {}
22 
24  auto comparator_pair = comparator_map_.find(getSortBy());
25  CHECK(comparator_pair != comparator_map_.end());
26  return comparator_pair->second;
27  }
28 
29  protected:
30  const std::map<std::string, S3ObjectComparator> comparator_map_{
32  [](const Aws::S3::Model::Object& lhs, const Aws::S3::Model::Object& rhs) -> bool {
33  return lhs.GetKey() < rhs.GetKey();
34  }},
36  [](const Aws::S3::Model::Object& lhs, const Aws::S3::Model::Object& rhs) -> bool {
37  return lhs.GetLastModified() < rhs.GetLastModified();
38  }},
40  [this](const Aws::S3::Model::Object& lhs,
41  const Aws::S3::Model::Object& rhs) -> bool {
42  auto lhs_name = lhs.GetKey();
43  auto rhs_name = rhs.GetKey();
44  return this->concatCaptureGroups(lhs_name) < this->concatCaptureGroups(rhs_name);
45  }},
47  [this](const Aws::S3::Model::Object& lhs,
48  const Aws::S3::Model::Object& rhs) -> bool {
49  return shared::common_regex_date_comp_(this->concatCaptureGroups(lhs.GetKey()),
50  this->concatCaptureGroups(rhs.GetKey()));
51  }},
53  [this](const Aws::S3::Model::Object& lhs,
54  const Aws::S3::Model::Object& rhs) -> bool {
56  this->concatCaptureGroups(lhs.GetKey()),
57  this->concatCaptureGroups(rhs.GetKey()));
58  }}};
59 };
60 } // namespace foreign_storage
S3ObjectComparator getFileComparator() override
const std::string REGEX_NUMBER_ORDER_TYPE
const std::string REGEX_ORDER_TYPE
shared utility for globbing files, paths can be specified as either a single file, directory or wildcards
const std::map< std::string, S3ObjectComparator > comparator_map_
FileOrderBase(const FilePathOptions &options)
const std::string REGEX_DATE_ORDER_TYPE
std::vector< Aws::S3::Model::Object > s3_objects_filter_sort_files(const std::vector< Aws::S3::Model::Object > &file_paths, const shared::FilePathOptions &options)
std::function< bool(const Aws::S3::Model::Object &, const Aws::S3::Model::Object &)> S3ObjectComparator
const std::string PATHNAME_ORDER_TYPE
FileOrderS3(const shared::FilePathOptions &options)
const std::string DATE_MODIFIED_ORDER_TYPE
virtual std::string concatCaptureGroups(const std::string &file_name) const
#define CHECK(condition)
Definition: Logger.h:291
const std::function< bool(const std::string &, const std::string &)> common_regex_number_comp_
const std::function< bool(const std::string &, const std::string &)> common_regex_date_comp_