OmniSciDB
85c2d10cdc
|
#include <FileInfo.h>
Public Member Functions | |
FileInfo (FileMgr *fileMgr, const int32_t fileId, FILE *f, const size_t pageSize, const size_t numPages, const bool init=false) | |
Constructor. More... | |
~FileInfo () | |
Destructor. More... | |
void | initNewFile () |
Adds all pages to freePages and zeroes first four bytes of header. More... | |
void | freePageDeferred (int32_t pageId) |
void | freePage (int32_t pageId, const bool isRolloff) |
int32_t | getFreePage () |
size_t | write (const size_t offset, const size_t size, int8_t *buf) |
size_t | read (const size_t offset, const size_t size, int8_t *buf) |
void | openExistingFile (std::vector< HeaderInfo > &headerVec, const int32_t fileMgrEpoch) |
void | print (bool pagesummary) |
Prints a summary of the file to stdout. More... | |
size_t | size () const |
Returns the number of bytes used by the file. More... | |
int32_t | syncToDisk () |
size_t | available () |
Returns the number of free bytes available. More... | |
size_t | numFreePages () |
Returns the number of free pages available. More... | |
size_t | used () |
Returns the amount of used bytes; size() - available() More... | |
Public Attributes | |
FileMgr * | fileMgr |
int32_t | fileId |
FILE * | f |
unique file identifier (i.e., used for a file name) More... | |
size_t | pageSize |
file stream object for the represented file More... | |
size_t | numPages |
the fixed size of each page in the file More... | |
bool | isDirty {false} |
the number of pages in the file More... | |
std::set< size_t > | freePages |
std::mutex | freePagesMutex_ |
set of page numbers of free pages More... | |
std::mutex | readWriteMutex_ |
Definition at line 55 of file FileInfo.h.
File_Namespace::FileInfo::FileInfo | ( | FileMgr * | fileMgr, |
const int32_t | fileId, | ||
FILE * | f, | ||
const size_t | pageSize, | ||
const size_t | numPages, | ||
const bool | init = false |
||
) |
Constructor.
Definition at line 28 of file FileInfo.cpp.
References initNewFile().
File_Namespace::FileInfo::~FileInfo | ( | ) |
Destructor.
Definition at line 40 of file FileInfo.cpp.
References File_Namespace::close(), and f.
|
inline |
Returns the number of free bytes available.
Definition at line 99 of file FileInfo.h.
References freePages, and pageSize.
Referenced by print(), and used().
void File_Namespace::FileInfo::freePage | ( | int32_t | pageId, |
const bool | isRolloff | ||
) |
Definition at line 206 of file FileInfo.cpp.
References CHECK, File_Namespace::DELETE_CONTINGENT, File_Namespace::FileMgr::epoch(), f, fileMgr, File_Namespace::FileMgr::free_page(), freePages, freePagesMutex_, isDirty, pageSize, readWriteMutex_, File_Namespace::ROLLOFF_CONTINGENT, and File_Namespace::write().
Referenced by File_Namespace::FileBuffer::freePage().
void File_Namespace::FileInfo::freePageDeferred | ( | int32_t | pageId | ) |
Definition at line 191 of file FileInfo.cpp.
References freePages, and freePagesMutex_.
int32_t File_Namespace::FileInfo::getFreePage | ( | ) |
Definition at line 235 of file FileInfo.cpp.
References freePages, and freePagesMutex_.
Referenced by File_Namespace::FileMgr::copySourcePageForCompaction(), File_Namespace::FileMgr::requestFreePage(), and File_Namespace::FileMgr::requestFreePages().
void File_Namespace::FileInfo::initNewFile | ( | ) |
Adds all pages to freePages and zeroes first four bytes of header.
Definition at line 47 of file FileInfo.cpp.
References f, freePages, isDirty, numPages, pageSize, and File_Namespace::write().
Referenced by FileInfo().
|
inline |
Returns the number of free pages available.
Definition at line 102 of file FileInfo.h.
References freePages, and freePagesMutex_.
void File_Namespace::FileInfo::openExistingFile | ( | std::vector< HeaderInfo > & | headerVec, |
const int32_t | fileMgrEpoch | ||
) |
Definition at line 71 of file FileInfo.cpp.
References CHECK_EQ, CHECK_GE, File_Namespace::DELETE_CONTINGENT, f, fileId, fileMgr, freePages, g_read_only, File_Namespace::FileMgr::get_fileMgrKey(), File_Namespace::FileMgr::hasFileMgrKey(), LOG, numPages, pageSize, File_Namespace::ROLLOFF_CONTINGENT, show_chunk(), VLOG, logger::WARNING, and File_Namespace::write().
Referenced by File_Namespace::FileMgr::openExistingFile().
void File_Namespace::FileInfo::print | ( | bool | pagesummary | ) |
Prints a summary of the file to stdout.
Definition at line 247 of file FileInfo.cpp.
References available(), fileId, size(), and used().
Definition at line 66 of file FileInfo.cpp.
References f, File_Namespace::read(), and readWriteMutex_.
Referenced by File_Namespace::FileBuffer::copyPage(), File_Namespace::FileMgr::copyPage(), File_Namespace::FileMgr::copyPageWithoutHeaderSize(), and File_Namespace::readForThread().
|
inline |
Returns the number of bytes used by the file.
Definition at line 92 of file FileInfo.h.
References numPages, and pageSize.
Referenced by print(), and used().
int32_t File_Namespace::FileInfo::syncToDisk | ( | ) |
Syncs file to disk via a buffer flush and then a sync (fflush and fsync on posix systems)
Definition at line 256 of file FileInfo.cpp.
References f, logger::FATAL, omnisci::fsync(), isDirty, LOG, and readWriteMutex_.
|
inline |
Returns the amount of used bytes; size() - available()
Definition at line 108 of file FileInfo.h.
References available(), and size().
Referenced by print().
Definition at line 60 of file FileInfo.cpp.
References f, isDirty, readWriteMutex_, and File_Namespace::write().
Referenced by File_Namespace::FileBuffer::append(), File_Namespace::FileBuffer::copyPage(), File_Namespace::FileMgr::copyPage(), File_Namespace::FileMgr::copyPageWithoutHeaderSize(), File_Namespace::FileBuffer::write(), and File_Namespace::FileBuffer::writeHeader().
FILE* File_Namespace::FileInfo::f |
unique file identifier (i.e., used for a file name)
Definition at line 58 of file FileInfo.h.
Referenced by freePage(), initNewFile(), openExistingFile(), read(), syncToDisk(), write(), and ~FileInfo().
int32_t File_Namespace::FileInfo::fileId |
Definition at line 57 of file FileInfo.h.
Referenced by File_Namespace::FileMgr::copyPageWithoutHeaderSize(), File_Namespace::FileMgr::copySourcePageForCompaction(), openExistingFile(), print(), File_Namespace::FileMgr::requestFreePage(), and File_Namespace::FileMgr::requestFreePages().
FileMgr* File_Namespace::FileInfo::fileMgr |
Definition at line 56 of file FileInfo.h.
Referenced by freePage(), and openExistingFile().
std::set<size_t> File_Namespace::FileInfo::freePages |
Definition at line 62 of file FileInfo.h.
Referenced by available(), freePage(), freePageDeferred(), getFreePage(), initNewFile(), numFreePages(), openExistingFile(), and File_Namespace::FileMgr::sortAndCopyFilePagesForCompaction().
std::mutex File_Namespace::FileInfo::freePagesMutex_ |
set of page numbers of free pages
Definition at line 63 of file FileInfo.h.
Referenced by freePage(), freePageDeferred(), getFreePage(), and numFreePages().
bool File_Namespace::FileInfo::isDirty {false} |
the number of pages in the file
Definition at line 61 of file FileInfo.h.
Referenced by freePage(), initNewFile(), syncToDisk(), and write().
size_t File_Namespace::FileInfo::numPages |
the fixed size of each page in the file
Definition at line 60 of file FileInfo.h.
Referenced by initNewFile(), openExistingFile(), and size().
size_t File_Namespace::FileInfo::pageSize |
file stream object for the represented file
Definition at line 59 of file FileInfo.h.
Referenced by available(), File_Namespace::FileMgr::copyPageWithoutHeaderSize(), freePage(), initNewFile(), openExistingFile(), and size().
std::mutex File_Namespace::FileInfo::readWriteMutex_ |
Definition at line 64 of file FileInfo.h.
Referenced by freePage(), read(), syncToDisk(), and write().