29 const int64_t generation)
30 : string_dict_(sd), generation_(generation) {}
89 if (inline_int_null_value<int32_t>() == string_id) {
105 const std::string& pattern,
107 const bool is_simple,
111 str.c_str(), str.size(), pattern.c_str(), pattern.size())
118 str.c_str(), str.size(), pattern.c_str(), pattern.size())
130 const bool is_simple,
131 const char escape)
const {
136 if (
is_like(str, pattern, icase, is_simple, escape)) {
137 result.push_back(kv.first);
146 const std::string& pattern,
147 const std::string& comp_operator) {
148 int res = str.compare(pattern);
149 if (comp_operator ==
"<") {
151 }
else if (comp_operator ==
"<=") {
153 }
else if (comp_operator ==
"=") {
155 }
else if (comp_operator ==
">") {
157 }
else if (comp_operator ==
">=") {
159 }
else if (comp_operator ==
"<>") {
162 throw std::runtime_error(
"unsupported string compare operator");
168 const std::string& pattern,
169 const std::string& comp_operator)
const {
174 if (
do_compare(str, pattern, comp_operator)) {
175 result.push_back(kv.first);
184 const std::string& pattern,
186 return regexp_like(str.c_str(), str.size(), pattern.c_str(), pattern.size(), escape);
192 const char escape)
const {
198 result.push_back(kv.first);
205 return string_dict_->getOrAdd(str);
209 int32_t string_id)
const noexcept {
210 if (string_id >= 0) {
211 return string_dict_.get()->getStringBytes(string_id);
214 auto it = transient_int_to_str_.find(string_id);
215 CHECK(it != transient_int_to_str_.end());
216 return std::make_pair(it->second.c_str(), it->second.size());
224 if (generation == -1) {
227 if (generation_ != -1) {
231 generation_ = generation;
std::pair< const char *, size_t > getStringBytes(int32_t string_id) const noexcept
std::vector< int32_t > getLike(const std::string &pattern, const bool icase, const bool is_simple, const char escape) const
std::map< int32_t, std::string > transient_int_to_str_
StringDictionary * getDictionary() noexcept
int32_t getIdOfStringNoGeneration(const std::string &str) const
size_t storageEntryCount() const
std::string getString(int32_t string_id) const
Constants for Builtin SQL Types supported by OmniSci.
std::vector< int32_t > getCompare(const std::string &pattern, const std::string &comp_operator) const
bool is_regexp_like(const std::string &str, const std::string &pattern, const char escape)
static constexpr int32_t INVALID_STR_ID
std::shared_ptr< StringDictionary > string_dict_
DEVICE bool regexp_like(const char *str, const int32_t str_len, const char *pattern, const int32_t pat_len, const char escape_char)
DEVICE bool string_ilike(const char *str, const int32_t str_len, const char *pattern, const int32_t pat_len, const char escape_char)
DEVICE bool string_like(const char *str, const int32_t str_len, const char *pattern, const int32_t pat_len, const char escape_char)
std::map< std::string, int32_t > transient_str_to_int_
bool is_like(const std::string &str, const std::string &pattern, const bool icase, const bool is_simple, const char escape)
void updateGeneration(const int64_t generation) noexcept
DEVICE bool string_ilike_simple(const char *str, const int32_t str_len, const char *pattern, const int32_t pat_len)
Functions to support the LIKE and ILIKE operator in SQL. Only single-byte character set is supported ...
bool do_compare(const std::string &str, const std::string &pattern, const std::string &comp_operator)
std::vector< int32_t > getRegexpLike(const std::string &pattern, const char escape) const
int32_t getOrAdd(const std::string &str) noexcept
StringDictionaryProxy(std::shared_ptr< StringDictionary > sd, const int64_t generation)
mapd_shared_lock< mapd_shared_mutex > read_lock
int32_t getOrAddTransient(const std::string &str)
mapd_unique_lock< mapd_shared_mutex > write_lock
int32_t getIdOfString(const std::string &str) const
DEVICE bool string_like_simple(const char *str, const int32_t str_len, const char *pattern, const int32_t pat_len)
mapd_shared_mutex rw_mutex_
int64_t getGeneration() const noexcept
int32_t truncate_to_generation(const int32_t id, const size_t generation)