MCPcopy Create free account
hub / github.com/F-Stack/f-stack / createDumpPayload

Function createDumpPayload

app/redis-6.2.6/src/cluster.c:5039–5066  ·  view source on GitHub ↗

Generates a DUMP-format representation of the object 'o', adding it to the * io stream pointed by 'rio'. This function can't fail. */

Source from the content-addressed store, hash-verified

5037/* Generates a DUMP-format representation of the object 'o', adding it to the
5038 * io stream pointed by 'rio'. This function can't fail. */
5039void createDumpPayload(rio *payload, robj *o, robj *key) {
5040 unsigned char buf[2];
5041 uint64_t crc;
5042
5043 /* Serialize the object in an RDB-like format. It consist of an object type
5044 * byte followed by the serialized object. This is understood by RESTORE. */
5045 rioInitWithBuffer(payload,sdsempty());
5046 serverAssert(rdbSaveObjectType(payload,o));
5047 serverAssert(rdbSaveObject(payload,o,key));
5048
5049 /* Write the footer, this is how it looks like:
5050 * ----------------+---------------------+---------------+
5051 * ... RDB payload | 2 bytes RDB version | 8 bytes CRC64 |
5052 * ----------------+---------------------+---------------+
5053 * RDB version and CRC are both in little endian.
5054 */
5055
5056 /* RDB version */
5057 buf[0] = RDB_VERSION & 0xff;
5058 buf[1] = (RDB_VERSION >> 8) & 0xff;
5059 payload->io.buffer.ptr = sdscatlen(payload->io.buffer.ptr,buf,2);
5060
5061 /* CRC64 */
5062 crc = crc64(0,(unsigned char*)payload->io.buffer.ptr,
5063 sdslen(payload->io.buffer.ptr));
5064 memrev64ifbe(&crc);
5065 payload->io.buffer.ptr = sdscatlen(payload->io.buffer.ptr,&crc,8);
5066}
5067
5068/* Verify that the RDB version of the dump payload matches the one of this Redis
5069 * instance and that the checksum is ok.

Callers 2

dumpCommandFunction · 0.85
migrateCommandFunction · 0.85

Calls 7

rioInitWithBufferFunction · 0.85
sdsemptyFunction · 0.85
rdbSaveObjectTypeFunction · 0.85
rdbSaveObjectFunction · 0.85
sdscatlenFunction · 0.85
crc64Function · 0.85
sdslenFunction · 0.85

Tested by

no test coverage detected