MCPcopy Create free account
hub / github.com/catboost/catboost / DoUnboundedNext

Method DoUnboundedNext

library/cpp/blockcodecs/core/stream.cpp:163–212  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

161TDecodedInput::~TDecodedInput() = default;
162
163size_t TDecodedInput::DoUnboundedNext(const void** ptr) {
164 if (!S_) {
165 return 0;
166 }
167
168 TCodecID codecId;
169 TBlockLen blockLen;
170
171 {
172 const size_t payload = sizeof(TCodecID) + sizeof(TBlockLen);
173 char buf[32];
174
175 S_->LoadOrFail(buf, payload);
176
177 TMemoryInput in(buf, payload);
178
179 ::Load(&in, codecId);
180 ::Load(&in, blockLen);
181 }
182
183 if (!blockLen) {
184 S_ = nullptr;
185
186 return 0;
187 }
188
189 if (Y_UNLIKELY(blockLen > 1024 * 1024 * 1024)) {
190 ythrow yexception() << "block size exceeds 1 GiB";
191 }
192
193 TBuffer block;
194 block.Resize(blockLen);
195
196 S_->LoadOrFail(block.Data(), blockLen);
197
198 auto codec = CodecByID(codecId);
199
200 if (C_) {
201 Y_ENSURE(C_->Name() == codec->Name(), TStringBuf("incorrect stream codec"));
202 }
203
204 if (codec->DecompressedLength(block) > MAX_BUF_LEN) {
205 ythrow yexception() << "broken stream";
206 }
207
208 codec->Decode(block, D_);
209 *ptr = D_.Data();
210
211 return D_.Size();
212}

Callers

nothing calls this directly

Calls 9

CodecByIDFunction · 0.85
LoadOrFailMethod · 0.80
LoadFunction · 0.50
ResizeMethod · 0.45
DataMethod · 0.45
NameMethod · 0.45
DecompressedLengthMethod · 0.45
DecodeMethod · 0.45
SizeMethod · 0.45

Tested by

no test coverage detected