[prev] 34 [next]

Single-file Disk Manager (cont)

// set up struct describing relation
Reln openRelation(DB db, char *rname) {
   Reln r = new(RelDescriptor);
   r->relname = strdup(rname);
   // get relation data from map tables
   r->start = ...;
   r->npages = ...;
   return r;
}
// stop using a relation
void closeRelation(Reln r) {
   free(r);
}
#define nPages(r)  (r->npages)
#define makePageId(r,i)  (r->first + i)