Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

2 . 1 . Data structures. The page size is hard - coded in the header file dberror. h ( PAGE _ SIZE ) .

2.1. Data structures. The page size is hard-coded in the header file dberror. h(PAGE_SIZE). 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 SM_FileHandle
A file handle SM_FileHandle 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 curPagePos=th page counted from the beginning of the
file. When opening a file, the current page should be the first page in the file (curPagePos=0) 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, e.g., 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 SM_FileHandle {
char *fileName;
int totalNumPages;
int curPagePos;
void *mgmtinfo;
}. SM_FileHandle;
Page Handle SM_PageHandle
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 PAGE_SIZE number of bytes long.
typedef char* SM_PageHandle;
2.2. 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 '??0' bytes.
openPageFile
Opens an existing page file. Should return RC_FILE_NOT_FOUND 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.
image text in transcribed

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Building The Data Lakehouse

Authors: Bill Inmon ,Mary Levins ,Ranjeet Srivastava

1st Edition

1634629663, 978-1634629669

More Books

Students also viewed these Databases questions