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

Method acquireSharedStringBuffers

bolt/vector/FlatVector.cpp:197–247  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

195
196template <>
197void FlatVector<StringView>::acquireSharedStringBuffers(
198 const BaseVector* source) {
199 if (!source) {
200 return;
201 }
202 if (source->typeKind() != TypeKind::VARBINARY &&
203 source->typeKind() != TypeKind::VARCHAR) {
204 return;
205 }
206 auto bufferCount = stringBuffers_.size();
207 source = source->wrappedVector();
208 switch (source->encoding()) {
209 case VectorEncoding::Simple::FLAT: {
210 auto* flat = source->asUnchecked<FlatVector<StringView>>();
211 for (auto& buffer : flat->stringBuffers_) {
212 addStringBuffer(buffer);
213 }
214 break;
215 }
216 case VectorEncoding::Simple::CONSTANT: {
217 if (!source->isNullAt(0)) {
218 auto* constant = source->asUnchecked<ConstantVector<StringView>>();
219 auto buffer = constant->getStringBuffer();
220 if (buffer != nullptr) {
221 addStringBuffer(buffer);
222 }
223 }
224 break;
225 }
226
227 default:
228 BOLT_UNREACHABLE(
229 "unexpected encoding inside acquireSharedStringBuffers: {}",
230 source->toString());
231 }
232 // if stringbuffers_.size() reach the integer multiple of logFreq, LOG the
233 // memory information of this vector
234 constexpr auto logFreq = 1024;
235 if (stringBuffers_.size() / logFreq > bufferCount / logFreq) {
236 uint64_t totalCapacity = 0, totalSize = 0;
237 for (auto buffer : stringBuffers_) {
238 totalSize += buffer->size();
239 totalCapacity += buffer->capacity();
240 }
241 LOG(INFO) << "FlatVector string buffers count: " << stringBuffers_.size()
242 << ", before acquire: " << bufferCount
243 << ", totalSize: " << totalSize
244 << ", totalCapacity: " << totalCapacity
245 << ", pool name: " << pool_->name();
246 }
247}
248
249template <>
250void FlatVector<StringView>::acquireSharedStringBuffersRecursive(

Callers 15

flattenAndExportFunction · 0.80
TEST_FFunction · 0.80
getValuesMethod · 0.80
scalarGatherCopyFunction · 0.80
applyTypedMethod · 0.80
applyMethod · 0.80
applyTypedMethod · 0.80
testUpperFlatVectorMethod · 0.80
testLowerFlatVectorMethod · 0.80
testReplaceInPlaceMethod · 0.80
applyMethod · 0.80
applyMethod · 0.80

Calls 9

getStringBufferMethod · 0.80
typeKindMethod · 0.45
sizeMethod · 0.45
wrappedVectorMethod · 0.45
encodingMethod · 0.45
isNullAtMethod · 0.45
toStringMethod · 0.45
capacityMethod · 0.45
nameMethod · 0.45

Tested by 5

TEST_FFunction · 0.64
applyTypedMethod · 0.64
testUpperFlatVectorMethod · 0.64
testLowerFlatVectorMethod · 0.64
testReplaceInPlaceMethod · 0.64