MCPcopy Create free account
hub / github.com/apache/cloudberry / BufFileLoadBuffer

Function BufFileLoadBuffer

src/backend/storage/file/buffile.c:598–635  ·  view source on GitHub ↗

* BufFileLoadBuffer * * Load some data into buffer, if possible, starting from curOffset. * At call, must have dirty = false, pos and nbytes = 0. * On exit, nbytes is number of bytes loaded. */

Source from the content-addressed store, hash-verified

596 * On exit, nbytes is number of bytes loaded.
597 */
598static void
599BufFileLoadBuffer(BufFile *file)
600{
601 File thisfile;
602
603 /*
604 * Advance to next component file if necessary and possible.
605 */
606 if (file->curOffset >= MAX_PHYSICAL_FILESIZE &&
607 file->curFile + 1 < file->numFiles)
608 {
609 file->curFile++;
610 file->curOffset = 0L;
611 }
612
613 /*
614 * Read whatever we can get, up to a full bufferload.
615 */
616 thisfile = file->files[file->curFile];
617 file->nbytes = FileRead(thisfile,
618 file->buffer.data,
619 BLCKSZ,
620 file->curOffset,
621 WAIT_EVENT_BUFFILE_READ);
622 if (file->nbytes < 0)
623 {
624 file->nbytes = 0;
625 ereport(ERROR,
626 (errcode_for_file_access(),
627 errmsg("could not read file \"%s\": %m",
628 FilePathName(thisfile))));
629 }
630
631 /* we choose not to advance curOffset here */
632
633 if (file->nbytes > 0)
634 pgBufferUsage.temp_blks_read++;
635}
636
637/*
638 * BufFileDumpBuffer

Callers 1

BufFileReadFunction · 0.85

Calls 4

FileReadFunction · 0.85
FilePathNameFunction · 0.85
errcode_for_file_accessFunction · 0.50
errmsgFunction · 0.50

Tested by

no test coverage detected