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

Function readConstant

bolt/vector/VectorSaver.cpp:349–375  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

347
348template <TypeKind kind>
349VectorPtr readConstant(
350 const TypePtr& type,
351 vector_size_t size,
352 bolt::memory::MemoryPool* pool,
353 std::istream& in) {
354 using T = typename TypeTraits<kind>::NativeType;
355
356 T value = read<T>(in);
357
358 if constexpr (std::is_same_v<T, StringView>) {
359 if (!value.isInline()) {
360 auto stringSize = read<int32_t>(in);
361 BufferPtr stringBuffer = AlignedBuffer::allocate<char>(stringSize, pool);
362 in.read(stringBuffer->template asMutable<char>(), stringSize);
363
364 return std::make_shared<ConstantVector<T>>(
365 pool,
366 size,
367 false,
368 type,
369 StringView(stringBuffer->as<char>(), stringSize));
370 }
371 }
372
373 return std::make_shared<ConstantVector<T>>(
374 pool, size, false, type, std::move(value));
375}
376
377VectorPtr readConstantVector(
378 const TypePtr& type,

Callers

nothing calls this directly

Calls 3

isInlineMethod · 0.80
StringViewClass · 0.50
readMethod · 0.45

Tested by

no test coverage detected