private ProcessDelete ( Lucene.Net.Index.Term deleteTerms ) : void | ||
deleteTerms | Lucene.Net.Index.Term | |
return | void |
internal static void DeleteDocuments(Term[] deleteTerms, bool moveOrRename) { // the optimistic overlapping detection algorithm here is tested in IndexingHistory_Fix**Overlap tests. change tests if this algorithm is changed. if (moveOrRename) { _history.Remove(deleteTerms); } else { _history.ProcessDelete(deleteTerms); } SetFlagsForDelete(deleteTerms); //_writerRestartLock.EnterReadLock(); //try //{ // //in case the system was shut down in the meantime // if (!LuceneManager.Running) // return; // _writer.DeleteDocuments(deleteTerms); //} //finally //{ // _writerRestartLock.ExitReadLock(); //} using (var wrFrame = IndexWriterFrame.Get(false)) // // DeleteDocuments { //in case the system was shut down in the meantime if (!LuceneManager.Running) { return; } _writer.DeleteDocuments(deleteTerms); } // don't need to check if indexing interfered here. If it did, change is detected in overlapped adddocument/updatedocument, and refresh (re-delete) is called there. // deletedocuments will never detect change in index, since it sets timestamp in indexhistory to maxvalue. }
public void IndexingHistory_ProcessDelete() { var history = new IndexingHistory(); var historyAcc = new IndexingHistoryAccessor(history); var size = 5; historyAcc.Initialize(size); Assert.IsTrue(history.Count == 0, string.Format("history.Count is {0}, expected: 0 (size: {1})", history.Count, size)); history.ProcessDelete(42); Assert.IsFalse(history.CheckForAdd(42, 1111), "CheckForAdd(42, 1111) returned with true"); Assert.IsFalse(history.CheckForUpdate(42, 1112), "CheckForUpdate(42, 1111) returned with true"); Assert.IsTrue(history.CheckForUpdate(43, 1111), "CheckForAdd(43, 1111) first call returned with false"); history.ProcessDelete(43); Assert.IsFalse(history.CheckForUpdate(43, 1111), "CheckForUpdate(43, 1111) second call returned with true"); Assert.IsTrue(history.Count == 2, string.Format("history.Count is {0}, expected: 2 (size: {1})", history.Count, size)); }