Exemplo n.º 1
0
        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();
        }
Exemplo n.º 2
0
        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);
        }
Exemplo n.º 3
0
        protected virtual Directory CreateIndex(LuceneSearcherState <TId, TDoc> state)
        {
            state.IndexingProgress += InvokeIndexingProgressEvent;
            var result = state.CreateIndex();

            state.IndexingProgress -= InvokeIndexingProgressEvent;

            return(result);
        }
Exemplo n.º 4
0
        public void LoadIndex(LuceneSearcherState <TId, TDoc> searcherState)
        {
            if (!searcherState.IsLoaded)
            {
                throw new InvalidOperationException();
            }

            CreateIndex(searcherState);
        }
Exemplo n.º 5
0
        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;
        }
Exemplo n.º 6
0
 protected abstract LuceneSpellcheckerState <TId, TDoc> CreateState(LuceneSearcherState <TId, TDoc> searcherState, Spellchecker spellchecker, bool loaded);