mirror of
https://github.com/dragonflydb/dragonfly.git
synced 2025-05-11 10:25:47 +02:00
chore: RdbSerializer::SaveListObject supports QList (#4101)
Now, `./rdb_test --list_experimental_v2` passes. Signed-off-by: Roman Gershman <roman@dragonflydb.io>
This commit is contained in:
parent
eadce55b67
commit
c43ba5f2cc
3 changed files with 25 additions and 13 deletions
|
@ -109,12 +109,16 @@ class QList {
|
|||
// Requires calling subsequent Next() to initialize the iterator.
|
||||
Iterator GetIterator(long idx) const;
|
||||
|
||||
uint32_t noded_count() const {
|
||||
uint32_t node_count() const {
|
||||
return len_;
|
||||
}
|
||||
|
||||
Iterator Erase(Iterator it);
|
||||
|
||||
const quicklistNode* Head() const {
|
||||
return head_;
|
||||
}
|
||||
|
||||
private:
|
||||
bool AllowCompression() const {
|
||||
return compress_ != 0;
|
||||
|
|
|
@ -29,6 +29,7 @@ extern "C" {
|
|||
#include "base/logging.h"
|
||||
#include "core/bloom.h"
|
||||
#include "core/json/json_object.h"
|
||||
#include "core/qlist.h"
|
||||
#include "core/size_tracking_channel.h"
|
||||
#include "core/sorted_map.h"
|
||||
#include "core/string_map.h"
|
||||
|
@ -168,12 +169,10 @@ uint8_t RdbObjectType(const PrimeValue& pv) {
|
|||
case OBJ_STRING:
|
||||
return RDB_TYPE_STRING;
|
||||
case OBJ_LIST:
|
||||
if (compact_enc == OBJ_ENCODING_QUICKLIST) {
|
||||
if (absl::GetFlag(FLAGS_list_rdb_encode_v2))
|
||||
return RDB_TYPE_LIST_QUICKLIST_2;
|
||||
return RDB_TYPE_LIST_QUICKLIST;
|
||||
if (compact_enc == OBJ_ENCODING_QUICKLIST || compact_enc == kEncodingQL2) {
|
||||
return absl::GetFlag(FLAGS_list_rdb_encode_v2) ? RDB_TYPE_LIST_QUICKLIST_2
|
||||
: RDB_TYPE_LIST_QUICKLIST;
|
||||
}
|
||||
|
||||
break;
|
||||
case OBJ_SET:
|
||||
if (compact_enc == kEncodingIntSet)
|
||||
|
@ -436,12 +435,21 @@ error_code RdbSerializer::SaveObject(const PrimeValue& pv) {
|
|||
|
||||
error_code RdbSerializer::SaveListObject(const PrimeValue& pv) {
|
||||
/* Save a list value */
|
||||
DCHECK_EQ(OBJ_ENCODING_QUICKLIST, pv.Encoding());
|
||||
const quicklist* ql = reinterpret_cast<const quicklist*>(pv.RObjPtr());
|
||||
quicklistNode* node = ql->head;
|
||||
DVLOG(2) << "Saving list of length " << ql->len;
|
||||
size_t len = 0;
|
||||
const quicklistNode* node = nullptr;
|
||||
|
||||
RETURN_ON_ERR(SaveLen(ql->len));
|
||||
if (pv.Encoding() == OBJ_ENCODING_QUICKLIST) {
|
||||
const quicklist* ql = reinterpret_cast<const quicklist*>(pv.RObjPtr());
|
||||
node = ql->head;
|
||||
DVLOG(2) << "Saving list of length " << ql->len;
|
||||
len = ql->len;
|
||||
} else {
|
||||
DCHECK_EQ(pv.Encoding(), kEncodingQL2);
|
||||
QList* ql = reinterpret_cast<QList*>(pv.RObjPtr());
|
||||
node = ql->Head();
|
||||
len = ql->node_count();
|
||||
}
|
||||
RETURN_ON_ERR(SaveLen(len));
|
||||
|
||||
while (node) {
|
||||
DVLOG(3) << "QL node (encoding/container/sz): " << node->encoding << "/" << node->container
|
||||
|
@ -759,7 +767,7 @@ error_code RdbSerializer::SaveListPackAsZiplist(uint8_t* lp) {
|
|||
return ec;
|
||||
}
|
||||
|
||||
error_code RdbSerializer::SavePlainNodeAsZiplist(quicklistNode* node) {
|
||||
error_code RdbSerializer::SavePlainNodeAsZiplist(const quicklistNode* node) {
|
||||
uint8_t* zl = ziplistNew();
|
||||
zl = ziplistPush(zl, node->entry, node->sz, ZIPLIST_TAIL);
|
||||
|
||||
|
|
|
@ -255,7 +255,7 @@ class RdbSerializer : public SerializerBase {
|
|||
std::error_code SaveListPackAsZiplist(uint8_t* lp);
|
||||
std::error_code SaveStreamPEL(rax* pel, bool nacks);
|
||||
std::error_code SaveStreamConsumers(streamCG* cg);
|
||||
std::error_code SavePlainNodeAsZiplist(quicklistNode* node);
|
||||
std::error_code SavePlainNodeAsZiplist(const quicklistNode* node);
|
||||
|
||||
// Might preempt
|
||||
void FlushIfNeeded(FlushState flush_state);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue