Package org.terrier.realtime.memory
Class MemoryInvertedIndex
- java.lang.Object
-
- org.terrier.realtime.memory.MemoryInvertedIndex
-
- All Implemented Interfaces:
java.io.Closeable
,java.io.Serializable
,java.lang.AutoCloseable
,PostingIndex<MemoryPointer>
- Direct Known Subclasses:
MemoryFieldsInvertedIndex
public class MemoryInvertedIndex extends java.lang.Object implements PostingIndex<MemoryPointer>, java.io.Serializable
A basic inverted file implementation for use with MemoryIndex structures. This version does not support fields or blocks. Since it is a memory-based structure, access is via a MemoryPointer rather than BitIndexPointer.- Since:
- 4.0
- Author:
- Richard McCreadie, Stuart Mackie
- See Also:
- Serialized Form
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description class
MemoryInvertedIndex.BasicMemoryPostingList
class
MemoryInvertedIndex.InvertedIterator
Inverted index iterator.
-
Field Summary
Fields Modifier and Type Field Description protected DocumentIndex
doi
protected Lexicon<java.lang.String>
lex
protected gnu.trove.TIntObjectHashMap<MemoryPostingList>
postings
-
Constructor Summary
Constructors Constructor Description MemoryInvertedIndex(Lexicon<java.lang.String> lex, DocumentIndex doi)
Constructor.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
add(int ptr, int docid, int freq)
Add posting to inverted file.boolean
addOrUpdate(int ptr, int docid, int freq)
Adds or updates the frequency of the term denoted by ptr by freq.void
close()
DocumentIndex
getDoi()
IterablePosting
getPostings(Pointer pointer)
Returns the posting iterator given a pointer.PostingIndexInputStream
iterator()
Return an iterator over the inverted file.void
remove(int ptr)
Remove a term posting list from the index, e.g.void
setDoi(DocumentIndex doi)
-
-
-
Field Detail
-
doi
protected DocumentIndex doi
-
lex
protected Lexicon<java.lang.String> lex
-
postings
protected gnu.trove.TIntObjectHashMap<MemoryPostingList> postings
-
-
Constructor Detail
-
MemoryInvertedIndex
public MemoryInvertedIndex(Lexicon<java.lang.String> lex, DocumentIndex doi)
Constructor.
-
-
Method Detail
-
add
public void add(int ptr, int docid, int freq)
Add posting to inverted file.
-
addOrUpdate
public boolean addOrUpdate(int ptr, int docid, int freq)
Adds or updates the frequency of the term denoted by ptr by freq.- Returns:
- true if a new posting was created, false if the document already contained the term
-
remove
public void remove(int ptr)
Remove a term posting list from the index, e.g. remove a stopword- Parameters:
ptr
-
-
getPostings
public IterablePosting getPostings(Pointer pointer) throws java.io.IOException
Returns the posting iterator given a pointer.- Specified by:
getPostings
in interfacePostingIndex<MemoryPointer>
- Returns:
- the posting iterator given a pointer.
- 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
-
iterator
public PostingIndexInputStream iterator()
Return an iterator over the inverted file.
-
getDoi
public DocumentIndex getDoi()
-
setDoi
public void setDoi(DocumentIndex doi)
-
-