Terrier IR Platform
2.2.1

uk.ac.gla.terrier.compression
Class BitFileInMemory

java.lang.Object
  extended by uk.ac.gla.terrier.compression.BitFileInMemory
All Implemented Interfaces:
java.io.Closeable, BitInSeekable

public class BitFileInMemory
extends java.lang.Object
implements BitInSeekable

Class which enables a BitFile to be read in memory

Version:
$Revision: 1.5 $
Author:
Craig Macdonald

Constructor Summary
BitFileInMemory(byte[] buffer)
          Create an object using the specified data as the compressed data
BitFileInMemory(java.io.InputStream is, long length)
          Loads the entire specified inputstream into memory.
BitFileInMemory(java.lang.String filename)
          Loads the entire file represented by filename into memory
 
Method Summary
 void close()
          Close this object.
 BitIn readReset(long startByteOffset, byte startBitOffset, long endByteOffset, byte endBitOffset)
          Reads from the file a specific number of bytes and after this call, a sequence of read calls may follow.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

BitFileInMemory

public BitFileInMemory(java.lang.String filename)
                throws java.io.IOException
Loads the entire file represented by filename into memory

Parameters:
filename - Location of bit file to read into memory
Throws:
java.io.IOException - if anything goes wrong reading the file

BitFileInMemory

public BitFileInMemory(java.io.InputStream is,
                       long length)
                throws java.io.IOException
Loads the entire specified inputstream into memory. Length is assumed to be as specified.

Parameters:
is - InputStream containing the compressed bitfile
length - Expected length of the input stream
Throws:
java.io.IOException - if anything goes wrong reading the inputstream

BitFileInMemory

public BitFileInMemory(byte[] buffer)
Create an object using the specified data as the compressed data

Method Detail

readReset

public BitIn readReset(long startByteOffset,
                       byte startBitOffset,
                       long endByteOffset,
                       byte endBitOffset)
Reads from the file a specific number of bytes and after this call, a sequence of read calls may follow. The offsets given as arguments are inclusive. For example, if we call this method with arguments 0, 2, 1, 7, it will read in a buffer the contents of the underlying file from the third bit of the first byte to the last bit of the second byte.

Specified by:
readReset in interface BitInSeekable
Parameters:
startByteOffset - the starting byte to read from
startBitOffset - the bit offset in the starting byte
endByteOffset - the ending byte
endBitOffset - the bit offset in the ending byte. This bit is the last bit of this entry.
Returns:
Returns the BitIn object to use to read that data

close

public void close()
Close this object. Does nothing.

Specified by:
close in interface java.io.Closeable

Terrier IR Platform
2.2.1

Terrier Information Retrieval Platform 2.2.1. Copyright 2004-2008 University of Glasgow