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

Method Read

library/cpp/netliba/v6/block_chain.h:82–106  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

80 {
81 }
82 void Read(void* dst, int sz) {
83 char* dstBuf = (char*)dst;
84 while (sz > 0) {
85 if (BlockId >= Chain.GetBlockCount()) {
86 // JACKPOT!
87 fprintf(stderr, "reading beyond chain end: BlockId %d, Chain.GetBlockCount() %d, Pos %d, BlockPos %d\n",
88 BlockId, Chain.GetBlockCount(), Pos, BlockPos);
89 Y_ASSERT(0 && "reading beyond chain end");
90 memset(dstBuf, 0, sz);
91 Failed = true;
92 return;
93 }
94 const TBlockChain::TBlock& blk = Chain.GetBlock(BlockId);
95 int copySize = Min(blk.Size - BlockPos, sz);
96 memcpy(dstBuf, blk.Data + BlockPos, copySize);
97 dstBuf += copySize;
98 Pos += copySize;
99 BlockPos += copySize;
100 sz -= copySize;
101 if (BlockPos == blk.Size) {
102 BlockPos = 0;
103 ++BlockId;
104 }
105 }
106 }
107 void Seek(int pos) {
108 if (pos < 0 || pos > Chain.GetSize()) {
109 Y_ASSERT(0);

Callers 11

SendDataMethod · 0.45
StartSendMethod · 0.45
ReadArrFunction · 0.45
ReadArr<TString>Function · 0.45
ReadYArrFunction · 0.45
ReadFunction · 0.45
ThreadFuncMethod · 0.45
LoadRequestDataFunction · 0.45
LoadResponseDataFunction · 0.45
GetDebugInfoFunction · 0.45

Calls 3

GetBlockMethod · 0.80
MinFunction · 0.50
GetBlockCountMethod · 0.45

Tested by

no test coverage detected