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

Function readMapVector

bolt/serializers/PrestoSerializer.cpp:579–621  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

577}
578
579void readMapVector(
580 ByteInputStream* source,
581 const TypePtr& type,
582 bolt::memory::MemoryPool* pool,
583 VectorPtr& result,
584 vector_size_t resultOffset,
585 bool useLosslessTimestamp) {
586 MapVector* mapVector = result->as<MapVector>();
587 const auto resultElementsOffset = mapVector->mapKeys()->size();
588 std::vector<TypePtr> childTypes = {type->childAt(0), type->childAt(1)};
589 std::vector<VectorPtr> children{mapVector->mapKeys(), mapVector->mapValues()};
590 readColumns(
591 source,
592 pool,
593 childTypes,
594 children,
595 resultElementsOffset,
596 useLosslessTimestamp);
597
598 int32_t hashTableSize = source->read<int32_t>();
599 if (hashTableSize != -1) {
600 // Skip over serialized hash table from Presto wire format.
601 source->skip(hashTableSize * sizeof(int32_t));
602 }
603
604 vector_size_t size = source->read<int32_t>();
605 mapVector->resize(resultOffset + size);
606 mapVector->setKeysAndValues(children[0], children[1]);
607
608 BufferPtr offsets = mapVector->mutableOffsets(resultOffset + size);
609 auto rawOffsets = offsets->asMutable<vector_size_t>();
610 BufferPtr sizes = mapVector->mutableSizes(resultOffset + size);
611 auto rawSizes = sizes->asMutable<vector_size_t>();
612 int32_t base = source->read<int32_t>();
613 for (int32_t i = 0; i < size; ++i) {
614 int32_t offset = source->read<int32_t>();
615 rawOffsets[resultOffset + i] = resultElementsOffset + base;
616 rawSizes[resultOffset + i] = offset - base;
617 base = offset;
618 }
619
620 readNulls(source, size, *mapVector, resultOffset);
621}
622
623int64_t packTimestampWithTimeZone(int64_t timestamp, int16_t timezone) {
624 return timezone | (timestamp << 12);

Callers

nothing calls this directly

Calls 11

childAtMethod · 0.80
setKeysAndValuesMethod · 0.80
mutableOffsetsMethod · 0.80
mutableSizesMethod · 0.80
readColumnsFunction · 0.70
readNullsFunction · 0.70
sizeMethod · 0.45
mapKeysMethod · 0.45
mapValuesMethod · 0.45
skipMethod · 0.45
resizeMethod · 0.45

Tested by

no test coverage detected