COMP9315 22T1 Final Exam The University of New South Wales
COMP9315 DBMS Implementation
22T1 Final Exam
DBMS Implementation
[Instructions] [PostgreSQL] [C] [Q1-3 Info]
[Q1] [Q2] [Q3] [Q4] [Q5] [Q6] [Q7] [Q8]

Question 1 (15 marks)

The q1 directory contains an incomplete program q1.c. You must complete this program so that it counts the number of tuples in a "no-frills" data file (see [Q1-3 Info] for details on what a "no-frills" data file is). The name of the data file is supplied as a command-line argument, e.g.

$ ./q1 data/Data1
20
$

"No-frills" files have at least one page of data, and all pages must contain PAGESIZE bytes. If the supplied file does not meet these criteria, then return the tuple count as -1. Otherwise, return the number of tuples that your program computed. Note that a "no-frills" file can consist of a single page of PAGESIZE bytes, all of which are '\0'; such a file should return a tuple count of 0.

Note that q1.c already does all of the command-line argument handling, and opens the data file for you. By the time your code runs, fd should contain a valid file descriptor for reading the data file. Note also that the supplied q1.c does not compile; you will need to make changes before you can compile and execute it.

To help you check whether your program is working correctly, there is a script called run_tests.sh which will run the program against all of the tests in the tests directory and report the results. It will also add the output from your program into the tests directory; comparing your output against the expected output might help you to debug your code. You can run the testing script as:

$ sh run_tests.sh

Once your program is working (passes all tests), follow the submission instructions below. If your program passes some tests, then you will receive some marks. If your program does not compile, or if you simply submit the supplied code (even with trivial changes), then your "answer" is worth zero marks.

Submission Instructions:

End of Question