| 200 | } |
| 201 | |
| 202 | void 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 | |
| 230 | void restoreVectorStringViews( |
| 231 | vector_size_t size, |
no test coverage detected