Package org.apache.hadoop.io
Class MapFile
java.lang.Object
org.apache.hadoop.io.MapFile
A file-based map from keys to values.
A map is a directory containing two files, the data file,
containing all keys and values in the map, and a smaller index
file, containing a fraction of the keys. The fraction is determined by
MapFile.Writer.getIndexInterval().
The index file is read entirely into memory. Thus key implementations should try to keep themselves small.
Map files are created by adding entries in-order. To maintain a large
database, perform updates by copying the previous version of a database and
merging in a sorted change list, to create a new version of the database in
a new file. Sorting large change lists can be done with SequenceFile.Sorter.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic classorg.apache.hadoop.io.MapFile.MergerClass to merge multiple MapFiles of same Key and Value types to one MapFilestatic classorg.apache.hadoop.io.MapFile.ReaderProvide access to an existing map.static classorg.apache.hadoop.io.MapFile.WriterWrites a new map. -
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic voiddelete(FileSystem fs, String name) Deletes the named map file.static longfix(FileSystem fs, Path dir, Class<? extends Writable> keyClass, Class<? extends Writable> valueClass, boolean dryrun, Configuration conf) This method attempts to fix a corrupt MapFile by re-creating its index.static voidstatic voidrename(FileSystem fs, String oldName, String newName) Renames an existing map directory.
-
Field Details
-
INDEX_FILE_NAME
The name of the index file.- See Also:
-
DATA_FILE_NAME
The name of the data file.- See Also:
-
-
Constructor Details
-
MapFile
protected MapFile()
-
-
Method Details
-
rename
Renames an existing map directory.- Parameters:
fs- fs.oldName- oldName.newName- newName.- Throws:
IOException- raised on errors performing I/O.
-
delete
Deletes the named map file.- Parameters:
fs- input fs.name- input name.- Throws:
IOException- raised on errors performing I/O.
-
fix
public static long fix(FileSystem fs, Path dir, Class<? extends Writable> keyClass, Class<? extends Writable> valueClass, boolean dryrun, Configuration conf) throws Exception This method attempts to fix a corrupt MapFile by re-creating its index.- Parameters:
fs- filesystemdir- directory containing the MapFile data and indexkeyClass- key class (has to be a subclass of Writable)valueClass- value class (has to be a subclass of Writable)dryrun- do not perform any changes, just report what needs to be doneconf- configuration.- Returns:
- number of valid entries in this MapFile, or -1 if no fixing was needed
- Throws:
Exception- Exception.
-
main
- Throws:
Exception
-