taco-db  0.1.0
Classes | Public Member Functions | Private Types | Private Member Functions | Private Attributes | Friends | List of all members
taco::VolatileCatCache Class Reference

#include <catalog/VolatileCatCache.h>

Inheritance diagram for taco::VolatileCatCache:
taco::CatCacheBase< VolatileCatCache > taco::CatCacheInternalAccess

Classes

struct  CatFileIterator
 An opaque handle for iterating a catalog file. More...
 
struct  InmemFile
 
class  InmemFileBulkLoadIterator
 

Public Member Functions

void InitializeFromExistingData ()
 Not implemented. More...
 
- Public Member Functions inherited from taco::CatCacheBase< VolatileCatCache >
 CatCacheBase ()
 
void InitializeFromExistingData ()
 Initializes the catalog cache from the existing data. More...
 
void InitializeFromInitData (const std::string &init_datafile)
 Creates the catalog from an init data file and initializes the catalog cache. More...
 
constexpr bool IsInitialized () const
 Returns if the catalog cache has been initialized. More...
 
std::shared_ptr< const SysTable_TableFindTable (Oid tabid)
 
Oid FindTableByName (absl::string_view tabname)
 
std::shared_ptr< const TableDescFindTableDesc (Oid tabid)
 
std::shared_ptr< const SysTable_TypeFindType (Oid typid)
 
std::string GetTypeName (Oid typid)
 Returns the type name of the specified type if it exists. More...
 
std::shared_ptr< const SysTable_FunctionFindFunction (Oid funcid)
 
Oid FindFunctionByName (absl::string_view funcname)
 
std::shared_ptr< const SysTable_FunctionArgsFindFunctionArgs (Oid funcid, int16_t funcargid)
 
std::shared_ptr< const SysTable_IndexFindIndex (Oid idxid)
 
Oid FindIndexByName (absl::string_view idxname)
 
std::vector< OidFindAllIndexesOfTable (Oid idxtabid)
 
std::shared_ptr< const IndexDescFindIndexDesc (Oid idxid)
 
Oid FindOperator (OpType optype, Oid oparg0typid, Oid oparg1typid)
 Returns the operator function id of the one with the specific operand types and operator type. More...
 
Oid FindCast (Oid castoprtypid, Oid castrettypid, bool must_be_implicit)
 Returns the cast function id of the one with the specific operand type and return type. More...
 
std::shared_ptr< const SysTable_AggregationFindAggregation (Oid aggid)
 Returns the aggregation systable struct for the aggregation with ID aggid. More...
 
Oid FindAggregationByNameAndOprType (absl::string_view aggname, Oid aggoprtypid)
 Returns the aggregation ID for the aggregation with the given name and aggregation operand type. More...
 
Oid FindAggregationByTidAndOprType (AggType aggtyp, Oid aggoprtypid)
 Returns the aggregation ID for the aggregation with the given type and operand type. More...
 
CCLookupTableEntrySearchForCatalogEntryByOid (Oid systabid, Oid idxid_hint, FieldId oid_colid, Oid oid)
 Searches for the systable entry with ID recid in the given systable systabid. More...
 
CCLookupTableEntrySearchForCatalogEntryByName (Oid systabid, Oid idxid_hint, FieldId name_colid, absl::string_view name)
 Searches for the systable entry with its name column at name_colid equals to name. More...
 
Oid AddTable (absl::string_view tabname, std::vector< Oid > coltypid, std::vector< uint64_t > coltypparam, std::vector< std::string > field_names, std::vector< bool > colisnullable, std::vector< bool > colisarray, FileId tabfid)
 Adds a table into the catalog. More...
 
Oid AddIndex (absl::string_view idxname, Oid idxtabid, IdxType idxtyp, bool idxunique, std::vector< FieldId > idxcoltabcolids, FileId idxfid, std::vector< Oid > idxcolltfuncids, std::vector< Oid > idxcoleqfuncids)
 Adds an index into the catalog. More...
 

Private Types

typedef FileId FileHandle
 An opaque handle for a catalog file. More...
 
typedef int PageHandle
 An opaque handle for a data page in an unformatted catalog file. More...
 

Private Member Functions

FileId CreateCatalogFile (bool format_heapfile, FieldOffset=0)
 Creates a new catalog file and returns its file ID. More...
 
FileHandle OpenCatalogFile (FileId fid, const TableDesc *tabdesc)
 Opens a catalog file for access. More...
 
void CloseCatalogFile (FileHandle &fh)
 Closes a catalog file pointed by the file handle. More...
 
PageHandle GetFirstPage (FileHandle &fh, char **pagebuf)
 Returns a handle to the first page in the unformatted catalog file with it pinned in the memory. More...
 
void MarkPageDirty (PageHandle &pghandle)
 Marks a page pointed by the page handle as dirty. More...
 
void ReleasePage (PageHandle &pghandle)
 Releases the pin over the page pointed by the page handle. More...
 
void AppendRecord (FileHandle &fh, Record &rec)
 Appends a record to the catalog file specified by the file ID. More...
 
CatFileIterator IterateCatEntry (FileHandle &fh)
 Creates an iterator over the catalog file specified by the file ID. More...
 
CatFileIterator IterateCatEntryFrom (FileHandle &fh, RecordId rid)
 Creates an iterator that starts at rid. More...
 
bool NextCatEntry (CatFileIterator &iter)
 Tries to move the iterator to the next row and returns whether such a row exists. More...
 
const char * GetCurrentCatEntry (CatFileIterator &iter)
 Returns the current catalog entry pointed by the iterator as a buffer pointer. More...
 
RecordId GetCurrentCatEntryRecordId (CatFileIterator &iter)
 Returns the current catalog entry's record ID. More...
 
void UpdateCurrentCatEntry (CatFileIterator &iter, Record &rec)
 Updates the current catalog entry pointed by the iterator with the record rec. More...
 
void EndIterateCatEntry (CatFileIterator &iter)
 Releses any resource associated with the catalog file iterator. More...
 
BulkLoadIteratorGetBulkLoadIterator (FileHandle &fh, std::shared_ptr< const TableDesc > tabdesc, std::shared_ptr< const IndexDesc > idxdesc)
 Returns a BulkLoadIterator for bulk loading a systable index. More...
 

Private Attributes

std::vector< std::unique_ptr< InmemFile > > m_systables
 This vector stores all our in-memory only files. More...
 
unique_malloced_ptr m_dbmeta_page
 The pointer to the in-memory only dbmeta page. More...
 

Friends

class InmemFileBulkLoadIterator
 
class CatCacheBase< VolatileCatCache >
 

Additional Inherited Members

- Protected Member Functions inherited from taco::CatCacheInternalAccess
template<class T >
std::vector< DatumGetDatumVector (const T &systable_struct)
 
- Static Protected Member Functions inherited from taco::CatCacheInternalAccess
static std::shared_ptr< void > CreateSysTableStruct (Oid tabid, const std::vector< Datum > &data)
 Creates a SysTable_xxx struct for a row stored in a record payout in the specified table. More...
 
template<class T >
static T * CreateSysTableStruct (const std::vector< Datum > &data)
 Creates a SysTable_xxx struct from a vector of data by invoking its Create() function. More...
 
template<class T >
static T * CopySysTableStruct (const T *s)
 
template<class T , class ... Args>
static T * ConstructSysTableStruct (Args &&...args)
 Constructs a SysTable_xxx struct from c++ values by invoking its constructor. More...
 

Member Typedef Documentation

◆ FileHandle

An opaque handle for a catalog file.

It must be automatically closed if it goes out of scope. In VolatileCatCache, the files do not need to be closed, so we just use the file ID as the handle.

◆ PageHandle

An opaque handle for a data page in an unformatted catalog file.

It must be automatically release if it goes out of scope.

Member Function Documentation

◆ AppendRecord()

void taco::VolatileCatCache::AppendRecord ( FileHandle fh,
Record rec 
)
private

Appends a record to the catalog file specified by the file ID.

This also updates the ‘rec.GetRecordID()’ to the record ID of the newly inserted record.

◆ CloseCatalogFile()

void taco::VolatileCatCache::CloseCatalogFile ( FileHandle fh)
private

Closes a catalog file pointed by the file handle.

This does nothing except for setting fh to INVALID_FID in VolatileCatCache.

◆ CreateCatalogFile()

FileId taco::VolatileCatCache::CreateCatalogFile ( bool  format_heapfile,
FieldOffset  = 0 
)
private

Creates a new catalog file and returns its file ID.

If format_heapfile is true, the opened file will be accessed through the following record and iterator iterfaces. Otherwise, it is accessed as an unformatted file consisting of pages, which should initially have just one page. The second argument is unused by VolatileCatCache and is only kept for compatibility.

The FileID does not need to be unique from regular files in the file manager, but the first file ever allocated through this function is assumed to have file ID 1.

Note this file ID is not allocated by the file manager in VolatileCatCache.

◆ EndIterateCatEntry()

void taco::VolatileCatCache::EndIterateCatEntry ( CatFileIterator iter)
private

Releses any resource associated with the catalog file iterator.

There is no resource associated with an iterator in VolatileCatCache, so this does nothing except for invalidating the iterator.

◆ GetBulkLoadIterator()

BulkLoadIterator * taco::VolatileCatCache::GetBulkLoadIterator ( FileHandle fh,
std::shared_ptr< const TableDesc tabdesc,
std::shared_ptr< const IndexDesc idxdesc 
)
private

Returns a BulkLoadIterator for bulk loading a systable index.

◆ GetCurrentCatEntry()

const char * taco::VolatileCatCache::GetCurrentCatEntry ( CatFileIterator iter)
private

Returns the current catalog entry pointed by the iterator as a buffer pointer.

It is undefined if a NextCatEntry has not been called or a previous call returns ‘false’.

◆ GetCurrentCatEntryRecordId()

RecordId taco::VolatileCatCache::GetCurrentCatEntryRecordId ( CatFileIterator iter)
private

Returns the current catalog entry's record ID.

It is undefined if a NextCatEntry has not been called or a previous call returns ‘false’.

◆ GetFirstPage()

VolatileCatCache::PageHandle taco::VolatileCatCache::GetFirstPage ( FileHandle fh,
char **  pagebuf 
)
private

Returns a handle to the first page in the unformatted catalog file with it pinned in the memory.

In VolatileCatCache, one may only invoke this on the DB meta file. And the returned page buffer is not in buffer manager, rather it's in our own internal state.

◆ InitializeFromExistingData()

void taco::VolatileCatCache::InitializeFromExistingData ( )
inline

Not implemented.

Volatile catlog cache is never saved on disk so it can't be initialized from an existing data directory.

◆ IterateCatEntry()

VolatileCatCache::CatFileIterator taco::VolatileCatCache::IterateCatEntry ( FileHandle fh)
private

Creates an iterator over the catalog file specified by the file ID.

◆ IterateCatEntryFrom()

VolatileCatCache::CatFileIterator taco::VolatileCatCache::IterateCatEntryFrom ( FileHandle fh,
RecordId  rid 
)
private

Creates an iterator that starts at rid.

The iterator may or may not return additional records after the first one if rid exists.

◆ MarkPageDirty()

void taco::VolatileCatCache::MarkPageDirty ( PageHandle pghandle)
private

Marks a page pointed by the page handle as dirty.

This does nothing in VolatileCatCache.

◆ NextCatEntry()

bool taco::VolatileCatCache::NextCatEntry ( CatFileIterator iter)
private

Tries to move the iterator to the next row and returns whether such a row exists.

◆ OpenCatalogFile()

VolatileCatCache::FileHandle taco::VolatileCatCache::OpenCatalogFile ( FileId  fid,
const TableDesc tabdesc 
)
private

Opens a catalog file for access.

The second argument tabdesc is always needed except for variable-length build during initialization and the db meta page.

VolatileCatCache does not use the provided tabdesc.

◆ ReleasePage()

void taco::VolatileCatCache::ReleasePage ( PageHandle pghandle)
private

Releases the pin over the page pointed by the page handle.

This does nothing in VolatileCatCache.

◆ UpdateCurrentCatEntry()

void taco::VolatileCatCache::UpdateCurrentCatEntry ( CatFileIterator iter,
Record rec 
)
private

Updates the current catalog entry pointed by the iterator with the record rec.

This invalidates the current position of the iterator so it is undefined to call either ‘GetCurrentCatEntry’ or ‘UpdateCurrentCatEntry’ after this call. However, one may still call ‘NextCatEntry’ on it to resume the iteration. There is no guarantee that the same entry will not be returned again though.

This is intended to be used for updating either a single entry (and then ending the iteration), or for performing initialization in the catalog initializer.

Friends And Related Function Documentation

◆ CatCacheBase< VolatileCatCache >

friend class CatCacheBase< VolatileCatCache >
friend

◆ InmemFileBulkLoadIterator

friend class InmemFileBulkLoadIterator
friend

Member Data Documentation

◆ m_dbmeta_page

unique_malloced_ptr taco::VolatileCatCache::m_dbmeta_page
private

The pointer to the in-memory only dbmeta page.

◆ m_systables

std::vector<std::unique_ptr<InmemFile> > taco::VolatileCatCache::m_systables
private

This vector stores all our in-memory only files.

The index into this file is file ID - 2.


The documentation for this class was generated from the following files: