Answered step by step
Verified Expert Solution
Question
1 Approved Answer
2 . 1 . Data structures. The page size is hard - coded in the header file dberror. h ( PAGE _ SIZE ) .
Data structures. The page size is hardcoded in the header file dberror. PAGESIZE Each of the methods
defined in the storage manager interface returns an integer return code also defined in dberror.h RC For details
see return codes below.
The methods in the interface use the following two data structures to store information about files and pages:
File Handle SMFileHandle
A file handle SMFileHandle represents an open page file. Besides the file name, the handle stores the
total number of pages in the file and the current page position.
The current page position is used by some of the read and write methods of the storage manager.
For example, readCurrentBlock reads the curPagePosth page counted from the beginning of the
file. When opening a file, the current page should be the first page in the file curPagePos and the
totalNumPages has to be initialized based on the file size.
Use the mgmtInfo to store additional information about the file needed by your implementation, eg a
POSIX file descriptor.
Hint: You should reserve some space in the beginning of a file to store information such as the total
number of pages.
Hint: Use mgmtInfo to store any bookkeeping info about a file your storage manager needs.
typedef struct SMFileHandle
char fileName;
int totalNumPages;
int curPagePos;
void mgmtinfo;
SMFileHandle;
Page Handle SMPageHandle
A page handle is a pointer to an area in memory storing the data of a page.
Methods that write the data pointed to by a page handle to disk or read a page from disk into the area
of memory pointed to by the page handle require that the handle is pointing to an previously allocated
block of memory that is at least PAGESIZE number of bytes long.
typedef char SMPageHandle;
File Related Methods.
createPageFile
Create a new page file fileName. The initial file size should be one page. This method should fill this
single page with bytes.
openPageFile
Opens an existing page file. Should return RCFILENOTFOUND if the file does not exist.
The second parameter is an existing file handle.
If opening the file is successful, then the fields of this file handle should be initialized with the information
about the opened file. For instance, you would have to read the total number of pages that are stored
in the file from disk.
closePageFile, destroyPageFile
Close an open page file or destroy delete a page file.
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started