org.apache.accumulo.core.file.rfile.bcfile
Class BCFile.Reader

java.lang.Object
  extended by org.apache.accumulo.core.file.rfile.bcfile.BCFile.Reader
All Implemented Interfaces:
Closeable
Enclosing class:
BCFile

public static class BCFile.Reader
extends Object
implements Closeable

BCFile Reader, interface to read the file's data and meta blocks.


Nested Class Summary
static class BCFile.Reader.BlockReader
          Access point to read a block.
 
Constructor Summary
BCFile.Reader(CachableBlockFile.Reader cache, org.apache.hadoop.fs.FSDataInputStream fin, long fileLength, org.apache.hadoop.conf.Configuration conf)
           
BCFile.Reader(org.apache.hadoop.fs.FSDataInputStream fin, long fileLength, org.apache.hadoop.conf.Configuration conf)
          Constructor
 
Method Summary
 void close()
          Finishing reading the BCFile.
 Utils.Version getAPIVersion()
          Get version of BCFile API.
 Utils.Version getBCFileVersion()
          Get version of BCFile file being read.
 int getBlockCount()
          Get the number of data blocks.
 int getBlockIndexNear(long offset)
          Find the smallest Block index whose starting offset is greater than or equal to the specified offset.
 BCFile.Reader.BlockReader getDataBlock(int blockIndex)
          Stream access to a Data Block.
 BCFile.Reader.BlockReader getDataBlock(long offset, long compressedSize, long rawSize)
           
 String getDefaultCompressionName()
          Get the name of the default compression algorithm.
 BCFile.Reader.BlockReader getMetaBlock(String name)
          Stream access to a Meta Block.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

BCFile.Reader

public BCFile.Reader(org.apache.hadoop.fs.FSDataInputStream fin,
                     long fileLength,
                     org.apache.hadoop.conf.Configuration conf)
              throws IOException
Constructor

Parameters:
fin - FS input stream.
fileLength - Length of the corresponding file
Throws:
IOException

BCFile.Reader

public BCFile.Reader(CachableBlockFile.Reader cache,
                     org.apache.hadoop.fs.FSDataInputStream fin,
                     long fileLength,
                     org.apache.hadoop.conf.Configuration conf)
              throws IOException
Throws:
IOException
Method Detail

getDefaultCompressionName

public String getDefaultCompressionName()
Get the name of the default compression algorithm.

Returns:
the name of the default compression algorithm.

getBCFileVersion

public Utils.Version getBCFileVersion()
Get version of BCFile file being read.

Returns:
version of BCFile file being read.

getAPIVersion

public Utils.Version getAPIVersion()
Get version of BCFile API.

Returns:
version of BCFile API.

close

public void close()
Finishing reading the BCFile. Release all resources.

Specified by:
close in interface Closeable

getBlockCount

public int getBlockCount()
Get the number of data blocks.

Returns:
the number of data blocks.

getMetaBlock

public BCFile.Reader.BlockReader getMetaBlock(String name)
                                       throws IOException,
                                              MetaBlockDoesNotExist
Stream access to a Meta Block.

Parameters:
name - meta block name
Returns:
BlockReader input stream for reading the meta block.
Throws:
IOException
MetaBlockDoesNotExist - The Meta Block with the given name does not exist.

getDataBlock

public BCFile.Reader.BlockReader getDataBlock(int blockIndex)
                                       throws IOException
Stream access to a Data Block.

Parameters:
blockIndex - 0-based data block index.
Returns:
BlockReader input stream for reading the data block.
Throws:
IOException

getDataBlock

public BCFile.Reader.BlockReader getDataBlock(long offset,
                                              long compressedSize,
                                              long rawSize)
                                       throws IOException
Throws:
IOException

getBlockIndexNear

public int getBlockIndexNear(long offset)
Find the smallest Block index whose starting offset is greater than or equal to the specified offset.

Parameters:
offset - User-specific offset.
Returns:
the index to the data Block if such block exists; or -1 otherwise.


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