This repository was archived by the owner on Mar 31, 2026. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 8
Expand file tree
/
Copy pathEnqueueCatalogLeafScanDriver.cs
More file actions
53 lines (45 loc) · 1.93 KB
/
EnqueueCatalogLeafScanDriver.cs
File metadata and controls
53 lines (45 loc) · 1.93 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
// Copyright (c) .NET Foundation. All rights reserved.
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
namespace NuGet.Insights.Worker.EnqueueCatalogLeafScan
{
public class EnqueueCatalogLeafScansDriver : ITableScanDriver<CatalogLeafScan>
{
private static readonly IList<string> DefaultSelectColumns = new[]
{
StorageUtility.PartitionKey,
StorageUtility.RowKey, // this is the LeafId
nameof(CatalogLeafScan.StorageSuffix),
nameof(CatalogLeafScan.ScanId),
nameof(CatalogLeafScan.PageId),
nameof(CatalogLeafScan.PackageId),
nameof(CatalogLeafScan.Min),
nameof(CatalogLeafScan.Max),
};
private readonly SchemaSerializer _serializer;
private readonly CatalogScanExpandService _expandService;
public EnqueueCatalogLeafScansDriver(
SchemaSerializer schemaSerializer,
CatalogScanExpandService expandService)
{
_serializer = schemaSerializer;
_expandService = expandService;
}
public IList<string> SelectColumns => DefaultSelectColumns;
public Task InitializeAsync(JsonElement? parameters)
{
return Task.CompletedTask;
}
public async Task ProcessEntitySegmentAsync(string tableName, JsonElement? parameters, IReadOnlyList<CatalogLeafScan> entities)
{
var deserializedParameters = (EnqueueCatalogLeafScansParameters)_serializer.Deserialize(parameters.Value).Data;
if (deserializedParameters.OneMessagePerId)
{
entities = entities
.GroupBy(x => x.PackageId, StringComparer.OrdinalIgnoreCase)
.Select(g => g.First())
.ToList();
}
await _expandService.EnqueueLeafScansAsync(entities);
}
}
}