Пример #1
0
        int _IndexThreshold   = 0; //for optimize by score. Only return when index <= _IndexThreshold.

        /// <summary>
        ///
        /// </summary>
        /// <param name="wordIndexes">word indexes informations</param>
        /// <param name="dbProvider">current dbprovider</param>
        /// <param name="dictForGroupBy">dict to calculate group by. If is null, don't need output group by</param>
        /// <param name="top">for optimize by score, how many records want to return</param>
        public MultiWordsDocIdEnumerator(WordIndexForQuery[] wordIndexes, DBProvider dbProvider,
                                         Hubble.Core.SFQL.Parse.DocumentResultWhereDictionary dictForGroupBy, int top, bool needFilterUntokenizedConditions)
        {
            _GroupByDict = dictForGroupBy;
            _NeedGroupBy = _GroupByDict != null;

            _DBProvider = dbProvider;

            WordIndexes = wordIndexes;

            Array.Sort(WordIndexes);

            if (_NeedGroupBy)
            {
                _GroupByLimit = _DBProvider.Table.GroupByLimit;
                _GroupByStep  = WordIndexes[WordIndexes.Length - 1].RelTotalCount / _GroupByLimit;
                if (_GroupByStep <= 0)
                {
                    _GroupByStep = 1;
                }
            }

            _OptimizeByScore = false;

            if (top >= 0 && !needFilterUntokenizedConditions)
            {
                _OptimizeByScore = true;
                int relTop = top + _DBProvider.DelProvider.Count; //should include del records

                _IndexThreshold = -1;

                long sum = 0;
                while (sum < relTop)
                {
                    _IndexThreshold++;

                    if (_IndexThreshold >= WordIndexes.Length)
                    {
                        _OptimizeByScore = false;
                        break;
                    }

                    sum += WordIndexes[_IndexThreshold].RelTotalCount;
                }
            }

            Reset();
        }
Пример #2
0
 public MultiWordsDocIdEnumerator(WordIndexForQuery[] wordIndexes, DBProvider dbProvider,
                                  Hubble.Core.SFQL.Parse.DocumentResultWhereDictionary dictForGroupBy)
     : this(wordIndexes, dbProvider, dictForGroupBy, -1, false)
 {
 }