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.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
Nested Classes Modifier and Type Class Description static class
FSArrayFile.ArrayFileIterator<V extends org.apache.hadoop.io.Writable>
ArrayFileIterator classstatic interface
FSArrayFile.ArrayFileWriter
interface ArrayFileWriter
-
Field Summary
Fields Modifier and Type Field Description protected RandomDataInput
dataFile
actual underlying data fileprotected java.lang.String
dataFilename
filename of the underlying fileprotected int
entrySize
total size of one key,value pairprotected int
numberOfEntries
The number of entries in the file.static java.lang.String
USUAL_EXTENSION
USUAL_EXTENSIONprotected FixedSizeWriteableFactory<V>
valueFactory
-
Constructor Summary
Constructors Modifier Constructor Description protected
FSArrayFile()
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 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
-
-
-
-
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.IOException
default 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:
iterator
in interfacejava.util.Collection<V extends org.apache.hadoop.io.Writable>
- Specified by:
iterator
in interfacejava.lang.Iterable<V extends org.apache.hadoop.io.Writable>
- Specified by:
iterator
in interfacejava.util.List<V extends org.apache.hadoop.io.Writable>
- Overrides:
iterator
in 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:
close
in interfacejava.lang.AutoCloseable
- Specified by:
close
in interfacejava.io.Closeable
- Throws:
java.io.IOException
-
-