Cache Layer
Relation Cache and Attribute Cache have size 12 (MAX OPEN) in each which each entry in these arrays store the catalog entry for each.
===Can have upto 12 relations open at a time (MAX_OPEN)===
An entry of the relation cache stores the relation catalog entry, the rec-id (block & slot number) of the entry on the disk and some other runtime data. An entry of the attribute cache is a liked list where each node contains one of the attribute catalog entries for the relation, the corresponding rec-ids and some runtime metadata.
Relation Cache Table Structure
typedef struct RelCatEntry {
unsigned char relName[ATTR_SIZE];
int numAttrs;
int numRecs;
int firstBlk;
int lastBlk;
int numSlotsPerBlk;
} RelCatEntry;
typedef struct RelCacheEntry {
RelCatEntry relCatEntry;
bool dirty;
RecId recId;
RecId searchIndex;
} RelCacheEntry;
Attribute Cat Entry
typedef struct AttrCatEntry {
unsigned char relName[ATTR_SIZE];
unsigned char attrName[ATTR_SIZE];
int attrType;
int primaryFlag;
int rootBlock;
int offset;
} AttrCatEntry;
typedef struct AttrCacheEntry {
AttrCatEntry attrCatEntry;
bool dirty;
RecId recId;
RecId searchIndex;
struct AttrCacheEntry *next
} AttrCacheEntry;
Open Relation Table Structure
A relation must have an entry in AttrCache, RelCache, and in Open Relation Table
typedef struct OpenRelTableMetaInfo {
bool free;
unsigned char relName[ATTR_SIZE];
} OpenRelTableMetaInfo;