20 assert(k.
size() == 4);
23 static void*
EncodeValue(uintptr_t v) {
return reinterpret_cast<void*
>(v); }
24 static int DecodeValue(
void* v) {
return reinterpret_cast<uintptr_t
>(v); }
57 void Insert(
int key,
int value,
int charge = 1) {
161 std::vector<Cache::Handle*> h;
167 for (
int i = 0; i < h.size(); i++) {
171 for (
int i = 0; i < h.size(); i++) {
180 const int kLight = 1;
181 const int kHeavy = 10;
185 const int weight = (index & 1) ? kLight : kHeavy;
186 Insert(index, 1000+index, weight);
191 int cached_weight = 0;
192 for (
int i = 0; i < index; i++) {
193 const int weight = (i & 1 ? kLight : kHeavy);
196 cached_weight += weight;
224 int main(
int argc,
char** argv) {
void PutFixed32(std::string *dst, uint32_t value)
static int DecodeKey(const Slice &k)
virtual Handle * Insert(const Slice &key, void *value, size_t charge, void(*deleter)(const Slice &key, void *value))=0
virtual uint64_t NewId()=0
static void Deleter(const Slice &key, void *v)
virtual void Release(Handle *handle)=0
virtual void * Value(Handle *handle)=0
static const char * EncodeKey(std::string *scratch, const Slice &target)
uint32_t DecodeFixed32(const char *ptr)
static int DecodeValue(void *v)
virtual Handle * Lookup(const Slice &key)=0
static void * EncodeValue(uintptr_t v)
std::vector< int > deleted_values_
static CacheTest * current_
std::vector< int > deleted_keys_
TEST(AutoCompactTest, ReadAll)
Cache * NewLRUCache(size_t capacity)
int main(int argc, char **argv)
void Insert(int key, int value, int charge=1)
Cache::Handle * InsertAndReturnHandle(int key, int value, int charge=1)
static const int kCacheSize
virtual void Erase(const Slice &key)=0
const char * data() const