示例#1
0
        /// <summary>
        /// Generate index actions for each provided ID. This reads the version list per package ID so we want to
        /// parallel this work by <see cref="AzureSearchJobConfiguration.MaxConcurrentVersionListWriters"/>.
        /// </summary>
        private async Task GenerateIndexActionsAsync(
            ConcurrentBag <string> idsToIndex,
            ConcurrentBag <IdAndValue <IndexActions> > indexActionsToPush,
            SortedDictionary <string, long> changes)
        {
            await ParallelAsync.Repeat(
                async() =>
            {
                while (idsToIndex.TryTake(out var id))
                {
                    var indexActions = await _indexActionBuilder.UpdateAsync(
                        id,
                        sf => _searchDocumentBuilder.UpdateDownloadCount(id, sf, changes[id]));

                    if (indexActions.IsEmpty)
                    {
                        continue;
                    }

                    Guard.Assert(indexActions.Hijack.Count == 0, "There should be no hijack index changes.");

                    indexActionsToPush.Add(new IdAndValue <IndexActions>(id, indexActions));
                }
            },
                _options.Value.MaxConcurrentVersionListWriters);
        }