Question
Java Programming: Show the full code with its output. There must be no error at all. In this part, you need to implement, in FileManager.java,
Java Programming: Show the full code with its output. There must be no error at all.
In this part, you need to implement, in FileManager.java, a basic storage manager that maintains a series of data objects in each data file without buffering (i.e., by directly reading/writing SlottedPages from/to data files). The methods to complete are as follows (your code needs to pass all of the 4 tests in FileManagerTest):
put(int fileID, Long location, Object o): puts object o at location location in the file specified by fileID. Here, location has a long-type value, whose first half (4 bytes corresponding to an integer) represents the ID of the page and the second half represents the index within the page. For example, put(10, 0x00000001L, o) stores object o in page 0 of the file whose ID is 10 (i.e., the first disk block in the file) at index 1 within the page. On the other hand, put(10, 0x00010000L, o) stores object o in page 1 of the file whose ID is 10 (i.e., the second disk block in the file) at index 0 within the page. Given a long-type argument location, use first(location) to get the ID of the page and second(location) to get the index within the page. After finding an appropriate page p, call put(int index, Object o) on p to put the object in that page and then call the updated(p, fileID) method of FileManager to indicate that the page p is updated (then the updated(p, fileID) method of FileManager automatically writes the page to the appropriate data file). If the location argument has an inappropriate value, then put(int fileID, Long location, Object o) needs to throw an InvalidLocationException.
get(int fileID, Long location): returns the object at location location in the file specified by fileID. remove(int fileID, Long location): (5 points) removes the object at location location from the file specified by fileID.
iterator(int fileID): returns an iterator over all objects stored in the the file specified by fileID. This method needs to use page(int fileID, int pageID) of FileManager and iterator() of SlottedPage. Make sure this method efficiently uses the memory (e.g., should NOT put all of the objects in the memory first thereby incurring high space overhead and then return an iterator over these objects).
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started