com.datasalt.pangool.io
Class TupleFile.Reader

java.lang.Object
  extended by com.datasalt.pangool.io.TupleFile.Reader
All Implemented Interfaces:
Closeable
Enclosing class:
TupleFile

public static class TupleFile.Reader
extends Object
implements Closeable

Reads SequenceFiles containing @{link ITuple} written using TupleFile.Writer. Typical usage would be:
TupleFile.Reader reader = new TupleFile.Reader(fs, file, conf); Tuple tuple = new Tuple(reader.getSchema()); while (reader.next(tuple) { .... } reader.close();


Constructor Summary
TupleFile.Reader(org.apache.hadoop.fs.FileSystem fs, org.apache.hadoop.conf.Configuration conf, org.apache.hadoop.fs.Path file)
          Open the named file.
TupleFile.Reader(org.apache.hadoop.fs.FileSystem fs, Schema targetSchema, org.apache.hadoop.conf.Configuration conf, org.apache.hadoop.fs.Path file)
          Open the named file.
 
Method Summary
 void close()
          Close the file.
 org.apache.hadoop.io.compress.CompressionCodec getCompressionCodec()
          Returns the compression codec of data in this file.
 org.apache.hadoop.io.SequenceFile.Metadata getMetadata()
          Returns the metadata object of the file
 long getPosition()
          Return the current byte position in the input file.
 Schema getSchema()
          Return the tuple's Schema in the file.
 boolean isBlockCompressed()
          Returns true if records are block-compressed.
 boolean isCompressed()
          Returns true if values are compressed.
 boolean next(ITuple tuple)
          Read the next ITuple in the file into tuple.
 void seek(long position)
          Set the current byte position in the input file.
 void sync(long position)
          Seek to the next sync mark past a given position.
 boolean syncSeen()
          Returns true iff the previous call to next passed a sync mark.
 String toString()
          Returns the name of the file.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

TupleFile.Reader

public TupleFile.Reader(org.apache.hadoop.fs.FileSystem fs,
                        Schema targetSchema,
                        org.apache.hadoop.conf.Configuration conf,
                        org.apache.hadoop.fs.Path file)
                 throws IOException
Open the named file. A specific Schema may be used in a backwards-compatible way.

Throws:
IOException

TupleFile.Reader

public TupleFile.Reader(org.apache.hadoop.fs.FileSystem fs,
                        org.apache.hadoop.conf.Configuration conf,
                        org.apache.hadoop.fs.Path file)
                 throws IOException
Open the named file.

Throws:
IOException
Method Detail

close

public void close()
           throws IOException
Close the file.

Specified by:
close in interface Closeable
Throws:
IOException

isCompressed

public boolean isCompressed()
Returns true if values are compressed.


isBlockCompressed

public boolean isBlockCompressed()
Returns true if records are block-compressed.


getCompressionCodec

public org.apache.hadoop.io.compress.CompressionCodec getCompressionCodec()
Returns the compression codec of data in this file.


getMetadata

public org.apache.hadoop.io.SequenceFile.Metadata getMetadata()
Returns the metadata object of the file


getSchema

public Schema getSchema()
Return the tuple's Schema in the file.


next

public boolean next(ITuple tuple)
             throws IOException
Read the next ITuple in the file into tuple. True if another entry exists, and false at end of file.

Throws:
IOException

seek

public void seek(long position)
          throws IOException
Set the current byte position in the input file.

The position passed must be a position returned by TupleFile.Writer.getLength() when writing this file. To seek to an arbitrary position, use sync(long).

Throws:
IOException

sync

public void sync(long position)
          throws IOException
Seek to the next sync mark past a given position.

Throws:
IOException

syncSeen

public boolean syncSeen()
Returns true iff the previous call to next passed a sync mark.


getPosition

public long getPosition()
                 throws IOException
Return the current byte position in the input file.

Throws:
IOException

toString

public String toString()
Returns the name of the file.

Overrides:
toString in class Object


Copyright © –2014 Datasalt Systems S.L.. All rights reserved.