Package org.terrier.structures
Class IndexUtil
- java.lang.Object
-
- org.terrier.structures.IndexUtil
-
public class IndexUtil extends java.lang.ObjectClass with handy utilities for use on an Index.- Since:
- 3.0
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classIndexUtil.Command
-
Constructor Summary
Constructors Constructor Description IndexUtil()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static voidclose(java.lang.Object o)Check to see if an object is closeable, and if so, close it.static voidconfigure(Index index, java.lang.Object o)Configures an object with the index, if the object implements IndexConfigurablestatic booleancopyStructure(IndexOnDisk sourceIndex, IndexOnDisk destIndex, java.lang.String sourceStructureName, java.lang.String destinationStructureName)Copies an index structure from one index to another.static voiddeleteIndex(java.lang.String path, java.lang.String prefix)Delete an existing indexstatic booleandeleteStructure(IndexOnDisk index, java.lang.String structureName)Delete the named structure from the specified index.static voidforceReloadStructure(Index index, java.lang.String structureName)Forces a structure to be reloaded, by removing it from the index's structure cachestatic voidforceStructure(Index index, java.lang.String structureName, java.lang.Object structure)Force the specified object into the structure cache of the specified object, as the given structure namestatic intgetFieldId(Index index, java.lang.String structureName, java.lang.String fieldName)static java.lang.String[]getStructures(PropertiesIndex index)Returns a list of the structures in the given indexstatic booleanisStructureOpen(IndexOnDisk index, java.lang.String structureName)Checks the underlying structurecache of the specificed index to see if the named index structure is there.static voidmain(java.lang.String[] args)Has some handy utilities for printing various index structures to System.out, such as: --printbitfile - print the bit file with the specified name --printbitentry - print one entry in a bit posting index. --printlex - print the entire lexicon --printdocument - print the document index --printlist - print the named list (e.g.static voidprintDocumentIndex(Index index, java.lang.String structureName)Print the contents of the document indexstatic voidprintMetaIndex(Index index, java.lang.String structureName)Print the contents of the meta indexstatic voidprintMetaIndexJson(Index index, java.lang.String structureName)static voidrenameIndex(java.lang.String srcPath, java.lang.String srcPrefix, java.lang.String dstPath, java.lang.String dstPrefix)Move an index from one location to anotherstatic booleanrenameIndexStructure(Index _index, java.lang.String sourceStructureName, java.lang.String destinationStructureName)Rename a structure within a given index.static IndexOnDiskreOpenIndex(Index index)static IndexOnDiskreOpenIndex(IndexOnDisk index)Reopen an existing index
-
-
-
Method Detail
-
main
public static void main(java.lang.String[] args)
Has some handy utilities for printing various index structures to System.out, such as:- --printbitfile - print the bit file with the specified name
- --printbitentry - print one entry in a bit posting index.
- --printlex - print the entire lexicon
- --printdocument - print the document index
- --printlist - print the named list (e.g. document index)
- --printmeta - print the meta index
-
forceStructure
public static void forceStructure(Index index, java.lang.String structureName, java.lang.Object structure)
Force the specified object into the structure cache of the specified object, as the given structure name- Parameters:
index- Index to operate onstructureName- which structure name to usestructure- which object to put into the structure cache
-
forceReloadStructure
public static void forceReloadStructure(Index index, java.lang.String structureName)
Forces a structure to be reloaded, by removing it from the index's structure cache
-
reOpenIndex
public static IndexOnDisk reOpenIndex(Index index) throws java.io.IOException
- Throws:
java.io.IOException
-
reOpenIndex
public static IndexOnDisk reOpenIndex(IndexOnDisk index) throws java.io.IOException
Reopen an existing index- Throws:
java.io.IOException
-
getStructures
public static java.lang.String[] getStructures(PropertiesIndex index)
Returns a list of the structures in the given index
-
renameIndex
public static void renameIndex(java.lang.String srcPath, java.lang.String srcPrefix, java.lang.String dstPath, java.lang.String dstPrefix) throws java.io.IOExceptionMove an index from one location to another- Throws:
java.io.IOException
-
deleteIndex
public static void deleteIndex(java.lang.String path, java.lang.String prefix) throws java.io.IOExceptionDelete an existing index- Throws:
java.io.IOException
-
printDocumentIndex
public static void printDocumentIndex(Index index, java.lang.String structureName) throws java.io.IOException
Print the contents of the document index- Throws:
java.io.IOException
-
deleteStructure
public static boolean deleteStructure(IndexOnDisk index, java.lang.String structureName) throws java.io.IOException
Delete the named structure from the specified index. Deletes files as well.- Parameters:
index- - index to operate onstructureName- name of structure to delete- Returns:
- true if structure was found and deleted, false otherwise
- Throws:
java.io.IOException
-
isStructureOpen
public static boolean isStructureOpen(IndexOnDisk index, java.lang.String structureName)
Checks the underlying structurecache of the specificed index to see if the named index structure is there.- Parameters:
index- index to examinestructureName- what structure- Returns:
- true if the structure cache contains the item
-
copyStructure
public static boolean copyStructure(IndexOnDisk sourceIndex, IndexOnDisk destIndex, java.lang.String sourceStructureName, java.lang.String destinationStructureName) throws java.io.IOException
Copies an index structure from one index to another.- Parameters:
sourceIndex-destIndex-sourceStructureName-destinationStructureName-- Throws:
java.io.IOException- if an IO problem occurs
-
printMetaIndex
public static void printMetaIndex(Index index, java.lang.String structureName) throws java.io.IOException
Print the contents of the meta index- Throws:
java.io.IOException
-
printMetaIndexJson
public static void printMetaIndexJson(Index index, java.lang.String structureName) throws java.io.IOException
- Throws:
java.io.IOException
-
getFieldId
public static int getFieldId(Index index, java.lang.String structureName, java.lang.String fieldName)
-
renameIndexStructure
public static boolean renameIndexStructure(Index _index, java.lang.String sourceStructureName, java.lang.String destinationStructureName) throws java.io.IOException
Rename a structure within a given index.- Returns:
- Returns true iff a structure was successfully renamed.
- Throws:
java.io.IOException
-
configure
public static void configure(Index index, java.lang.Object o)
Configures an object with the index, if the object implements IndexConfigurable
-
close
public static void close(java.lang.Object o) throws java.io.IOExceptionCheck to see if an object is closeable, and if so, close it. Propagate any exception thrown.- Parameters:
o- object to check for being closeable.- Throws:
java.io.IOException- if exception thrown while closing.
-
-