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:
java.io.Closeable, java.lang.Iterable<V>, java.util.Collection<V>, java.util.List<V>
Direct Known Subclasses:
FSADocumentIndex, FSArrayFileInMem

public class FSArrayFile<V extends org.apache.hadoop.io.Writable>
extends java.util.AbstractList<V>
implements java.io.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  java.lang.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 java.lang.String USUAL_EXTENSION
          USUAL_EXTENSION
protected  FixedSizeWriteableFactory<V> valueFactory
           
 
Fields inherited from class java.util.AbstractList
modCount
 
Constructor Summary
protected FSArrayFile()
           
  FSArrayFile(Index index, java.lang.String structureName)
          constructor
  FSArrayFile(java.lang.String filename, boolean updateable, FixedSizeWriteableFactory<V> _valueFactory)
          default constructor
 
Method Summary
 void close()
           
 V get(int entryNumber)
           
 java.util.Iterator<V> iterator()
           
 int size()
           
static FSArrayFile.ArrayFileWriter writeFSArrayFile(java.lang.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 java.lang.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 java.lang.String dataFilename
filename of the underlying file

Constructor Detail

FSArrayFile

protected FSArrayFile()

FSArrayFile

public FSArrayFile(Index index,
                   java.lang.String structureName)
            throws java.io.IOException
constructor

Parameters:
index -
structureName -
Throws:
java.io.IOException

FSArrayFile

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

Parameters:
filename -
updateable -
_valueFactory -
Throws:
java.io.IOException
Method Detail

size

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

get

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

iterator

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

writeFSArrayFile

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

Parameters:
filename -
Returns:
fixed size array file
Throws:
java.io.IOException

close

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


Terrier 3.5. Copyright © 2004-2011 University of Glasgow