mirror of
https://github.com/dragonflydb/dragonfly.git
synced 2024-12-14 11:58:02 +00:00
fix: Do not attempt to defrag StringSet
as a StringMap
(#4283)
That'd be a total waste of time and energy, not to mention you'll crash. Fixes #4167
This commit is contained in:
parent
44e27efc00
commit
0562796cac
2 changed files with 11 additions and 2 deletions
|
@ -305,9 +305,9 @@ pair<void*, bool> DefragSet(unsigned encoding, void* ptr, float ratio) {
|
|||
return DefragIntSet((intset*)ptr, ratio);
|
||||
}
|
||||
|
||||
// StringMap supports re-allocation of it's internal nodes
|
||||
case kEncodingStrMap2: {
|
||||
return DefragStrMap2((StringMap*)ptr, ratio);
|
||||
// Still not implemented
|
||||
return {ptr, false};
|
||||
}
|
||||
|
||||
default:
|
||||
|
|
|
@ -16,6 +16,7 @@
|
|||
#include "core/detail/bitpacking.h"
|
||||
#include "core/flat_set.h"
|
||||
#include "core/mi_memory_resource.h"
|
||||
#include "core/string_set.h"
|
||||
|
||||
extern "C" {
|
||||
#include "redis/intset.h"
|
||||
|
@ -575,6 +576,14 @@ TEST_F(CompactObjectTest, DefragHash) {
|
|||
}
|
||||
}
|
||||
|
||||
TEST_F(CompactObjectTest, DefragSet) {
|
||||
// This is still not implemented
|
||||
StringSet* s = new StringSet();
|
||||
s->Add("str");
|
||||
cobj_.InitRobj(OBJ_SET, kEncodingStrMap2, s);
|
||||
ASSERT_FALSE(cobj_.DefragIfNeeded(0.8));
|
||||
}
|
||||
|
||||
TEST_F(CompactObjectTest, RawInterface) {
|
||||
string str(50, 'a'), tmp, owned;
|
||||
cobj_.SetString(str);
|
||||
|
|
Loading…
Reference in a new issue