protected override SearchResult DoExecute(SearchParams p) { p.skip = this.LucQuery.Skip; var maxtop = p.numDocs - p.skip; if (maxtop < 1) { return(SearchResult.Empty); } SearchResult r = null; SearchResult r1 = null; var howManyList = new List <int>(Querying.DefaultTopAndGrowth); if (howManyList[howManyList.Count - 1] == 0) { howManyList[howManyList.Count - 1] = int.MaxValue; } if (p.top < int.MaxValue) { var howMany = p.top; if ((long)howMany > maxtop) { howMany = maxtop - p.skip; } while (howManyList.Count > 0) { if (howMany < howManyList[0]) { break; } howManyList.RemoveAt(0); } howManyList.Insert(0, howMany); } var top0 = p.top; for (var i = 0; i < howManyList.Count; i++) { var defaultTop = howManyList[i]; if (defaultTop == 0) { defaultTop = p.numDocs; } p.howMany = defaultTop; p.useHowMany = i < howManyList.Count - 1; var maxSize = i == 0 ? p.numDocs : r.totalCount; p.collectorSize = Math.Min(defaultTop, maxSize - p.skip) + p.skip; r1 = this.Search(p); if (i == 0) { r = r1; } else { r.Add(r1); } p.skip += r.nextIndex; p.top = top0 - r.result.Count; if (r.result.Count == 0 || r.result.Count >= top0 || r.result.Count >= r.totalCount) { break; } } return(r); }
protected override SearchResult DoExecute(Query query, bool allVersions, IndexReader idxReader, Stopwatch timer) { var numDocs = idxReader.NumDocs(); var start = this.LucQuery.Skip; var maxtop = numDocs - start; if (maxtop < 1) { return(SearchResult.Empty); } var user = this.LucQuery.User; var currentUser = AccessProvider.Current.GetCurrentUser(); if (user == null) { user = currentUser; } var isCurrentUser = user.Id == currentUser.Id; int top = this.LucQuery.Top != 0 ? this.LucQuery.Top : this.LucQuery.PageSize; if (top == 0) { top = int.MaxValue; } var searcher = new IndexSearcher(idxReader); var p = new SearchParams { query = query, allVersions = allVersions, searcher = searcher, user = user, isCurrentUser = isCurrentUser, skip = start, timer = timer, top = top }; SearchResult r = null; SearchResult r1 = null; try { var defaultTops = SenseNet.ContentRepository.Storage.StorageContext.Search.DefaultTopAndGrowth; var howManyList = new List <int>(defaultTops); if (howManyList[howManyList.Count - 1] == 0) { howManyList[howManyList.Count - 1] = int.MaxValue; } if (top < int.MaxValue) { var howMany = (top < int.MaxValue / 2) ? top * 2 : int.MaxValue; // numDocs; // * 4; // * 2; if ((long)howMany > maxtop) { howMany = maxtop - start; } while (howManyList.Count > 0) { if (howMany < howManyList[0]) { break; } howManyList.RemoveAt(0); } howManyList.Insert(0, howMany); } for (var i = 0; i < howManyList.Count; i++) { var defaultTop = howManyList[i]; if (defaultTop == 0) { defaultTop = numDocs; } p.howMany = defaultTop; p.useHowMany = i < howManyList.Count - 1; var maxSize = i == 0 ? numDocs : r.totalCount; p.collectorSize = Math.Min(defaultTop, maxSize - p.skip) + p.skip; r1 = Search(p); if (i == 0) { r = r1; } else { r.Add(r1); } p.skip += r.nextIndex; p.top = top - r.result.Count; if (r.result.Count >= top || r.result.Count >= r.totalCount) { break; } } p.timer.Stop(); return(r); } finally { if (searcher != null) { searcher.Close(); searcher = null; } } }