taco-db  0.1.0
PersistentCatCache.h
Go to the documentation of this file.
1 #ifndef CATALOG_PERSISTENTCATCACHE_H
2 #define CATALOG_PERSISTENTCATCACHE_H
3 
4 #include "tdb.h"
5 
6 #include "catalog/CatCacheBase.h"
8 #include "storage/FileManager.h"
9 #include "storage/Record.h"
10 #include "storage/Table.h"
11 #include "index/BulkLoadIterator.h"
12 
13 namespace taco {
14 
15 class PersistentCatCache: public CatCacheBase<PersistentCatCache> {
16 public:
18 
19 private:
30  FileId CreateCatalogFile(bool format_heapfile);
31 
38  struct FileHandle {
39  // the file ID of the table
41 
42  // the heap file, this might be nullptr initially
43  std::unique_ptr<Table> m_table;
44  };
45 
51  FileHandle OpenCatalogFile(FileId fid, const TableDesc *tabdesc);
52 
56  void CloseCatalogFile(FileHandle &fh);
57 
63 
75  PageHandle GetFirstPage(FileHandle &fh, char **pagebuf);
76 
80  void MarkPageDirty(PageHandle &pghandle);
81 
85  void ReleasePage(PageHandle &pghandle);
86 
92  void AppendRecord(FileHandle &fh, Record &rec);
93 
99 
104 
110 
115  bool NextCatEntry(CatFileIterator &iter);
116 
122  const char *GetCurrentCatEntry(CatFileIterator &iter);
123 
129 
142  void UpdateCurrentCatEntry(CatFileIterator &iter, Record &rec);
143 
148 
153  FileHandle &fh,
154  std::shared_ptr<const TableDesc> tabdesc,
155  std::shared_ptr<const IndexDesc> idxdesc);
156 
163 
169 
171 };
172 
177 extern template class CatCacheBase<PersistentCatCache>;
178 
179 } // namespace taco
180 
181 #endif // CATALOG_PERSISTENTCATCACHE_H
taco::PersistentCatCache::GetBulkLoadIterator
BulkLoadIterator * GetBulkLoadIterator(FileHandle &fh, std::shared_ptr< const TableDesc > tabdesc, std::shared_ptr< const IndexDesc > idxdesc)
Returns a BulkLoadIterator for bulk loading a systable index.
Definition: PersistentCatCache.cpp:168
taco::FieldOffset
int16_t FieldOffset
Definition: tdb_base.h:212
taco::TableDesc
Definition: TableDesc.h:11
taco::PersistentCatCache::NextCatEntry
bool NextCatEntry(CatFileIterator &iter)
Tries to move the iterator to the next row and returns whether such a row exists.
Definition: PersistentCatCache.cpp:141
taco::PersistentCatCache::CloseCatalogFile
void CloseCatalogFile(FileHandle &fh)
Closes a catalog file pointed by the file handle.
Definition: PersistentCatCache.cpp:97
taco
Definition: datum.h:28
taco::PersistentCatCache
Definition: PersistentCatCache.h:15
taco::PersistentCatCache::GetCurrentCatEntry
const char * GetCurrentCatEntry(CatFileIterator &iter)
Returns the current catalog entry pointed by the iterator as a buffer pointer.
Definition: PersistentCatCache.cpp:146
Table.h
taco::PersistentCatCache::ReleasePage
void ReleasePage(PageHandle &pghandle)
Releases the pin over the page pointed by the page handle.
Definition: PersistentCatCache.cpp:118
taco::RecordId
The record ID of a record on a page is a pair of ‘(PageNumber, SlotId)’.
Definition: Record.h:17
taco::Table::Iterator
The Iterator interface for scanning the heap file.
Definition: Table.h:185
taco::PersistentCatCache::m_dbmetapg_pid
PageNumber m_dbmetapg_pid
The page number of the DB meta page, which is the first page of the DB meta file.
Definition: PersistentCatCache.h:168
taco::PersistentCatCache::IterateCatEntry
CatFileIterator IterateCatEntry(FileHandle &fh)
Creates an iterator over the catalog file specified by the file ID.
Definition: PersistentCatCache.cpp:129
tdb.h
taco::PersistentCatCache::FileHandle::m_fid
FileId m_fid
Definition: PersistentCatCache.h:40
taco::PersistentCatCache::CatFileIterator
Table::Iterator CatFileIterator
An opaque handle for iterating a catalog file.
Definition: PersistentCatCache.h:98
taco::PersistentCatCache::MarkPageDirty
void MarkPageDirty(PageHandle &pghandle)
Marks a page pointed by the page handle as dirty.
Definition: PersistentCatCache.cpp:113
taco::PersistentCatCache::PageHandle
ScopedBufferId PageHandle
An opaque handle for a data page in an unformatted catalog file.
Definition: PersistentCatCache.h:62
taco::PersistentCatCache::OpenCatalogFile
FileHandle OpenCatalogFile(FileId fid, const TableDesc *tabdesc)
Opens a catalog file for access.
Definition: PersistentCatCache.cpp:61
taco::PersistentCatCache::_CreateTableIfNullForFileHandle
void _CreateTableIfNullForFileHandle(FileHandle &fh, FieldOffset reclen)
Creates the Table object in the file handle using a fake table descriptor.
Definition: PersistentCatCache.cpp:178
taco::FileId
uint32_t FileId
The file ID.
Definition: tdb_base.h:222
taco::PersistentCatCache::FileHandle::m_table
std::unique_ptr< Table > m_table
Definition: PersistentCatCache.h:43
CatCacheBase.h
taco::BulkLoadIterator
BulkLoadIterator is an interface for providing (key, RecordId) pairs for index bulk loading.
Definition: BulkLoadIterator.h:17
taco::ResourceGuard< BufferId, BufferUnpin, BufferId, INVALID_BUFID >
taco::Record
Definition: Record.h:87
taco::PersistentCatCache::IterateCatEntryFrom
CatFileIterator IterateCatEntryFrom(FileHandle &fh, RecordId rid)
Creates an iterator that starts at rid.
Definition: PersistentCatCache.cpp:135
taco::PersistentCatCache::GetFirstPage
PageHandle GetFirstPage(FileHandle &fh, char **pagebuf)
Returns a handle to the first page in the unformatted catalog file with it pinned in the memory.
Definition: PersistentCatCache.cpp:103
taco::PersistentCatCache::PersistentCatCache
PersistentCatCache()
Definition: PersistentCatCache.cpp:16
taco::PersistentCatCache::GetCurrentCatEntryRecordId
RecordId GetCurrentCatEntryRecordId(CatFileIterator &iter)
Returns the current catalog entry's record ID.
Definition: PersistentCatCache.cpp:151
taco::PersistentCatCache::UpdateCurrentCatEntry
void UpdateCurrentCatEntry(CatFileIterator &iter, Record &rec)
Updates the current catalog entry pointed by the iterator with the record rec.
Definition: PersistentCatCache.cpp:156
taco::PersistentCatCache::EndIterateCatEntry
void EndIterateCatEntry(CatFileIterator &iter)
Releses any resource associated with the catalog file iterator.
Definition: PersistentCatCache.cpp:162
BufferManager.h
BulkLoadIterator.h
FileManager.h
taco::PersistentCatCache::AppendRecord
void AppendRecord(FileHandle &fh, Record &rec)
Appends a record to the catalog file specified by the file ID.
Definition: PersistentCatCache.cpp:123
taco::PersistentCatCache::CreateCatalogFile
FileId CreateCatalogFile(bool format_heapfile)
Creates a new catalog file and returns its file ID.
Definition: PersistentCatCache.cpp:20
Record.h
taco::CatCacheBase
CatCacheBase implements the common routines and public interfaces for accessing and modifying the sys...
Definition: CatCacheBase.h:103
taco::PersistentCatCache::FileHandle
An opaque handle for a catalog file.
Definition: PersistentCatCache.h:38
taco::PageNumber
uint32_t PageNumber
Definition: tdb_base.h:214