OmniSciDB  340b00dbf6
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
anonymous_namespace{StringDictionary.cpp} Namespace Reference

Functions

int checked_open (const char *path, const bool recover)
 
const uint64_t round_up_p2 (const uint64_t num)
 
uint32_t rk_hash (const std::string_view &str)
 
template<class T >
void log_encoding_error (std::string_view str)
 
bool is_like (const std::string &str, const std::string &pattern, const bool icase, const bool is_simple, const char escape)
 
bool is_regexp_like (const std::string &str, const std::string &pattern, const char escape)
 

Variables

const int SYSTEM_PAGE_SIZE = omnisci::get_page_size()
 

Function Documentation

int anonymous_namespace{StringDictionary.cpp}::checked_open ( const char *  path,
const bool  recover 
)

Definition at line 51 of file StringDictionary.cpp.

References logger::ERROR, LOG, and omnisci::open().

Referenced by StringDictionary::StringDictionary().

51  {
52  auto fd = omnisci::open(path, O_RDWR | O_CREAT | (recover ? O_APPEND : O_TRUNC), 0644);
53  if (fd > 0) {
54  return fd;
55  }
56  auto err = std::string("Dictionary path ") + std::string(path) +
57  std::string(" does not exist.");
58  LOG(ERROR) << err;
59  throw DictPayloadUnavailable(err);
60 }
int open(const char *path, int flags, int mode)
Definition: omnisci_fs.cpp:64
#define LOG(tag)
Definition: Logger.h:188

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

bool anonymous_namespace{StringDictionary.cpp}::is_like ( const std::string &  str,
const std::string &  pattern,
const bool  icase,
const bool  is_simple,
const char  escape 
)

Definition at line 590 of file StringDictionary.cpp.

References string_ilike(), string_ilike_simple(), string_like(), and string_like_simple().

Referenced by StringDictionaryProxy::getLike(), and StringDictionary::getLike().

594  {
595  return icase
596  ? (is_simple ? string_ilike_simple(
597  str.c_str(), str.size(), pattern.c_str(), pattern.size())
598  : string_ilike(str.c_str(),
599  str.size(),
600  pattern.c_str(),
601  pattern.size(),
602  escape))
603  : (is_simple ? string_like_simple(
604  str.c_str(), str.size(), pattern.c_str(), pattern.size())
605  : string_like(str.c_str(),
606  str.size(),
607  pattern.c_str(),
608  pattern.size(),
609  escape));
610 }
DEVICE bool string_ilike(const char *str, const int32_t str_len, const char *pattern, const int32_t pat_len, const char escape_char)
Definition: StringLike.cpp:257
DEVICE bool string_like(const char *str, const int32_t str_len, const char *pattern, const int32_t pat_len, const char escape_char)
Definition: StringLike.cpp:246
DEVICE bool string_ilike_simple(const char *str, const int32_t str_len, const char *pattern, const int32_t pat_len)
Definition: StringLike.cpp:59
DEVICE bool string_like_simple(const char *str, const int32_t str_len, const char *pattern, const int32_t pat_len)
Definition: StringLike.cpp:43

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

bool anonymous_namespace{StringDictionary.cpp}::is_regexp_like ( const std::string &  str,
const std::string &  pattern,
const char  escape 
)

Definition at line 880 of file StringDictionary.cpp.

References regexp_like().

Referenced by StringDictionaryProxy::getRegexpLike(), and StringDictionary::getRegexpLike().

882  {
883  return regexp_like(str.c_str(), str.size(), pattern.c_str(), pattern.size(), escape);
884 }
DEVICE bool regexp_like(const char *str, const int32_t str_len, const char *pattern, const int32_t pat_len, const char escape_char)
Definition: Regexp.cpp:41

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

template<class T >
void anonymous_namespace{StringDictionary.cpp}::log_encoding_error ( std::string_view  str)

Definition at line 300 of file StringDictionary.cpp.

References logger::ERROR, LOG, and omnisci.dtypes::T.

300  {
301  LOG(ERROR) << "Could not encode string: " << str
302  << ", the encoded value doesn't fit in " << sizeof(T) * 8
303  << " bits. Will store NULL instead.";
304 }
#define LOG(tag)
Definition: Logger.h:188
uint32_t anonymous_namespace{StringDictionary.cpp}::rk_hash ( const std::string_view &  str)

Definition at line 80 of file StringDictionary.cpp.

Referenced by StringDictionary::getOrAddBulk(), StringDictionary::getOrAddImpl(), StringDictionary::getUnlocked(), StringDictionary::hashStrings(), StringDictionary::increaseCapacity(), StringDictionary::increaseCapacityFromStorageAndMemory(), and StringDictionary::StringDictionary().

80  {
81  uint32_t str_hash = 1;
82  // rely on fact that unsigned overflow is defined and wraps
83  for (size_t i = 0; i < str.size(); ++i) {
84  str_hash = str_hash * 997 + str[i];
85  }
86  return str_hash;
87 }

+ Here is the caller graph for this function:

const uint64_t anonymous_namespace{StringDictionary.cpp}::round_up_p2 ( const uint64_t  num)

Definition at line 62 of file StringDictionary.cpp.

Referenced by StringDictionary::StringDictionary().

62  {
63  uint64_t in = num;
64  in--;
65  in |= in >> 1;
66  in |= in >> 2;
67  in |= in >> 4;
68  in |= in >> 8;
69  in |= in >> 16;
70  in++;
71  // TODO MAT deal with case where filesize has been increased but reality is
72  // we are constrained to 2^31.
73  // In that situation this calculation will wrap to zero
74  if (in == 0 || (in > (UINT32_MAX))) {
75  in = UINT32_MAX;
76  }
77  return in;
78 }

+ Here is the caller graph for this function:

Variable Documentation

const int anonymous_namespace{StringDictionary.cpp}::SYSTEM_PAGE_SIZE = omnisci::get_page_size()