Description
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
- Data file change: For every record being saved, store the key explicitly followed by the data record
- Index file change: Store 100 integers as a placeholder for offset of deleted records
Main PDS functions
- pds_open
Changes as needed for Storage Structure Changes noted above
- put_rec_by_key
Changes as needed for Storage Structure Changes noted above
- get_rec_by_ndx_key
Changes as needed for managing deleted objects
- pds_close
Changes as needed for Storage Structure Changes noted above
- 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
- Use contact_loader.c program to import contacts in bulk for testing. Input file with data is given to you.
- The following driver program is given to you:
- 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.
- Test your program thoroughly with the above driver program with the test input file
- Do additional testing by creating your own test input files
Commands
- 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
- 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





