Package org.terrier.realtime.memory
Class MemoryDocumentIndex
- java.lang.Object
-
- org.terrier.realtime.memory.MemoryDocumentIndex
-
- All Implemented Interfaces:
java.io.Serializable
,DocumentIndex
- Direct Known Subclasses:
MemoryDocumentIndexFields
,MemoryDocumentIndexMap
public class MemoryDocumentIndex extends java.lang.Object implements DocumentIndex, java.io.Serializable
An in-memory version of the Document index. Stores the length of each document.- Since:
- 4.0
- Author:
- Richard McCreadie, Stuart Mackie
- See Also:
- Serialized Form
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description class
MemoryDocumentIndex.DocumentIterator
Document index iterator.class
MemoryDocumentIndex.DocumentIterator2
Document index iterator, iterates over DocumentIndexEntry only, in constrast to DocumentIterator
-
Field Summary
Fields Modifier and Type Field Description gnu.trove.TIntArrayList
docLengths
-
Constructor Summary
Constructors Constructor Description MemoryDocumentIndex()
Constructor.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
addDocument(int length)
Add document length to document index.DocumentIndexEntry
getDocumentEntry(int docid)
Return the document index entry based on its docid.int
getDocumentLength(int docid)
Return the length of the document.int
getNumberOfDocuments()
Return the number of documents.java.util.Iterator<DocumentIndexEntry>
iterator()
Return an iterator over the document index.java.util.Iterator<java.util.Map.Entry<java.lang.Integer,DocumentIndexEntry>>
iteratorOverEntries()
Return an iterator over the document index.void
setLength(int docid, int newLength)
-
-
-
Method Detail
-
addDocument
public void addDocument(int length)
Add document length to document index.
-
setLength
public void setLength(int docid, int newLength)
-
getDocumentEntry
public DocumentIndexEntry getDocumentEntry(int docid) throws java.io.IOException
Return the document index entry based on its docid.- Specified by:
getDocumentEntry
in interfaceDocumentIndex
- Returns:
- the document index entry based on its docid.
- Throws:
java.io.IOException
-
getDocumentLength
public int getDocumentLength(int docid) throws java.io.IOException
Return the length of the document.- Specified by:
getDocumentLength
in interfaceDocumentIndex
- Returns:
- the length of the document.
- Throws:
java.io.IOException
-
getNumberOfDocuments
public int getNumberOfDocuments()
Return the number of documents.- Specified by:
getNumberOfDocuments
in interfaceDocumentIndex
- Returns:
- the number of documents.
-
iteratorOverEntries
public java.util.Iterator<java.util.Map.Entry<java.lang.Integer,DocumentIndexEntry>> iteratorOverEntries()
Return an iterator over the document index. iterates over Map.Entry, where the key is the integer docid - only used my the Memory index, not the index-on-disk.
-
iterator
public java.util.Iterator<DocumentIndexEntry> iterator()
Return an iterator over the document index.
-
-