public class MapFileReader<V> extends Object implements Closeable
MapFile.Reader, used in MapFileRecordReader and MapFileSequenceRecordReader
Note: This also handles multiple map files, such as the output from Spark, which gives a set of map files
in directories like /part-r-00000, /part-r-00001| Constructor and Description |
|---|
MapFileReader(List<String> paths,
IndexToKey indexToKey,
Class<? extends org.apache.hadoop.io.Writable> recordClass) |
MapFileReader(String path) |
MapFileReader(String path,
IndexToKey indexToKey,
Class<? extends org.apache.hadoop.io.Writable> recordClass) |
| Modifier and Type | Method and Description |
|---|---|
void |
close() |
V |
getRecord(long index)
It a single record from the map file for the given index
|
long |
numRecords()
Determine the total number of records in the map file, using the
IndexToKey instance |
public MapFileReader(String path, IndexToKey indexToKey, Class<? extends org.apache.hadoop.io.Writable> recordClass) throws IOException
path - Path (directory) of the MapFileindexToKey - Instance used to convert long indices to key values. This allows for lookup by keyrecordClass - Class of the records in the MapFileIOException - If an error occurs during opening or initialisationpublic MapFileReader(List<String> paths, IndexToKey indexToKey, Class<? extends org.apache.hadoop.io.Writable> recordClass) throws IOException
IOExceptionpublic long numRecords()
IndexToKey instancepublic V getRecord(long index) throws IOException
index - Index, between 0 and numRecords()-1IOException - If an error occurs during readingpublic void close()
throws IOException
close in interface Closeableclose in interface AutoCloseableIOExceptionCopyright © 2017. All rights reserved.