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 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.java.lang.String[]
uncompress(byte[] compressed)
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.void
writeDocumentEntry(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:
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
-
writeDocumentEntry
public void writeDocumentEntry(java.lang.String[] data)
Description copied from class:MemoryMetaIndex
This method has been made public for creating- Overrides:
writeDocumentEntry
in classMemoryMetaIndex
-
iterator
public java.util.Iterator<java.lang.String[]> iterator()
Return iterator over meta-data index.- Overrides:
iterator
in classMemoryMetaIndex
-
uncompress
public java.lang.String[] uncompress(byte[] compressed)
-
-