Package org.apache.maven.index.context
Class MergedIndexingContext
java.lang.Object
org.apache.maven.index.context.AbstractIndexingContext
org.apache.maven.index.context.MergedIndexingContext
- All Implemented Interfaces:
IndexingContext
A merged indexing context that offers read only "view" on multiple other indexing contexts merged and presented as
one. Usable for searching and publishing, but all write operations are basically noop.
- Author:
- cstamas
-
Field Summary
Fields inherited from interface org.apache.maven.index.context.IndexingContext
INDEX_CHAIN_ID, INDEX_CHUNK_COUNTER, INDEX_CHUNK_PREFIX, INDEX_FILE_PREFIX, INDEX_ID, INDEX_LEGACY_TIMESTAMP, INDEX_PACKER_PROPERTIES_FILE, INDEX_PROPERTY_PREFIX, INDEX_REMOTE_PROPERTIES_FILE, INDEX_TIME_DAY_FORMAT, INDEX_TIME_FORMAT, INDEX_TIMESTAMP, INDEX_UPDATER_PROPERTIES_FILE
-
Constructor Summary
ConstructorDescriptionMergedIndexingContext
(String id, String repositoryId, File repository, File indexDirectoryFile, boolean searchable, ContextMemberProvider membersProvider) MergedIndexingContext
(String id, String repositoryId, File repository, org.apache.lucene.store.Directory indexDirectory, boolean searchable, ContextMemberProvider membersProvider) Deprecated. -
Method Summary
Modifier and TypeMethodDescriptionorg.apache.lucene.search.IndexSearcher
Acquires a fresh instance ofIndexSearcher
.void
close
(boolean deleteFiles) Shuts down this context.void
commit()
Commits changes to context, eventually refreshing readers/searchers too.Gets all group names stored in the current indexing contextorg.apache.lucene.analysis.Analyzer
Returns the Lucene Analyzer of this context used for by IndexWriter and IndexSearcher.Returns the GavCalculator for this Context.getId()
Returns this indexing context id.List of IndexCreators used in this context.org.apache.lucene.store.Directory
Returns url for the index updateorg.apache.lucene.index.IndexWriter
Returns the Lucene IndexWriter (thread safe, shared instance) of this context.Returns location for the local repository.Returns repository id.Returns public repository url.Gets root group names stored in the current indexing contextint
getSize()
Returns a number that represents the "size" useful for doing comparisons between contexts (which one has more data indexed?).Returns index update timeboolean
Is the context searchable when doing "non-targeted" searches? Ie.void
merge
(org.apache.lucene.store.Directory directory) Merges content of given Lucene directory with this context.void
merge
(org.apache.lucene.store.Directory directory, DocumentFilter filter) Merges content of given Lucene directory with this context, but filters out the unwanted ones.void
merge
(org.apache.lucene.store.Directory directory, DocumentFilter filter, Set<String> allGroups, Set<String> rootGroups) Merges content of given Lucene directory with this context, but filters out the unwanted ones and adds the groups to the context.void
optimize()
Optimizes index.void
purge()
Purge (cleans) the context, deletes/empties the index and restores the context to new/empty state.void
Rebuilds stored group names from the indexvoid
releaseIndexSearcher
(org.apache.lucene.search.IndexSearcher indexSearcher) Releases theIndexSearcher
instance.void
replace
(org.apache.lucene.store.Directory directory) Replaces the Lucene index with the one from supplied directory.void
void
rollback()
Rolls back changes to context, eventually refreshing readers/searchers too.void
setAllGroups
(Collection<String> groups) Sets all group names stored in the current indexing contextprotected void
Sets index location.void
setRootGroups
(Collection<String> groups) Sets root group names stored in the current indexing contextvoid
setSearchable
(boolean searchable) Sets is the context searchable when doing "non-targeted" searches.void
void
updateTimestamp
(boolean save) void
updateTimestamp
(boolean save, Date date) Methods inherited from class org.apache.maven.index.context.AbstractIndexingContext
isReceivingUpdates
-
Constructor Details
-
MergedIndexingContext
public MergedIndexingContext(String id, String repositoryId, File repository, File indexDirectoryFile, boolean searchable, ContextMemberProvider membersProvider) throws IOException - Throws:
IOException
-
MergedIndexingContext
@Deprecated public MergedIndexingContext(String id, String repositoryId, File repository, org.apache.lucene.store.Directory indexDirectory, boolean searchable, ContextMemberProvider membersProvider) throws IOException Deprecated.- Throws:
IOException
-
-
Method Details
-
getMembers
-
getId
Description copied from interface:IndexingContext
Returns this indexing context id. -
getRepositoryId
Description copied from interface:IndexingContext
Returns repository id. -
getRepository
Description copied from interface:IndexingContext
Returns location for the local repository. -
getRepositoryUrl
Description copied from interface:IndexingContext
Returns public repository url. -
getIndexUpdateUrl
Description copied from interface:IndexingContext
Returns url for the index update -
isSearchable
public boolean isSearchable()Description copied from interface:IndexingContext
Is the context searchable when doing "non-targeted" searches? Ie. Should it take a part when searching without specifying context?- Returns:
-
setSearchable
public void setSearchable(boolean searchable) Description copied from interface:IndexingContext
Sets is the context searchable when doing "non-targeted" searches.- Parameters:
searchable
-
-
getTimestamp
Description copied from interface:IndexingContext
Returns index update time -
updateTimestamp
- Throws:
IOException
-
updateTimestamp
- Throws:
IOException
-
updateTimestamp
- Throws:
IOException
-
getSize
Description copied from interface:IndexingContext
Returns a number that represents the "size" useful for doing comparisons between contexts (which one has more data indexed?). The number return does not represent the count of ArtifactInfos, neither other "meaningful" info, it is purely to be used for inter-context comparisons only!- Returns:
- Throws:
IOException
-
acquireIndexSearcher
Description copied from interface:IndexingContext
Acquires a fresh instance ofIndexSearcher
. You have to release the received instance withIndexingContext.releaseIndexSearcher(IndexSearcher)
otherwise you are about to introduce leak.- Returns:
- Throws:
IOException
-
releaseIndexSearcher
public void releaseIndexSearcher(org.apache.lucene.search.IndexSearcher indexSearcher) throws IOException Description copied from interface:IndexingContext
Releases theIndexSearcher
instance.- Parameters:
indexSearcher
-- Throws:
IOException
-
getIndexWriter
Description copied from interface:IndexingContext
Returns the Lucene IndexWriter (thread safe, shared instance) of this context.- Returns:
- indexWriter
- Throws:
IOException
-
getIndexCreators
Description copied from interface:IndexingContext
List of IndexCreators used in this context.- Returns:
- list of index creators.
-
getAnalyzer
public org.apache.lucene.analysis.Analyzer getAnalyzer()Description copied from interface:IndexingContext
Returns the Lucene Analyzer of this context used for by IndexWriter and IndexSearcher. Note: this method always creates a new instance of analyzer!- Returns:
-
commit
Description copied from interface:IndexingContext
Commits changes to context, eventually refreshing readers/searchers too.- Throws:
IOException
-
rollback
Description copied from interface:IndexingContext
Rolls back changes to context, eventually refreshing readers/searchers too.- Throws:
IOException
-
optimize
Description copied from interface:IndexingContext
Optimizes index. According to Lucene 3.6+ Javadoc, there is no more sense to optimize, so this method might become "noop".- Throws:
IOException
-
close
Description copied from interface:IndexingContext
Shuts down this context.- Throws:
IOException
-
purge
Description copied from interface:IndexingContext
Purge (cleans) the context, deletes/empties the index and restores the context to new/empty state.- Throws:
IOException
-
merge
Description copied from interface:IndexingContext
Merges content of given Lucene directory with this context.- Parameters:
directory
- - the directory to merge- Throws:
IOException
-
merge
public void merge(org.apache.lucene.store.Directory directory, DocumentFilter filter) throws IOException Description copied from interface:IndexingContext
Merges content of given Lucene directory with this context, but filters out the unwanted ones.- Parameters:
directory
- - the directory to merge- Throws:
IOException
-
merge
public void merge(org.apache.lucene.store.Directory directory, DocumentFilter filter, Set<String> allGroups, Set<String> rootGroups) throws IOException Description copied from interface:IndexingContext
Merges content of given Lucene directory with this context, but filters out the unwanted ones and adds the groups to the context.- Parameters:
directory
- - the directory to merge- Throws:
IOException
-
replace
Description copied from interface:IndexingContext
Replaces the Lucene index with the one from supplied directory.- Parameters:
directory
-- Throws:
IOException
-
replace
public void replace(org.apache.lucene.store.Directory directory, Set<String> allGroups, Set<String> rootGroups) throws IOException - Throws:
IOException
-
getIndexDirectory
public org.apache.lucene.store.Directory getIndexDirectory() -
getIndexDirectoryFile
-
setIndexDirectoryFile
Sets index location. As usually index is persistent (is on disk), this will point to that value, but in some circumstances (ie, using RAMDisk for index), this will point to an existing tmp directory.- Throws:
IOException
-
getGavCalculator
Description copied from interface:IndexingContext
Returns the GavCalculator for this Context. Implies repository layout. -
setAllGroups
Description copied from interface:IndexingContext
Sets all group names stored in the current indexing context- Throws:
IOException
-
getAllGroups
Description copied from interface:IndexingContext
Gets all group names stored in the current indexing context- Throws:
IOException
-
setRootGroups
Description copied from interface:IndexingContext
Sets root group names stored in the current indexing context- Throws:
IOException
-
getRootGroups
Description copied from interface:IndexingContext
Gets root group names stored in the current indexing context- Throws:
IOException
-
rebuildGroups
Description copied from interface:IndexingContext
Rebuilds stored group names from the index- Throws:
IOException
-