OmniSciDB  8a228a1076
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

◆ checked_mmap()

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

Definition at line 62 of file StringDictionary.cpp.

References CHECK.

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

62  {
63  auto ptr = mmap(nullptr, sz, PROT_WRITE | PROT_READ, MAP_SHARED, fd, 0);
64  CHECK(ptr != reinterpret_cast<void*>(-1));
65 #ifdef __linux__
66 #ifdef MADV_HUGEPAGE
67  madvise(ptr, sz, MADV_RANDOM | MADV_WILLNEED | MADV_HUGEPAGE);
68 #else
69  madvise(ptr, sz, MADV_RANDOM | MADV_WILLNEED);
70 #endif
71 #endif
72  return ptr;
73 }
int64_t const int32_t sz
#define CHECK(condition)
Definition: Logger.h:197
+ Here is the caller graph for this function:

◆ checked_munmap()

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

Definition at line 74 of file StringDictionary.cpp.

References CHECK_EQ.

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

74  {
75  CHECK_EQ(0, munmap(addr, length));
76 }
#define CHECK_EQ(x, y)
Definition: Logger.h:205
+ Here is the caller graph for this function:

◆ checked_open()

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 File_Namespace::open().

Referenced by StringDictionary::StringDictionary().

51  {
52  auto fd = 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 }
#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:87
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ file_size()

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

Definition at line 44 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().

44  {
45  struct stat buf;
46  int err = fstat(fd, &buf);
47  CHECK_EQ(0, err);
48  return buf.st_size;
49 }
#define CHECK_EQ(x, y)
Definition: Logger.h:205
+ Here is the caller graph for this function:

◆ is_like()

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

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

Referenced by StringDictionary::getLike().

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

◆ is_regexp_like()

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

Definition at line 895 of file StringDictionary.cpp.

References regexp_like().

Referenced by StringDictionary::getRegexpLike().

897  {
898  return regexp_like(str.c_str(), str.size(), pattern.c_str(), pattern.size(), escape);
899 }
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:

◆ log_encoding_error()

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

Definition at line 315 of file StringDictionary.cpp.

References logger::ERROR, and LOG.

315  {
316  LOG(ERROR) << "Could not encode string: " << str
317  << ", the encoded value doesn't fit in " << sizeof(T) * 8
318  << " bits. Will store NULL instead.";
319 }
#define LOG(tag)
Definition: Logger.h:188

◆ rk_hash()

uint32_t anonymous_namespace{StringDictionary.cpp}::rk_hash ( const std::string_view &  str)

Definition at line 96 of file StringDictionary.cpp.

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

96  {
97  uint32_t str_hash = 1;
98  // rely on fact that unsigned overflow is defined and wraps
99  for (size_t i = 0; i < str.size(); ++i) {
100  str_hash = str_hash * 997 + str[i];
101  }
102  return str_hash;
103 }
+ Here is the caller graph for this function:

◆ round_up_p2()

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

Definition at line 78 of file StringDictionary.cpp.

Referenced by StringDictionary::StringDictionary().

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

Variable Documentation

◆ SYSTEM_PAGE_SIZE

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