org.opensolaris.opengrok.index
Class IndexDatabase

java.lang.Object
  extended by org.opensolaris.opengrok.index.IndexDatabase

public class IndexDatabase
extends java.lang.Object

This class is used to create / update the index databases. Currently we use one index database per project.


Constructor Summary
IndexDatabase()
          Create a new instance of the Index Database.
IndexDatabase(Project project)
          Create a new instance of an Index Database for a given project
 
Method Summary
 boolean addDirectory(java.lang.String dir)
          By default the indexer will traverse all directories in the project.
 void createSpellingSuggestions()
          Generate a spelling suggestion for the definitions stored in defs
 boolean equals(java.lang.Object obj)
           
static org.apache.lucene.index.IndexReader getIndexReader(java.lang.String path)
          Get an indexReader for the Index database where a given file
 int hashCode()
           
 void interrupt()
          Interrupt the index generation (and the index generation will stop as soon as possible)
static void listAllFiles()
          List all files in all of the index databases
static void listAllFiles(java.util.List<java.lang.String> subFiles)
          List all files in some of the index databases
 void listFiles()
          List all of the files in this index database
 void listTokens(int freq)
           
 void optimize()
          Optimize the index database
 void update()
          Update the content of this index database
static void updateAll(java.util.concurrent.ExecutorService executor)
          Update the index database for all of the projects.
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

IndexDatabase

public IndexDatabase()
              throws java.io.IOException
Create a new instance of the Index Database. Use this constructor if you don't use any projects

Throws:
java.io.IOException - if an error occurs while creating directories

IndexDatabase

public IndexDatabase(Project project)
              throws java.io.IOException
Create a new instance of an Index Database for a given project

Parameters:
project - the project to create the database for
Throws:
java.io.IOException - if an errror occurs while creating directories
Method Detail

updateAll

public static void updateAll(java.util.concurrent.ExecutorService executor)
                      throws java.lang.Exception
Update the index database for all of the projects. Print progress to standard out.

Parameters:
executor - An executor to run the job
Throws:
java.lang.Exception - if an error occurs

addDirectory

public boolean addDirectory(java.lang.String dir)
By default the indexer will traverse all directories in the project. If you add directories with this function update will just process the specified directories.

Parameters:
dir - The directory to scan

update

public void update()
            throws java.lang.Exception
Update the content of this index database

Throws:
java.lang.Exception - if an error occurs

optimize

public void optimize()
Optimize the index database


createSpellingSuggestions

public void createSpellingSuggestions()
Generate a spelling suggestion for the definitions stored in defs


interrupt

public void interrupt()
Interrupt the index generation (and the index generation will stop as soon as possible)


listAllFiles

public static void listAllFiles()
                         throws java.lang.Exception
List all files in all of the index databases

Throws:
java.lang.Exception - if an error occurs

listAllFiles

public static void listAllFiles(java.util.List<java.lang.String> subFiles)
                         throws java.lang.Exception
List all files in some of the index databases

Parameters:
subFiles - Subdirectories for the various projects to list the files for (or null or an empty list to dump all projects)
Throws:
java.lang.Exception - if an error occurs

listFiles

public void listFiles()
               throws java.lang.Exception
List all of the files in this index database

Throws:
java.lang.Exception - if an error occurs

listTokens

public void listTokens(int freq)
                throws java.lang.Exception
Throws:
java.lang.Exception

getIndexReader

public static org.apache.lucene.index.IndexReader getIndexReader(java.lang.String path)
Get an indexReader for the Index database where a given file

Parameters:
path - the file to get the database for
Returns:
The index database where the file should be located or null if it cannot be located.

equals

public boolean equals(java.lang.Object obj)
Overrides:
equals in class java.lang.Object

hashCode

public int hashCode()
Overrides:
hashCode in class java.lang.Object