Skip to content

Commit 9e3ef11

Browse files
committed
refactor: remove extra files changes
1 parent 9d493a4 commit 9e3ef11

12 files changed

+94
-472
lines changed

src/core/CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ add_subdirectory(json)
2121
set(SEARCH_LIB query_parser)
2222

2323
add_library(dfly_core allocation_tracker.cc bloom.cc compact_object.cc dense_set.cc
24-
dragonfly_core.cc extent_tree.cc huff_coder.cc intrusive_string_list.cc
24+
dragonfly_core.cc extent_tree.cc huff_coder.cc
2525
interpreter.cc glob_matcher.cc mi_memory_resource.cc qlist.cc sds_utils.cc
2626
segment_allocator.cc score_map.cc small_string.cc sorted_map.cc task_queue.cc
2727
tx_queue.cc string_set.cc string_map.cc top_keys.cc detail/bitpacking.cc)

src/core/compact_object.cc

Lines changed: 3 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,6 @@ extern "C" {
2626
#include "core/bloom.h"
2727
#include "core/detail/bitpacking.h"
2828
#include "core/huff_coder.h"
29-
#include "core/intrusive_string_set.h"
3029
#include "core/qlist.h"
3130
#include "core/sorted_map.h"
3231
#include "core/string_map.h"
@@ -67,12 +66,11 @@ size_t UpdateSize(size_t size, int64_t update) {
6766

6867
inline void FreeObjSet(unsigned encoding, void* ptr, MemoryResource* mr) {
6968
switch (encoding) {
70-
case kEncodingStrMap2:
69+
case kEncodingStrMap2: {
7170
CompactObj::DeleteMR<StringSet>(ptr);
7271
break;
73-
case kEncodingIntrusiveSet:
74-
CompactObj::DeleteMR<IntrusiveStringSet>(ptr);
75-
break;
72+
}
73+
7674
case kEncodingIntSet:
7775
zfree((void*)ptr);
7876
break;
@@ -100,10 +98,6 @@ size_t MallocUsedSet(unsigned encoding, void* ptr) {
10098
StringSet* ss = (StringSet*)ptr;
10199
return ss->ObjMallocUsed() + ss->SetMallocUsed() + zmalloc_usable_size(ptr);
102100
}
103-
case kEncodingIntrusiveSet: {
104-
IntrusiveStringSet* ss = (IntrusiveStringSet*)ptr;
105-
return ss->ObjMallocUsed() + ss->SetMallocUsed() + zmalloc_usable_size(ptr);
106-
}
107101
case kEncodingIntSet:
108102
return intsetBlobLen((intset*)ptr);
109103
}
@@ -330,10 +324,6 @@ pair<void*, bool> DefragSet(unsigned encoding, void* ptr, float ratio) {
330324
case kEncodingStrMap2: {
331325
return DefragStrSet((StringSet*)ptr, ratio);
332326
}
333-
case kEncodingIntrusiveSet:
334-
// TODO add defrag logic
335-
LOG(WARNING) << "DefragSet for IntrusiveSet isn't implemented";
336-
return {ptr, false};
337327

338328
default:
339329
ABSL_UNREACHABLE();
@@ -469,10 +459,6 @@ size_t RobjWrapper::Size() const {
469459
StringSet* ss = (StringSet*)inner_obj_;
470460
return ss->UpperBoundSize();
471461
}
472-
case kEncodingIntrusiveSet: {
473-
auto* ss = (IntrusiveStringSet*)inner_obj_;
474-
return ss->UpperBoundSize();
475-
}
476462
default:
477463
LOG(FATAL) << "Unexpected encoding " << encoding_;
478464
};

src/core/compact_object.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@
1919
namespace dfly {
2020

2121
constexpr unsigned kEncodingIntSet = 0;
22-
constexpr unsigned kEncodingIntrusiveSet = 1;
2322
constexpr unsigned kEncodingStrMap2 = 2; // for set/map encodings of strings using DenseSet
2423
constexpr unsigned kEncodingQL2 = 1;
2524
constexpr unsigned kEncodingListPack = 3;

src/core/dense_set.h

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ class DenseSet {
4646
static constexpr size_t kLinkBit = 1ULL << 52;
4747
static constexpr size_t kDisplaceBit = 1ULL << 53;
4848
static constexpr size_t kDisplaceDirectionBit = 1ULL << 54;
49-
static constexpr size_t kExpiryBit = 1ULL << 55;
49+
static constexpr size_t kTtlBit = 1ULL << 55;
5050
static constexpr size_t kTagMask = 4095ULL << 52; // we reserve 12 high bits.
5151

5252
class DensePtr {
@@ -74,7 +74,7 @@ class DenseSet {
7474
}
7575

7676
bool HasTtl() const {
77-
return (uptr() & kExpiryBit) != 0;
77+
return (uptr() & kTtlBit) != 0;
7878
}
7979

8080
bool IsEmpty() const {
@@ -111,9 +111,9 @@ class DenseSet {
111111

112112
void SetTtl(bool b) {
113113
if (b)
114-
ptr_ = (void*)(uptr() | kExpiryBit);
114+
ptr_ = (void*)(uptr() | kTtlBit);
115115
else
116-
ptr_ = (void*)(uptr() & (~kExpiryBit));
116+
ptr_ = (void*)(uptr() & (~kTtlBit));
117117
}
118118

119119
void Reset() {

src/core/intrusive_string_list.cc

Lines changed: 0 additions & 10 deletions
This file was deleted.

src/server/container_utils.cc

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@
55

66
#include "base/flags.h"
77
#include "base/logging.h"
8-
#include "core/intrusive_string_set.h"
98
#include "core/qlist.h"
109
#include "core/sorted_map.h"
1110
#include "core/string_map.h"
@@ -200,20 +199,13 @@ bool IterateSet(const PrimeValue& pv, const IterateFunc& func) {
200199
while (success && intsetGet(is, ii++, &ival)) {
201200
success = func(ContainerEntry{ival});
202201
}
203-
} else if (pv.Encoding() == kEncodingStrMap2) {
202+
} else {
204203
for (sds ptr : *static_cast<StringSet*>(pv.RObjPtr())) {
205204
if (!func(ContainerEntry{ptr, sdslen(ptr)})) {
206205
success = false;
207206
break;
208207
}
209208
}
210-
} else if (pv.Encoding() == kEncodingIntrusiveSet) {
211-
for (auto ptr : *static_cast<IntrusiveStringSet*>(pv.RObjPtr())) {
212-
if (!func(ContainerEntry{ptr.Key().data(), ptr.Key().size()})) {
213-
success = false;
214-
break;
215-
}
216-
}
217209
}
218210

219211
return success;

src/server/db_slice.cc

Lines changed: 10 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@ extern "C" {
1212

1313
#include "base/flags.h"
1414
#include "base/logging.h"
15-
#include "core/intrusive_string_set.h"
1615
#include "core/top_keys.h"
1716
#include "search/doc_index.h"
1817
#include "server/channel_store.h"
@@ -1675,27 +1674,19 @@ void DbSlice::PerformDeletionAtomic(Iterator del_it, ExpIterator exp_it, DbTable
16751674
table); // Key
16761675
AccountObjectMemory(del_it.key(), pv.ObjType(), -value_heap_size, table); // Value
16771676

1678-
if (del_it->first.IsAsyncDelete() && pv.ObjType() == OBJ_SET) {
1679-
if (pv.Encoding() == kEncodingStrMap2) {
1680-
DenseSet* ds = (DenseSet*)pv.RObjPtr();
1681-
pv.SetRObjPtr(nullptr);
1682-
const size_t kClearStepSize = 512;
1683-
1684-
uint32_t next = ds->ClearStep(0, kClearStepSize);
1685-
if (next < ds->BucketCount()) {
1686-
AsyncDeleter::EnqueDeletion(next, ds);
1687-
} else {
1688-
CompactObj::DeleteMR<DenseSet>(ds);
1689-
}
1690-
} // del_it->first.IsAsyncDelete()
1691-
else if (pv.Encoding() == kEncodingIntrusiveSet) {
1692-
IntrusiveStringSet* ds = (IntrusiveStringSet*)pv.RObjPtr();
1693-
pv.SetRObjPtr(nullptr);
1677+
if (del_it->first.IsAsyncDelete() && pv.ObjType() == OBJ_SET &&
1678+
pv.Encoding() == kEncodingStrMap2) {
1679+
DenseSet* ds = (DenseSet*)pv.RObjPtr();
1680+
pv.SetRObjPtr(nullptr);
1681+
const size_t kClearStepSize = 512;
16941682

1683+
uint32_t next = ds->ClearStep(0, kClearStepSize);
1684+
if (next < ds->BucketCount()) {
1685+
AsyncDeleter::EnqueDeletion(next, ds);
1686+
} else {
16951687
CompactObj::DeleteMR<DenseSet>(ds);
1696-
LOG(WARNING) << "Implement async deletion for IntrusiveStringSet";
16971688
}
1698-
}
1689+
} // del_it->first.IsAsyncDelete()
16991690

17001691
if (table->slots_stats) {
17011692
SlotId sid = KeySlot(del_it.key());

src/server/debugcmd.cc

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -465,8 +465,6 @@ const char* EncodingName(unsigned obj_type, unsigned encoding) {
465465
switch (encoding) {
466466
case kEncodingIntSet:
467467
return "intset";
468-
case kEncodingIntrusiveSet:
469-
return "intrusive_set";
470468
case kEncodingStrMap2:
471469
return "dense_set";
472470
case OBJ_ENCODING_SKIPLIST: // we kept the old enum for zset

src/server/rdb_load.cc

Lines changed: 22 additions & 107 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,6 @@ extern "C" {
2929
#include "base/flags.h"
3030
#include "base/logging.h"
3131
#include "core/bloom.h"
32-
#include "core/intrusive_string_set.h"
3332
#include "core/json/json_object.h"
3433
#include "core/qlist.h"
3534
#include "core/sorted_map.h"
@@ -58,7 +57,6 @@ ABSL_DECLARE_FLAG(int32_t, list_max_listpack_size);
5857
ABSL_DECLARE_FLAG(int32_t, list_compress_depth);
5958
ABSL_DECLARE_FLAG(uint32_t, dbnum);
6059
ABSL_DECLARE_FLAG(bool, list_experimental_v2);
61-
ABSL_DECLARE_FLAG(bool, stringset_experimental);
6260
ABSL_FLAG(bool, rdb_load_dry_run, false, "Dry run RDB load without applying changes");
6361
ABSL_FLAG(bool, rdb_ignore_expiry, false, "Ignore Key Expiry when loding from RDB snapshot");
6462

@@ -336,10 +334,8 @@ void RdbLoaderBase::OpaqueObjLoader::CreateSet(const LoadTrace* ltrace) {
336334
if (inner_obj) {
337335
if (is_intset) {
338336
zfree(inner_obj);
339-
} else if (!absl::GetFlag(FLAGS_stringset_experimental)) {
340-
CompactObj::DeleteMR<StringSet>(inner_obj);
341337
} else {
342-
CompactObj::DeleteMR<IntrusiveStringSet>(inner_obj);
338+
CompactObj::DeleteMR<StringSet>(inner_obj);
343339
}
344340
}
345341
});
@@ -359,7 +355,7 @@ void RdbLoaderBase::OpaqueObjLoader::CreateSet(const LoadTrace* ltrace) {
359355
}
360356
return true;
361357
});
362-
} else if (!absl::GetFlag(FLAGS_stringset_experimental)) {
358+
} else {
363359
StringSet* set;
364360
if (config_.append) {
365361
// Note we always use StringSet when the object is being streamed.
@@ -381,55 +377,6 @@ void RdbLoaderBase::OpaqueObjLoader::CreateSet(const LoadTrace* ltrace) {
381377
increment = 2;
382378
}
383379

384-
for (size_t i = 0; i < ltrace->arr.size(); i += increment) {
385-
string_view element = ToSV(ltrace->arr[i].rdb_var);
386-
387-
uint32_t ttl_sec = UINT32_MAX;
388-
if (increment == 2) {
389-
int64_t ttl_time = -1;
390-
string_view ttl_str = ToSV(ltrace->arr[i + 1].rdb_var);
391-
if (!absl::SimpleAtoi(ttl_str, &ttl_time)) {
392-
LOG(ERROR) << "Can't parse set TTL " << ttl_str;
393-
ec_ = RdbError(errc::rdb_file_corrupted);
394-
return;
395-
}
396-
397-
if (ttl_time != -1) {
398-
if (ttl_time < set->time_now()) {
399-
continue;
400-
}
401-
402-
ttl_sec = ttl_time - set->time_now();
403-
}
404-
}
405-
if (!set->Add(element, ttl_sec)) {
406-
LOG(ERROR) << "Duplicate set members detected";
407-
ec_ = RdbError(errc::duplicate_key);
408-
return;
409-
}
410-
}
411-
} else {
412-
IntrusiveStringSet* set;
413-
if (config_.append) {
414-
// Note we always use StringSet when the object is being streamed.
415-
if (!EnsureObjEncoding(OBJ_SET, kEncodingIntrusiveSet)) {
416-
return;
417-
}
418-
set = static_cast<IntrusiveStringSet*>(pv_->RObjPtr());
419-
} else {
420-
set = CompactObj::AllocateMR<IntrusiveStringSet>();
421-
set->set_time(MemberTimeSeconds(GetCurrentTimeMs()));
422-
inner_obj = set;
423-
424-
// Expand the set up front to avoid rehashing.
425-
set->Reserve((config_.reserve > len) ? config_.reserve : len);
426-
}
427-
428-
size_t increment = 1;
429-
if (rdb_type_ == RDB_TYPE_SET_WITH_EXPIRY) {
430-
increment = 2;
431-
}
432-
433380
for (size_t i = 0; i < ltrace->arr.size(); i += increment) {
434381
string_view element = ToSV(ltrace->arr[i].rdb_var);
435382

@@ -463,9 +410,7 @@ void RdbLoaderBase::OpaqueObjLoader::CreateSet(const LoadTrace* ltrace) {
463410
return;
464411

465412
if (!config_.append) {
466-
int str_set_encoding =
467-
absl::GetFlag(FLAGS_stringset_experimental) ? kEncodingIntrusiveSet : kEncodingStrMap2;
468-
pv_->InitRobj(OBJ_SET, is_intset ? kEncodingIntSet : str_set_encoding, inner_obj);
413+
pv_->InitRobj(OBJ_SET, is_intset ? kEncodingIntSet : kEncodingStrMap2, inner_obj);
469414
}
470415
std::move(cleanup).Cancel();
471416
}
@@ -932,26 +877,14 @@ void RdbLoaderBase::OpaqueObjLoader::HandleBlob(string_view blob) {
932877
unsigned len = intsetLen(is);
933878

934879
if (len > SetFamily::MaxIntsetEntries()) {
935-
if (!absl::GetFlag(FLAGS_stringset_experimental)) {
936-
StringSet* set = SetFamily::ConvertToStrSet(is, len);
880+
StringSet* set = SetFamily::ConvertToStrSet(is, len);
937881

938-
if (!set) {
939-
LOG(ERROR) << "OOM in ConvertToStrSet " << len;
940-
ec_ = RdbError(errc::out_of_memory);
941-
return;
942-
}
943-
pv_->InitRobj(OBJ_SET, kEncodingStrMap2, set);
944-
} else {
945-
IntrusiveStringSet* set = SetFamily::ConvertToIntrStrSet(is, len);
946-
947-
if (!set) {
948-
LOG(ERROR) << "OOM in ConvertToStrSet " << len;
949-
ec_ = RdbError(errc::out_of_memory);
950-
return;
951-
}
952-
pv_->InitRobj(OBJ_SET, kEncodingIntrusiveSet, set);
882+
if (!set) {
883+
LOG(ERROR) << "OOM in ConvertToStrSet " << len;
884+
ec_ = RdbError(errc::out_of_memory);
885+
return;
953886
}
954-
887+
pv_->InitRobj(OBJ_SET, kEncodingStrMap2, set);
955888
} else {
956889
intset* mine = (intset*)zmalloc(blob.size());
957890
::memcpy(mine, blob.data(), blob.size());
@@ -965,39 +898,21 @@ void RdbLoaderBase::OpaqueObjLoader::HandleBlob(string_view blob) {
965898
}
966899

967900
unsigned char* lp = (unsigned char*)blob.data();
968-
if (!absl::GetFlag(FLAGS_stringset_experimental)) {
969-
StringSet* set = CompactObj::AllocateMR<StringSet>();
970-
for (unsigned char* cur = lpFirst(lp); cur != nullptr; cur = lpNext(lp, cur)) {
971-
unsigned char field_buf[LP_INTBUF_SIZE];
972-
string_view elem = container_utils::LpGetView(cur, field_buf);
973-
if (!set->Add(elem)) {
974-
LOG(ERROR) << "Duplicate member " << elem;
975-
ec_ = RdbError(errc::duplicate_key);
976-
break;
977-
}
978-
}
979-
if (ec_) {
980-
CompactObj::DeleteMR<StringSet>(set);
981-
return;
982-
}
983-
pv_->InitRobj(OBJ_SET, kEncodingStrMap2, set);
984-
} else {
985-
IntrusiveStringSet* set = CompactObj::AllocateMR<IntrusiveStringSet>();
986-
for (unsigned char* cur = lpFirst(lp); cur != nullptr; cur = lpNext(lp, cur)) {
987-
unsigned char field_buf[LP_INTBUF_SIZE];
988-
string_view elem = container_utils::LpGetView(cur, field_buf);
989-
if (!set->Add(elem)) {
990-
LOG(ERROR) << "Duplicate member " << elem;
991-
ec_ = RdbError(errc::duplicate_key);
992-
break;
993-
}
994-
}
995-
if (ec_) {
996-
CompactObj::DeleteMR<IntrusiveStringSet>(set);
997-
return;
901+
StringSet* set = CompactObj::AllocateMR<StringSet>();
902+
for (unsigned char* cur = lpFirst(lp); cur != nullptr; cur = lpNext(lp, cur)) {
903+
unsigned char field_buf[LP_INTBUF_SIZE];
904+
string_view elem = container_utils::LpGetView(cur, field_buf);
905+
if (!set->Add(elem)) {
906+
LOG(ERROR) << "Duplicate member " << elem;
907+
ec_ = RdbError(errc::duplicate_key);
908+
break;
998909
}
999-
pv_->InitRobj(OBJ_SET, kEncodingIntrusiveSet, set);
1000910
}
911+
if (ec_) {
912+
CompactObj::DeleteMR<StringSet>(set);
913+
return;
914+
}
915+
pv_->InitRobj(OBJ_SET, kEncodingStrMap2, set);
1001916
} else if (rdb_type_ == RDB_TYPE_HASH_ZIPLIST || rdb_type_ == RDB_TYPE_HASH_LISTPACK) {
1002917
unsigned char* lp = lpNew(blob.size());
1003918
switch (rdb_type_) {

0 commit comments

Comments
 (0)