Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Task The goal of this assignment is to implement a simple storage manager - a module that is capable of reading blocks from a file

Task
The goal of this assignment is to implement a simple storage manager - a module that is capable of reading blocks
from a file on disk into memory and writing blocks from memory to a file on disk. The storage manager deals with
pages (blocks) of fixed size (PAGE_SIZE). In addition to reading and writing pages from a file, it provides methods for
creating, opening, and closing files. The storage manager has to maintain several types of information for an open
file: The number of total pages in the file, the current page position (for reading and writing), the file name, and a
POSIX file descriptor or FILE pointer. In your implementation you should implement the interface described below.
Please commit a text file README. txt that (shortly) describes the ideas behind your solution and the code structure.
Comment your code!
INTERFACE
The interface your storage manager should implement is given as a header file storage_mgr.h. The content of this
header is shown below. Two additional headers
and test_helpers.h define error codes and constants
and macros used in the test cases.
#ifndef STORAGE_MGR_H
#define STORAGE_MGR_H
#include "dberror.h"
??************************************************************************************************************************
handle data structures
************************************************************************************************************************?
typedef struct SM_FileHandle {
char * fileName;
int totalNumPages;
int curPagePos;
void *mgmtInfo;
} SM_FileHandle;
typedef char * SM_PageHandle;
??************************************************************************************************************************
, interface
************************************************************************************************************************?
/* manipulating page files */
extern void initStorageManager (void);
extern RC createPageFile (char * fileName);
extern RC openPageFile (char *fileName, SM_FileHandle *fHandle);
extern RC closePageFile (SM_FileHandle *fHandle);
extern RC destroyPageFile (char * fileName);
/* reading blocks from disc */
extern RC readBlock (int pageNum, SM_FileHandle *fHandle, SM_PageHandle memPage);
extern int getBlockPos (SM_FileHandle *fHandle);
extern RC readFirstBlock (SM_FileHandle *fHandle, SM_PageHandle memPage);
extern RC readPreviousBlock (SM_FileHandle *fHandle, SM_PageHandle memPage);
extern RC readCurrentBlock (SM_FileHandle *fHandle, SM_PageHandle memPage);
extern RC readNextBlock (SM_FileHandle *fHandle, SM_PageHandle memPage);
extern RC readLastBlock (SM_FileHandle *fHandle, SM_PageHandle memPage);
/* writing blocks to a page file */
extern RC writeBlock (int pageNum, SM_FileHandle *fHandle, SM_PageHandle memPage);
extern RC writeCurrentBlock (SM_FileHandle *fHandle, SM_PageHandle memPage);
extern RC appendEmptyBlock (SM_FileHandle *fHandle);
extern RC ensureCapacity (int number0fPages, SM_FileHandle *fHandle);
#endif
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

Advances In Databases And Information Systems 25th European Conference Adbis 2021 Tartu Estonia August 24 26 2021 Proceedings Lncs 12843

Authors: Ladjel Bellatreche ,Marlon Dumas ,Panagiotis Karras ,Raimundas Matulevicius

1st Edition

3030824713, 978-3030824716

More Books

Students also viewed these Databases questions