private CheckForUpdate ( int versionId, long timestamp ) : bool | ||
versionId | int | |
timestamp | long | |
Résultat | bool |
internal static void UpdateDocument(Term updateTerm, Document document) { // the optimistic overlapping detection algorithm here is tested in IndexingHistory_Fix**Overlap tests. change tests if this algorithm is changed. var versionId = _history.GetVersionId(document); var timestamp = _history.GetTimestamp(document); if (!_history.CheckForUpdate(versionId, timestamp)) { return; } SetFlagsForUpdate(document); //_writerRestartLock.EnterReadLock(); //try //{ // //in case the system was shut down in the meantime // if (!LuceneManager.Running) // return; // _writer.UpdateDocument(updateTerm, document); //} //finally //{ // _writerRestartLock.ExitReadLock(); //} using (var wrFrame = IndexWriterFrame.Get(false)) // // UpdateDocument { //in case the system was shut down in the meantime if (!LuceneManager.Running) { return; } _writer.UpdateDocument(updateTerm, document); } // check if indexing has interfered with other indexing activity for the same versionid if (_history.CheckHistoryChange(versionId, timestamp)) { RefreshDocument(versionId); } }
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)); }