taco-db
0.1.0
|
#include <catalog/VolatileCatCache.h>
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_Table > | FindTable (Oid tabid) |
Oid | FindTableByName (absl::string_view tabname) |
std::shared_ptr< const TableDesc > | FindTableDesc (Oid tabid) |
std::shared_ptr< const SysTable_Type > | FindType (Oid typid) |
std::string | GetTypeName (Oid typid) |
Returns the type name of the specified type if it exists. More... | |
std::shared_ptr< const SysTable_Function > | FindFunction (Oid funcid) |
Oid | FindFunctionByName (absl::string_view funcname) |
std::shared_ptr< const SysTable_FunctionArgs > | FindFunctionArgs (Oid funcid, int16_t funcargid) |
std::shared_ptr< const SysTable_Index > | FindIndex (Oid idxid) |
Oid | FindIndexByName (absl::string_view idxname) |
std::vector< Oid > | FindAllIndexesOfTable (Oid idxtabid) |
std::shared_ptr< const IndexDesc > | FindIndexDesc (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_Aggregation > | FindAggregation (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... | |
CCLookupTableEntry * | SearchForCatalogEntryByOid (Oid systabid, Oid idxid_hint, FieldId oid_colid, Oid oid) |
Searches for the systable entry with ID recid in the given systable systabid . More... | |
CCLookupTableEntry * | SearchForCatalogEntryByName (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... | |
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. 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< Datum > | GetDatumVector (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... | |
|
private |
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.
|
private |
An opaque handle for a data page in an unformatted catalog file.
It must be automatically release if it goes out of scope.
|
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.
|
private |
Closes a catalog file pointed by the file handle.
This does nothing except for setting fh to INVALID_FID in VolatileCatCache.
|
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.
|
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.
|
private |
Returns a BulkLoadIterator for bulk loading a systable index.
|
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’.
|
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’.
|
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.
|
inline |
Not implemented.
Volatile catlog cache is never saved on disk so it can't be initialized from an existing data directory.
|
private |
Creates an iterator over the catalog file specified by the file ID.
|
private |
Creates an iterator that starts at rid
.
The iterator may or may not return additional records after the first one if rid
exists.
|
private |
Marks a page pointed by the page handle as dirty.
This does nothing in VolatileCatCache.
|
private |
Tries to move the iterator to the next row and returns whether such a row exists.
|
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
.
|
private |
Releases the pin over the page pointed by the page handle.
This does nothing in VolatileCatCache.
|
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.
|
friend |
|
friend |
|
private |
The pointer to the in-memory only dbmeta page.
|
private |
This vector stores all our in-memory only files.
The index into this file is file ID - 2.