mirror of
https://github.com/dragonflydb/dragonfly.git
synced 2025-05-11 10:25:47 +02:00
fix: skip empty objects on load and replication (#3514)
* skip empty objects in rdb save * skip empty objects in rdb load * delete empty keys in FindReadOnly --------- Signed-off-by: kostas <kostas@dragonflydb.io>
This commit is contained in:
parent
84a697dd75
commit
b979994025
11 changed files with 185 additions and 12 deletions
|
@ -574,6 +574,12 @@ size_t CompactObj::Size() const {
|
|||
case ROBJ_TAG:
|
||||
raw_size = u_.r_obj.Size();
|
||||
break;
|
||||
case JSON_TAG:
|
||||
raw_size = u_.json_obj.json_len;
|
||||
break;
|
||||
case SBF_TAG:
|
||||
raw_size = u_.sbf->current_size();
|
||||
break;
|
||||
default:
|
||||
LOG(DFATAL) << "Should not reach " << int(taglen_);
|
||||
}
|
||||
|
@ -684,9 +690,11 @@ void CompactObj::SetJson(JsonType&& j) {
|
|||
if (taglen_ == JSON_TAG && u_.json_obj.encoding == kEncodingJsonCons) {
|
||||
// already json
|
||||
DCHECK(u_.json_obj.json_ptr != nullptr); // must be allocated
|
||||
u_.json_obj.json_len = j.size();
|
||||
u_.json_obj.json_ptr->swap(j);
|
||||
} else {
|
||||
SetMeta(JSON_TAG);
|
||||
u_.json_obj.json_len = j.size();
|
||||
u_.json_obj.json_ptr = AllocateMR<JsonType>(std::move(j));
|
||||
u_.json_obj.encoding = kEncodingJsonCons;
|
||||
}
|
||||
|
@ -842,6 +850,11 @@ bool CompactObj::HasAllocated() const {
|
|||
return true;
|
||||
}
|
||||
|
||||
bool CompactObj::TagAllowsEmptyValue() const {
|
||||
const auto type = ObjType();
|
||||
return type == OBJ_JSON || type == OBJ_STREAM || type == OBJ_STRING || type == OBJ_SBF;
|
||||
}
|
||||
|
||||
void __attribute__((noinline)) CompactObj::GetString(string* res) const {
|
||||
res->resize(Size());
|
||||
GetString(res->data());
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue