27 return (uint32_t) *(
reinterpret_cast<const uint32_t *
>(key.
digest) + 1);
36 unsigned int cache_entries,
43 , max_entries_(cache_entries)
44 , entries_(cache_entries, shash::Any(),
hasher_any,
45 perf::StatisticsTemplate(
"lru", statistics))
47 , counters_(statistics)
49 int retval = pthread_rwlock_init(&
rwlock_, NULL);
64 pthread_rwlock_destroy(&
rwlock_);
75 memcpy(&a, ptr.
pointer,
sizeof(a));
79 const bool update_lru =
false;
82 buf.address =
static_cast<char *
>(ptr.
pointer) +
sizeof(a);
91 const bool update_lru =
false;
101 memcpy(&tmp, buf,
sizeof(tmp));
108 if (!tmp.
address)
return -errno;
115 if (!tmp.
address)
return -ENOMEM;
123 memcpy(buf, &tmp,
sizeof(*buf));
169 const bool update_lru =
false;
176 id.ToString().c_str());
185 const bool update_lru =
false;
192 id.ToString().c_str());
207 id.ToString().c_str(), mem.
refcount);
211 id.ToString().c_str());
226 id.ToString().c_str(), mem.
refcount);
230 id.ToString().c_str());
249 if (offset > mem.
size) {
251 offset, mem.
size,
id.ToString().c_str());
254 uint64_t copy_size = std::min(mem.
size - offset, size);
257 memcpy(buf, static_cast<char *>(mem.
address) + offset, copy_size);
288 size_t old_size = mem.
size;
332 id.ToString().c_str());
337 id.ToString().c_str());
int64_t Xadd(class Counter *counter, const int64_t delta)
unsigned int max_entries_
static const double kCompactThreshold
MemoryKvStore(unsigned int cache_entries, MemoryAllocator alloc, unsigned alloc_size, perf::StatisticsTemplate statistics)
void * Allocate(uint64_t size, void *header, unsigned header_size)
perf::Counter * n_getrefcount
bool Contains(const shash::Any &id)
std::string ToString(const bool with_suffix=false) const
int64_t Read(const shash::Any &id, void *buf, size_t size, size_t offset)
virtual bool Insert(const Key &key, const Value &value)
unsigned int entry_count_
assert((mem||(size==0))&&"Out Of Memory")
static uint32_t hasher_any(const ComparableHash &key)
virtual void FilterGet(Key *key, Value *value)
static CallbackTN * MakeCallback(typename BoundCallback< MallocHeap::BlockPtr, DelegateT >::CallbackMethod method, DelegateT *delegate)
bool DoDelete(const shash::Any &id)
virtual bool FilterNext()
unsigned char digest[digest_size_]
perf::Counter * n_getsize
perf::Counter * sz_deleted
MemoryAllocator allocator_
void OnBlockMove(const MallocHeap::BlockPtr &ptr)
int64_t GetRefcount(const shash::Any &id)
int DoCommit(const MemoryBuffer &buf)
void Set(const int64_t val)
int Commit(const MemoryBuffer &buf)
virtual void FilterDelete()
bool IncRef(const shash::Any &id)
virtual bool UpdateValue(const Key &key, const Value &value)
perf::Counter * sz_shrunk
void MarkFree(void *block)
bool Unref(const shash::Any &id)
virtual void FilterBegin()
int DoMalloc(MemoryBuffer *buf)
bool ShrinkTo(size_t size)
void Inc(class Counter *counter)
bool Delete(const shash::Any &id)
int64_t GetSize(const shash::Any &id)
lru::LruCache< shash::Any, MemoryBuffer > entries_
virtual bool Lookup(const Key &key, Value *value, bool update_lru=true)
void DoFree(MemoryBuffer *buf)
perf::Counter * n_shrinkto
virtual bool Forget(const Key &key)
perf::Counter * sz_committed
CVMFS_EXPORT void LogCvmfs(const LogSource source, const int mask, const char *format,...)