Modifier and Type | Field and Description |
---|---|
static String |
LZO_INDEX_SUFFIX |
static String |
LZO_TMP_INDEX_SUFFIX |
static long |
NOT_FOUND |
Constructor and Description |
---|
LzoIndex()
Create an empty index, typically indicating no index file exists.
|
LzoIndex(int blocks)
Create an index specifying the number of LZO blocks in the file.
|
Modifier and Type | Method and Description |
---|---|
long |
alignSliceEndToIndex(long end,
long fileSize)
Nudge a given file slice end to the nearest LZO block end no earlier than
the current slice end.
|
long |
alignSliceStartToIndex(long start,
long end)
Nudge a given file slice start to the nearest LZO block start no earlier than
the current slice start.
|
static void |
createIndex(org.apache.hadoop.fs.FileSystem fs,
org.apache.hadoop.fs.Path lzoFile)
Index an lzo file to allow the input format to split them into separate map
jobs.
|
long |
findNextPosition(long pos)
Find the next lzo block start from the given position.
|
int |
getNumberOfBlocks()
Get the total number of blocks in the index file.
|
long |
getPosition(int block)
Get the block offset for a given block.
|
boolean |
isEmpty()
Return true if the index has no blocks set.
|
static LzoIndex |
readIndex(org.apache.hadoop.fs.FileSystem fs,
org.apache.hadoop.fs.Path lzoFile)
Read the index of the lzo file.
|
void |
set(int blockNumber,
long pos)
Set the position for the block.
|
public static final String LZO_INDEX_SUFFIX
public static final String LZO_TMP_INDEX_SUFFIX
public static final long NOT_FOUND
public LzoIndex()
public LzoIndex(int blocks)
blocks
- The number of blocks in the LZO file the index is representing.public void set(int blockNumber, long pos)
blockNumber
- Block to set pos for.pos
- Position.public int getNumberOfBlocks()
public long getPosition(int block)
block
- public long findNextPosition(long pos)
pos
- The position to start looking from.public boolean isEmpty()
public long alignSliceStartToIndex(long start, long end)
start
- The current slice startend
- The current slice endpublic long alignSliceEndToIndex(long end, long fileSize)
end
- The current slice endfileSize
- The size of the file, i.e. the max end position.public static LzoIndex readIndex(org.apache.hadoop.fs.FileSystem fs, org.apache.hadoop.fs.Path lzoFile) throws IOException
fs
- The index file is on this file system.lzoFile
- the file whose index we are reading -- NOT the index file itself. That is,
pass in filename.lzo, not filename.lzo.index, for this parameter.IOException
public static void createIndex(org.apache.hadoop.fs.FileSystem fs, org.apache.hadoop.fs.Path lzoFile) throws IOException
fs
- File system that contains the file.lzoFile
- the lzo file to index. For filename.lzo, the created index file will be
filename.lzo.index.IOException