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 2 (20 marks)

The q2 directory contains an incomplete program q2.c. You must complete this program so that it finds and prints the longest tuple 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.

$ ./q2 data/Data1
rtmeplzf,yjbjivazjj,txaqfxbctg,kbbq,mqanq
$

If the file is an empty "no-frills" file (one page containing zero tuples) or is a completely empty file (zero bytes), you should print "<none>". If the last page is longer than zero bytes but less than PAGESIZE, the file is not a valid "no-frills" data file, and so you should also print "<none>".

Note that q2.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 while the supplied q2.c does compile, it outputs junk.

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