1
0
Fork 0
mirror of https://github.com/dragonflydb/dragonfly.git synced 2024-12-15 17:51:06 +00:00

chore: extend RobjWrapper::sz_ to 2^56 (#3849)

Also remove unused quicklist function.
Relates to #3800

Signed-off-by: Roman Gershman <roman@dragonflydb.io>
This commit is contained in:
Roman Gershman 2024-10-02 11:20:34 +03:00 committed by GitHub
parent a3abf41f4e
commit a01dfcb5b6
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 8 additions and 45 deletions

View file

@ -34,8 +34,9 @@ class RobjWrapper {
public:
using MemoryResource = PMR_NS::memory_resource;
RobjWrapper() {
RobjWrapper() : sz_(0), type_(0), encoding_(0) {
}
size_t MallocUsed() const;
uint64_t HashCode() const;
@ -78,7 +79,7 @@ class RobjWrapper {
size_t InnerObjMallocUsed() const;
void MakeInnerRoom(size_t current_cap, size_t desired, MemoryResource* mr);
void Set(void* p, uint32_t s) {
void Set(void* p, size_t s) {
inner_obj_ = p;
sz_ = s;
}
@ -86,14 +87,14 @@ class RobjWrapper {
void* inner_obj_ = nullptr;
// semantics depend on the type. For OBJ_STRING it's string length.
uint32_t sz_ = 0;
uint32_t type_ : 4;
uint32_t encoding_ : 4;
uint32_t : 24;
uint64_t sz_ : 56;
uint64_t type_ : 4;
uint64_t encoding_ : 4;
} __attribute__((packed));
static_assert(sizeof(RobjWrapper) == 16);
struct TieredColdRecord;
} // namespace detail

View file

@ -1375,43 +1375,6 @@ void quicklistSetDirection(quicklistIter *iter, int direction) {
iter->direction = direction;
}
/* Duplicate the quicklist.
* On success a copy of the original quicklist is returned.
*
* The original quicklist both on success or error is never modified.
*
* Returns newly allocated quicklist. */
quicklist *quicklistDup(quicklist *orig) {
quicklist *copy;
copy = quicklistNew(orig->fill, orig->compress);
for (quicklistNode *current = orig->head; current; current = current->next) {
quicklistNode *node = quicklistCreateNode();
if (current->encoding == QUICKLIST_NODE_ENCODING_LZF) {
quicklistLZF *lzf = (quicklistLZF *)current->entry;
size_t lzf_sz = sizeof(*lzf) + lzf->sz;
node->entry = zmalloc(lzf_sz);
memcpy(node->entry, current->entry, lzf_sz);
} else if (current->encoding == QUICKLIST_NODE_ENCODING_RAW) {
node->entry = zmalloc(current->sz);
memcpy(node->entry, current->entry, current->sz);
}
node->count = current->count;
copy->count += node->count;
node->sz = current->sz;
node->encoding = current->encoding;
node->container = current->container;
_quicklistInsertNodeAfter(copy, copy->tail, node);
}
/* copy->count must equal orig->count here */
return copy;
}
/* Populate 'entry' with the element at the specified zero-based index
* where 0 is the head, 1 is the element next to head
* and so on. Negative integers are used in order to count

View file

@ -176,7 +176,6 @@ quicklistIter *quicklistGetIteratorEntryAtIdx(quicklist *quicklist, const long l
int quicklistNext(quicklistIter *iter, quicklistEntry *entry);
void quicklistSetDirection(quicklistIter *iter, int direction);
void quicklistReleaseIterator(quicklistIter *iter);
quicklist *quicklistDup(quicklist *orig);
void quicklistRotate(quicklist *quicklist);
int quicklistPopCustom(quicklist *quicklist,
int where,