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

Functions

size_t file_size (const int fd)
 
int checked_open (const char *path, const bool recover)
 
void * checked_mmap (const int fd, const size_t sz)
 
void checked_munmap (void *addr, size_t length)
 
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 = getpagesize()
 

Function Documentation

void* anonymous_namespace{StringDictionary.cpp}::checked_mmap ( const int  fd,
const size_t  sz 
)

Definition at line 60 of file StringDictionary.cpp.

References CHECK().

Referenced by StringDictionary::checkAndConditionallyIncreaseOffsetCapacity(), StringDictionary::checkAndConditionallyIncreasePayloadCapacity(), and StringDictionary::StringDictionary().

60  {
61  auto ptr = mmap(nullptr, sz, PROT_WRITE | PROT_READ, MAP_SHARED, fd, 0);
62  CHECK(ptr != reinterpret_cast<void*>(-1));
63 #ifdef __linux__
64 #ifdef MADV_HUGEPAGE
65  madvise(ptr, sz, MADV_RANDOM | MADV_WILLNEED | MADV_HUGEPAGE);
66 #else
67  madvise(ptr, sz, MADV_RANDOM | MADV_WILLNEED);
68 #endif
69 #endif
70  return ptr;
71 }
CHECK(cgen_state)

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void anonymous_namespace{StringDictionary.cpp}::checked_munmap ( void *  addr,
size_t  length 
)

Definition at line 72 of file StringDictionary.cpp.

References CHECK_EQ.

Referenced by StringDictionary::checkAndConditionallyIncreaseOffsetCapacity(), StringDictionary::checkAndConditionallyIncreasePayloadCapacity(), and StringDictionary::~StringDictionary().

72  {
73  CHECK_EQ(0, munmap(addr, length));
74 }
#define CHECK_EQ(x, y)
Definition: Logger.h:205

+ Here is the caller graph for this function:

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

Definition at line 49 of file StringDictionary.cpp.

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

Referenced by StringDictionary::StringDictionary().

49  {
50  auto fd = open(path, O_RDWR | O_CREAT | (recover ? O_APPEND : O_TRUNC), 0644);
51  if (fd > 0) {
52  return fd;
53  }
54  auto err = std::string("Dictionary path ") + std::string(path) +
55  std::string(" does not exist.");
56  LOG(ERROR) << err;
57  throw DictPayloadUnavailable(err);
58 }
#define LOG(tag)
Definition: Logger.h:188
FILE * open(int fileId)
Opens/creates the file with the given id; returns NULL on error.
Definition: File.cpp:82

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

size_t anonymous_namespace{StringDictionary.cpp}::file_size ( const int  fd)

Definition at line 42 of file StringDictionary.cpp.

References CHECK_EQ.

Referenced by anonymous_namespace{TableArchiver.cpp}::adjust_altered_table_files(), get_filesize(), File_Namespace::FileMgr::init(), File_Namespace::FileMgr::openDBMetaFile(), File_Namespace::FileMgr::openEpochFile(), and StringDictionary::StringDictionary().

42  {
43  struct stat buf;
44  int err = fstat(fd, &buf);
45  CHECK_EQ(0, err);
46  return buf.st_size;
47 }
#define CHECK_EQ(x, y)
Definition: Logger.h:205

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

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

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

574  {
575  return icase
576  ? (is_simple ? string_ilike_simple(
577  str.c_str(), str.size(), pattern.c_str(), pattern.size())
578  : string_ilike(str.c_str(),
579  str.size(),
580  pattern.c_str(),
581  pattern.size(),
582  escape))
583  : (is_simple ? string_like_simple(
584  str.c_str(), str.size(), pattern.c_str(), pattern.size())
585  : string_like(str.c_str(),
586  str.size(),
587  pattern.c_str(),
588  pattern.size(),
589  escape));
590 }
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 860 of file StringDictionary.cpp.

References regexp_like().

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

862  {
863  return regexp_like(str.c_str(), str.size(), pattern.c_str(), pattern.size(), escape);
864 }
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:40

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

References logger::ERROR, and LOG.

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

Definition at line 94 of file StringDictionary.cpp.

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

94  {
95  uint32_t str_hash = 1;
96  // rely on fact that unsigned overflow is defined and wraps
97  for (size_t i = 0; i < str.size(); ++i) {
98  str_hash = str_hash * 997 + str[i];
99  }
100  return str_hash;
101 }

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

Referenced by StringDictionary::StringDictionary().

76  {
77  uint64_t in = num;
78  in--;
79  in |= in >> 1;
80  in |= in >> 2;
81  in |= in >> 4;
82  in |= in >> 8;
83  in |= in >> 16;
84  in++;
85  // TODO MAT deal with case where filesize has been increased but reality is
86  // we are constrained to 2^31.
87  // In that situation this calculation will wrap to zero
88  if (in == 0 || (in > (UINT32_MAX))) {
89  in = UINT32_MAX;
90  }
91  return in;
92 }

+ Here is the caller graph for this function:

Variable Documentation

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