internal void LoadIndex(LuceneSearcherState <TId, TDoc> state) { BeginLoad?.Invoke(); bool stateExisted = State != null; if (!stateExisted) { State = state; } var index = CreateIndex(state); if (index == null) { return; } state.Load(index); if (stateExisted) { State.Dispose(); State = state; } Loaded?.Invoke(); }
protected virtual Directory CreateIndex(LuceneSearcherState <TId, TDoc> searcherState) { var spellchecker = CreateSpellchecker(); var state = CreateState(searcherState, spellchecker, loaded: false); bool stateExisted = State != null; if (!stateExisted) { State = state; } void progressHandler() => IndexingProgress?.Invoke(); state.IndexingProgress += progressHandler; var result = state.CreateIndex(); state.IndexingProgress -= progressHandler; if (stateExisted) { State.Dispose(); State = state; } return(result); }
protected virtual Directory CreateIndex(LuceneSearcherState <TId, TDoc> state) { state.IndexingProgress += InvokeIndexingProgressEvent; var result = state.CreateIndex(); state.IndexingProgress -= InvokeIndexingProgressEvent; return(result); }
public void LoadIndex(LuceneSearcherState <TId, TDoc> searcherState) { if (!searcherState.IsLoaded) { throw new InvalidOperationException(); } CreateIndex(searcherState); }
protected LuceneSpellcheckerState( Spellchecker spellchecker, LuceneSearcherState <TId, TDoc> searcherState, IDocumentAdapter <TId, TDoc> adapter, Func <int> maxCount, bool loaded) { _spellchecker = spellchecker; _reader = searcherState.Reader; _adapter = adapter; _maxCount = maxCount; IsLoaded = loaded; }
protected abstract LuceneSpellcheckerState <TId, TDoc> CreateState(LuceneSearcherState <TId, TDoc> searcherState, Spellchecker spellchecker, bool loaded);