MCPcopy Create free account
hub / github.com/Snapchat/KeyDB / deserializeStoredStringObject

Function deserializeStoredStringObject

src/object.cpp:1599–1628  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1597}
1598
1599robj *deserializeStoredStringObject(const char *data, size_t cb)
1600{
1601 uint64_t mvcc = *reinterpret_cast<const uint64_t*>(data);
1602 const robj *oT = (const robj*)(data+sizeof(uint64_t));
1603 robj *newObject = nullptr;
1604 switch (oT->encoding)
1605 {
1606 case OBJ_ENCODING_INT:
1607 newObject = createObject(OBJ_STRING, nullptr);
1608 newObject->encoding = oT->encoding;
1609 newObject->m_ptr = oT->m_ptr;
1610 break;
1611
1612 case OBJ_ENCODING_EMBSTR:
1613 newObject = createEmbeddedStringObject(data+sizeof(robj)+sizeof(mvcc), cb-sizeof(robj)-sizeof(uint64_t));
1614 break;
1615
1616 case OBJ_ENCODING_RAW:
1617 newObject = createObject(OBJ_STRING, sdsnewlen(SDS_NOINIT,cb-sizeof(robj)-sizeof(uint64_t)));
1618 newObject->lru = oT->lru;
1619 memcpy(newObject->m_ptr, data+sizeof(robj)+sizeof(mvcc), cb-sizeof(robj)-sizeof(mvcc));
1620 break;
1621
1622 default:
1623 serverPanic("Unknown string object encoding from storage");
1624 }
1625 setMvccTstamp(newObject, mvcc);
1626
1627 return newObject;
1628}
1629
1630robj *deserializeStoredObject(const void *data, size_t cb)
1631{

Callers 1

deserializeStoredObjectFunction · 0.85

Calls 4

createObjectFunction · 0.85
sdsnewlenFunction · 0.85
setMvccTstampFunction · 0.85

Tested by

no test coverage detected