Exemple #1
0
        private void CheckIndexState()
        {
            log.Debug("Checking Index state...");
            int last  = _index.GetLastIndexedRecordNumber();
            int count = _archive.Count();

            if (last < count)
            {
                log.Debug("Rebuilding index...");
                log.Debug("   last index count = " + last);
                log.Debug("   data items count = " + count);
                // check last index record and archive record
                //       rebuild index if needed
                for (int i = last; i < count; i++)
                {
                    bool deleted = false;
                    T    key     = _archive.GetKey(i, out deleted);
                    if (deleted == false)
                    {
                        _index.Set(key, i);
                    }
                    else
                    {
                        _index.RemoveKey(key);
                    }

                    if (i % 100000 == 0)
                    {
                        log.Debug("100,000 items re-indexed");
                    }
                }
                log.Debug("Rebuild index done.");
            }
        }