mirror of
https://github.com/dragonflydb/dragonfly.git
synced 2025-05-11 02:15:45 +02: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:
parent
a3abf41f4e
commit
a01dfcb5b6
3 changed files with 8 additions and 45 deletions
|
@ -34,8 +34,9 @@ class RobjWrapper {
|
||||||
public:
|
public:
|
||||||
using MemoryResource = PMR_NS::memory_resource;
|
using MemoryResource = PMR_NS::memory_resource;
|
||||||
|
|
||||||
RobjWrapper() {
|
RobjWrapper() : sz_(0), type_(0), encoding_(0) {
|
||||||
}
|
}
|
||||||
|
|
||||||
size_t MallocUsed() const;
|
size_t MallocUsed() const;
|
||||||
|
|
||||||
uint64_t HashCode() const;
|
uint64_t HashCode() const;
|
||||||
|
@ -78,7 +79,7 @@ class RobjWrapper {
|
||||||
size_t InnerObjMallocUsed() const;
|
size_t InnerObjMallocUsed() const;
|
||||||
void MakeInnerRoom(size_t current_cap, size_t desired, MemoryResource* mr);
|
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;
|
inner_obj_ = p;
|
||||||
sz_ = s;
|
sz_ = s;
|
||||||
}
|
}
|
||||||
|
@ -86,14 +87,14 @@ class RobjWrapper {
|
||||||
void* inner_obj_ = nullptr;
|
void* inner_obj_ = nullptr;
|
||||||
|
|
||||||
// semantics depend on the type. For OBJ_STRING it's string length.
|
// semantics depend on the type. For OBJ_STRING it's string length.
|
||||||
uint32_t sz_ = 0;
|
uint64_t sz_ : 56;
|
||||||
|
|
||||||
uint32_t type_ : 4;
|
|
||||||
uint32_t encoding_ : 4;
|
|
||||||
uint32_t : 24;
|
|
||||||
|
|
||||||
|
uint64_t type_ : 4;
|
||||||
|
uint64_t encoding_ : 4;
|
||||||
} __attribute__((packed));
|
} __attribute__((packed));
|
||||||
|
|
||||||
|
static_assert(sizeof(RobjWrapper) == 16);
|
||||||
|
|
||||||
struct TieredColdRecord;
|
struct TieredColdRecord;
|
||||||
|
|
||||||
} // namespace detail
|
} // namespace detail
|
||||||
|
|
|
@ -1375,43 +1375,6 @@ void quicklistSetDirection(quicklistIter *iter, int direction) {
|
||||||
iter->direction = 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
|
/* Populate 'entry' with the element at the specified zero-based index
|
||||||
* where 0 is the head, 1 is the element next to head
|
* where 0 is the head, 1 is the element next to head
|
||||||
* and so on. Negative integers are used in order to count
|
* and so on. Negative integers are used in order to count
|
||||||
|
|
|
@ -176,7 +176,6 @@ quicklistIter *quicklistGetIteratorEntryAtIdx(quicklist *quicklist, const long l
|
||||||
int quicklistNext(quicklistIter *iter, quicklistEntry *entry);
|
int quicklistNext(quicklistIter *iter, quicklistEntry *entry);
|
||||||
void quicklistSetDirection(quicklistIter *iter, int direction);
|
void quicklistSetDirection(quicklistIter *iter, int direction);
|
||||||
void quicklistReleaseIterator(quicklistIter *iter);
|
void quicklistReleaseIterator(quicklistIter *iter);
|
||||||
quicklist *quicklistDup(quicklist *orig);
|
|
||||||
void quicklistRotate(quicklist *quicklist);
|
void quicklistRotate(quicklist *quicklist);
|
||||||
int quicklistPopCustom(quicklist *quicklist,
|
int quicklistPopCustom(quicklist *quicklist,
|
||||||
int where,
|
int where,
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue