Package org.opengrok.indexer.index
Class Indexer
java.lang.Object
org.opengrok.indexer.index.Indexer
Creates and updates an inverted source index as well as generates Xref, file
stats etc., if specified in the options.
We shall use / as path delimiter in whole opengrok for uuids and paths from Windows systems, the path shall be converted when entering the index or web and converted back if needed* to access original file
Windows already supports opening /var/opengrok
as C:\var\opengrok
-
Field Summary
Fields -
Method Summary
Modifier and TypeMethodDescriptionvoid
doIndexerExecution
(@Nullable Set<Project> projects, @Nullable IndexChangedListener progress, Map<Repository, Optional<Exception>> historyCacheResults) This is the second phase of the indexer which generates Lucene index by passing source code files throughctags
, generating xrefs and storing data from the source files in the index (along with history, if any).void
doIndexerExecution
(Set<Project> projects, IndexChangedListener progress) static Indexer
static void
Program entry point.static String[]
parseOptions
(String[] argv) Parse OpenGrok Indexer options This method was created so that it would be easier to write unit tests against the Indexer option parsing mechanism.prepareIndexer
(RuntimeEnvironment env, boolean searchRepositories, boolean addProjects, List<String> subFiles, List<String> repositories) Wrapper for prepareIndexer() that always generates history cache.prepareIndexer
(RuntimeEnvironment env, Set<String> searchPaths, boolean addProjects, boolean createHistoryCache, List<String> repositories) Generate history cache and/or scan the repositories.static int
The body ofmain(String[])
.void
sendToConfigHost
(RuntimeEnvironment env, String webAppURI) static void
writeConfigToFile
(RuntimeEnvironment env, String filename) Write configuration to a file.
-
Field Details
-
PATH_SEPARATOR
public static final char PATH_SEPARATOR- See Also:
-
PATH_SEPARATOR_STRING
-
-
Method Details
-
getInstance
-
main
Program entry point.- Parameters:
argv
- argument vector
-
runMain
The body ofmain(String[])
. AvoidsSystem.exit()
so that it can be used for testing without the test runner thinking the VM went away unexpectedly.- Parameters:
argv
- argument vector passed from the wrapper- Returns:
- 0 on success, positive number on error
-
parseOptions
Parse OpenGrok Indexer options This method was created so that it would be easier to write unit tests against the Indexer option parsing mechanism.Limit usage lines to
OptionParser.Option.MAX_DESCRIPTION_LINE_LENGTH
characters for concise formatting.- Parameters:
argv
- the command line arguments- Returns:
- array of remaining non option arguments
- Throws:
ParseException
- if parsing failed
-
writeConfigToFile
Write configuration to a file.- Parameters:
env
- runtime environmentfilename
- file name to write the configuration to- Throws:
IOException
- if I/O exception occurred
-
prepareIndexer
@TestOnly public Map<Repository,Optional<Exception>> prepareIndexer(RuntimeEnvironment env, boolean searchRepositories, boolean addProjects, List<String> subFiles, List<String> repositories) throws IndexerException, IOException Wrapper for prepareIndexer() that always generates history cache.- Returns:
- map of repository to optional exception
- Throws:
IndexerException
IOException
-
prepareIndexer
public Map<Repository,Optional<Exception>> prepareIndexer(RuntimeEnvironment env, Set<String> searchPaths, boolean addProjects, boolean createHistoryCache, List<String> repositories) throws IndexerException Generate history cache and/or scan the repositories.This is the first phase of the indexing where history cache is being generated for repositories (at least for those which support getting history per directory).
- Parameters:
env
- runtime environmentsearchPaths
- list of paths relative to source root in which to search for repositoriesaddProjects
- if true, add projectscreateHistoryCache
- create history cache flagrepositories
- list of repository paths relative to source root- Returns:
- map of repository to exception
- Throws:
IndexerException
- indexer exception
-
doIndexerExecution
@VisibleForTesting public void doIndexerExecution(Set<Project> projects, IndexChangedListener progress) throws IOException, IndexerException - Throws:
IOException
IndexerException
-
doIndexerExecution
public void doIndexerExecution(@Nullable @Nullable Set<Project> projects, @Nullable @Nullable IndexChangedListener progress, Map<Repository, Optional<Exception>> historyCacheResults) throws IOException, IndexerExceptionThis is the second phase of the indexer which generates Lucene index by passing source code files throughctags
, generating xrefs and storing data from the source files in the index (along with history, if any).- Parameters:
projects
- if notnull
, index just the projects specifiedprogress
- if notnull
, an object to receive notifications as indexer progress is madehistoryCacheResults
- per repository results of history cache update- Throws:
IOException
- if I/O exception occurredIndexerException
- if the indexing has failed for any reason
-
sendToConfigHost
-