OmniSciDB  a47db9e897
 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 &str)
 
template<class T >
void log_encoding_error (const std::string &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 55 of file StringDictionary.cpp.

References CHECK().

Referenced by StringDictionary::appendToStorage(), and StringDictionary::StringDictionary().

55  {
56  auto ptr = mmap(nullptr, sz, PROT_WRITE | PROT_READ, MAP_SHARED, fd, 0);
57  CHECK(ptr != reinterpret_cast<void*>(-1));
58 #ifdef __linux__
59 #ifdef MADV_HUGEPAGE
60  madvise(ptr, sz, MADV_RANDOM | MADV_WILLNEED | MADV_HUGEPAGE);
61 #else
62  madvise(ptr, sz, MADV_RANDOM | MADV_WILLNEED);
63 #endif
64 #endif
65  return ptr;
66 }
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 67 of file StringDictionary.cpp.

References CHECK_EQ.

Referenced by StringDictionary::appendToStorage(), and StringDictionary::~StringDictionary().

67  {
68  CHECK_EQ(0, munmap(addr, length));
69 }
#define CHECK_EQ(x, y)
Definition: Logger.h:198

+ Here is the caller graph for this function:

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

Definition at line 44 of file StringDictionary.cpp.

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

Referenced by StringDictionary::StringDictionary().

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

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

References CHECK_EQ.

Referenced by Catalog_Namespace::Catalog::adjustAlteredTableFiles(), get_filesize(), File_Namespace::FileMgr::init(), File_Namespace::FileMgr::openDBMetaFile(), File_Namespace::FileMgr::openEpochFile(), and StringDictionary::StringDictionary().

37  {
38  struct stat buf;
39  int err = fstat(fd, &buf);
40  CHECK_EQ(0, err);
41  return buf.st_size;
42 }
#define CHECK_EQ(x, y)
Definition: Logger.h:198

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

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

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

424  {
425  return icase
426  ? (is_simple ? string_ilike_simple(
427  str.c_str(), str.size(), pattern.c_str(), pattern.size())
428  : string_ilike(str.c_str(),
429  str.size(),
430  pattern.c_str(),
431  pattern.size(),
432  escape))
433  : (is_simple ? string_like_simple(
434  str.c_str(), str.size(), pattern.c_str(), pattern.size())
435  : string_like(str.c_str(),
436  str.size(),
437  pattern.c_str(),
438  pattern.size(),
439  escape));
440 }
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 710 of file StringDictionary.cpp.

References regexp_like().

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

712  {
713  return regexp_like(str.c_str(), str.size(), pattern.c_str(), pattern.size(), escape);
714 }
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 ( const std::string &  str)

Definition at line 261 of file StringDictionary.cpp.

References logger::ERROR, and LOG.

261  {
262  LOG(ERROR) << "Could not encode string: " << str
263  << ", the encoded value doesn't fit in " << sizeof(T) * 8
264  << " bits. Will store NULL instead.";
265 }
#define LOG(tag)
Definition: Logger.h:185
uint32_t anonymous_namespace{StringDictionary.cpp}::rk_hash ( const std::string &  str)

Definition at line 89 of file StringDictionary.cpp.

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

89  {
90  uint32_t str_hash = 1;
91  // rely on fact that unsigned overflow is defined and wraps
92  for (size_t i = 0; i < str.size(); ++i) {
93  str_hash = str_hash * 997 + str[i];
94  }
95  return str_hash;
96 }

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

Referenced by StringDictionary::StringDictionary().

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

+ Here is the caller graph for this function:

Variable Documentation

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