Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

For all files and paths, use the Files and Paths APIs from the java.nio.file package when possible. A public clear method. 1 Walk the data

For all files and paths, use the Files and Paths APIs from the java.nio.file package when possible. A public clear method.
1 Walk the data directory by streaming as follows:
i Skip the first path in the stream, which is itself being walked and shouldnt be deleted.
ii Sort the stream in reverse order, which streams from the lowest files to the highest directories.
iii For each path in the stream, delete the corresponding file or directory.
2 Call writeInt 0 to the size file under the metadata directory.
3 Call writeInt 0 to the fingerprint file under the metadata directory.
N Public methods for the following statistics and predicates:
1 The name method which returns the name of the table root, excluding the base directories (without an extension).
2 The columns method which returns the lines (list of strings) read from the columns file under the metadata directory.
3 The degree method which returns the size of the list of columns which is returned by the columns method.
4 The size method which returns readInt from the size file under the metadata directory.
5 The hashCode method which returns readInt from the fingerprint file under the metadata directory.
6 Dont implement capacity or loadFactor, because this is a FileTable, not a DataTable.
7 The equals method which returns true if the parameter is any table with the same fingerprint (as in previous modules).
O A public put method which takes a key parameter (string), then a list of fields parameter (list of objects).
1 If the degree of the given row doesnt match the result of calling the degree method, throw an illegal argument exception.
2 Find the path of the digest of the given key (calling steps K and L in order).
3 Create a new row composed of the key parameter and the list of fields parameter.
4 Check if a file exists at the path of the digest to determine a hit or a miss.
5 On a hit, readRow from the path of the old row, writeRow to the path with the new row, writeInt to the fingerprint
path under the metadata directory to update it (like in previous modules), and return the old list of fields.
6 On a miss, writeRow to the path with the new row, writeInt to the size and fingerprint paths under the metadata
directory to update them (like in previous modules), and return null.
P A public get method which takes a key parameter.
1 Find the path of the digest of the key equal to the given object (calling steps K and L in order).
2 Check if a file exists at the path of the digest to determine a hit or a miss.
3 On a hit, readRow from the path of the old row, and return the old list of fields.
4 On a miss, return null.
Q A public remove method which takes a key parameter.
1 Find the path of the digest of the key equal to the given object (calling steps K and L in order).
2 Check if a file exists at the path of the digest to determine a hit or a miss.
3 On a hit, readRow from the path of the old row, deleteRow at the same path, writeInt to the size and fingerprint
paths under the metadata directory to update them (like in previous modules), and return the old list of fields.
4 On a miss, return null.
R A public iterator method which returns an iterator of rows.
1 Walk the data directory by streaming as follows:
i Filter the stream to include only files which arent directories.
ii Map each path in the stream to the row stored there using readRow.
2 Return the iterator from the stream.
S A public toString method.
1 Return an unsorted view of the table by calling toTabularView.

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_2

Step: 3

blur-text-image_3

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

Microsoft SQL Server 2012 Unleashed

Authors: Ray Rankins, Paul Bertucci

1st Edition

0133408507, 9780133408508

More Books

Students also viewed these Databases questions