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

Method WriteImpl

library/cpp/netliba/v6/ib_memstream.cpp:7–36  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

5
6namespace NNetliba {
7 int TIBMemStream::WriteImpl(const void* userBuffer, int sizeArg) {
8 const char* srcData = (const char*)userBuffer;
9 int size = sizeArg;
10 for (;;) {
11 if (size == 0)
12 return sizeArg;
13 if (CurBlock == Blocks.ysize()) {
14 // add new block
15 TBlock& blk = Blocks.emplace_back();
16 blk.StartOffset = GetLength();
17 int szLog = 17 + Min(Blocks.ysize() / 2, 13);
18 blk.BufSize = 1 << szLog;
19 blk.DataSize = 0;
20 blk.Mem = MemPool->Alloc(blk.BufSize);
21 Y_ASSERT(CurBlockOffset == 0);
22 }
23 TBlock& curBlk = Blocks[CurBlock];
24 int leftSpace = curBlk.BufSize - CurBlockOffset;
25 int copySize = Min(size, leftSpace);
26 memcpy(curBlk.Mem->GetData() + CurBlockOffset, srcData, copySize);
27 size -= copySize;
28 CurBlockOffset += copySize;
29 srcData += copySize;
30 curBlk.DataSize = Max(curBlk.DataSize, CurBlockOffset);
31 if (CurBlockOffset == curBlk.BufSize) {
32 ++CurBlock;
33 CurBlockOffset = 0;
34 }
35 }
36 }
37
38 int TIBMemStream::ReadImpl(void* userBuffer, int sizeArg) {
39 char* dstData = (char*)userBuffer;

Callers

nothing calls this directly

Calls 7

GetLengthFunction · 0.50
MinFunction · 0.50
MaxFunction · 0.50
ysizeMethod · 0.45
emplace_backMethod · 0.45
AllocMethod · 0.45
GetDataMethod · 0.45

Tested by

no test coverage detected