Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

This will be a programming assignment, and requires you to write a program. You may choose which language you prefer, from C or Java. The

This will be a programming assignment, and requires you to write a program. You may choose which language you prefer, from C or Java.

The program will take one mandatory command-line argument, the name of a folder/directory which will be where a collection of data is stored. You get to choose the structure of data in that folder, except that the folder may not contain (directly or indirectly) more than 50 files.

When it runs, it will read commands from the user through standard input. The commands it must accept are:

ADD ; ; ;

SHOW =

SHOW >

SHOW <

DELETE =

SET =

WHEN =

QUIT

This input will be kept very simple. Each line in the input will contain one command (i.e. no command will be split over multiple lines). Each line will be at most 1000 characters in length. These will be very rigidly formatted such that where a space occurs above, only a single space is valid. For example, an add command will be formatted specifically as ADD, followed by a space, followed by characters up to but not including a semi-colon (which will be the name), followed by a semi-colon, followed by a space, followed by characters up to but not including a semi-colon (which will be the email), followed by a semi-colon, followed by a space, followed by digits up to but not including a semi-colon (which will be the year), followed by a semi-colon, followed by a space, followed by digits up to but not including the end of line (which will be the country).

When the QUIT command is executed, it will exit the program, making sure any data is saved.

When the ADD command is executed, it will add a record to the collection. The records values will be the four items read (the name, email, year, and country).

When the DELETE command is executed, it will delete all records from the collection where the attribute matches the value specified.

When the SET command is executed, it will find all records in the collection whose attribute (attr2) matches the given value (value2), and sets those records attribute (attr) to the value give (value).

When the SHOW command is executed, it will find any records in the collection where the given attribute is equal to, less than, or greater than (depending on the operator used) the value provided,

and will print their results to the standard output. The results will be printed such that each record found is printed on a separate line. Each line of results will contain the name, followed by a semi-colon, followed by the email, followed by a semi-colon, followed by the year, followed by a semi-colon, followed by the country. The rows output from the SHOW command may occur in any order (it doesnt require them to be sorted).

An example input:

ADD Mitchell wane; mitchellwane@email.ca; 1987; France

ADD Shane stein; shanestein@email.ca; 1986; France

ADD Tux; tux_rules@penguin.net; 2000; England

SHOW name = Tux

SET year = 1996 WHEN name = Tux

SHOW name = Tux

ADD Sam; Samwilliam@email.ca; 1972; France

SHOW year < 1997

DELETE name = Shane stein

SHOW year < 1990

QUIT

Would produce the following output (rows 3 and 4 might be in a different order):

Tux;tux_rules@penguin.net;2000;England

Tux;tux_rules@penguin.net;1996;England

Shane stein; shanestein@email.ca ;1986; France

Sam; Samwilliam@email.ca; 1972; France

Sam; Samwilliam@email.ca; 1972; Canada

Note:

Your program will be tested with a memory limit of 512M, but large test cases will be used. That means your program must be able to handle more data than can fit in memory all at once.

If the end of input (end of file) is found, it should do the same as quitting the program with the QUIT command.

If the program is terminated abnormally (through a CTRL+C), data must still be preserved. Thus, if the program terminates that way, and then is run again, any data changes must not be lost.

This will be tested on a very large test suite. The assignment mark will be based on the correctness of the program, and upon the quality of the code submitted (sensible code structure, readability, and appropriate error/exception management).

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

Database Internals A Deep Dive Into How Distributed Data Systems Work

Authors: Alex Petrov

1st Edition

1492040347, 978-1492040347

More Books

Students also viewed these Databases questions