OmniSciDB
a5dc49c757
|
#include <FileInfo.h>
Public Member Functions | |
FileInfo (FileMgr *fileMgr, const int32_t fileId, FILE *f, const size_t pageSize, const size_t numPages, const std::string &file_path, 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 epoch) |
int32_t | getFreePage () |
size_t | write (const size_t offset, const size_t size, const int8_t *buf) |
size_t | read (const size_t offset, const size_t size, int8_t *buf) |
void | openExistingFile (std::vector< HeaderInfo > &headerVec) |
std::string | print () const |
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 () const |
Returns the number of free bytes available. More... | |
size_t | numFreePages () const |
Returns the number of free pages available. More... | |
std::set< size_t > | getFreePages () const |
size_t | used () const |
Returns the amount of used bytes; size() - available() More... | |
void | freePageImmediate (int32_t page_num) |
void | recoverPage (const ChunkKey &chunk_key, int32_t page_num) |
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::string | file_path |
set of page numbers of free pages More... | |
std::mutex | freePagesMutex_ |
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 std::string & | file_path, | ||
const bool | init = false |
||
) |
Constructor.
Definition at line 31 of file FileInfo.cpp.
References initNewFile().
File_Namespace::FileInfo::~FileInfo | ( | ) |
Destructor.
Definition at line 49 of file FileInfo.cpp.
References File_Namespace::close(), and f.
|
inline |
Returns the number of free bytes available.
Definition at line 102 of file FileInfo.h.
References numFreePages(), and pageSize.
Referenced by print(), and used().
void File_Namespace::FileInfo::freePage | ( | int32_t | pageId, |
const bool | isRolloff, | ||
int32_t | epoch | ||
) |
Definition at line 187 of file FileInfo.cpp.
References CHECK, File_Namespace::DELETE_CONTINGENT, fileMgr, File_Namespace::FileMgr::free_page(), pageSize, File_Namespace::ROLLOFF_CONTINGENT, and write().
Referenced by File_Namespace::FileBuffer::freePage(), and File_Namespace::CachingFileMgr::updatePageIfDeleted().
void File_Namespace::FileInfo::freePageDeferred | ( | int32_t | pageId | ) |
Definition at line 172 of file FileInfo.cpp.
References freePages, and freePagesMutex_.
Referenced by freePageImmediate().
void File_Namespace::FileInfo::freePageImmediate | ( | int32_t | page_num | ) |
Definition at line 245 of file FileInfo.cpp.
References freePageDeferred(), pageSize, and write().
Referenced by initNewFile(), openExistingFile(), and File_Namespace::FileMgr::updatePageIfDeleted().
int32_t File_Namespace::FileInfo::getFreePage | ( | ) |
Definition at line 204 of file FileInfo.cpp.
References freePages, and freePagesMutex_.
Referenced by File_Namespace::FileMgr::copySourcePageForCompaction(), File_Namespace::FileMgr::requestFreePage(), File_Namespace::CachingFileMgr::requestFreePage(), and File_Namespace::FileMgr::requestFreePages().
|
inline |
void File_Namespace::FileInfo::initNewFile | ( | ) |
Adds all pages to freePages and zeroes first four bytes of header.
Definition at line 56 of file FileInfo.cpp.
References freePageImmediate(), and numPages.
Referenced by FileInfo().
|
inline |
Returns the number of free pages available.
Definition at line 105 of file FileInfo.h.
References freePages, and freePagesMutex_.
Referenced by available().
void File_Namespace::FileInfo::openExistingFile | ( | std::vector< HeaderInfo > & | headerVec | ) |
Definition at line 75 of file FileInfo.cpp.
References CHECK_EQ, CHECK_GE, CHUNK_KEY_DB_IDX, CHUNK_KEY_TABLE_IDX, File_Namespace::FileMgr::epoch(), f, fileId, fileMgr, freePageImmediate(), freePages, g_multi_instance, g_read_only, LOG, numPages, pageSize, show_chunk(), File_Namespace::FileMgr::updatePageIfDeleted(), VLOG, and logger::WARNING.
std::string File_Namespace::FileInfo::print | ( | ) | const |
Prints a summary of the file to stdout.
Definition at line 216 of file FileInfo.cpp.
References available(), fileId, size(), and used().
size_t File_Namespace::FileInfo::read | ( | const size_t | offset, |
const size_t | size, | ||
int8_t * | buf | ||
) |
Definition at line 70 of file FileInfo.cpp.
References f, file_path, File_Namespace::read(), and readWriteMutex_.
Referenced by File_Namespace::FileBuffer::copyPage(), File_Namespace::FileMgr::copyPage(), File_Namespace::FileMgr::copyPageWithoutHeaderSize(), and File_Namespace::readForThread().
void File_Namespace::FileInfo::recoverPage | ( | const ChunkKey & | chunk_key, |
int32_t | page_num | ||
) |
Definition at line 252 of file FileInfo.cpp.
References CHECK, g_multi_instance, pageSize, and write().
Referenced by File_Namespace::FileMgr::updatePageIfDeleted().
|
inline |
Returns the number of bytes used by the file.
Definition at line 95 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 225 of file FileInfo.cpp.
References f, logger::FATAL, heavyai::fsync(), isDirty, LOG, and readWriteMutex_.
|
inline |
Returns the amount of used bytes; size() - available()
Definition at line 116 of file FileInfo.h.
References available(), and size().
Referenced by print().
size_t File_Namespace::FileInfo::write | ( | const size_t | offset, |
const size_t | size, | ||
const int8_t * | buf | ||
) |
Definition at line 64 of file FileInfo.cpp.
References f, fileMgr, isDirty, readWriteMutex_, and File_Namespace::FileMgr::writeFile().
Referenced by File_Namespace::FileBuffer::append(), File_Namespace::FileBuffer::copyPage(), File_Namespace::FileMgr::copyPage(), File_Namespace::FileMgr::copyPageWithoutHeaderSize(), freePage(), freePageImmediate(), recoverPage(), 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 openExistingFile(), read(), syncToDisk(), write(), and ~FileInfo().
std::string File_Namespace::FileInfo::file_path |
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(), File_Namespace::CachingFileMgr::requestFreePage(), and File_Namespace::FileMgr::requestFreePages().
FileMgr* File_Namespace::FileInfo::fileMgr |
Definition at line 56 of file FileInfo.h.
Referenced by freePage(), openExistingFile(), and write().
std::set<size_t> File_Namespace::FileInfo::freePages |
Definition at line 62 of file FileInfo.h.
Referenced by freePageDeferred(), getFreePage(), getFreePages(), numFreePages(), openExistingFile(), and File_Namespace::FileMgr::sortAndCopyFilePagesForCompaction().
|
mutable |
Definition at line 64 of file FileInfo.h.
Referenced by freePageDeferred(), getFreePage(), getFreePages(), 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 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(), freePageImmediate(), openExistingFile(), recoverPage(), and size().
|
mutable |
Definition at line 65 of file FileInfo.h.
Referenced by read(), syncToDisk(), and write().