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

Method getData

bolt/exec/OutputBuffer.cpp:107–154  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

105}
106
107std::vector<std::unique_ptr<folly::IOBuf>> DestinationBuffer::getData(
108 uint64_t maxBytes,
109 int64_t sequence,
110 DataAvailableCallback notify,
111 DataConsumerActiveCheckCallback activeCheck,
112 ArbitraryBuffer* arbitraryBuffer) {
113 BOLT_CHECK_GE(
114 sequence, sequence_, "Get received for an already acknowledged item");
115 if (arbitraryBuffer != nullptr) {
116 loadData(arbitraryBuffer, maxBytes);
117 }
118
119 if (sequence - sequence_ > data_.size()) {
120 VLOG(1) << this << " Out of order get: " << sequence << " over "
121 << sequence_ << " Setting second notify " << notifySequence_
122 << " / " << sequence;
123 notify_ = std::move(notify);
124 aliveCheck_ = std::move(activeCheck);
125 notifySequence_ = std::min(notifySequence_, sequence);
126 notifyMaxBytes_ = maxBytes;
127 return {};
128 }
129
130 if (sequence - sequence_ == data_.size()) {
131 notify_ = std::move(notify);
132 aliveCheck_ = std::move(activeCheck);
133 notifySequence_ = sequence;
134 notifyMaxBytes_ = maxBytes;
135 return {};
136 }
137
138 std::vector<std::unique_ptr<folly::IOBuf>> result;
139 uint64_t resultBytes = 0;
140 for (auto i = sequence - sequence_; i < data_.size(); ++i) {
141 // nullptr is used as end marker
142 if (data_[i] == nullptr) {
143 BOLT_CHECK_EQ(i, data_.size() - 1, "null marker found in the middle");
144 result.push_back(nullptr);
145 break;
146 }
147 result.push_back(data_[i]->getIOBuf());
148 resultBytes += data_[i]->size();
149 if (resultBytes >= maxBytes) {
150 break;
151 }
152 }
153 return result;
154}
155
156void DestinationBuffer::enqueue(std::shared_ptr<SerializedPage> data) {
157 // Drop duplicate end markers.

Callers 12

runShuffleMethod · 0.45
TEST_FFunction · 0.45
doFetchMethod · 0.45
TEST_FFunction · 0.45
fetchMethod · 0.45
fetchEndMarkerMethod · 0.45
registerForEndMarkerMethod · 0.45
registerForDataMethod · 0.45
dataFetcherMethod · 0.45
TEST_FFunction · 0.45
requestMethod · 0.45
getDataFunction · 0.45

Calls 9

releaseAfterAcknowledgeFunction · 0.85
notifyFunction · 0.85
minFunction · 0.50
sizeMethod · 0.45
push_backMethod · 0.45
getIOBufMethod · 0.45
getMethod · 0.45
acknowledgeMethod · 0.45
emptyMethod · 0.45

Tested by 11

runShuffleMethod · 0.36
TEST_FFunction · 0.36
doFetchMethod · 0.36
TEST_FFunction · 0.36
fetchMethod · 0.36
fetchEndMarkerMethod · 0.36
registerForEndMarkerMethod · 0.36
registerForDataMethod · 0.36
dataFetcherMethod · 0.36
TEST_FFunction · 0.36
requestMethod · 0.36