Package org.terrier.realtime.memory
Class MemoryCompressedMetaIndex
- java.lang.Object
-
- org.terrier.structures.indexing.MetaIndexBuilder
-
- org.terrier.realtime.memory.MemoryMetaIndex
-
- org.terrier.realtime.memory.MemoryCompressedMetaIndex
-
- All Implemented Interfaces:
java.io.Closeable,java.io.Serializable,java.lang.AutoCloseable,MetaIndexMap,MetaIndex
public class MemoryCompressedMetaIndex extends MemoryMetaIndex implements MetaIndexMap
An in-memory version of a Meta-data index. 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. This is a Meta index that heavily compresses its content. This will make it slower to access but is useful when storing large volumes of content. It uses GZIP compression on each record in the meta indexProperties
- 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, Dyaa Albakour
- See Also:
- Serialized Form
-
-
Constructor Summary
Constructors Constructor Description MemoryCompressedMetaIndex()Constructor.MemoryCompressedMetaIndex(java.lang.String[] keys, int[] keylengths)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidclose()Delete contents of metadata index (but keep keys).java.lang.String[]getAllItems(int docid)Obtain all metadata for specified document.intgetDocument(java.lang.String key, java.lang.String value)Not implemented.java.lang.StringgetItem(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.java.lang.String[]uncompress(byte[] compressed)voidwriteDocumentEntry(int docid, java.lang.String[] data)voidwriteDocumentEntry(int docid, java.util.Map<java.lang.String,java.lang.String> data)Write meta-data for document.voidwriteDocumentEntry(java.lang.String[] data)This method has been made public for creating-
Methods inherited from class org.terrier.realtime.memory.MemoryMetaIndex
_binarySearch, getKeyLengths, getReverseKeys, size, 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:
getKeysin interfaceMetaIndex- Overrides:
getKeysin classMemoryMetaIndex
-
getItem
public java.lang.String getItem(java.lang.String key, int docid) throws java.io.IOExceptionObtain metadata of specified type for specified document.- Specified by:
getItemin interfaceMetaIndex- Overrides:
getItemin classMemoryMetaIndex- Throws:
java.io.IOException
-
getAllItems
public java.lang.String[] getAllItems(int docid) throws java.io.IOExceptionObtain all metadata for specified document.- Specified by:
getAllItemsin interfaceMetaIndex- Overrides:
getAllItemsin classMemoryMetaIndex- Throws:
java.io.IOException
-
getItems
public java.lang.String[] getItems(java.lang.String key, int[] docids) throws java.io.IOExceptionObtain metadata of specified type for specified documents.- Specified by:
getItemsin interfaceMetaIndex- Overrides:
getItemsin classMemoryMetaIndex- Throws:
java.io.IOException
-
getItems
public java.lang.String[] getItems(java.lang.String[] keys, int docid) throws java.io.IOExceptionObtain metadata of specified types for specified document.- Specified by:
getItemsin interfaceMetaIndex- Overrides:
getItemsin classMemoryMetaIndex- Throws:
java.io.IOException
-
getItems
public java.lang.String[][] getItems(java.lang.String[] keys, int[] docids) throws java.io.IOExceptionObtain metadata of specified types for specified documents. Return array is indexed by documents, then by metakeys.- Specified by:
getItemsin interfaceMetaIndex- Overrides:
getItemsin classMemoryMetaIndex- Throws:
java.io.IOException
-
writeDocumentEntry
public void writeDocumentEntry(int docid, java.util.Map<java.lang.String,java.lang.String> data) throws java.lang.ExceptionWrite meta-data for document.- Throws:
java.lang.Exception
-
writeDocumentEntry
public void writeDocumentEntry(int docid, java.lang.String[] data)- Specified by:
writeDocumentEntryin interfaceMetaIndexMap
-
getDocument
public int getDocument(java.lang.String key, java.lang.String value) throws java.io.IOExceptionNot implemented.- Specified by:
getDocumentin interfaceMetaIndex- Overrides:
getDocumentin classMemoryMetaIndex- Throws:
java.io.IOException
-
close
public void close() throws java.io.IOExceptionDelete contents of metadata index (but keep keys).- Specified by:
closein interfacejava.lang.AutoCloseable- Specified by:
closein interfacejava.io.Closeable- Overrides:
closein classMemoryMetaIndex- Throws:
java.io.IOException
-
writeDocumentEntry
public void writeDocumentEntry(java.lang.String[] data)
Description copied from class:MemoryMetaIndexThis method has been made public for creating- Overrides:
writeDocumentEntryin classMemoryMetaIndex
-
iterator
public java.util.Iterator<java.lang.String[]> iterator()
Return iterator over meta-data index.- Overrides:
iteratorin classMemoryMetaIndex
-
uncompress
public java.lang.String[] uncompress(byte[] compressed)
-
-