org.terrier.structures.collections
Class FSArrayFile<V extends org.apache.hadoop.io.Writable>

java.lang.Object
  extended by java.util.AbstractCollection<E>
      extended by java.util.AbstractList<V>
          extended by org.terrier.structures.collections.FSArrayFile<V>
Type Parameters:
V - Type of Writable
All Implemented Interfaces:
Closeable, Iterable<V>, Collection<V>, List<V>
Direct Known Subclasses:
FSADocumentIndex, FSArrayFileInMem

public class FSArrayFile<V extends org.apache.hadoop.io.Writable>
extends AbstractList<V>
implements Closeable

A file for accessing Writable classes written on disk. These must be of fixed size. This implementation is read-only, but does implement the List interface.

Since:
3.0
Author:
Craig Macdonald

Nested Class Summary
static class FSArrayFile.ArrayFileIterator<V extends org.apache.hadoop.io.Writable>
          ArrayFileIterator class
static interface FSArrayFile.ArrayFileWriter
          interface ArrayFileWriter
 
Field Summary
protected  RandomDataInput dataFile
          actual underlying data file
protected  String dataFilename
          filename of the underlying file
protected  int entrySize
          total size of one key,value pair
protected  int numberOfEntries
          The number of entries in the file.
static String USUAL_EXTENSION
          USUAL_EXTENSION
protected  FixedSizeWriteableFactory<V> valueFactory
           
 
Fields inherited from class java.util.AbstractList
modCount
 
Constructor Summary
protected FSArrayFile()
           
  FSArrayFile(Index index, String structureName)
          constructor
  FSArrayFile(String filename, boolean updateable, FixedSizeWriteableFactory<V> _valueFactory)
          default constructor
 
Method Summary
 void close()
           
 V get(int entryNumber)
           
 Iterator<V> iterator()
           
 int size()
           
static FSArrayFile.ArrayFileWriter writeFSArrayFile(String filename)
          writeFSArrayFile
 
Methods inherited from class java.util.AbstractList
add, add, addAll, clear, equals, hashCode, indexOf, lastIndexOf, listIterator, listIterator, remove, removeRange, set, subList
 
Methods inherited from class java.util.AbstractCollection
addAll, contains, containsAll, isEmpty, remove, removeAll, retainAll, toArray, toArray, toString
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface java.util.List
addAll, contains, containsAll, isEmpty, remove, removeAll, retainAll, toArray, toArray
 

Field Detail

USUAL_EXTENSION

public static final String USUAL_EXTENSION
USUAL_EXTENSION

See Also:
Constant Field Values

valueFactory

protected FixedSizeWriteableFactory<V extends org.apache.hadoop.io.Writable> valueFactory

numberOfEntries

protected int numberOfEntries
The number of entries in the file.


entrySize

protected int entrySize
total size of one key,value pair


dataFile

protected RandomDataInput dataFile
actual underlying data file


dataFilename

protected String dataFilename
filename of the underlying file

Constructor Detail

FSArrayFile

protected FSArrayFile()

FSArrayFile

public FSArrayFile(Index index,
                   String structureName)
            throws IOException
constructor

Parameters:
index -
structureName -
Throws:
IOException

FSArrayFile

public FSArrayFile(String filename,
                   boolean updateable,
                   FixedSizeWriteableFactory<V> _valueFactory)
            throws IOException
default constructor

Parameters:
filename -
updateable -
_valueFactory -
Throws:
IOException
Method Detail

size

public int size()
Specified by:
size in interface Collection<V extends org.apache.hadoop.io.Writable>
Specified by:
size in interface List<V extends org.apache.hadoop.io.Writable>
Specified by:
size in class AbstractCollection<V extends org.apache.hadoop.io.Writable>

get

public V get(int entryNumber)
Specified by:
get in interface List<V extends org.apache.hadoop.io.Writable>
Specified by:
get in class AbstractList<V extends org.apache.hadoop.io.Writable>

iterator

public Iterator<V> iterator()
Specified by:
iterator in interface Iterable<V extends org.apache.hadoop.io.Writable>
Specified by:
iterator in interface Collection<V extends org.apache.hadoop.io.Writable>
Specified by:
iterator in interface List<V extends org.apache.hadoop.io.Writable>
Overrides:
iterator in class AbstractList<V extends org.apache.hadoop.io.Writable>

writeFSArrayFile

public static FSArrayFile.ArrayFileWriter writeFSArrayFile(String filename)
                                                    throws IOException
writeFSArrayFile

Parameters:
filename -
Returns:
fixed size array file
Throws:
IOException

close

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


Terrier 3.6. Copyright © 2004-2011 University of Glasgow