mirror of
https://github.com/XRPLF/rippled.git
synced 2025-12-06 17:27:55 +00:00
Add a hash-index component for block
Summary: this is the key component extracted from diff: https://reviews.facebook.net/D14271 I separate it to a dedicated patch to make the review easier. Test Plan: added a unit test and passed it. Reviewers: haobo, sdong, dhruba CC: leveldb Differential Revision: https://reviews.facebook.net/D16245
This commit is contained in:
@@ -39,12 +39,12 @@ class Arena {
|
||||
// Returns an estimate of the total memory usage of data allocated
|
||||
// by the arena (exclude the space allocated but not yet used for future
|
||||
// allocations).
|
||||
const size_t ApproximateMemoryUsage() {
|
||||
size_t ApproximateMemoryUsage() const {
|
||||
return blocks_memory_ + blocks_.capacity() * sizeof(char*) -
|
||||
alloc_bytes_remaining_;
|
||||
}
|
||||
|
||||
const size_t MemoryAllocatedBytes() { return blocks_memory_; }
|
||||
size_t MemoryAllocatedBytes() const { return blocks_memory_; }
|
||||
|
||||
private:
|
||||
// Number of bytes allocated in one block
|
||||
|
||||
@@ -46,5 +46,4 @@ uint32_t Hash(const char* data, size_t n, uint32_t seed) {
|
||||
return h;
|
||||
}
|
||||
|
||||
|
||||
} // namespace rocksdb
|
||||
|
||||
@@ -11,6 +11,7 @@
|
||||
*/
|
||||
#pragma once
|
||||
#include <stdint.h>
|
||||
#include "rocksdb/slice.h"
|
||||
|
||||
#if defined(__x86_64__)
|
||||
#define MURMUR_HASH MurmurHash64A
|
||||
@@ -29,5 +30,13 @@ typedef unsigned int murmur_t;
|
||||
unsigned int MurmurHashNeutral2 ( const void * key, int len, unsigned int seed );
|
||||
#define MurmurHash MurmurHashNeutral2
|
||||
typedef unsigned int murmur_t;
|
||||
|
||||
#endif
|
||||
|
||||
// Allow slice to be hashable by murmur hash.
|
||||
namespace rocksdb {
|
||||
struct murmur_hash {
|
||||
size_t operator()(const Slice& slice) const {
|
||||
return MurmurHash(slice.data(), slice.size(), 0);
|
||||
}
|
||||
};
|
||||
} // rocksdb
|
||||
|
||||
Reference in New Issue
Block a user