OmniSciDB  72c90bc290
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
StringDictionaryGenerations.cpp
Go to the documentation of this file.
1 /*
2  * Copyright 2022 HEAVY.AI, Inc.
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16 
18 
19 #include "Logger/Logger.h"
20 
22  const uint64_t generation) {
23  dict_key_to_generation_.emplace(dict_key, generation);
24 }
25 
27  const uint64_t generation) {
28  CHECK(dict_key_to_generation_.count(dict_key));
29  dict_key_to_generation_[dict_key] = generation;
30 }
31 
33  const shared::StringDictKey& id) const {
34  const auto it = dict_key_to_generation_.find(id);
35  if (it != dict_key_to_generation_.end()) {
36  return it->second;
37  }
38  if (id.isTransientDict()) {
39  return 0;
40  }
41  // This happens when the query didn't need to do any translation from string
42  // to id. Return an invalid generation and StringDictionaryProxy will assert
43  // the methods which require a generation (the ones which go from string to id)
44  // are called on it if it has an invalid generation, only the id from string
45  // direction is allowed in such cases. Once a query finishes its effective
46  // execution, the generations are cleared and the string to id direction
47  // isn't needed anymore, only the opposite for the returned result set.
48  return -1;
49 }
50 
51 const std::unordered_map<shared::StringDictKey, uint64_t>&
54 }
55 
58 }
void setGeneration(const shared::StringDictKey &dict_key, const uint64_t generation)
void updateGeneration(const shared::StringDictKey &dict_key, const uint64_t generation)
int64_t getGeneration(const shared::StringDictKey &dict_key) const
#define CHECK(condition)
Definition: Logger.h:291
DEVICE void swap(ARGS &&...args)
Definition: gpu_enabled.h:114
const std::unordered_map< shared::StringDictKey, uint64_t > & asMap() const
std::unordered_map< shared::StringDictKey, uint64_t > dict_key_to_generation_