org.terrier.structures
Class IndexUtil

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

public class IndexUtil
extends Object

Class with handy utilities for use on an Index.

Since:
3.0

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

Throws:
Exception

forceStructure

public static void forceStructure(Index index,
                                  String structureName,
                                  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,
                                        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 IOException
Reopen an existing index

Throws:
IOException

getStructures

public static String[] getStructures(Index index)
Returns a list of the structures in the given index


renameIndex

public static void renameIndex(String srcPath,
                               String srcPrefix,
                               String dstPath,
                               String dstPrefix)
                        throws IOException
Move an index from one location to another

Throws:
IOException

deleteIndex

public static void deleteIndex(String path,
                               String prefix)
                        throws IOException
Delete an existing index

Throws:
IOException

printDocumentIndex

public static void printDocumentIndex(Index index,
                                      String structureName)
                               throws IOException
Print the contents of the document index

Throws:
IOException

deleteStructure

public static boolean deleteStructure(Index index,
                                      String structureName)
                               throws 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:
IOException

copyStructure

public static boolean copyStructure(Index sourceIndex,
                                    Index destIndex,
                                    String sourceStructureName,
                                    String destinationStructureName)
                             throws IOException
Copies an index structure from one index to another.

Parameters:
sourceIndex -
destIndex -
sourceStructureName -
destinationStructureName -
Throws:
IOException - if an IO problem occurs

printMetaIndex

public static void printMetaIndex(Index index,
                                  String structureName)
                           throws IOException
Print the contents of the meta index

Throws:
IOException

renameIndexStructure

public static boolean renameIndexStructure(Index index,
                                           String sourceStructureName,
                                           String destinationStructureName)
                                    throws IOException
Rename a structure within a given index.

Returns:
Returns true iff a structure was successfully renamed.
Throws:
IOException

configure

public static void configure(Index index,
                             Object o)
Configures an object with the index, if the object implements IndexConfigurable


close

public static void close(Object o)
                  throws 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:
IOException - if exception thrown while closing.


Terrier 3.6. Copyright © 2004-2011 University of Glasgow