Package org.terrier.realtime.memory
Class MemoryDocumentIndexMap
- java.lang.Object
-
- org.terrier.realtime.memory.MemoryDocumentIndex
-
- org.terrier.realtime.memory.MemoryDocumentIndexMap
-
- All Implemented Interfaces:
java.io.Serializable
,DocumentIndex
- Direct Known Subclasses:
MemoryDocumentIndexFieldsMap
public class MemoryDocumentIndexMap extends MemoryDocumentIndex
This class is a special variant of the Memory index class where the Document index is backed by a fast mapping structure in memory.- Since:
- 4.0
- Author:
- Richard McCreadie, Dyaa Albakour
- See Also:
- Serialized Form
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description class
MemoryDocumentIndexMap.DocumentMapIterator2
Document index iterator, iterates over DocumentIndexEntry only.-
Nested classes/interfaces inherited from class org.terrier.realtime.memory.MemoryDocumentIndex
MemoryDocumentIndex.DocumentIterator, MemoryDocumentIndex.DocumentIterator2
-
-
Field Summary
-
Fields inherited from class org.terrier.realtime.memory.MemoryDocumentIndex
docLengths
-
-
Constructor Summary
Constructors Constructor Description MemoryDocumentIndexMap()
Constructor.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
addDocument(int length)
Add document length to document index.void
addDocument(int docid, int length)
Add document length to document index.void
close()
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.-
Methods inherited from class org.terrier.realtime.memory.MemoryDocumentIndex
setLength
-
-
-
-
Method Detail
-
addDocument
public void addDocument(int docid, int length)
Add document length to document index.
-
addDocument
public void addDocument(int length)
Description copied from class:MemoryDocumentIndex
Add document length to document index.- Overrides:
addDocument
in classMemoryDocumentIndex
-
getDocumentEntry
public DocumentIndexEntry getDocumentEntry(int docid)
Return the document index entry based on its docid.- Specified by:
getDocumentEntry
in interfaceDocumentIndex
- Overrides:
getDocumentEntry
in classMemoryDocumentIndex
- Returns:
- the document index entry based on its docid.
-
getDocumentLength
public int getDocumentLength(int docid)
Return the length of the document.- Specified by:
getDocumentLength
in interfaceDocumentIndex
- Overrides:
getDocumentLength
in classMemoryDocumentIndex
- Returns:
- the length of the document.
-
getNumberOfDocuments
public int getNumberOfDocuments()
Description copied from class:MemoryDocumentIndex
Return the number of documents.- Specified by:
getNumberOfDocuments
in interfaceDocumentIndex
- Overrides:
getNumberOfDocuments
in classMemoryDocumentIndex
- Returns:
- the number of documents.
-
iteratorOverEntries
public java.util.Iterator<java.util.Map.Entry<java.lang.Integer,DocumentIndexEntry>> iteratorOverEntries()
Description copied from class:MemoryDocumentIndex
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.- Overrides:
iteratorOverEntries
in classMemoryDocumentIndex
-
iterator
public java.util.Iterator<DocumentIndexEntry> iterator()
Description copied from class:MemoryDocumentIndex
Return an iterator over the document index.- Overrides:
iterator
in classMemoryDocumentIndex
-
close
public void close()
-
-