libfoedus-core
FOEDUS Core Library
foedus::cache::CacheBucket Struct Referencefinal

Hash bucket in cache table. More...

Detailed Description

Hash bucket in cache table.

Every essential information in the hashtable is repsented in this 8-byte. Thus, all simple reads/writes are guaranteed to be complete and consistent (at least regular). This is one of the main tricks to make snapshot cache wait-free.

Higher 32 bit is PageIdTag to efficiently check (with false positives) the bucket points to the page or not. Lower 32 bit is ContentId, or the offset in the page pool.

We always read-write these information as complete 64bit to allow regular-reads and atomic-writes. We never do atomic operations in this module thanks to the loose requirement in the snapshot cache.

But, just be careful on regular-reads and implicitly-atomic-writes. Compiler might do something surprising if we don't explicitly prohibit it. For this purpose, we use a macro equivalent to linux's ACCESS_ONCE. For more details, see: http://lwn.net/Articles/508991/

Definition at line 140 of file cache_hashtable.hpp.

#include <cache_hashtable.hpp>

Public Member Functions

void reset (ContentId id=0, PageIdTag tag=0)
 
ContentId get_content_id () const
 
void set_content_id (ContentId id)
 
bool is_content_set () const
 
PageIdTag get_tag () const
 
void set_tag (PageIdTag tag)
 same note as set_content_id() More...
 

Public Attributes

uint64_t data_
 

Member Function Documentation

ContentId foedus::cache::CacheBucket::get_content_id ( ) const
inline

Definition at line 147 of file cache_hashtable.hpp.

References data_.

Referenced by foedus::cache::CacheHashtable::evict_overflow_loop(), foedus::cache::CacheHashtable::find(), foedus::cache::CacheHashtable::find_batch(), and is_content_set().

147 { return data_; }

Here is the caller graph for this function:

PageIdTag foedus::cache::CacheBucket::get_tag ( ) const
inline

Definition at line 155 of file cache_hashtable.hpp.

Referenced by foedus::cache::CacheHashtable::find(), and foedus::cache::CacheHashtable::find_batch().

155 { return static_cast<PageIdTag>(data_ >> 32); }
uint32_t PageIdTag
This is a lossy-compressed representation of SnapshotPagePointer used to quickly identify whether the...

Here is the caller graph for this function:

bool foedus::cache::CacheBucket::is_content_set ( ) const
inline

Definition at line 153 of file cache_hashtable.hpp.

References get_content_id().

153 { return get_content_id() != 0; }
ContentId get_content_id() const

Here is the call graph for this function:

void foedus::cache::CacheBucket::reset ( ContentId  id = 0,
PageIdTag  tag = 0 
)
inline

Definition at line 143 of file cache_hashtable.hpp.

Referenced by foedus::cache::CacheHashtable::CacheHashtable(), and foedus::cache::CacheHashtable::install().

143  {
144  data_ = (static_cast<uint64_t>(tag) << 32) | id;
145  }

Here is the caller graph for this function:

void foedus::cache::CacheBucket::set_content_id ( ContentId  id)
inline
Note
this operation is not guaranteed to be either atomic or reglar. This should be called only in a local instance of this object, then copied to somewhere as a whole 64bit.

Definition at line 152 of file cache_hashtable.hpp.

152 { data_ = (data_ & 0xFFFFFFFF00000000ULL) | id; }
void foedus::cache::CacheBucket::set_tag ( PageIdTag  tag)
inline

same note as set_content_id()

Definition at line 157 of file cache_hashtable.hpp.

157  {
158  data_ = (data_ & 0x00000000FFFFFFFFULL) | (static_cast<uint64_t>(tag) << 32);
159  }

Member Data Documentation

uint64_t foedus::cache::CacheBucket::data_

The documentation for this struct was generated from the following file: