OmniSciDB  471d68cefb
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
shared Namespace Reference

Namespaces

 anonymous_namespace{file_path_util.cpp}
 

Classes

class  FileNotFoundException
 
class  NoRegexFilterMatchException
 
class  FileOrderBase
 
class  FileOrderLocal
 
struct  PrintContainer
 
struct  is_std_container
 
struct  is_std_container< std::deque< T, A > >
 
struct  is_std_container< std::list< T, A > >
 
struct  is_std_container< std::set< T, A > >
 
struct  is_std_container< std::unordered_set< T, A > >
 
struct  is_std_container< std::vector< T, A > >
 
struct  DivUMod
 

Typedefs

using LocalFileComparator = std::function< bool(const std::string &, const std::string &)>
 

Functions

std::string decode_base64_uri (const std::string &data, bool trim_nulls)
 
std::string decode_base64 (const std::string &val, bool trim_nulls)
 
std::string decode_base64 (const std::string &val)
 
static std::string encode_base64 (const std::string &val)
 
void validate_sort_options (const std::optional< std::string > &sort_by, const std::optional< std::string > &sort_regex)
 
std::vector< std::string > local_glob_filter_sort_files (const std::string &file_path, const std::optional< std::string > &filter_regex, const std::optional< std::string > &sort_by, const std::optional< std::string > &sort_regex)
 
void throw_file_not_found (const std::string &file_path)
 
void throw_no_filter_match (const std::string &pattern)
 
bool isPowOfTwo (unsigned n)
 
unsigned getExpOfTwo (unsigned n)
 
size_t formatDate (char *buf, size_t const max, int64_t const unixtime)
 
size_t formatDateTime (char *buf, size_t const max, int64_t const timestamp, int const dimension)
 
size_t formatHMS (char *buf, size_t const max, int64_t const unixtime)
 
template<typename K , typename V >
V & get_from_map (std::map< K, V > &map, const K &key)
 
template<typename K , typename V >
const V & get_from_map (const std::map< K, V > &map, const K &key)
 
template<typename T >
size_t appendMove (std::vector< T > &destination, std::vector< T > &source)
 
template<typename... Ts, typename T >
bool dynamic_castable_to_any (T const *ptr)
 
template<typename CONTAINER >
PrintContainer< CONTAINER > printContainer (CONTAINER &container)
 
template<typename OSTREAM , typename CONTAINER >
OSTREAM & operator<< (OSTREAM &os, PrintContainer< CONTAINER > pc)
 
DivUMod divUMod (int64_t num, int64_t den)
 
uint64_t unsignedMod (int64_t num, int64_t den)
 
template<typename T , typename U >
bool contains (const T &container, const U &element)
 
template<typename... COEFFICIENTS>
constexpr double horner (double const x, double const c0, COEFFICIENTS...c)
 
double fastAtanh (double const x)
 
double fastCos (double const x)
 
double fastCosh (double const x)
 
double fastSin (double const x)
 
double fastSinh (double const x)
 
template<typename T , size_t N>
constexpr std::array< T, N > powersOf (T const a)
 
template<size_t N>
constexpr std::array< double, N > inversePowersOf (double const a)
 
double power10 (unsigned const x)
 
double power10inv (unsigned const x)
 
template<typename TO , typename FROM >
TO reinterpret_bits (FROM const from)
 
template<typename... STR>
constexpr std::array
< std::string_view, sizeof...(STR)> 
string_view_array (STR &&...str)
 

Variables

const std::string FILE_SORT_ORDER_BY_KEY = "FILE_SORT_ORDER_BY"
 
const std::string FILE_SORT_REGEX_KEY = "FILE_SORT_REGEX"
 
const std::string PATHNAME_ORDER_TYPE = "PATHNAME"
 
const std::string DATE_MODIFIED_ORDER_TYPE = "DATE_MODIFIED"
 
const std::string REGEX_ORDER_TYPE = "REGEX"
 
const std::string REGEX_DATE_ORDER_TYPE = "REGEX_DATE"
 
const std::string REGEX_NUMBER_ORDER_TYPE = "REGEX_NUMBER"
 
const std::array< std::string, 5 > supported_file_sort_order_types
 
const std::array< std::string, 2 > non_regex_sort_order_types
 
const std::array< std::string, 3 > regex_sort_order_types
 
const std::function< bool(const
std::string &, const
std::string &)> 
common_regex_date_comp_
 
const std::function< bool(const
std::string &, const
std::string &)> 
common_regex_number_comp_
 

Typedef Documentation

using shared::LocalFileComparator = typedef std::function<bool(const std::string&, const std::string&)>

Definition at line 43 of file file_path_util.h.

Function Documentation

template<typename T >
size_t shared::appendMove ( std::vector< T > &  destination,
std::vector< T > &  source 
)

Definition at line 74 of file misc.h.

74  {
75  if (source.empty()) {
76  return 0;
77  } else if (destination.empty()) {
78  destination = std::move(source);
79  return destination.size();
80  } else {
81  size_t const source_size = source.size();
82  destination.reserve(destination.size() + source_size);
83  std::move(std::begin(source), std::end(source), std::back_inserter(destination));
84  source.clear();
85  return source_size;
86  }
87 }
template<typename T , typename U >
bool shared::contains ( const T &  container,
const U &  element 
)
inline

Definition at line 188 of file misc.h.

Referenced by foreign_storage::ParquetDataWrapper::fetchChunkMetadata(), Catalog_Namespace::Catalog::getForeignServersForUser(), TableOptimizer::getFragmentIndexes(), foreign_storage::anonymous_namespace{FileReader.cpp}::is_compressed_file(), Grantee::reassignObjectOwners(), Catalog_Namespace::SysCatalog::reassignObjectOwners(), Catalog_Namespace::Catalog::reassignOwners(), TableOptimizer::vacuumFragments(), validate_sort_options(), foreign_storage::ForeignDataWrapperFactory::validateDataWrapperType(), and foreign_storage::AbstractFileStorageDataWrapper::validateServerOptions().

188  {
189  if (std::find(container.begin(), container.end(), element) == container.end()) {
190  return false;
191  } else {
192  return true;
193  }
194 }

+ Here is the caller graph for this function:

std::string shared::decode_base64 ( const std::string &  val,
bool  trim_nulls 
)
inline

Definition at line 27 of file base64.h.

Referenced by decode_base64(), and decode_base64_uri().

27  {
28  // For some strings, signatature particualary it is important no to trim
29  // '\0' characters
30  using namespace boost::archive::iterators;
31  using It = transform_width<binary_from_base64<std::string::const_iterator>, 8, 6>;
32 
33  if (!trim_nulls) {
34  return std::string(It(val.begin()), It(val.end()));
35  }
36  return boost::algorithm::trim_right_copy_if(
37  std::string(It(std::begin(val)), It(std::end(val))),
38  [](char c) { return c == '\0'; });
39 }

+ Here is the caller graph for this function:

std::string shared::decode_base64 ( const std::string &  val)
inline

Definition at line 41 of file base64.h.

References decode_base64().

41  {
42  return decode_base64(val, true);
43 }
std::string decode_base64(const std::string &val, bool trim_nulls)
Definition: base64.h:27

+ Here is the call graph for this function:

std::string shared::decode_base64_uri ( const std::string &  data,
bool  trim_nulls 
)

Definition at line 21 of file base64.cpp.

References decode_base64().

21  {
22  // Allocate a string large enough to hold exta '=' as padding
23  std::string uri_dec;
24  size_t data_len = data.length();
25  // base64_uri encoding removes '=' padding at the end of the string.
26  size_t padding = 4 - (data_len % 4);
27  if (padding == 4) {
28  padding = 0;
29  }
30  uri_dec.resize(data_len + padding);
31 
32  // base64_uri encoding replaces all '+' and '/' with '-' and '_' respectively.
33  std::transform(
34  data.begin(), data.end(), uri_dec.begin(), [](unsigned char c) -> unsigned char {
35  switch (c) {
36  case '-':
37  return '+';
38  case '_':
39  return '/';
40  default:
41  return c;
42  }
43  });
44  if (padding != 0) {
45  uri_dec.replace(uri_dec.begin() + data_len, uri_dec.end(), padding, '=');
46  }
47  // in the case of a signature from a JWT trim_nulls should be false
48  return decode_base64(uri_dec, trim_nulls);
49 }
std::string decode_base64(const std::string &val, bool trim_nulls)
Definition: base64.h:27

+ Here is the call graph for this function:

DivUMod shared::divUMod ( int64_t  num,
int64_t  den 
)
inline

Definition at line 169 of file misc.h.

References shared::DivUMod::quot.

Referenced by formatDate(), and formatDateTime().

169  {
170  DivUMod div{num / den, num % den};
171  if (div.rem < 0) {
172  --div.quot;
173  div.rem += den;
174  }
175  return div;
176 }

+ Here is the caller graph for this function:

template<typename... Ts, typename T >
bool shared::dynamic_castable_to_any ( T const ptr)

Definition at line 90 of file misc.h.

90  {
91  return (... || dynamic_cast<Ts const*>(ptr));
92 }
static std::string shared::encode_base64 ( const std::string &  val)
inlinestatic

Definition at line 45 of file base64.h.

45  {
46  using namespace boost::archive::iterators;
47  using It = base64_from_binary<transform_width<std::string::const_iterator, 6, 8>>;
48  auto tmp = std::string(It(std::begin(val)), It(std::end(val)));
49  return tmp.append((3 - val.size() % 3) % 3, '=');
50 }
double shared::fastAtanh ( double const  x)
inline

Definition at line 208 of file misc.h.

References horner().

Referenced by Transform4326ToUTM::Transform4326ToUTM().

208  {
209  // Mathematica: CoefficientList[Normal@Series[ArcTanh[x],{x,0,16}],x] // InputForm
210  return x * horner(x * x, 1, 1 / 3., 1 / 5., 1 / 7., 1 / 9., 1 / 11., 1 / 13., 1 / 15.);
211 }
constexpr double horner(double const x, double const c0, COEFFICIENTS...c)
Definition: misc.h:198

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

double shared::fastCos ( double const  x)
inline

Definition at line 214 of file misc.h.

References horner().

Referenced by Transform4326ToUTM::Transform4326ToUTM().

214  {
215  // Mathematica: CoefficientList[Normal@Series[Cos[x],{x,0,16}],x] // InputForm
216  // clang-format off
217  return horner(x * x, 1, -1/2., 1/24., -1/720., 1/40320., -1/3628800.,
218  1/479001600., -1/87178291200., 1/20922789888000.);
219  // clang-format on
220 }
constexpr double horner(double const x, double const c0, COEFFICIENTS...c)
Definition: misc.h:198

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

double shared::fastCosh ( double const  x)
inline

Definition at line 223 of file misc.h.

References horner().

Referenced by Transform4326ToUTM::calculateY(), TransformUTMTo4326::calculateY(), and TransformUTMTo4326::TransformUTMTo4326().

223  {
224  // Mathematica: CoefficientList[Normal@Series[Cosh[x],{x,0,16}],x] // InputForm
225  // clang-format off
226  return horner(x * x, 1, 1/2., 1/24., 1/720., 1/40320., 1/3628800.,
227  1/479001600., 1/87178291200., 1/20922789888000.);
228  // clang-format on
229 }
constexpr double horner(double const x, double const c0, COEFFICIENTS...c)
Definition: misc.h:198

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

double shared::fastSin ( double const  x)
inline

Definition at line 232 of file misc.h.

References horner().

Referenced by Transform4326ToUTM::Transform4326ToUTM().

232  {
233  // Mathematica: CoefficientList[Normal@Series[Sin[x],{x,0,16}],x] // InputForm
234  // clang-format off
235  return x * horner(x * x, 1, -1/6., 1/120., -1/5040., 1/362880.,
236  -1/39916800., 1/6227020800., -1/1307674368000.);
237  // clang-format on
238 }
constexpr double horner(double const x, double const c0, COEFFICIENTS...c)
Definition: misc.h:198

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

double shared::fastSinh ( double const  x)
inline

Definition at line 241 of file misc.h.

References horner().

Referenced by Transform4326ToUTM::calculateX(), TransformUTMTo4326::calculateX(), and TransformUTMTo4326::TransformUTMTo4326().

241  {
242  // Mathematica: CoefficientList[Normal@Series[Sinh[x],{x,0,16}],x] // InputForm
243  // clang-format off
244  return x * horner(x * x, 1, 1/6., 1/120., 1/5040., 1/362880.,
245  1/39916800., 1/6227020800., 1/1307674368000.);
246  // clang-format on
247 }
constexpr double horner(double const x, double const c0, COEFFICIENTS...c)
Definition: misc.h:198

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

size_t shared::formatDate ( char *  buf,
size_t const  max,
int64_t const  unixtime 
)

Definition at line 25 of file misc.cpp.

References divUMod(), shared::DivUMod::quot, and shared::DivUMod::rem.

Referenced by DatumToString().

25  {
26  DivUMod const div_day = divUMod(unixtime, 24 * 60 * 60);
27  DivUMod const div_era = divUMod(div_day.quot - 11017, 146097);
28  unsigned const doe = static_cast<unsigned>(div_era.rem);
29  unsigned const yoe = (doe - doe / 1460 + doe / 36524 - (doe == 146096)) / 365;
30  unsigned const doy = doe - (365 * yoe + yoe / 4 - yoe / 100);
31  unsigned const moy = (5 * doy + 2) / 153;
32  static_assert(8 <= sizeof(long long)); // long long needed for snprintf()
33  long long const y = 2000 + div_era.quot * 400 + yoe + (9 < moy);
34  unsigned const m = moy + (9 < moy ? -9 : 3);
35  unsigned const d = doy - (153 * moy + 2) / 5 + 1;
36  int const len = snprintf(buf, max, "%04lld-%02u-%02u", y, m, d);
37  if (0 <= len && static_cast<size_t>(len) < max) {
38  return static_cast<size_t>(len);
39  }
40  return 0;
41 }
DivUMod divUMod(int64_t num, int64_t den)
Definition: misc.h:169

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

size_t shared::formatDateTime ( char *  buf,
size_t const  max,
int64_t const  timestamp,
int const  dimension 
)

Definition at line 43 of file misc.cpp.

References divUMod(), shared::DivUMod::quot, and shared::DivUMod::rem.

Referenced by DatumToString().

46  {
47  constexpr int pow10[10]{
48  1, 10, 100, 1000, 10000, 100000, 1000000, 10000000, 100000000, 1000000000};
49  DivUMod const div_hip = divUMod(timestamp, pow10[dimension]);
50  DivUMod const div_day = divUMod(div_hip.quot, 24 * 60 * 60);
51  DivUMod const div_era = divUMod(div_day.quot - 11017, 146097);
52  unsigned const doe = static_cast<unsigned>(div_era.rem);
53  unsigned const yoe = (doe - doe / 1460 + doe / 36524 - (doe == 146096)) / 365;
54  unsigned const doy = doe - (365 * yoe + yoe / 4 - yoe / 100);
55  unsigned const moy = (5 * doy + 2) / 153;
56  static_assert(8 <= sizeof(long long)); // long long needed for snprintf()
57  long long const y = 2000 + div_era.quot * 400 + yoe + (9 < moy);
58  unsigned const m = moy + (9 < moy ? -9 : 3);
59  unsigned const d = doy - (153 * moy + 2) / 5 + 1;
60  unsigned const minutes = static_cast<unsigned>(div_day.rem) / 60;
61  unsigned const ss = div_day.rem % 60;
62  unsigned const hh = minutes / 60;
63  unsigned const mm = minutes % 60;
64  int const len =
65  snprintf(buf, max, "%04lld-%02u-%02u %02u:%02u:%02u", y, m, d, hh, mm, ss);
66  if (0 <= len && static_cast<size_t>(len) < max) {
67  if (dimension) {
68  int const len_frac = snprintf(
69  buf + len, max - len, ".%0*d", dimension, static_cast<int>(div_hip.rem));
70  if (0 <= len_frac && static_cast<size_t>(len + len_frac) < max) {
71  return static_cast<size_t>(len + len_frac);
72  }
73  } else {
74  return static_cast<size_t>(len);
75  }
76  }
77  return 0;
78 }
DivUMod divUMod(int64_t num, int64_t den)
Definition: misc.h:169

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

size_t shared::formatHMS ( char *  buf,
size_t const  max,
int64_t const  unixtime 
)

Definition at line 80 of file misc.cpp.

References unsignedMod().

Referenced by DatumToString(), import_export::QueryExporterCSV::exportResults(), import_export::anonymous_namespace{QueryExporterGDAL.cpp}::insert_array_column(), and import_export::anonymous_namespace{QueryExporterGDAL.cpp}::insert_scalar_column().

80  {
81  unsigned const seconds = static_cast<unsigned>(unsignedMod(unixtime, 24 * 60 * 60));
82  unsigned const minutes = seconds / 60;
83  unsigned const ss = seconds % 60;
84  unsigned const hh = minutes / 60;
85  unsigned const mm = minutes % 60;
86  int const len = snprintf(buf, max, "%02u:%02u:%02u", hh, mm, ss);
87  if (0 <= len && static_cast<size_t>(len) < max) {
88  return static_cast<size_t>(len);
89  }
90  return 0;
91 }
uint64_t unsignedMod(int64_t num, int64_t den)
Definition: misc.h:179

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

template<typename K , typename V >
V& shared::get_from_map ( std::map< K, V > &  map,
const K &  key 
)

Definition at line 58 of file misc.h.

References CHECK.

Referenced by Buffer_Namespace::TieredCpuBufferMgr::getAllocatorForSlab(), foreign_storage::ParquetDataWrapper::initializeChunkBuffers(), foreign_storage::ParquetDataWrapper::loadBuffersUsingLazyParquetChunkLoader(), foreign_storage::LazyParquetChunkLoader::loadRowGroups(), and foreign_storage::AbstractTextFileDataWrapper::updateMetadata().

58  {
59  auto find_it = map.find(key);
60  CHECK(find_it != map.end());
61  return find_it->second;
62 }
#define CHECK(condition)
Definition: Logger.h:209

+ Here is the caller graph for this function:

template<typename K , typename V >
const V& shared::get_from_map ( const std::map< K, V > &  map,
const K &  key 
)

Definition at line 65 of file misc.h.

References CHECK.

65  {
66  auto find_it = map.find(key);
67  CHECK(find_it != map.end());
68  return find_it->second;
69 }
#define CHECK(condition)
Definition: Logger.h:209
unsigned shared::getExpOfTwo ( unsigned  n)

Definition at line 23 of file MathUtils.cpp.

References i.

Referenced by Executor::addUdfIrToModule().

23  {
24  unsigned i = 0;
25 
26  while ((n = n >> 1)) {
27  ++i;
28  }
29 
30  return i;
31 }
constexpr double n
Definition: Utm.h:46

+ Here is the caller graph for this function:

template<typename... COEFFICIENTS>
constexpr double shared::horner ( double const  x,
double const  c0,
COEFFICIENTS...  c 
)

Definition at line 198 of file misc.h.

Referenced by fastAtanh(), fastCos(), fastCosh(), fastSin(), and fastSinh().

198  {
199  if constexpr (sizeof...(COEFFICIENTS) == 0) { // NOLINT
200  return c0;
201  } else {
202  return horner(x, c...) * x + c0;
203  }
204  return {}; // quiet nvcc warning https://stackoverflow.com/a/64561686/2700898
205 }
constexpr double horner(double const x, double const c0, COEFFICIENTS...c)
Definition: misc.h:198

+ Here is the caller graph for this function:

template<size_t N>
constexpr std::array<double, N> shared::inversePowersOf ( double const  a)

Definition at line 257 of file misc.h.

References anonymous_namespace{misc.h}::inversePowersOfImpl().

257  {
258  return inversePowersOfImpl(a, std::make_index_sequence<N>{});
259 }
constexpr double a
Definition: Utm.h:38
constexpr std::array< double, sizeof...(Indices)> inversePowersOfImpl(double const a, std::index_sequence< Indices...>)
Definition: misc.h:47

+ Here is the call graph for this function:

bool shared::isPowOfTwo ( unsigned  n)

Definition at line 19 of file MathUtils.cpp.

19  {
20  return (n & (n - 1)) == 0;
21 }
constexpr double n
Definition: Utm.h:46
std::vector< std::string > shared::local_glob_filter_sort_files ( const std::string &  file_path,
const std::optional< std::string > &  filter_regex,
const std::optional< std::string > &  sort_by,
const std::optional< std::string > &  sort_regex 
)

Definition at line 108 of file file_path_util.cpp.

References shared::anonymous_namespace{file_path_util.cpp}::glob_local_recursive_files(), PATHNAME_ORDER_TYPE, and shared::anonymous_namespace{file_path_util.cpp}::regex_file_filter().

Referenced by import_export::DataStreamSink::archivePlumber(), ddl_utils::get_expanded_file_paths(), foreign_storage::ParquetDataWrapper::getAllFilePaths(), and foreign_storage::LocalMultiFileReader::LocalMultiFileReader().

112  {
113  auto result_files = glob_local_recursive_files(file_path);
114  if (filter_regex.has_value()) {
115  result_files = regex_file_filter(filter_regex.value(), result_files);
116  }
117  // initial lexicographical order ensures a determinisitc ordering for files not matching
118  // sort_regex
119  auto initial_file_order = FileOrderLocal(std::nullopt, PATHNAME_ORDER_TYPE);
120  auto lexi_comp = initial_file_order.getFileComparator();
121  std::stable_sort(result_files.begin(), result_files.end(), lexi_comp);
122 
123  auto file_order = FileOrderLocal(sort_regex, sort_by);
124  auto comp = file_order.getFileComparator();
125  std::stable_sort(result_files.begin(), result_files.end(), comp);
126  return result_files;
127 }
const std::string PATHNAME_ORDER_TYPE
std::vector< std::string > glob_local_recursive_files(const std::string &file_path)
std::vector< std::string > regex_file_filter(const std::string &pattern, const std::vector< std::string > &file_paths)

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

template<typename OSTREAM , typename CONTAINER >
OSTREAM& shared::operator<< ( OSTREAM &  os,
PrintContainer< CONTAINER >  pc 
)

Definition at line 123 of file misc.h.

References printContainer().

123  {
124  if (pc.container.empty()) {
125  return os << "()";
126  } else {
127  if constexpr (is_std_container<typename CONTAINER::value_type>::value) { // NOLINT
128  os << '(';
129  for (auto& container : pc.container) {
130  os << printContainer(container);
131  }
132  } else {
133  for (auto itr = pc.container.begin(); itr != pc.container.end(); ++itr) {
134  if constexpr (std::is_pointer_v<typename CONTAINER::value_type>) { // NOLINT
135  os << (itr == pc.container.begin() ? '(' : ' ') << (void const*)*itr;
136  } else {
137  os << (itr == pc.container.begin() ? '(' : ' ') << *itr;
138  }
139  }
140  }
141  return os << ')';
142  }
143 }
PrintContainer< CONTAINER > printContainer(CONTAINER &container)
Definition: misc.h:105

+ Here is the call graph for this function:

double shared::power10 ( unsigned const  x)
inline

Definition at line 262 of file misc.h.

References anonymous_namespace{Utm.h}::N.

Referenced by Analyzer::anonymous_namespace{Analyzer.cpp}::floatFromDecimal().

262  {
263  constexpr unsigned N = 20;
264  constexpr auto pow10 = powersOf<double, N>(10.0);
265  return x < N ? pow10[x] : (pow10[N - 1] * 10) * power10(x - N);
266 }
double power10(unsigned const x)
Definition: misc.h:262
constexpr unsigned N
Definition: Utm.h:118

+ Here is the caller graph for this function:

double shared::power10inv ( unsigned const  x)
inline

Definition at line 269 of file misc.h.

References anonymous_namespace{Utm.h}::N.

Referenced by CodeGenerator::codegenCastToFp().

269  {
270  constexpr unsigned N = 20;
271  constexpr auto pow10inv = inversePowersOf<N>(10.0);
272  return x < N ? pow10inv[x] : (pow10inv[N - 1] / 10) * power10inv(x - N);
273 }
double power10inv(unsigned const x)
Definition: misc.h:269
constexpr unsigned N
Definition: Utm.h:118

+ Here is the caller graph for this function:

template<typename T , size_t N>
constexpr std::array<T, N> shared::powersOf ( T const  a)

Definition at line 251 of file misc.h.

References anonymous_namespace{Utm.h}::a.

251  {
252  return powersOfImpl<T>(a, std::make_index_sequence<N>{});
253 }
constexpr double a
Definition: Utm.h:38
template<typename CONTAINER >
PrintContainer<CONTAINER> shared::printContainer ( CONTAINER &  container)
template<typename TO , typename FROM >
TO shared::reinterpret_bits ( FROM const  from)
inline

Definition at line 277 of file misc.h.

References FROM, TO, and to.

277  {
278  TO to{0};
279  memcpy(&to, &from, sizeof(TO) < sizeof(FROM) ? sizeof(TO) : sizeof(FROM));
280  return to;
281 }
#define TO
#define FROM
char * to
template<typename... STR>
constexpr std::array<std::string_view, sizeof...(STR)> shared::string_view_array ( STR &&...  str)

Definition at line 284 of file misc.h.

284  {
285  return {std::forward<STR>(str)...};
286 }
void shared::throw_file_not_found ( const std::string &  file_path)
inline

Definition at line 79 of file file_path_util.h.

Referenced by shared::anonymous_namespace{file_path_util.cpp}::glob_local_recursive_files().

79  {
80  throw FileNotFoundException{"File or directory \"" + file_path + "\" does not exist."};
81 }

+ Here is the caller graph for this function:

void shared::throw_no_filter_match ( const std::string &  pattern)
inline

Definition at line 89 of file file_path_util.h.

Referenced by shared::anonymous_namespace{file_path_util.cpp}::regex_file_filter(), and foreign_storage::anonymous_namespace{S3FilePathUtil.cpp}::s3_objects_regex_file_filter().

89  {
90  throw NoRegexFilterMatchException{"No files matched the regex file path \"" + pattern +
91  "\"."};
92 }

+ Here is the caller graph for this function:

uint64_t shared::unsignedMod ( int64_t  num,
int64_t  den 
)
inline

Definition at line 179 of file misc.h.

Referenced by formatHMS().

179  {
180  int64_t mod = num % den;
181  if (mod < 0) {
182  mod += den;
183  }
184  return mod;
185 }

+ Here is the caller graph for this function:

void shared::validate_sort_options ( const std::optional< std::string > &  sort_by,
const std::optional< std::string > &  sort_regex 
)

Definition at line 32 of file file_path_util.cpp.

References contains(), FILE_SORT_ORDER_BY_KEY, FILE_SORT_REGEX_KEY, join(), non_regex_sort_order_types, PATHNAME_ORDER_TYPE, regex_sort_order_types, supported_file_sort_order_types, and to_upper().

Referenced by import_export::DataStreamSink::archivePlumber(), and foreign_storage::AbstractFileStorageDataWrapper::validateTableOptions().

33  {
34  const auto sort_by_str = to_upper(sort_by.value_or(PATHNAME_ORDER_TYPE));
35 
37  throw std::runtime_error{FILE_SORT_ORDER_BY_KEY +
38  " must be one of the following options: " +
40  }
41 
42  if (shared::contains(non_regex_sort_order_types, sort_by_str) &&
43  sort_regex.has_value()) {
44  throw std::runtime_error{"Option \"" + FILE_SORT_REGEX_KEY +
45  "\" must not be set for selected option \"" +
46  FILE_SORT_ORDER_BY_KEY + "='" + sort_by_str + "'\"."};
47  }
48 
49  if (shared::contains(regex_sort_order_types, sort_by_str) && !sort_regex.has_value()) {
50  throw std::runtime_error{"Option \"" + FILE_SORT_REGEX_KEY +
51  "\" must be set for selected option \"" +
52  FILE_SORT_ORDER_BY_KEY + "='" + sort_by_str + "'\"."};
53  }
54 }
bool contains(const T &container, const U &element)
Definition: misc.h:188
const std::array< std::string, 2 > non_regex_sort_order_types
const std::string FILE_SORT_REGEX_KEY
std::string join(T const &container, std::string const &delim)
const std::string PATHNAME_ORDER_TYPE
const std::string FILE_SORT_ORDER_BY_KEY
std::string to_upper(const std::string &str)
const std::array< std::string, 5 > supported_file_sort_order_types
const std::array< std::string, 3 > regex_sort_order_types

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

Variable Documentation

const std::function<bool(const std::string&, const std::string&)> shared::common_regex_date_comp_
Initial value:
= [](const std::string& lhs, const std::string& rhs) -> bool {
int64_t lhs_t;
int64_t rhs_t;
try {
lhs_t = dateTimeParse<kDATE>(lhs, 0);
} catch (const std::exception& e) {
lhs_t = 0;
}
try {
rhs_t = dateTimeParse<kDATE>(rhs, 0);
} catch (const std::exception& e) {
rhs_t = 0;
}
return lhs_t < rhs_t;
}

Definition at line 112 of file file_path_util.h.

const std::function<bool(const std::string&, const std::string&)> shared::common_regex_number_comp_
Initial value:
=
[](const std::string& lhs, const std::string& rhs) -> bool {
int64_t lhs_i;
int64_t rhs_i;
try {
lhs_i = stoll(lhs, 0);
} catch (const std::exception& e) {
lhs_i = 0;
}
try {
rhs_i = stoll(rhs, 0);
} catch (const std::exception& e) {
rhs_i = 0;
}
return lhs_i < rhs_i;
}

Definition at line 128 of file file_path_util.h.

const std::string shared::DATE_MODIFIED_ORDER_TYPE = "DATE_MODIFIED"
inline

Definition at line 53 of file file_path_util.h.

const std::string shared::FILE_SORT_ORDER_BY_KEY = "FILE_SORT_ORDER_BY"
inline

Definition at line 49 of file file_path_util.h.

Referenced by validate_sort_options().

const std::string shared::FILE_SORT_REGEX_KEY = "FILE_SORT_REGEX"
inline

Definition at line 50 of file file_path_util.h.

Referenced by validate_sort_options().

const std::array<std::string, 2> shared::non_regex_sort_order_types
inline
Initial value:
{
const std::string PATHNAME_ORDER_TYPE
const std::string DATE_MODIFIED_ORDER_TYPE

Definition at line 65 of file file_path_util.h.

Referenced by validate_sort_options().

const std::string shared::REGEX_DATE_ORDER_TYPE = "REGEX_DATE"
inline

Definition at line 55 of file file_path_util.h.

const std::string shared::REGEX_NUMBER_ORDER_TYPE = "REGEX_NUMBER"
inline

Definition at line 56 of file file_path_util.h.

const std::string shared::REGEX_ORDER_TYPE = "REGEX"
inline

Definition at line 54 of file file_path_util.h.

const std::array<std::string, 3> shared::regex_sort_order_types
inline
Initial value:
const std::string REGEX_NUMBER_ORDER_TYPE
const std::string REGEX_ORDER_TYPE
const std::string REGEX_DATE_ORDER_TYPE

Definition at line 69 of file file_path_util.h.

Referenced by validate_sort_options().

const std::array<std::string, 5> shared::supported_file_sort_order_types
inline
Initial value:
{
const std::string REGEX_NUMBER_ORDER_TYPE
const std::string REGEX_ORDER_TYPE
const std::string REGEX_DATE_ORDER_TYPE
const std::string PATHNAME_ORDER_TYPE
const std::string DATE_MODIFIED_ORDER_TYPE

Definition at line 58 of file file_path_util.h.

Referenced by validate_sort_options().