org.apache.avro.mapred
Class SequenceFileReader<K,V>

java.lang.Object
  extended by org.apache.avro.mapred.SequenceFileReader<K,V>
All Implemented Interfaces:
Closeable, Iterable<Pair<K,V>>, Iterator<Pair<K,V>>, FileReader<Pair<K,V>>

public class SequenceFileReader<K,V>
extends Object
implements FileReader<Pair<K,V>>

A FileReader for sequence files.


Constructor Summary
SequenceFileReader(File file)
           
SequenceFileReader(SequenceFile.Reader reader, Configuration conf)
           
SequenceFileReader(URI uri, Configuration c)
           
 
Method Summary
 void close()
           
 Schema getSchema()
          Return the schema for data in this file.
 boolean hasNext()
           
 Iterator<Pair<K,V>> iterator()
           
 Pair<K,V> next()
           
 Pair<K,V> next(Pair<K,V> reuse)
          Read the next datum from the file.
 boolean pastSync(long position)
          Return true if past the next synchronization point after a position.
 void remove()
           
 void sync(long position)
          Move to the next synchronization point after a position.
 long tell()
          Return the current position in the input.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

SequenceFileReader

public SequenceFileReader(File file)
                   throws IOException
Throws:
IOException

SequenceFileReader

public SequenceFileReader(URI uri,
                          Configuration c)
                   throws IOException
Throws:
IOException

SequenceFileReader

public SequenceFileReader(SequenceFile.Reader reader,
                          Configuration conf)
Method Detail

close

public void close()
           throws IOException
Specified by:
close in interface Closeable
Throws:
IOException

remove

public void remove()
Specified by:
remove in interface Iterator<Pair<K,V>>

iterator

public Iterator<Pair<K,V>> iterator()
Specified by:
iterator in interface Iterable<Pair<K,V>>

getSchema

public Schema getSchema()
Description copied from interface: FileReader
Return the schema for data in this file.

Specified by:
getSchema in interface FileReader<Pair<K,V>>

hasNext

public boolean hasNext()
Specified by:
hasNext in interface Iterator<Pair<K,V>>

next

public Pair<K,V> next()
Specified by:
next in interface Iterator<Pair<K,V>>

next

public Pair<K,V> next(Pair<K,V> reuse)
               throws IOException
Description copied from interface: FileReader
Read the next datum from the file.

Specified by:
next in interface FileReader<Pair<K,V>>
Parameters:
reuse - an instance to reuse.
Throws:
IOException

sync

public void sync(long position)
          throws IOException
Description copied from interface: FileReader
Move to the next synchronization point after a position. To process a range of file entires, call this with the starting position, then check FileReader.pastSync(long) with the end point before each call to Iterator.next().

Specified by:
sync in interface FileReader<Pair<K,V>>
Throws:
IOException

pastSync

public boolean pastSync(long position)
                 throws IOException
Description copied from interface: FileReader
Return true if past the next synchronization point after a position.

Specified by:
pastSync in interface FileReader<Pair<K,V>>
Throws:
IOException

tell

public long tell()
          throws IOException
Description copied from interface: FileReader
Return the current position in the input.

Specified by:
tell in interface FileReader<Pair<K,V>>
Throws:
IOException


Copyright © 2011 The Apache Software Foundation. All Rights Reserved.