OmniSciDB  fe05a0c208
 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)
 
string_dict_hash_t hash_string (const std::string_view &str)
 
template<class T >
void throw_encoding_error (std::string_view str, std::string_view folder)
 
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:194

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

string_dict_hash_t anonymous_namespace{StringDictionary.cpp}::hash_string ( const std::string_view &  str)

Definition at line 80 of file StringDictionary.cpp.

References i.

Referenced by StringDictionary::getOrAddBulk(), StringDictionary::getOrAddImpl(), StringDictionary::getUnlocked(), StringDictionary::hashStrings(), StringDictionary::increaseHashTableCapacity(), StringDictionary::increaseHashTableCapacityFromStorageAndMemory(), and StringDictionary::StringDictionary().

80  {
81  string_dict_hash_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 }
uint32_t string_dict_hash_t

+ 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 610 of file StringDictionary.cpp.

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

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

614  {
615  return icase
616  ? (is_simple ? string_ilike_simple(
617  str.c_str(), str.size(), pattern.c_str(), pattern.size())
618  : string_ilike(str.c_str(),
619  str.size(),
620  pattern.c_str(),
621  pattern.size(),
622  escape))
623  : (is_simple ? string_like_simple(
624  str.c_str(), str.size(), pattern.c_str(), pattern.size())
625  : string_like(str.c_str(),
626  str.size(),
627  pattern.c_str(),
628  pattern.size(),
629  escape));
630 }
RUNTIME_EXPORT 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
RUNTIME_EXPORT 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
RUNTIME_EXPORT 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
RUNTIME_EXPORT 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

+ 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 900 of file StringDictionary.cpp.

References regexp_like().

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

902  {
903  return regexp_like(str.c_str(), str.size(), pattern.c_str(), pattern.size(), escape);
904 }
RUNTIME_EXPORT 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:

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

Definition at line 62 of file StringDictionary.cpp.

References UINT32_MAX.

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 }
#define UINT32_MAX

+ Here is the caller graph for this function:

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

Definition at line 306 of file StringDictionary.cpp.

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

306  {
307  std::ostringstream oss;
308  oss << "The text encoded column stored at " << folder << ", has exceeded its limit of "
309  << sizeof(T) * 8 << " bits (" << static_cast<size_t>(max_valid_int_value<T>() + 1)
310  << " unique values)."
311  << " There was an attempt to add the new string '" << str
312  << "'. Table will need to be recreated with larger String Dictionary Capacity";
313  LOG(ERROR) << oss.str();
314  throw std::runtime_error(oss.str());
315 }
#define LOG(tag)
Definition: Logger.h:194

Variable Documentation

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