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

Function writeStringViews

bolt/vector/VectorSaver.cpp:202–228  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

200}
201
202void writeStringViews(
203 vector_size_t size,
204 const BufferPtr& strings,
205 const std::vector<BufferPtr>& stringBuffers,
206 std::ostream& out) {
207 write<int32_t>(strings->size(), out);
208
209 auto rawBytes = strings->as<char>();
210 auto rawValues = strings->as<StringView>();
211 for (auto i = 0; i < size; ++i) {
212 auto stringView = rawValues[i];
213 if (stringView.isInline()) {
214 out.write(rawBytes + i * sizeof(StringView), sizeof(StringView));
215 } else {
216 // Size.
217 write<int32_t>(stringView.size(), out);
218
219 // 4 bytes of zeros for prefix. We'll fill this in appropriately when
220 // deserializing.
221 write<int32_t>(0, out);
222
223 // Offset.
224 auto offset = computeStringOffset(stringView, stringBuffers);
225 write<int64_t>(offset, out);
226 }
227 }
228}
229
230void restoreVectorStringViews(
231 vector_size_t size,

Callers 1

writeFlatVectorFunction · 0.85

Calls 4

computeStringOffsetFunction · 0.85
isInlineMethod · 0.80
sizeMethod · 0.45
writeMethod · 0.45

Tested by

no test coverage detected