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

Method serialize

bolt/exec/ContainerRow2RowSerde.cpp:20–71  ·  view source on GitHub ↗

static

Source from the content-addressed store, hash-verified

18namespace bytedance::bolt::exec {
19// static
20void ContainerRow2RowSerde::serialize(
21 char* row,
22 char*& current,
23 const char* bufferEnd,
24 const RowFormatInfo& info) {
25 simd::memcpy(current, row, info.fixRowSize);
26 char* currentHead = current;
27 current += info.fixRowSize;
28
29 for (const auto& [isStr, rowColumn] : info.variableColumns) {
30 if (RowContainer::isNullAt(row, rowColumn)) {
31 continue;
32 }
33 if (isStr) {
34 const StringView& sv =
35 *reinterpret_cast<StringView*>(row + rowColumn.offset());
36 if (!sv.isInline()) {
37 if (reinterpret_cast<const HashStringAllocator::Header*>(sv.data())[-1]
38 .size() >= sv.size()) {
39 simd::memcpy(current, sv.data(), sv.size());
40 } else {
41 auto stream = HashStringAllocator::prepareRead(
42 HashStringAllocator::headerOf(sv.data()));
43 stream->readBytes(current, sv.size());
44 }
45 // clear data ptr of StringView to increase compress ratio
46 *(char**)(currentHead + rowColumn.offset() + sizeof(uint64_t)) =
47 nullptr;
48 current += sv.size();
49 BOLT_CHECK(current <= bufferEnd);
50 }
51 } else {
52 const auto value =
53 *reinterpret_cast<std::string_view*>(row + rowColumn.offset());
54
55 auto stream = HashStringAllocator::prepareRead(
56 HashStringAllocator::headerOf(value.data()));
57 stream->readBytes(current, value.size());
58 current += value.size();
59 BOLT_CHECK(current <= bufferEnd);
60 }
61 }
62 for (auto& accumulator : info.serializableAccumulators) {
63 current = accumulator.serializeAccumulator(currentHead, current);
64 BOLT_CHECK(current <= bufferEnd);
65 }
66
67 // make row size aligned with alignment
68 auto actualSize = current - currentHead;
69 auto rowSize = bits::roundUp(actualSize, info.alignment);
70 current += rowSize - actualSize;
71}
72
73// static
74int32_t ContainerRow2RowSerde::deserialize(

Callers

nothing calls this directly

Calls 10

memcpyFunction · 0.85
prepareReadFunction · 0.85
roundUpFunction · 0.85
isInlineMethod · 0.80
isNullAtFunction · 0.50
offsetMethod · 0.45
sizeMethod · 0.45
dataMethod · 0.45
readBytesMethod · 0.45
serializeAccumulatorMethod · 0.45

Tested by

no test coverage detected