0.9.8.10
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
Classes | Public Member Functions | Static Public Member Functions | Private Types | Private Member Functions | Static Private Member Functions | Private Attributes | Static Private Attributes | List of all members
Hypertable::FileBlockCache Class Reference

#include <FileBlockCache.h>

Classes

class  BlockCacheEntry
 
struct  DecrementRefCount
 
struct  HashI64
 

Public Member Functions

 FileBlockCache (int64_t min_memory, int64_t max_memory, bool compressed)
 
 ~FileBlockCache ()
 
bool compressed ()
 
bool checkout (int file_id, uint64_t file_offset, uint8_t **blockp, uint32_t *lengthp)
 
void checkin (int file_id, uint64_t file_offset)
 
bool insert (int file_id, uint64_t file_offset, uint8_t *block, uint32_t length, const EventPtr &event, bool checkout)
 
bool contains (int file_id, uint64_t file_offset)
 
void increase_limit (int64_t amount)
 
int64_t decrease_limit (int64_t amount)
 Lowers the memory limit. More...
 
int64_t get_limit ()
 
void cap_memory_use ()
 Sets limit to memory currently used, it will not reduce the limit below min_memory. More...
 
int64_t memory_used ()
 
int64_t available ()
 
void get_stats (uint64_t *max_memoryp, uint64_t *available_memoryp, uint64_t *accessesp, uint64_t *hitsp)
 

Static Public Member Functions

static int get_next_file_id ()
 

Private Types

typedef
boost::multi_index_container
< BlockCacheEntry, indexed_by
< sequenced<>, hashed_unique
< const_mem_fun
< BlockCacheEntry, int64_t,&BlockCacheEntry::key >
, HashI64 > > > 
BlockCache
 
typedef BlockCache::nth_index
< 0 >::type 
Sequence
 
typedef BlockCache::nth_index
< 1 >::type 
HashIndex
 

Private Member Functions

int64_t make_room (int64_t amount)
 

Static Private Member Functions

static int64_t make_key (int file_id, uint64_t file_offset)
 

Private Attributes

std::mutex m_mutex
 
BlockCache m_cache
 
int64_t m_min_memory
 
int64_t m_max_memory
 
int64_t m_limit
 
int64_t m_available
 
uint64_t m_accesses
 
uint64_t m_hits
 
bool m_compressed
 

Static Private Attributes

static std::atomic< int > ms_next_file_id {0}
 

Detailed Description

Definition at line 40 of file FileBlockCache.h.

Member Typedef Documentation

typedef boost::multi_index_container< BlockCacheEntry, indexed_by< sequenced<>, hashed_unique<const_mem_fun<BlockCacheEntry, int64_t, &BlockCacheEntry::key>, HashI64> > > Hypertable::FileBlockCache::BlockCache
private

Definition at line 154 of file FileBlockCache.h.

typedef BlockCache::nth_index<1>::type Hypertable::FileBlockCache::HashIndex
private

Definition at line 157 of file FileBlockCache.h.

typedef BlockCache::nth_index<0>::type Hypertable::FileBlockCache::Sequence
private

Definition at line 156 of file FileBlockCache.h.

Constructor & Destructor Documentation

Hypertable::FileBlockCache::FileBlockCache ( int64_t  min_memory,
int64_t  max_memory,
bool  compressed 
)
inline

Definition at line 45 of file FileBlockCache.h.

FileBlockCache::~FileBlockCache ( )

Definition at line 35 of file FileBlockCache.cc.

Member Function Documentation

int64_t Hypertable::FileBlockCache::available ( )
inline

Definition at line 100 of file FileBlockCache.h.

void Hypertable::FileBlockCache::cap_memory_use ( )
inline

Sets limit to memory currently used, it will not reduce the limit below min_memory.

Definition at line 82 of file FileBlockCache.h.

void FileBlockCache::checkin ( int  file_id,
uint64_t  file_offset 
)

Definition at line 72 of file FileBlockCache.cc.

bool FileBlockCache::checkout ( int  file_id,
uint64_t  file_offset,
uint8_t **  blockp,
uint32_t *  lengthp 
)

Definition at line 45 of file FileBlockCache.cc.

bool Hypertable::FileBlockCache::compressed ( )
inline

Definition at line 51 of file FileBlockCache.h.

bool FileBlockCache::contains ( int  file_id,
uint64_t  file_offset 
)

Definition at line 122 of file FileBlockCache.cc.

int64_t FileBlockCache::decrease_limit ( int64_t  amount)

Lowers the memory limit.

This method will free memory if necessary to bring the limit down by 'amount' It will not reduce the limit below min_memory

Parameters
amountAmount to reduce limit by
Returns
amount of memory deallocated by the method

Definition at line 146 of file FileBlockCache.cc.

int64_t Hypertable::FileBlockCache::get_limit ( )
inline

Definition at line 73 of file FileBlockCache.h.

static int Hypertable::FileBlockCache::get_next_file_id ( )
inlinestatic

Definition at line 105 of file FileBlockCache.h.

void FileBlockCache::get_stats ( uint64_t *  max_memoryp,
uint64_t *  available_memoryp,
uint64_t *  accessesp,
uint64_t *  hitsp 
)

Definition at line 181 of file FileBlockCache.cc.

void FileBlockCache::increase_limit ( int64_t  amount)

Definition at line 136 of file FileBlockCache.cc.

bool FileBlockCache::insert ( int  file_id,
uint64_t  file_offset,
uint8_t *  block,
uint32_t  length,
const EventPtr event,
bool  checkout 
)

Definition at line 86 of file FileBlockCache.cc.

static int64_t Hypertable::FileBlockCache::make_key ( int  file_id,
uint64_t  file_offset 
)
inlinestaticprivate

Definition at line 114 of file FileBlockCache.h.

int64_t FileBlockCache::make_room ( int64_t  amount)
private

Definition at line 162 of file FileBlockCache.cc.

int64_t Hypertable::FileBlockCache::memory_used ( )
inline

Definition at line 95 of file FileBlockCache.h.

Member Data Documentation

uint64_t Hypertable::FileBlockCache::m_accesses
private

Definition at line 165 of file FileBlockCache.h.

int64_t Hypertable::FileBlockCache::m_available
private

Definition at line 164 of file FileBlockCache.h.

BlockCache Hypertable::FileBlockCache::m_cache
private

Definition at line 160 of file FileBlockCache.h.

bool Hypertable::FileBlockCache::m_compressed
private

Definition at line 167 of file FileBlockCache.h.

uint64_t Hypertable::FileBlockCache::m_hits
private

Definition at line 166 of file FileBlockCache.h.

int64_t Hypertable::FileBlockCache::m_limit
private

Definition at line 163 of file FileBlockCache.h.

int64_t Hypertable::FileBlockCache::m_max_memory
private

Definition at line 162 of file FileBlockCache.h.

int64_t Hypertable::FileBlockCache::m_min_memory
private

Definition at line 161 of file FileBlockCache.h.

std::mutex Hypertable::FileBlockCache::m_mutex
private

Definition at line 159 of file FileBlockCache.h.

atomic< int > FileBlockCache::ms_next_file_id {0}
staticprivate

Definition at line 42 of file FileBlockCache.h.


The documentation for this class was generated from the following files: