public class WriterWithStats extends Object
Modifier and Type | Method and Description |
---|---|
void |
addDocuments(Collection<org.apache.lucene.document.Document> document) |
void |
close()
Closes this stream and releases any system resources associated with it.
|
void |
commit() |
void |
deleteDocuments(org.apache.lucene.index.Term identifyingTerm) |
long |
getCommitFrequency() |
DefaultIndexEngine.FlushPolicy |
getFlushPolicy() |
org.apache.lucene.index.IndexWriter |
getLuceneWriter() |
static com.atlassian.jira.index.Writer |
maybeWrap(com.atlassian.jira.index.WriterWrapper delegate,
boolean isRamDirectory) |
void |
optimize()
No longer supported, no-op since Jira 8.0
|
boolean |
replaceDocumentsWithVersion(Collection<org.apache.lucene.document.Document> newDocuments)
Replace a collection of documents identified by parent entity id
IndexDirectoryFactory.Name#getParentEntityIdFieldName()
with the new collection newDocuments if the version (= max entity version in newDocuments of the
new collection newDocuments as defined by IndexDirectoryFactory.Name#getEntityVersionFromDocument(Document)
is greater than or equal to the version of the existing collection (at least a single element exists with version lower then the
new collection version. |
void |
updateDocumentConditionally(org.apache.lucene.index.Term identifyingTerm,
org.apache.lucene.document.Document document,
String optimisticLockField)
Updates the document with the given
identifyingTerm if and only if the value optimisticLockField
in the index is equal to the value of document.get(optimisticLockField) . |
void |
updateDocuments(org.apache.lucene.index.Term identifyingTerm,
Collection<org.apache.lucene.document.Document> document) |
int |
updateDocumentsWithVersion(Collection<org.apache.lucene.document.Document> newDocuments)
For each document in
newDocuments updates the index if the version of the newDocuments element
is greater than or equal to the version of the document with the same id (as defined by IndexDirectoryFactory.Name.getEntityIdFromDocument(Document) )
in this index. |
public static com.atlassian.jira.index.Writer maybeWrap(com.atlassian.jira.index.WriterWrapper delegate, boolean isRamDirectory)
public org.apache.lucene.index.IndexWriter getLuceneWriter()
public void addDocuments(@Nonnull Collection<org.apache.lucene.document.Document> document) throws IOException
IOException
public void deleteDocuments(@Nonnull org.apache.lucene.index.Term identifyingTerm) throws IOException
IOException
public void updateDocuments(@Nonnull org.apache.lucene.index.Term identifyingTerm, @Nonnull Collection<org.apache.lucene.document.Document> document) throws IOException
IOException
public void updateDocumentConditionally(@Nonnull org.apache.lucene.index.Term identifyingTerm, @Nonnull org.apache.lucene.document.Document document, @Nonnull String optimisticLockField) throws IOException
identifyingTerm
if and only if the value optimisticLockField
in the index is equal to the value of document.get(optimisticLockField)
. This is useful for achieving
optimistic locking when updating the index (used in conjunction with a "version" or "updated date" field).identifyingTerm
- a Term that uniquely identifies the document to be updateddocument
- a new DocumentoptimisticLockField
- a String containing a field nameIOException
public int updateDocumentsWithVersion(@Nonnull Collection<org.apache.lucene.document.Document> newDocuments) throws IOException, IllegalStateException, IllegalArgumentException
newDocuments
updates the index if the version of the newDocuments
element
is greater than or equal to the version of the document with the same id (as defined by IndexDirectoryFactory.Name.getEntityIdFromDocument(Document)
)
in this index.
Note that this method is only supported if this Writer
is for one of the indexes defined in: IndexDirectoryFactory.Name
Note that this method does not replace the existing collection so it cannot be used for applying deletes.
Note that this method fails fast, i.e. it will throw when processing a single document throws and will skip the rest.
newDocuments
- collection of documents with ids and versionsnewDocuments
were processed)IOException
IllegalStateException
IllegalArgumentException
public boolean replaceDocumentsWithVersion(@Nonnull Collection<org.apache.lucene.document.Document> newDocuments) throws IOException, IllegalStateException, IllegalArgumentException
IndexDirectoryFactory.Name#getParentEntityIdFieldName()
with the new collection newDocuments
if the version (= max entity version in newDocuments
of the
new collection newDocuments
as defined by IndexDirectoryFactory.Name#getEntityVersionFromDocument(Document)
is greater than or equal to the version of the existing collection (at least a single element exists with version lower then the
new collection version.newDocuments
- collection of documents with parent id and versiontrue
if the new collection was added to indexIOException
IllegalStateException
IllegalArgumentException
public void optimize() throws IOException
IOException
public void close()
Closeable
public void commit()
public DefaultIndexEngine.FlushPolicy getFlushPolicy()
public long getCommitFrequency()
Copyright © 2002-2023 Atlassian. All Rights Reserved.