Class FSArrayFile<V extends org.apache.hadoop.io.Writable>
- java.lang.Object
-
- java.util.AbstractCollection<E>
-
- java.util.AbstractList<V>
-
- org.terrier.structures.collections.FSArrayFile<V>
-
- Type Parameters:
V- Type of Writable
- All Implemented Interfaces:
java.io.Closeable,java.lang.AutoCloseable,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.CloseableA 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
Nested Classes Modifier and Type Class Description static classFSArrayFile.ArrayFileIterator<V extends org.apache.hadoop.io.Writable>ArrayFileIterator classstatic interfaceFSArrayFile.ArrayFileWriterinterface ArrayFileWriter
-
Field Summary
Fields Modifier and Type Field Description protected RandomDataInputdataFileactual underlying data fileprotected java.lang.StringdataFilenamefilename of the underlying fileprotected intentrySizetotal size of one key,value pairprotected intnumberOfEntriesThe number of entries in the file.static java.lang.StringUSUAL_EXTENSIONUSUAL_EXTENSIONprotected FixedSizeWriteableFactory<V>valueFactory
-
Constructor Summary
Constructors Modifier Constructor Description protectedFSArrayFile()FSArrayFile(java.lang.String filename, boolean updateable, FixedSizeWriteableFactory<V> _valueFactory)default constructorFSArrayFile(IndexOnDisk index, java.lang.String structureName)constructor
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description voidclose()Vget(int entryNumber)java.util.Iterator<V>iterator()intsize()static FSArrayFile.ArrayFileWriterwriteFSArrayFile(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
-
-
-
-
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(IndexOnDisk 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.IOExceptiondefault constructor- Parameters:
filename-updateable-_valueFactory-- Throws:
java.io.IOException
-
-
Method Detail
-
size
public int size()
-
get
public V get(int entryNumber)
-
iterator
public java.util.Iterator<V> iterator()
- Specified by:
iteratorin interfacejava.util.Collection<V extends org.apache.hadoop.io.Writable>- Specified by:
iteratorin interfacejava.lang.Iterable<V extends org.apache.hadoop.io.Writable>- Specified by:
iteratorin interfacejava.util.List<V extends org.apache.hadoop.io.Writable>- Overrides:
iteratorin classjava.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:
closein interfacejava.lang.AutoCloseable- Specified by:
closein interfacejava.io.Closeable- Throws:
java.io.IOException
-
-