public abstract class SpatialRecordReader<K,V>
extends java.lang.Object
Rectangle
that indicates the MBR of the corresponding partition.
In case of a non-indexed file, the key is an invalid rectangle. See
Rectangle.isValid()
.ShapeLineRecordReader
,
ShapeRecordReader
,
ShapeArrayRecordReader
,
RTreeRecordReader
Modifier and Type | Class and Description |
---|---|
static class |
SpatialRecordReader.ShapeIterator
An iterator that iterates over all shapes in the input file
|
Modifier and Type | Field and Description |
---|---|
protected long |
blockSize
Block size for the read file.
|
protected edu.umn.cs.spatialHadoop.mapred.SpatialRecordReader.BlockType |
blockType
The type of the currently parsed block
|
protected byte[] |
buffer
Some bytes that were read from the stream but not parsed yet
|
protected Rectangle |
cellMbr
The boundary of the partition currently being read
|
protected long |
end
Last offset to stop at
|
protected LineReader |
lineReader
Reads lines from text files
|
protected long |
pos
Position of the next byte to read/prase from the input
|
protected long |
start
First offset that is read from the input
|
protected Text |
tempLine
A temporary text to read lines from lineReader
|
Constructor and Description |
---|
SpatialRecordReader(CombineFileSplit split,
Configuration conf,
Reporter reporter,
java.lang.Integer index)
Initialize from an input split
|
SpatialRecordReader(Configuration job,
FileSplit split)
Initialize from a FileSplit
|
SpatialRecordReader(Configuration job,
long s,
long l,
Path p)
Initialize from a path and file range
|
SpatialRecordReader(java.io.InputStream in,
long offset,
long endOffset)
Construct from an input stream already set to the first byte to read.
|
Modifier and Type | Method and Description |
---|---|
void |
close() |
long |
getPos()
Returns the current position in the data file.
|
float |
getProgress() |
protected boolean |
initializeReader()
Initializes the reader to read from the input stream or file.
|
protected boolean |
nextLine(Text value)
Reads the next line from input and return true if a line was read.
|
protected boolean |
nextRTree(RTree<? extends Shape> rtree)
Reads the next RTree from file.
|
protected boolean |
nextShape(Shape s)
Reads next shape from input and returns true.
|
protected boolean |
nextShapeIter(SpatialRecordReader.ShapeIterator iter)
Returns an iterator that iterates over all remaining shapes in the file.
|
protected boolean |
nextShapes(ArrayWritable shapes)
Reads all shapes left in the current block in one shot.
|
protected long start
protected long end
protected long pos
protected LineReader lineReader
protected Text tempLine
protected byte[] buffer
protected long blockSize
protected Rectangle cellMbr
protected edu.umn.cs.spatialHadoop.mapred.SpatialRecordReader.BlockType blockType
public SpatialRecordReader(CombineFileSplit split, Configuration conf, Reporter reporter, java.lang.Integer index) throws java.io.IOException
split
- conf
- reporter
- index
- java.io.IOException
public SpatialRecordReader(Configuration job, FileSplit split) throws java.io.IOException
job
- split
- java.io.IOException
public SpatialRecordReader(Configuration job, long s, long l, Path p) throws java.io.IOException
job
- s
- l
- p
- java.io.IOException
public SpatialRecordReader(java.io.InputStream in, long offset, long endOffset) throws java.io.IOException
in
- offset
- endOffset
- java.io.IOException
public long getPos() throws java.io.IOException
getFilePosition()
.
However, if the file is compressed, this value indicates the position
in the decompressed stream.java.io.IOException
public void close() throws java.io.IOException
java.io.IOException
public float getProgress() throws java.io.IOException
java.io.IOException
protected boolean initializeReader() throws java.io.IOException
java.io.IOException
protected boolean nextLine(Text value) throws java.io.IOException
value
- java.io.IOException
protected boolean nextShape(Shape s) throws java.io.IOException
nextLine(Text)
then parses the returned
line by calling TextSerializable.fromText(Text)
on that line. If no stock
shape is set, a NullPointerException
is thrown.s
- java.io.IOException
protected boolean nextShapes(ArrayWritable shapes) throws java.io.IOException
nextShape(Shape)
until one of the following conditions happen.
1. The whole file is read. No more records to read.
2. Number of parsed records reaches the threshold defined by the
configuration parameter spatialHadoop.mapred.MaxShapesPerRead.
To disable this check, set the configuration parameter to -1
3. Total size of parsed data from file reaches the threshold defined by
the configuration parameter spatialHadoop.mapred.MaxBytesPerRead.
To disable this check, set the configuration parameter to -1.shapes
- java.io.IOException
protected boolean nextShapeIter(SpatialRecordReader.ShapeIterator iter) throws java.io.IOException
iter
- java.io.IOException
protected boolean nextRTree(RTree<? extends Shape> rtree) throws java.io.IOException
RTree.readFields(DataInput)
on the input stream.rtree
- java.io.IOException