Package org.terrier.realtime.memory
Class MemoryMetaIndexMap
- java.lang.Object
-
- org.terrier.structures.indexing.MetaIndexBuilder
-
- org.terrier.realtime.memory.MemoryMetaIndex
-
- org.terrier.realtime.memory.MemoryMetaIndexMap
-
- All Implemented Interfaces:
java.io.Closeable
,java.io.Serializable
,java.lang.AutoCloseable
,MetaIndexMap
,MetaIndex
public class MemoryMetaIndexMap extends MemoryMetaIndex implements MetaIndexMap
A memory meta index structure that supports fast look-ups via a map. It stores additional information about each document, e.g. the docno or title. Access to the memory versions of the meta index are faster than the on-disk versions, but can use up large amounts of RAM to store.Properties
- indexer.meta.forward.keys - key names to store in the meta index
- indexer.meta.forward.keylens - max key lengths for keys to store (this is ignored unless metaindex.crop is set)
- metaindex.compressed.crop.long - should the content to store be cropped down to the length specified in indexer.meta.forward.keylens?
- Since:
- 4.0
- Author:
- Richard McCreadie, Stuart Mackie
- See Also:
- Serialized Form
-
-
Constructor Summary
Constructors Constructor Description MemoryMetaIndexMap()
Constructor.MemoryMetaIndexMap(java.lang.String[] keys, int[] keylengths)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
close()
Delete contents of metadata index (but keep keys).java.lang.String[]
getAllItems(int docid)
Obtain all metadata for specified document.int
getDocument(java.lang.String key, java.lang.String value)
Not implemented.java.lang.String
getItem(java.lang.String key, int docid)
Obtain metadata of specified type for specified document.java.lang.String[]
getItems(java.lang.String[] keys, int docid)
Obtain metadata of specified types for specified document.java.lang.String[][]
getItems(java.lang.String[] keys, int[] docids)
Obtain metadata of specified types for specified documents.java.lang.String[]
getItems(java.lang.String key, int[] docids)
Obtain metadata of specified type for specified documents.java.lang.String[]
getKeys()
Returns the keys of this meta indexjava.util.Iterator<java.lang.String[]>
iterator()
Return iterator over meta-data index.void
writeDocumentEntry(int docid, java.lang.String[] data)
void
writeDocumentEntry(int docid, java.util.Map<java.lang.String,java.lang.String> data)
Write meta-data for document.-
Methods inherited from class org.terrier.realtime.memory.MemoryMetaIndex
_binarySearch, getKeyLengths, getReverseKeys, size, writeDocumentEntry, writeDocumentEntry
-
Methods inherited from class org.terrier.structures.indexing.MetaIndexBuilder
create
-
-
-
-
Method Detail
-
getKeys
public java.lang.String[] getKeys()
Returns the keys of this meta index- Specified by:
getKeys
in interfaceMetaIndex
- Overrides:
getKeys
in classMemoryMetaIndex
-
getItem
public java.lang.String getItem(java.lang.String key, int docid) throws java.io.IOException
Obtain metadata of specified type for specified document.- Specified by:
getItem
in interfaceMetaIndex
- Overrides:
getItem
in classMemoryMetaIndex
- Throws:
java.io.IOException
-
getAllItems
public java.lang.String[] getAllItems(int docid) throws java.io.IOException
Obtain all metadata for specified document.- Specified by:
getAllItems
in interfaceMetaIndex
- Overrides:
getAllItems
in classMemoryMetaIndex
- Throws:
java.io.IOException
-
getItems
public java.lang.String[] getItems(java.lang.String key, int[] docids) throws java.io.IOException
Obtain metadata of specified type for specified documents.- Specified by:
getItems
in interfaceMetaIndex
- Overrides:
getItems
in classMemoryMetaIndex
- Throws:
java.io.IOException
-
getItems
public java.lang.String[] getItems(java.lang.String[] keys, int docid) throws java.io.IOException
Obtain metadata of specified types for specified document.- Specified by:
getItems
in interfaceMetaIndex
- Overrides:
getItems
in classMemoryMetaIndex
- Throws:
java.io.IOException
-
getItems
public java.lang.String[][] getItems(java.lang.String[] keys, int[] docids) throws java.io.IOException
Obtain metadata of specified types for specified documents. Return array is indexed by documents, then by metakeys.- Specified by:
getItems
in interfaceMetaIndex
- Overrides:
getItems
in classMemoryMetaIndex
- Throws:
java.io.IOException
-
writeDocumentEntry
public void writeDocumentEntry(int docid, java.util.Map<java.lang.String,java.lang.String> data) throws java.lang.Exception
Write meta-data for document.- Throws:
java.lang.Exception
-
writeDocumentEntry
public void writeDocumentEntry(int docid, java.lang.String[] data)
- Specified by:
writeDocumentEntry
in interfaceMetaIndexMap
-
getDocument
public int getDocument(java.lang.String key, java.lang.String value) throws java.io.IOException
Not implemented.- Specified by:
getDocument
in interfaceMetaIndex
- Overrides:
getDocument
in classMemoryMetaIndex
- Throws:
java.io.IOException
-
close
public void close() throws java.io.IOException
Delete contents of metadata index (but keep keys).- Specified by:
close
in interfacejava.lang.AutoCloseable
- Specified by:
close
in interfacejava.io.Closeable
- Overrides:
close
in classMemoryMetaIndex
- Throws:
java.io.IOException
-
iterator
public java.util.Iterator<java.lang.String[]> iterator()
Return iterator over meta-data index.- Overrides:
iterator
in classMemoryMetaIndex
-
-