mirror of
https://github.com/XRPLF/rippled.git
synced 2025-12-06 17:27:55 +00:00
Merge branch 'master' into columnfamilies
This commit is contained in:
@@ -52,6 +52,8 @@ class Arena {
|
||||
// same size of that allocation.
|
||||
virtual size_t IrregularBlockNum() const { return irregular_block_num; }
|
||||
|
||||
size_t BlockSize() const { return kBlockSize; }
|
||||
|
||||
private:
|
||||
// Number of bytes allocated in one block
|
||||
const size_t kBlockSize;
|
||||
|
||||
@@ -291,9 +291,11 @@ static inline uint32_t LE_LOAD32(const uint8_t *p) {
|
||||
return DecodeFixed32(reinterpret_cast<const char*>(p));
|
||||
}
|
||||
|
||||
#ifdef __SSE4_2__
|
||||
static inline uint64_t LE_LOAD64(const uint8_t *p) {
|
||||
return DecodeFixed64(reinterpret_cast<const char*>(p));
|
||||
}
|
||||
#endif
|
||||
|
||||
static inline void Slow_CRC32(uint64_t* l, uint8_t const **p) {
|
||||
uint32_t c = *l ^ LE_LOAD32(*p);
|
||||
|
||||
@@ -141,8 +141,8 @@ class HashLinkListRep : public MemTableRep {
|
||||
|
||||
class FullListIterator : public MemTableRep::Iterator {
|
||||
public:
|
||||
explicit FullListIterator(FullList* list)
|
||||
: iter_(list), full_list_(list) {}
|
||||
explicit FullListIterator(FullList* list, Arena* arena)
|
||||
: iter_(list), full_list_(list), arena_(arena) {}
|
||||
|
||||
virtual ~FullListIterator() {
|
||||
}
|
||||
@@ -196,6 +196,7 @@ class HashLinkListRep : public MemTableRep {
|
||||
FullList::Iterator iter_;
|
||||
// To destruct with the iterator.
|
||||
std::unique_ptr<FullList> full_list_;
|
||||
std::unique_ptr<Arena> arena_;
|
||||
std::string tmp_; // For passing to EncodeKey
|
||||
};
|
||||
|
||||
@@ -416,7 +417,9 @@ void HashLinkListRep::Get(const LookupKey& k, void* callback_args,
|
||||
}
|
||||
|
||||
MemTableRep::Iterator* HashLinkListRep::GetIterator() {
|
||||
auto list = new FullList(compare_, arena_);
|
||||
// allocate a new arena of similar size to the one currently in use
|
||||
Arena* new_arena = new Arena(arena_->BlockSize());
|
||||
auto list = new FullList(compare_, new_arena);
|
||||
for (size_t i = 0; i < bucket_size_; ++i) {
|
||||
auto bucket = GetBucket(i);
|
||||
if (bucket != nullptr) {
|
||||
@@ -426,7 +429,7 @@ MemTableRep::Iterator* HashLinkListRep::GetIterator() {
|
||||
}
|
||||
}
|
||||
}
|
||||
return new FullListIterator(list);
|
||||
return new FullListIterator(list, new_arena);
|
||||
}
|
||||
|
||||
MemTableRep::Iterator* HashLinkListRep::GetPrefixIterator(
|
||||
|
||||
@@ -81,10 +81,9 @@ class HashSkipListRep : public MemTableRep {
|
||||
|
||||
class Iterator : public MemTableRep::Iterator {
|
||||
public:
|
||||
explicit Iterator(Bucket* list, bool own_list = true)
|
||||
: list_(list),
|
||||
iter_(list),
|
||||
own_list_(own_list) {}
|
||||
explicit Iterator(Bucket* list, bool own_list = true,
|
||||
Arena* arena = nullptr)
|
||||
: list_(list), iter_(list), own_list_(own_list), arena_(arena) {}
|
||||
|
||||
virtual ~Iterator() {
|
||||
// if we own the list, we should also delete it
|
||||
@@ -163,6 +162,7 @@ class HashSkipListRep : public MemTableRep {
|
||||
// here we track if we own list_. If we own it, we are also
|
||||
// responsible for it's cleaning. This is a poor man's shared_ptr
|
||||
bool own_list_;
|
||||
std::unique_ptr<Arena> arena_;
|
||||
std::string tmp_; // For passing to EncodeKey
|
||||
};
|
||||
|
||||
@@ -289,7 +289,9 @@ void HashSkipListRep::Get(const LookupKey& k, void* callback_args,
|
||||
}
|
||||
|
||||
MemTableRep::Iterator* HashSkipListRep::GetIterator() {
|
||||
auto list = new Bucket(compare_, arena_);
|
||||
// allocate a new arena of similar size to the one currently in use
|
||||
Arena* new_arena = new Arena(arena_->BlockSize());
|
||||
auto list = new Bucket(compare_, new_arena);
|
||||
for (size_t i = 0; i < bucket_size_; ++i) {
|
||||
auto bucket = GetBucket(i);
|
||||
if (bucket != nullptr) {
|
||||
@@ -299,7 +301,7 @@ MemTableRep::Iterator* HashSkipListRep::GetIterator() {
|
||||
}
|
||||
}
|
||||
}
|
||||
return new Iterator(list);
|
||||
return new Iterator(list, true, new_arena);
|
||||
}
|
||||
|
||||
MemTableRep::Iterator* HashSkipListRep::GetPrefixIterator(const Slice& prefix) {
|
||||
|
||||
Reference in New Issue
Block a user