MCPcopy Create free account
hub / github.com/bytedance/bolt / readStringView

Function readStringView

bolt/exec/tests/utils/RowBasedSerde.cpp:597–608  ·  view source on GitHub ↗

Returns a view over a serialized string with the string as a contiguous array of bytes. This may use 'storage' for a temporary copy.

Source from the content-addressed store, hash-verified

595// contiguous array of bytes. This may use 'storage' for a temporary
596// copy.
597StringView readStringView(ByteInputStream& stream, std::string& storage) {
598 int32_t size = stream.read<int32_t>();
599 auto view = stream.nextView(size);
600 if (view.size() == size) {
601 // The string is all in one piece, no copy.
602 return StringView(view.data(), view.size());
603 }
604 storage.resize(size);
605 memcpy(storage.data(), view.data(), view.size());
606 stream.readBytes(storage.data() + view.size(), size - view.size());
607 return StringView(storage);
608}
609
610// Comparison of two serializations.
611std::optional<int32_t> compareSwitch(

Callers 2

VARCHAR>Method · 0.70
VARBINARY>Method · 0.70

Calls 7

memcpyFunction · 0.85
StringViewClass · 0.50
nextViewMethod · 0.45
sizeMethod · 0.45
dataMethod · 0.45
resizeMethod · 0.45
readBytesMethod · 0.45

Tested by

no test coverage detected