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

Method getOutput

bolt/exec/Limit.cpp:63–126  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

61}
62
63RowVectorPtr Limit::getOutput() {
64 if (input_ == nullptr || (remainingOffset_ == 0 && remainingLimit_ == 0)) {
65 return nullptr;
66 }
67
68 const auto inputSize = input_->size();
69
70 if (remainingOffset_ >= inputSize) {
71 remainingOffset_ -= inputSize;
72 input_ = nullptr;
73 return nullptr;
74 }
75
76 if (remainingOffset_ > 0) {
77 // Return a subset of input_ rows.
78 const auto outputSize =
79 std::min(inputSize - remainingOffset_, remainingLimit_);
80
81 RowVectorPtr output;
82 // Either use dictionary encoding to support offset or use zerocopy buffer
83 // slice.
84 if (this->operatorCtx_->execCtx()
85 ->queryCtx()
86 ->queryConfig()
87 .limitOffsetDictionaryEncoding()) {
88 BufferPtr indices = allocateIndices(outputSize, pool());
89 auto rawIndices = indices->asMutable<vector_size_t>();
90 std::iota(rawIndices, rawIndices + outputSize, remainingOffset_);
91
92 output = fillOutput(outputSize, indices);
93 } else {
94 output = std::dynamic_pointer_cast<RowVector>(
95 input_->slice(remainingOffset_, outputSize));
96 }
97 remainingOffset_ = 0;
98 remainingLimit_ -= outputSize;
99 input_ = nullptr;
100 if (remainingLimit_ == 0) {
101 finished_ = true;
102 }
103 return output;
104 }
105
106 if (remainingLimit_ <= inputSize) {
107 finished_ = true;
108 }
109
110 if (remainingLimit_ >= inputSize) {
111 remainingLimit_ -= inputSize;
112 auto output = input_;
113 input_.reset();
114 return output;
115 }
116
117 auto output = std::make_shared<RowVector>(
118 input_->pool(),
119 input_->type(),
120 input_->nulls(),

Callers

nothing calls this directly

Calls 14

allocateIndicesFunction · 0.85
queryCtxMethod · 0.80
minFunction · 0.50
poolFunction · 0.50
iotaFunction · 0.50
sizeMethod · 0.45
execCtxMethod · 0.45
sliceMethod · 0.45
resetMethod · 0.45
poolMethod · 0.45
typeMethod · 0.45

Tested by

no test coverage detected