MCPcopy Create free account
hub / github.com/apple/foundationdb / fillReadingBuffer

Method fillReadingBuffer

fdbserver/DiskQueue.actor.cpp:763–788  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

761 }
762
763 Future<int> fillReadingBuffer() {
764 // If we're right at the end of a file...
765 if (readingPage * sizeof(Page) >= (size_t)files[readingFile].size) {
766 readingFile++;
767 readingPage = 0;
768 if (readingFile >= 2) {
769 // Recovery complete
770 readingBuffer.clear();
771 writingPos = files[1].size;
772 return 0;
773 }
774 }
775
776 // Read up to 1MB into readingBuffer
777 int len = std::min<int64_t>((files[readingFile].size / sizeof(Page) - readingPage) * sizeof(Page),
778 BUGGIFY_WITH_PROB(1.0) ? sizeof(Page) * deterministicRandom()->randomInt(1, 4)
779 : (1 << 20));
780 readingBuffer.clear();
781 readingBuffer.alignReserve(sizeof(Page), len);
782 void* p = readingBuffer.append(len);
783
784 auto pos = readingPage * sizeof(Page);
785 readingPage += len / sizeof(Page);
786 ASSERT(int64_t(p) % sizeof(Page) == 0);
787 return files[readingFile].f->read(p, len, pos);
788 }
789
790 ACTOR static UNCANCELLABLE Future<Standalone<StringRef>> readNextPage(RawDiskQueue_TwoFiles* self) {
791 state TrackMe trackMe(self);

Callers 1

readNextPageMethod · 0.95

Calls 6

deterministicRandomFunction · 0.85
alignReserveMethod · 0.80
clearMethod · 0.65
readMethod · 0.65
randomIntMethod · 0.45
appendMethod · 0.45

Tested by

no test coverage detected