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

Method Pread

util/system/direct_io.cpp:227–246  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

225}
226
227size_t TDirectIOBufferedFile::Pread(void* buffer, size_t byteCount, ui64 offset) {
228 if (!byteCount) {
229 return 0;
230 }
231
232 size_t readFromFile = 0;
233 if (offset < FlushedBytes) {
234 readFromFile = Min<ui64>(byteCount, FlushedBytes - offset);
235 size_t bytesRead = ReadFromFile(buffer, readFromFile, offset);
236 if (bytesRead != readFromFile || readFromFile == byteCount) {
237 return bytesRead;
238 }
239 }
240 ui64 start = offset > FlushedBytes ? offset - FlushedBytes : 0;
241 ui64 count = Min<ui64>(DataLen - start, byteCount - readFromFile);
242 if (count) {
243 memcpy((char*)buffer + readFromFile, (const char*)Buffer + start, count);
244 }
245 return count + readFromFile;
246}
247
248void TDirectIOBufferedFile::Pwrite(const void* buffer, size_t byteCount, ui64 offset) {
249 if (offset > WritePosition) {

Callers 1

PreadSafeMethod · 0.45

Calls 1

ReadFromFileFunction · 0.50

Tested by

no test coverage detected