OmniSciDB  94e8789169
 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 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:

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

Definition at line 80 of file StringDictionary.cpp.

References generate_TableFunctionsFactory_init::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 606 of file StringDictionary.cpp.

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

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

610  {
611  return icase
612  ? (is_simple ? string_ilike_simple(
613  str.c_str(), str.size(), pattern.c_str(), pattern.size())
614  : string_ilike(str.c_str(),
615  str.size(),
616  pattern.c_str(),
617  pattern.size(),
618  escape))
619  : (is_simple ? string_like_simple(
620  str.c_str(), str.size(), pattern.c_str(), pattern.size())
621  : string_like(str.c_str(),
622  str.size(),
623  pattern.c_str(),
624  pattern.size(),
625  escape));
626 }
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 896 of file StringDictionary.cpp.

References regexp_like().

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

898  {
899  return regexp_like(str.c_str(), str.size(), pattern.c_str(), pattern.size(), escape);
900 }
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 303 of file StringDictionary.cpp.

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

303  {
304  LOG(ERROR) << "Could not encode string: " << str
305  << ", the encoded value doesn't fit in " << sizeof(T) * 8
306  << " bits. Will store NULL instead.";
307 }
#define LOG(tag)
Definition: Logger.h:188
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()