Question: A. Description. In this project, we will build a simplistic inmemory database in c, accessible through a naive commandline textbased user interface (i.e., the user

A. Description. In this project, we will build a simplistic inmemory database in c, accessible through a naive commandline textbased user interface (i.e., the user types commands in order to interact with the inmemory database). Your interface should interpret script files, in addition to accepting one command at a time from the keyboard, and use a userlevel library that implements the inmemory database. We will start by describing the user interface. The executable of your program must be named naiveinterface. Your makefile must ensure this. The naiveinterface program must support the following usage: naiveinterface [scriptfile]. When no arguments are given, naiveinterface should enter a loop in which it accepts one command at a time as keyboard input (e.g., using scanf). The user types a command, and then presses return on the keyboard to execute it (i.e., the command will end with a newline character). Your program must block until the command completes and, if the return code is abnormal, print out a message to that effect. Alternatively, your program should open the given file (if one is provided) and interpret the contents as a sequence of commands to execute. You may assume that each line of the script file corresponds to one command. Your user interface should accept and support the following commands:

quit: When this command is encountered, naiveinterface should stop processing commands, prompt the user for confirmation (i.e., Are you sure you want to exit? All files will be lost! Y/N), accept the user input, delete all data structures and intermediate files (if any) created, and exit.

Output redirection: Your naiveinterface program should allow output to be redirected to a file (e.g., executing the command srchindx -o ALT indx.txt flightdata > foo.txt should execute srchindx in the flightdata directory and print its output in file foo.txt).

create: This command is used for creating new files, directories, and links. This is a separate program that can be executed by naiveinterface, or can be executed from a terminal by running its executable file. The create program should support the following usage:

create -f filepath creates an empty, ordinary file whose name is given in the specified path. The path can be an absolute pathname, a relative pathname, or just a bare filename, in which case the file should be created in the current directory. The new file should have permission 0640 specified in octal. 1

create -d dirpath creates a new directory whose name is given in the specified path. The new file should have permission 0750 specified in octal.

create -h oldname linkname creates a hard link. oldname is the path or name of an existing file, and linkname is the path or name of the hard link to be created.

create -s oldname linkname creates a symbolic (i.e., soft) link. oldname is the path or name of an existing file, and linkname is the path or name of the symbolic link to be created.

fileconverter: This command is used for converting a binary file containing flight data records into a set of text files. You can assume that the binary file has been produced error-free and that records in the binary file correspond one-to-one to records (one for each line) in the text file. The fileconverter program should support the following usage: fileconverter infile outdirectory, where parameter infile is the name of the input file, and outdirectory indicates the directory where the output files are to be stored. You may assume that each line of the output text file contains information about a single flight in the format: AirlineCodeFlightNumber OriginAirportCode DestinationAirportCode , where the four items are separated by single whitespace characters and the format of is YYYY-MM-DD HH:MM. Note that this format is easily comparable. For example, a record would look like AA43 DFW DTW 2016-01-06 11:00, with 2016-01-06 11:00 being the DepartureDate.

Given a binary input file, your fileconverter program should produce a collection of text files (using the create command), such that each file contains only flights operated by a single airline. The set of files should be stored in outdirectory. For example, all American Airlines flights should be stored in AA.txt, whereas all Delta flights should be stored in DL.txt. Additionally, flight records in a text file should be sorted in order of .

indexer: This command is used to parse a set of files and create an inverted index, which maps each airport code found in the files to the subset of files that contain that code. Your inverted index should additionally maintain the frequency with which each airport code appears in each file. The inverted index should be maintained in sorted order by airport code. The executable version of your indexer program must support the following usage: indexer [inverted-index file name] directory, where the first argument, inverted-index file name, is the name of a file that your program should create to hold the inverted index. The second argument, directory, is the name of the directory that contains files your indexer should index. If only a directory is provided as argument (i.e., the first argument is a directory), your indexer program should operate on the specified directory and generate the default index file invind.txt. You may assume that files in a directory cannot have the same name. The index file should be stored in the following format:

term

name1 count1 name2 count2 name3 count3 name4 count4 name5 count5

For example, 2 ATL (AA.txt, 10), (DL.txt, 3) DFW (DL.txt, 1) Note that the above depiction provides a logical view of the inverted index. In your program, you have to define appropriate data structures to hold the mappings (i.e., airport code list of files), the list of records, and the records (file name, count). After constructing the entire inverted index in memory, only then should your program save it to a file. Additionally, the mapping is to be maintained in ascending sorted order based on the ASCII coding of characters (i.e., A before B and AA before AB), whereas records in each list are to be maintained in descending sorted order based on frequency counts of the terms in the files.

srchindx: This command is used to perform a search over a file or a directory using an inverted index file. Specifically, your srchindx is to support the following usage: srchindx flag terms [inverted-index file name] [path], where the argument inverted-index file name denotes the name of the file that your indexer has created to hold the inverted index, and [path] is the filename to a file or directory. Given a filename, your program should search for terms in that filename only. Given a directory, your program should search for terms in all files in the directory (and subdirectories, if any) recursively. terms is a list of terms to be used for search and can be 1 or more. If more than one terms are provided, they will be separated by semicolons (e.g., ALT;DFW). Argument flag indicates if search is to be performed on origin (-o) or destination (-d) airports accordingly. For example,

o Execution of command srchindx -o ALT;DFW indx.txt flightdata, should search for records with origin airports ALT or DFW. The search should be performed across all files under directory flightdata using the inverted index stored in file indx.txt

o Issuing command srchindx -d ALT flightdata, should result in search of records with destination airport ALT in all files under directory flightdata using the inverted index stored in file invind.txt (i.e., the default filename for the inverted index).

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!