-
-
Notifications
You must be signed in to change notification settings - Fork 123
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Cleanup, ensure correct disposal, ensure absolute max results
- Loading branch information
Showing
13 changed files
with
57 additions
and
70 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,2 @@ | ||
const Examine.Search.QueryOptions.AbsoluteMaxResults = 10000 -> int | ||
static Examine.SearchExtensions.Escape(this string s, float boost) -> Examine.Search.IExamineValue | ||
Check warning on line 2 in src/Examine.Core/PublicAPI.Unshipped.txt GitHub Actions / build
Check warning on line 2 in src/Examine.Core/PublicAPI.Unshipped.txt GitHub Actions / build
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -28,13 +28,15 @@ public class SyncedFileSystemDirectoryFactory : FileSystemDirectoryFactory | |
private readonly bool _tryFixMainIndexIfCorrupt; | ||
private readonly ILogger<SyncedFileSystemDirectoryFactory> _logger; | ||
private ExamineReplicator _replicator; | ||
private Directory _mainLuceneDir; | ||
|
||
public SyncedFileSystemDirectoryFactory( | ||
Check warning on line 33 in src/Examine.Lucene/Directories/SyncedFileSystemDirectoryFactory.cs GitHub Actions / build
|
||
DirectoryInfo localDir, | ||
DirectoryInfo mainDir, | ||
ILockFactory lockFactory, | ||
ILoggerFactory loggerFactory) | ||
: this(localDir, mainDir, lockFactory, loggerFactory, false) | ||
ILoggerFactory loggerFactory, | ||
IOptionsMonitor<LuceneDirectoryIndexOptions> indexOptions) | ||
: this(localDir, mainDir, lockFactory, loggerFactory, indexOptions, false) | ||
{ | ||
} | ||
|
||
|
@@ -43,8 +45,9 @@ public SyncedFileSystemDirectoryFactory( | |
DirectoryInfo mainDir, | ||
ILockFactory lockFactory, | ||
ILoggerFactory loggerFactory, | ||
IOptionsMonitor<LuceneDirectoryIndexOptions> indexOptions, | ||
bool tryFixMainIndexIfCorrupt) | ||
: base(mainDir, lockFactory) | ||
: base(mainDir, lockFactory, indexOptions) | ||
{ | ||
_localDir = localDir; | ||
_mainDir = mainDir; | ||
|
@@ -64,19 +67,19 @@ internal CreateResult TryCreateDirectory(LuceneIndex luceneIndex, bool forceUnlo | |
// used by the replicator, will be a short lived directory for each synced revision and deleted when finished. | ||
var tempDir = new DirectoryInfo(Path.Combine(_localDir.FullName, "Rep", Guid.NewGuid().ToString("N"))); | ||
|
||
var mainLuceneDir = base.CreateDirectory(luceneIndex, forceUnlock); | ||
_mainLuceneDir = base.CreateDirectory(luceneIndex, forceUnlock); | ||
var localLuceneDir = FSDirectory.Open( | ||
localLuceneIndexFolder, | ||
LockFactory.GetLockFactory(localLuceneIndexFolder)); | ||
|
||
var mainIndexExists = DirectoryReader.IndexExists(mainLuceneDir); | ||
var mainIndexExists = DirectoryReader.IndexExists(_mainLuceneDir); | ||
var localIndexExists = DirectoryReader.IndexExists(localLuceneDir); | ||
|
||
var mainResult = CreateResult.Init; | ||
|
||
if (mainIndexExists) | ||
{ | ||
mainResult = CheckIndexHealthAndFix(mainLuceneDir, luceneIndex.Name, _tryFixMainIndexIfCorrupt); | ||
mainResult = CheckIndexHealthAndFix(_mainLuceneDir, luceneIndex.Name, _tryFixMainIndexIfCorrupt); | ||
} | ||
|
||
// the main index is/was unhealthy or missing, lets check the local index if it exists | ||
|
@@ -108,7 +111,7 @@ internal CreateResult TryCreateDirectory(LuceneIndex luceneIndex, bool forceUnlo | |
? OpenMode.APPEND | ||
: OpenMode.CREATE; | ||
|
||
mainResult |= TryGetIndexWriter(openMode, mainLuceneDir, true, luceneIndex.Name, out var indexWriter); | ||
mainResult |= TryGetIndexWriter(openMode, _mainLuceneDir, true, luceneIndex.Name, out var indexWriter); | ||
using (indexWriter) | ||
{ | ||
if (!mainResult.HasFlag(CreateResult.SyncedFromLocal)) | ||
|
@@ -119,7 +122,7 @@ internal CreateResult TryCreateDirectory(LuceneIndex luceneIndex, bool forceUnlo | |
} | ||
|
||
// now create the replicator that will copy from local to main on schedule | ||
_replicator = new ExamineReplicator(_loggerFactory, luceneIndex, mainLuceneDir, tempDir); | ||
_replicator = new ExamineReplicator(_loggerFactory, luceneIndex, _mainLuceneDir, tempDir); | ||
|
||
if (forceUnlock) | ||
{ | ||
|
@@ -161,6 +164,7 @@ protected override void Dispose(bool disposing) | |
if (disposing) | ||
{ | ||
_replicator?.Dispose(); | ||
_mainLuceneDir?.Dispose(); | ||
} | ||
} | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,11 @@ | ||
Examine.Lucene.Directories.FileSystemDirectoryFactory.FileSystemDirectoryFactory(System.IO.DirectoryInfo baseDir, Examine.Lucene.Directories.ILockFactory lockFactory, Microsoft.Extensions.Options.IOptionsMonitor<Examine.Lucene.LuceneDirectoryIndexOptions> indexOptions) -> void | ||
Examine.Lucene.Directories.SyncedFileSystemDirectoryFactory.SyncedFileSystemDirectoryFactory(System.IO.DirectoryInfo localDir, System.IO.DirectoryInfo mainDir, Examine.Lucene.Directories.ILockFactory lockFactory, Microsoft.Extensions.Logging.ILoggerFactory loggerFactory, bool tryFixMainIndexIfCorrupt) -> void | ||
Examine.Lucene.Directories.TempEnvFileSystemDirectoryFactory.TempEnvFileSystemDirectoryFactory(Examine.Lucene.Directories.IApplicationIdentifier applicationIdentifier, Examine.Lucene.Directories.ILockFactory lockFactory, Microsoft.Extensions.Options.IOptionsMonitor<Examine.Lucene.LuceneDirectoryIndexOptions> indexOptions) -> void | ||
Examine.Lucene.LuceneIndexOptions.NrtEnabled.get -> bool | ||
Examine.Lucene.LuceneIndexOptions.NrtEnabled.set -> void | ||
Examine.Lucene.LuceneIndexOptions.NrtTargetMaxStaleSec.get -> double | ||
Examine.Lucene.LuceneIndexOptions.NrtTargetMaxStaleSec.set -> void | ||
Examine.Lucene.LuceneIndexOptions.NrtTargetMinStaleSec.get -> double | ||
Examine.Lucene.LuceneIndexOptions.NrtTargetMinStaleSec.set -> void | ||
Examine.Lucene.Search.SearcherReference.SearcherReference() -> void | ||
virtual Examine.Lucene.Providers.LuceneIndex.UpdateLuceneDocument(Lucene.Net.Index.Term term, Lucene.Net.Documents.Document doc) -> long? |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,45 +1,19 @@ | ||
using System; | ||
using Lucene.Net.Search; | ||
|
||
namespace Examine.Lucene.Search | ||
{ | ||
// TODO: struct | ||
public readonly struct SearcherReference : ISearcherReference | ||
{ | ||
//private bool _disposedValue; | ||
private readonly SearcherManager _searcherManager; | ||
private readonly IndexSearcher _searcher; | ||
|
||
public SearcherReference(SearcherManager searcherManager) | ||
{ | ||
_searcherManager = searcherManager; | ||
_searcher = _searcherManager.Acquire(); | ||
IndexSearcher = _searcherManager.Acquire(); | ||
} | ||
|
||
public IndexSearcher IndexSearcher | ||
{ | ||
get | ||
{ | ||
//if (_disposedValue) | ||
//{ | ||
// throw new ObjectDisposedException($"{nameof(SearcherReference)} is disposed"); | ||
//} | ||
|
||
//return _searcher ??= _searcherManager.Acquire(); | ||
return _searcher; | ||
} | ||
} | ||
public IndexSearcher IndexSearcher { get; } | ||
|
||
public void Dispose() | ||
{ | ||
//if (!_disposedValue) | ||
//{ | ||
//if (_searcher != null) | ||
//{ | ||
_searcherManager.Release(_searcher); | ||
//} | ||
// _disposedValue = true; | ||
//} | ||
} | ||
public void Dispose() => _searcherManager.Release(IndexSearcher); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters