public void AppendResults(Node node, SearchResultInfo resultInfo) { if (resultInfo.SearchId != Id) { throw new ArgumentException("Results are for a different search."); } var dirs = resultInfo.Directories.Select(d => new SearchResult(this, node, d)); var files = resultInfo.Files.Select(f => new SearchResult(this, node, f)).ToList(); var newResults = dirs.Concat(files).ToList(); this.results.AddRange(newResults); files.ForEach(f => { if (!this.allFileResults.ContainsKey(f.InfoHash)) { this.allFileResults.Add(f.InfoHash, new List <SearchResult>()); } this.allFileResults[f.InfoHash].Add(f); }); NewResults?.Invoke(this, new SearchResultsEventArgs(newResults)); }
public override UniformPair <ISet <MultiKey <EventBean> > > Join( EventBean[][] newDataPerStream, EventBean[][] oldDataPerStream, ExprEvaluatorContext exprEvaluatorContext) { NewResults.Clear(); // We add and remove data in one call to each index. // Most indexes will add first then remove as newdata and olddata may contain the same event. // Unique indexes may remove then add. for (int stream = 0; stream < newDataPerStream.Length; stream++) { var repositories = Repositories; for (int j = 0; j < repositories[stream].Length; j++) { repositories[stream][j].AddRemove(newDataPerStream[stream], oldDataPerStream[stream], exprEvaluatorContext); } } // for outer joins, execute each query strategy if (_isOuterJoins) { for (int i = 0; i < newDataPerStream.Length; i++) { if (newDataPerStream[i] != null) { QueryStrategies[i].Lookup(newDataPerStream[i], NewResults, exprEvaluatorContext); } } } // handle all-inner joins by executing the smallest number of event's query strategy else { int minStream = -1; int minStreamCount = -1; for (int i = 0; i < newDataPerStream.Length; i++) { if (newDataPerStream[i] != null) { if (newDataPerStream[i].Length == 0) { minStream = -1; break; } if (newDataPerStream[i].Length > minStreamCount) { minStream = i; minStreamCount = newDataPerStream[i].Length; } } } if (minStream != -1) { QueryStrategies[minStream].Lookup(newDataPerStream[minStream], NewResults, exprEvaluatorContext); } } return(new UniformPair <ISet <MultiKey <EventBean> > >(NewResults, OldResults)); }
private void OnNewResults(EventArgs e) { NewResults?.Invoke(this, e); }