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

Method Read

library/cpp/netliba/v12/block_chain.h:89–113  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

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

Callers 11

StartSendMethod · 0.45
AddDataToPacketQueueFunction · 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