CheckForAdd() приватный Метод

private CheckForAdd ( int versionId, long timestamp ) : bool
versionId int
timestamp long
Результат bool
Пример #1
0
        /*-----------------------------------------------------------------------------------------*/

        internal static void AddCompleteDocument(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.CheckForAdd(versionId, timestamp))
            {
                return;
            }
            //_writerRestartLock.EnterReadLock();
            //try
            //{
            //    //in case the system was shut down in the meantime
            //    if (!LuceneManager.Running)
            //        return;
            //    if (_executingUnprocessedIndexingActivities)
            //        _writer.DeleteDocuments(GetVersionIdTerm(versionId));
            //    _writer.AddDocument(document);
            //}
            //finally
            //{
            //    _writerRestartLock.ExitReadLock();
            //}
            using (var wrFrame = IndexWriterFrame.Get(false)) // // AddCompleteDocument
            {
                if (!LuceneManager.Running)
                {
                    return;
                }
                if (_executingUnprocessedIndexingActivities)
                {
                    wrFrame.IndexWriter.DeleteDocuments(GetVersionIdTerm(versionId));
                }
                wrFrame.IndexWriter.AddDocument(document);
            }

            // check if indexing has interfered with other indexing activity for the same versionid
            if (_history.CheckHistoryChange(versionId, timestamp))
            {
                RefreshDocument(versionId);
            }
        }
Пример #2
0
        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));
        }