$25
Modifications to Datastore (UPDATE and DELETE)
In this lab session, you will implement UPDATE and DELETE in Personal Data Store (PDS) based on a key field.
Storage Structure Changes
1. Data file change: For every record being saved, store the key explicitly followed by the data record
2. Index file change: Store 100 integers as a placeholder for offset of deleted records
Main PDS functions
A) pds_open
Changes as needed for Storage Structure Changes noted above
B) put_rec_by_key
Changes as needed for Storage Structure Changes noted above
C) get_rec_by_ndx_key
Changes as needed for managing deleted objects
D) pds_close
Changes as needed for Storage Structure Changes noted above
E) get_rec_by_non_ndx_key
Changes as needed for managing deleted objects
G) bst.c
Impletement bst_delete to delete node from BST
H) New Functions in pds.c
// update
// Search for index entry in BST
// Seek to the file location based on offset in index entry
// Overwrite the existing record with the given record // In case of any error, return PDS_MODIFY_FAILED int update_by_key( int key, void *newrec );
// pds_delete
// Search for index entry in BST // store the offset value in to free list int delete_by_key( int key );
Testing
a. Use contact_loader.c program to import contacts in bulk for testing. Input file with data is given to you.
b. The following driver program is given to you:
• pds_tester.c (generic testing with input data file like testcase.in).
• This file takes a file with commands such as (CREATE, STORE, RETRIEVE, OPEN, CLOSE) inside.
c. Test your program thoroughly with the above driver program with the test input file
d. Do additional testing by creating your own test input files
Commands
A. Use the following command for creating contact_loader executable:
gcc -o contact_loader contact_loader.c bst.c contact.c pds.c
Use contact loader to import data using the following command:
contact_loader scandemo contact_dump.txt
B. Use the following command for creating pds_tester executable:
gcc -o pds_tester bst.c contact.c pds.c pds_tester.c
For testing using pds_tester, use the following command:
pds_tester testcase.in
Submission
Upload ONLY the following file to LMS:
• pds.c
• bst.c
YOU ARE NOT EXPECTED CHANGE ANY OF THE OTHER FILES GIVEN TO YOU