MCPcopy Create free account
hub / github.com/4paradigm/OpenMLDB / UnpackString

Function UnpackString

src/codec/memcomparable_format.h:344–378  ·  view source on GitHub ↗

Function of type rdb_index_field_unpack_t */

Source from the content-addressed store, hash-verified

342 Function of type rdb_index_field_unpack_t
343*/
344__attribute__((unused)) static int UnpackString(const void *src, void *dst,
345 int32_t *size) {
346 if (src == nullptr) {
347 return -1;
348 }
349 const uchar *usrc = (uchar *)src; // NOLINT
350 uchar *udst = (uchar *)dst; // NOLINT
351 const uchar *ptr;
352 size_t len = 0;
353 bool finished = false;
354 /* Decode the length-emitted encoding here */
355 while ((ptr = Read(RDB_ESCAPE_LENGTH, &usrc))) {
356 uint32_t used_bytes =
357 CalcUnpackVariableFormat(ptr[RDB_ESCAPE_LENGTH - 1], &finished);
358 if (used_bytes == (uint32_t)-1) {
359 return -2;
360 }
361 /*
362 Now, we need to decode used_bytes of data and append them to the
363 value.
364 */
365 memcpy(udst, ptr, used_bytes);
366 udst += used_bytes;
367 len += used_bytes;
368 if (finished) {
369 break;
370 }
371 }
372 if (!finished) {
373 return -3;
374 }
375 /* Save the length */
376 *size = len;
377 return 0;
378}
379
380} // namespace codec
381} // namespace fedb

Callers 1

TEST_FFunction · 0.85

Calls 2

ReadFunction · 0.85
CalcUnpackVariableFormatFunction · 0.85

Tested by 1

TEST_FFunction · 0.68