org.terrier.structures
Class IndexUtil

java.lang.Object
  extended by org.terrier.structures.IndexUtil

public class IndexUtil
extends java.lang.Object

Class with handy utilities for use on an Index.

Since:
3.0

Constructor Summary
IndexUtil()
           
 
Method Summary
static void close(java.lang.Object o)
          Check to see if an object is closeable, and if so, close it.
static void configure(Index index, java.lang.Object o)
          Configures an object with the index, if the object implements IndexConfigurable
static boolean copyStructure(Index sourceIndex, Index destIndex, java.lang.String sourceStructureName, java.lang.String destinationStructureName)
          Copies an index structure from one index to another.
static void deleteIndex(java.lang.String path, java.lang.String prefix)
          Delete an existing index
static boolean deleteStructure(Index index, java.lang.String structureName)
          Delete the named structure from the specified index.
static void forceReloadStructure(Index index, java.lang.String structureName)
          Forces a structure to be reloaded, by removing it from the index's structure cache
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
static java.lang.String[] getStructures(Index index)
          Returns a list of the structures in the given index
static void main(java.lang.String[] args)
          Has some handy utilities for printing various index structures to System.out.
static void printDocumentIndex(Index index, java.lang.String structureName)
          Print the contents of the document index
static void printMetaIndex(Index index, java.lang.String structureName)
          Print the contents of the meta index
static void renameIndex(java.lang.String srcPath, java.lang.String srcPrefix, java.lang.String dstPath, java.lang.String dstPrefix)
          Move an index from one location to another
static boolean renameIndexStructure(Index index, java.lang.String sourceStructureName, java.lang.String destinationStructureName)
          Rename a structure within a given index.
static Index reOpenIndex(Index index)
          Reopen an existing index
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

IndexUtil

public IndexUtil()
Method Detail

main

public static void main(java.lang.String[] args)
                 throws java.lang.Exception
Has some handy utilities for printing various index structures to System.out.

Throws:
java.lang.Exception

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 on
structureName - which structure name to use
structure - 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 Index reOpenIndex(Index index)
                         throws java.io.IOException
Reopen an existing index

Throws:
java.io.IOException

getStructures

public static java.lang.String[] getStructures(Index 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.IOException
Move 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.IOException
Delete 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(Index 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 on
structureName - name of structure to delete
Returns:
true if structure was found and deleted, false otherwise
Throws:
java.io.IOException

copyStructure

public static boolean copyStructure(Index sourceIndex,
                                    Index 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

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.IOException
Check 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.


Terrier 3.5. Copyright © 2004-2011 University of Glasgow