protected override LuceneSpellcheckerState <int, Card> CreateState(LuceneSearcherState <int, Card> searcherState, Spellchecker spellchecker, bool loaded) => new CardSpellcheckerState( _repo, spellchecker, (CardSearcherState)searcherState, (CardDocumentAdapter)Adapter, () => MaxCount, loaded);
protected override Directory CreateIndex(LuceneSearcherState <int, Card> state) { Directory index; if (_version.IsUpToDate) { using (var fsDirectory = FSDirectory.Open(_version.Directory)) index = new RAMDirectory(fsDirectory, IOContext.READ_ONCE); return(index); } if (!_repo.IsLocalizationLoadingComplete) { throw new InvalidOperationException($"{nameof(CardRepository)} must load localizations first"); } _version.CreateDirectory(); index = base.CreateIndex(state); if (index == null) { return(null); } index.SaveTo(_version.Directory); _version.SetIsUpToDate(); return(index); }
protected override Directory CreateIndex(LuceneSearcherState <long, DeckModel> state) { Directory index; if (!_indexCreated && _version.IsUpToDate) { lock (_syncDirectory) using (var fsDirectory = FSDirectory.Open(_version.Directory)) { index = new RAMDirectory(fsDirectory, IOContext.READ_ONCE); _indexCreated = true; return(index); } } IsUpdating = true; index = base.CreateIndex(state); if (index != null) { lock (_syncDirectory) { _version.CreateDirectory(); index.SaveTo(_version.Directory); _version.SetIsUpToDate(); } _indexCreated = true; } IsUpdating = false; return(index); }
protected override Directory CreateIndex(LuceneSearcherState <int, Card> state) { _version.RemoveObsoleteIndexes(); if (_version.IsUpToDate) { using var directory = FSDirectory.Open(_version.IndexDirectory.Value); return(new RAMDirectory(directory, IOContext.READ_ONCE)); } if (!_repo.IsLocalizationLoadingComplete.Signaled) { throw new InvalidOperationException($"{nameof(CardRepository)} must load localizations first"); } _version.CreateDirectory(); var index = base.CreateIndex(state); if (index == null) { return(null); } index.SaveTo(_version.IndexDirectory.Value); _version.SetIsUpToDate(); return(index); }
protected override LuceneSpellcheckerState <long, DeckModel> CreateState( LuceneSearcherState <long, DeckModel> searcherState, Spellchecker spellchecker, bool loaded) => new DeckSpellcheckerState( spellchecker, (DeckSearcherState)searcherState, (DeckDocumentAdapter)Adapter, () => MaxCount, loaded);
protected override Directory CreateIndex(LuceneSearcherState <long, DeckModel> state) { lock (_syncDirectory) _version.RemoveObsoleteIndexes(); Directory index; if (!_indexCreated && _version.IsUpToDate) { lock (_syncDirectory) { using var fsDirectory = FSDirectory.Open(_version.IndexDirectory.Value); index = new RAMDirectory(fsDirectory, IOContext.READ_ONCE); _indexCreated = true; return(index); } } IsUpdating = true; index = base.CreateIndex(state); if (index != null) { lock (_syncDirectory) { _version.CreateDirectory(); index.SaveTo(_version.IndexDirectory.Value); _version.SetIsUpToDate(); } _indexCreated = true; } IsUpdating = false; InvokeIndexingProgressEvent(); return(index); }
protected override Directory CreateIndex(LuceneSearcherState <long, DeckModel> searcherState) { lock (_syncDirectory) _version.RemoveObsoleteIndexes(); Directory index; if (!_indexCreated && _version.IsUpToDate) { lock (_syncDirectory) using (var fsDirectory = FSDirectory.Open(_version.IndexDirectory.Value)) index = new RAMDirectory(fsDirectory, IOContext.READ_ONCE); var spellchecker = CreateSpellchecker(); spellchecker.Load(index); var state = CreateState(searcherState, spellchecker, loaded: true); Update(state); _indexCreated = true; return(index); } index = base.CreateIndex(searcherState); if (index == null) { return(null); } lock (_syncDirectory) _version.CreateDirectory(); index.SaveTo(_version.IndexDirectory.Value); _version.SetIsUpToDate(); _indexCreated = true; return(index); }