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

Method spillInput

bolt/exec/RowNumber.cpp:477–519  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

475}
476
477void RowNumber::spillInput(
478 const RowVectorPtr& input,
479 memory::MemoryPool* pool) {
480 const auto numInput = input->size();
481
482 std::vector<uint32_t> spillPartitions(numInput);
483 const auto singlePartition =
484 spillHashFunction_->partition(*input, spillPartitions);
485
486 const auto numPartitions = spillHashFunction_->numPartitions();
487
488 std::vector<BufferPtr> partitionIndices(numPartitions);
489 std::vector<vector_size_t*> rawPartitionIndices(numPartitions);
490
491 for (auto i = 0; i < numPartitions; ++i) {
492 partitionIndices[i] = allocateIndices(numInput, pool);
493 rawPartitionIndices[i] = partitionIndices[i]->asMutable<vector_size_t>();
494 }
495
496 std::vector<vector_size_t> numSpillInputs(numPartitions, 0);
497
498 for (auto row = 0; row < numInput; ++row) {
499 const auto partition = singlePartition.has_value() ? singlePartition.value()
500 : spillPartitions[row];
501 rawPartitionIndices[partition][numSpillInputs[partition]++] = row;
502 }
503
504 // Ensure vector are lazy loaded before spilling.
505 for (auto i = 0; i < input->childrenSize(); ++i) {
506 input->childAt(i)->loadedVector();
507 }
508
509 for (int32_t partition = 0; partition < numSpillInputs.size(); ++partition) {
510 const auto numInputs = numSpillInputs[partition];
511 if (numInputs == 0) {
512 continue;
513 }
514
515 inputSpiller_->spill(
516 partition,
517 wrapAndCombineDict(numInputs, partitionIndices[partition], input));
518 }
519}
520
521} // namespace bytedance::bolt::exec

Callers

nothing calls this directly

Calls 11

allocateIndicesFunction · 0.85
wrapAndCombineDictFunction · 0.85
has_valueMethod · 0.80
childAtMethod · 0.80
sizeMethod · 0.45
partitionMethod · 0.45
numPartitionsMethod · 0.45
valueMethod · 0.45
childrenSizeMethod · 0.45
loadedVectorMethod · 0.45
spillMethod · 0.45

Tested by

no test coverage detected