M - the message type extending WritableComparable.public final class SortedFile<M extends org.apache.hadoop.io.WritableComparable> extends Object implements org.apache.hadoop.util.IndexedSortable, Closeable
WritableComparable in order defined in it.| Constructor and Description |
|---|
SortedFile(String dir,
String finalFileName,
int bufferSize,
Class<M> msgClass)
Creates a single sorted file.
|
SortedFile(String dir,
String finalFileName,
int bufferSize,
Class<M> msgClass,
boolean intermediateMerge)
Creates a single sorted file.
|
| Modifier and Type | Method and Description |
|---|---|
void |
close() |
void |
collect(M msg)
Collects a message.
|
int |
compare(int left,
int right) |
void |
swap(int left,
int right) |
public SortedFile(String dir, String finalFileName, int bufferSize, Class<M> msgClass) throws IOException
dir - the directory to use for swapping, will be created if not
exists.finalFileName - the final file where the data should end up merged.bufferSize - the buffersize. By default, the spill starts when 90% of
the buffer is reached, so you should overallocated ~10% of the
data.msgClass - the class that implements the comparable, usually the
message class that will be added into collect.IOException - in case the directory couldn't be created if not
exists.public SortedFile(String dir, String finalFileName, int bufferSize, Class<M> msgClass, boolean intermediateMerge) throws IOException
dir - the directory to use for swapping, will be created if not
exists.finalFileName - the final file where the data should end up merged.bufferSize - the buffersize. By default, the spill starts when 90% of
the buffer is reached, so you should overallocated ~10% of the
data.msgClass - the class that implements the comparable, usually the
message class that will be added into collect.intermediateMerge - if true, the outputted single sorted file has a
special format so the Merger can read it for further
merging.IOException - in case the directory couldn't be created if not
exists.public void collect(M msg) throws IOException
msg - the message to add.IOException - when an IO error happens.public int compare(int left,
int right)
compare in interface org.apache.hadoop.util.IndexedSortablepublic void swap(int left,
int right)
swap in interface org.apache.hadoop.util.IndexedSortablepublic void close()
throws IOException
close in interface Closeableclose in interface AutoCloseableIOExceptionCopyright © 2016. All rights reserved.