public override void StartSearcher(string[] searchWords, Chunk chunk, IntermediateQueue intermediateQueue) { Task.Run(() => { new Searcher(searchWords, chunk, intermediateQueue).FindWordsAndPositions(); }); }
public async Task <Dictionary <string, List <int> > > GetWordsPositions() { IntermediateQueue intermediateQueue = new IntermediateQueue(); int countChunks = _chunks.Count(); foreach (var chunk in _chunks) { StartSearcher(_searchWords, chunk, intermediateQueue); } var collector = await CreateCollectorAsync(intermediateQueue, countChunks); return(collector); }
public override bool Equals(object obj) { IntermediateQueue secondQueue = (IntermediateQueue)obj; var l1 = _queue.ToArray(); var l2 = secondQueue._queue.ToArray(); if (l1.Length != l2.Length) { return(false); } for (int i = 0; i < l1.Length; i++) { if (l1[i].Key != l2[i].Key || l1[i].Value != l2[i].Value) { return(false); } } return(true); }
public override Task <Dictionary <string, List <int> > > CreateCollectorAsync(IntermediateQueue intermediateQueue, int countChunks) { return(Task <Dictionary <string, List <int> > > .Run(() => { return new Collector(intermediateQueue, countChunks).GetWordsAndPositionsList(); })); }
public abstract Task <Dictionary <string, List <int> > > CreateCollectorAsync(IntermediateQueue intermediateQueue, int countChunks);
public abstract void StartSearcher(string[] searchWords, Chunk chunk, IntermediateQueue intermediateQueue);
public Searcher(string[] searchWords, Chunk chunk, IntermediateQueue intermediateQueue) { _searchWords = searchWords; _chunk = chunk; _intermediateQueue = intermediateQueue; }
public Collector(IntermediateQueue intermediateQueue, int countChunks) { _intermediateQueue = intermediateQueue; _countChunks = countChunks; }