Description
The required task is to build a simplified query processor that accesses data from the partitioned ratings table.
Input Data: – Same as in Assignment 1 i.e. ratings.dat file.
Required Task: – Below are the steps you need to follow to fulfill this assignment:
RangeQuery() – o Implement a Python function RangeQuery that takes as input: (1)
RatingMinValue (2) RatingMaxValue (3) openconnection (4) outputPath o Please note that the RangeQuery would not use ratings table but it would use the range and round robin partitions of the ratings table.
- RangeQuery() then returns all tuples for which the rating value is larger than or equal to RatingMinValue and less than or equal to RatingMaxValue.
- The returned tuples should be stored in outputPath. Each line represents a tuple that has the following format such that PartitionName represents the full name of the partition i.e. RangeRatingsPart1 or RoundRobinRatingsPart4 in which this tuple resides.
PartitionName, UserID, MovieID, Rating Example:
RangeRatingsPart0,1,377,0.5
RoundRobinRatingsPart1,1,377,0.5
- Note: Please use ‘,’ (COMMA, no space character) as delimiter between PartitionName, UserID, MovieID and Rating.
PointQuery() – o Implement a Python function PointQuery that takes as input: (1) RatingValue.
(2) openconnection (3) outputPath o Please note that the PointQuery would not use ratings table but it would use the range and round robin partitions of the ratings table.
- PointQuery() then returns all tuples for which the rating value is equal to RatingValue.
- The returned tuples should be stored in outputPath. Each line represents a tuple that has the following format such that PartitionName represents the full name of the partition i.e. RangeRatingsPart1 or RoundRobinRatingsPart4 in which this tuple resides.
PartitionName, UserID, MovieID, Rating
Example
RangeRatingsPart3,23,459,3.5
RoundRobinRatingsPart4,31,221,0
- Note: Please use ‘,’ (COMMA, no space character) as delimiter between PartitionName, UserID, MovieID and Rating.
Please use the function signature exactly same as mentioned in Assignment2_Interface.py .
Naming Convention to be followed strictly: Database name – ddsassignment2
Name of Rating table – ratings
Postgres User name – postgres Postgres password – 1234
How to use tester.py:
Open the Assignment2.zip file and dump all the contents in a folder.
Also move ratings.dat file to this folder.
As per the naming conventions provided above, setup your postgresql.
Once the setup is done, test the tester.py by simply running it.
It should provide the following output:
Now, you can implement your functions in Assignment2_Interface.py and once done, use the tester again to generate the output.
DONOT CHANGE tester.py and Assignment1.py. Changing anyone of these would cause problems and the system will stop working, and may lead to deduction of marks.
PLEASE KEEP IN MIND, this tester is just for your help. For grading purpose, an additional set of test cases would be used. It will try to break your code. So, please provide the functionalities accordingly, so that it handles all possible scenarios.
Instructions for Assignment: –
Please follow these instructions closely
- Please follow the function signature as provided in the Assignment2_Interfacy.py.
- Please use the same database name, table name, user name and password as provided in the assignment to keep it consistent.
- Please make sure to run the provided tester and make sure there is no indentation error. In case of any compilation error, 0 marks will be given.
- Do not modify Assignment1.pyc library and tester.py. In case any modification is needed, please post the same on discussion board.
- For any case of doubt in the assignment, PLEASE USE Discussion Boards, Individual mails would not be entertained.
- Also, it is an individual’s responsibilities to clarify his/her doubts, so read and use Discussion Board extensively.
- The output file should have the exactly same format with the sample. The grading is based on string comparison. One mismatch will cause 1 point loss, two mismatch will cause 2 points loss, etc.
- Pay attention to the outputPath. If you output the result to a different path, the grading script will be able to locate your file. You will get 0 point.
Submission Instructions:
- Only submit the .py file. Do not change the file name. Do not put it into a folder or upload a zip.
- Multiple submissions are allowed. Only the latest submission will be graded. No late submission is accepted.
Note: – Failure to follow the instructions provided in the document will result in the loss of the points.
- Ratings
- RangeRatingsPart0 to RangeRatingsPartN (where N = number of partition – 1)
- Same structure as Ratings table
- If value of N is 5 then here is the list of table created for Range Partitionin
- RoundRobinRatingsPart0 to RoundRobinRatingsPartN (where N = number of partition – 1)
- Same structure as Ratings table
- If value of N is 5 then here is the list of table created for Round Robin Partitioning
- RangeRatingsMetadata
If PartitionNum is 0, then it means table RangeRatingsPart0 is being referred and this table contains records for rating values >= minrating and <= maxrating.
If PartitionNum is N ( N > 1), then it means table RangeRatingsPartN is being referred and this table contains records for rating values > minrating and <= maxrating.
Example: – If N is 1, the RangeRatingsPart1 is being referred and this partition contains all the record for which the rating values are 1 < value <= 2.
- RoundRobinRatingsMetadata
Partitionnum denotes total number of partition and tablenextinsert denotes that next partition the record should b






