MCPcopy Create free account
hub / github.com/FirebirdSQL/firebird / BCBHashTable

Class BCBHashTable

src/jrd/cch.cpp:241–283  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

239
240
241class BCBHashTable
242{
243#ifdef HASH_USE_CDS_LIST
244 using chain_type = BdbList;
245#else
246 using chain_type = que;
247#endif
248
249public:
250 BCBHashTable(MemoryPool& pool, ULONG count) :
251 m_pool(pool),
252 m_count(0),
253 m_chains(nullptr)
254 {
255 resize(count);
256 }
257
258 ~BCBHashTable()
259 {
260 clear();
261 }
262
263 void resize(ULONG count);
264 void clear();
265
266 BufferDesc* find(const PageNumber& page) const;
267
268 // tries to put bdb into hash slot by page
269 // if succeed, removes bdb from old slot, if necessary, and returns NULL
270 // else, returns BufferDesc that is currently occupies target slot
271 BufferDesc* emplace(BufferDesc* bdb, const PageNumber& page, bool remove);
272
273 void remove(BufferDesc* bdb);
274private:
275 ULONG hash(const PageNumber& pageno) const
276 {
277 return pageno.getPageNum() % m_count;
278 }
279
280 MemoryPool& m_pool;
281 ULONG m_count;
282 chain_type* m_chains;
283};
284
285}
286

Callers 1

CCH_initFunction · 0.70

Calls

no outgoing calls

Tested by

no test coverage detected