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

Method ReadBinaryString

library/cpp/yson/detail.h:526–557  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

524 }
525
526 void ReadBinaryString(TStringBuf* value) {
527 ui32 ulength = 0;
528 if (!TBaseStream::ReadVarint32(&ulength)) {
529 ythrow TYsonException() << "Error parsing varint value";
530 }
531
532 i32 length = ZigZagDecode32(ulength);
533 if (length < 0) {
534 ythrow TYsonException() << "Negative binary string literal length " << length;
535 }
536
537 if (TBaseStream::Begin() + length <= TBaseStream::End()) {
538 *value = TStringBuf(TBaseStream::Begin(), length);
539 TBaseStream::Advance(length);
540 } else { // reading in Buffer
541 size_t needToRead = length;
542 Buffer_.clear();
543 while (needToRead) {
544 if (TBaseStream::IsEmpty()) {
545 TBaseStream::Refresh();
546 continue;
547 }
548 size_t readingBytes = Min(needToRead, TBaseStream::Length());
549
550 Buffer_.insert(Buffer_.end(), TBaseStream::Begin(), TBaseStream::Begin() + readingBytes);
551 CheckMemoryLimit();
552 needToRead -= readingBytes;
553 TBaseStream::Advance(readingBytes);
554 }
555 *value = TStringBuf(Buffer_.data(), Buffer_.size());
556 }
557 }
558
559 template <bool AllowFinish>
560 bool ReadBoolean() {

Callers

nothing calls this directly

Calls 12

BeginClass · 0.85
LengthClass · 0.85
ZigZagDecode32Function · 0.70
ReadVarint32Function · 0.50
AdvanceFunction · 0.50
IsEmptyFunction · 0.50
MinFunction · 0.50
clearMethod · 0.45
insertMethod · 0.45
endMethod · 0.45
dataMethod · 0.45
sizeMethod · 0.45

Tested by

no test coverage detected