Skip to content

Commit c22beae

Browse files
authored
Support ScannedCount on DynamoDb Document Model (#3751)
1 parent 008b072 commit c22beae

File tree

435 files changed

+5835
-65
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

435 files changed

+5835
-65
lines changed
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
{
2+
"services": [
3+
{
4+
"serviceName": "DynamoDBv2",
5+
"type": "patch",
6+
"changeLogMessages": [
7+
"Exposed ScannedCount property on the Search class within the Document Model."
8+
]
9+
}
10+
]
11+
}

generator/ServiceClientGeneratorLib/Generators/ProjectFiles/VS2017ProjectFile.cs

Lines changed: 69 additions & 54 deletions
Large diffs are not rendered by default.

generator/ServiceClientGeneratorLib/Generators/ProjectFiles/VS2017ProjectFile.tt

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -153,9 +153,18 @@
153153
<#
154154
else
155155
{
156+
if(this.Project.AssemblyName == "AWSSDK.UnitTests.DynamoDBv2.NetFramework")
157+
{
158+
#>
159+
<AssemblyOriginatorKeyFile>../../../../awssdk.dll.snk</AssemblyOriginatorKeyFile>
160+
<#
161+
}
162+
else
163+
{
156164
#>
157165
<AssemblyOriginatorKeyFile>../../../awssdk.dll.snk</AssemblyOriginatorKeyFile>
158166
<#
167+
}
159168
}
160169
#>
161170
</PropertyGroup>

generator/ServiceClientGeneratorLib/Generators/SourceFiles/AssemblyInfo.cs

Lines changed: 20 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -69,12 +69,24 @@ public override string TransformText()
6969

7070
#line default
7171
#line hidden
72-
this.Write(@""")]
73-
#else
74-
#error Unknown platform constant - unable to set correct AssemblyDescription
75-
#endif
76-
77-
[assembly: AssemblyConfiguration("""")]
72+
this.Write("\")]\r\n#else\r\n#error Unknown platform constant - unable to set correct AssemblyDesc" +
73+
"ription\r\n#endif\r\n\r\n");
74+
75+
#line 25 "C:\codebase\v4\aws-sdk-net-v4\generator\ServiceClientGeneratorLib\Generators\SourceFiles\AssemblyInfo.tt"
76+
if (this.Config.AssemblyTitle=="AWSSDK.DynamoDBv2") {
77+
78+
#line default
79+
#line hidden
80+
this.Write(@"[assembly: InternalsVisibleTo(""AWSSDK.UnitTests.DynamoDBv2.NetFramework, PublicKey=0024000004800000940000000602000000240000525341310004000001000100db5f59f098d27276c7833875a6263a3cc74ab17ba9a9df0b52aedbe7252745db7274d5271fd79c1f08f668ecfa8eaab5626fa76adc811d3c8fc55859b0d09d3bc0a84eecd0ba891f2b8a2fc55141cdcc37c2053d53491e650a479967c3622762977900eddbf1252ed08a2413f00a28f3a0752a81203f03ccb7f684db373518b4"")]
81+
[assembly: InternalsVisibleTo(""AWSSDK.UnitTests.NetFramework, PublicKey=0024000004800000940000000602000000240000525341310004000001000100db5f59f098d27276c7833875a6263a3cc74ab17ba9a9df0b52aedbe7252745db7274d5271fd79c1f08f668ecfa8eaab5626fa76adc811d3c8fc55859b0d09d3bc0a84eecd0ba891f2b8a2fc55141cdcc37c2053d53491e650a479967c3622762977900eddbf1252ed08a2413f00a28f3a0752a81203f03ccb7f684db373518b4"")]
82+
");
83+
84+
#line 28 "C:\codebase\v4\aws-sdk-net-v4\generator\ServiceClientGeneratorLib\Generators\SourceFiles\AssemblyInfo.tt"
85+
}
86+
87+
#line default
88+
#line hidden
89+
this.Write(@"[assembly: AssemblyConfiguration("""")]
7890
[assembly: AssemblyProduct(""Amazon Web Services SDK for .NET"")]
7991
[assembly: AssemblyCompany(""Amazon.com, Inc"")]
8092
[assembly: AssemblyCopyright(""Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved."")]
@@ -98,14 +110,14 @@ public override string TransformText()
98110
// [assembly: AssemblyVersion(""1.0.*"")]
99111
[assembly: AssemblyVersion(""");
100112

101-
#line 47 "C:\codebase\v4\aws-sdk-net-v4\generator\ServiceClientGeneratorLib\Generators\SourceFiles\AssemblyInfo.tt"
113+
#line 51 "C:\codebase\v4\aws-sdk-net-v4\generator\ServiceClientGeneratorLib\Generators\SourceFiles\AssemblyInfo.tt"
102114
this.Write(this.ToStringHelper.ToStringWithCulture(this.Config.ServiceVersion));
103115

104116
#line default
105117
#line hidden
106118
this.Write("\")]\r\n[assembly: AssemblyFileVersion(\"");
107119

108-
#line 48 "C:\codebase\v4\aws-sdk-net-v4\generator\ServiceClientGeneratorLib\Generators\SourceFiles\AssemblyInfo.tt"
120+
#line 52 "C:\codebase\v4\aws-sdk-net-v4\generator\ServiceClientGeneratorLib\Generators\SourceFiles\AssemblyInfo.tt"
109121
this.Write(this.ToStringHelper.ToStringWithCulture(this.Config.ServiceFileVersion));
110122

111123
#line default

generator/ServiceClientGeneratorLib/Generators/SourceFiles/AssemblyInfo.tt

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,10 @@ using System.Runtime.CompilerServices;
2222
#error Unknown platform constant - unable to set correct AssemblyDescription
2323
#endif
2424

25+
<# if (this.Config.AssemblyTitle=="AWSSDK.DynamoDBv2") { #>
26+
[assembly: InternalsVisibleTo("AWSSDK.UnitTests.DynamoDBv2.NetFramework, PublicKey=0024000004800000940000000602000000240000525341310004000001000100db5f59f098d27276c7833875a6263a3cc74ab17ba9a9df0b52aedbe7252745db7274d5271fd79c1f08f668ecfa8eaab5626fa76adc811d3c8fc55859b0d09d3bc0a84eecd0ba891f2b8a2fc55141cdcc37c2053d53491e650a479967c3622762977900eddbf1252ed08a2413f00a28f3a0752a81203f03ccb7f684db373518b4")]
27+
[assembly: InternalsVisibleTo("AWSSDK.UnitTests.NetFramework, PublicKey=0024000004800000940000000602000000240000525341310004000001000100db5f59f098d27276c7833875a6263a3cc74ab17ba9a9df0b52aedbe7252745db7274d5271fd79c1f08f668ecfa8eaab5626fa76adc811d3c8fc55859b0d09d3bc0a84eecd0ba891f2b8a2fc55141cdcc37c2053d53491e650a479967c3622762977900eddbf1252ed08a2413f00a28f3a0752a81203f03ccb7f684db373518b4")]
28+
<# } #>
2529
[assembly: AssemblyConfiguration("")]
2630
[assembly: AssemblyProduct("Amazon Web Services SDK for .NET")]
2731
[assembly: AssemblyCompany("Amazon.com, Inc")]

generator/ServiceClientGeneratorLib/UnitTestProjectFileCreator.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,8 @@ public void Execute(string unitTestRoot, IEnumerable<ServiceConfiguration> servi
9696
}
9797
projectProperties.FxcopAnalyzerRuleSetFilePath = Utils.PathCombineAlt("..", "..", "..", "..", "AWSDotNetSDK.ruleset");
9898
projectProperties.FxcopAnalyzerRuleSetFilePathForBuild = Utils.PathCombineAlt("..", "..", "..", "..", "AWSDotNetSDKForBuild.ruleset");
99+
projectProperties.SignBinaries = true;
100+
99101
}
100102

101103
if (serviceProjectReferences != null)

sdk/src/Services/DynamoDBv2/Custom/DocumentModel/Search.cs

Lines changed: 40 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -163,6 +163,25 @@ public partial interface ISearch
163163
/// </summary>
164164
int Count { get; }
165165

166+
/// <summary>
167+
/// Gets the total number of items evaluated, before any ScanFilter is applied, for the current call.
168+
/// <para>
169+
/// The number of items evaluated, before any <c>ScanFilter</c> is applied. A high <c>ScannedCount</c>
170+
/// value with few, or no, <c>Count</c> results indicates an inefficient <c>Scan</c> operation.
171+
/// For more information, see <a href="https://docs.aws.amazon.com/amazondynamodb/latest/developerguide/QueryAndScan.html#Count">Count
172+
/// and ScannedCount</a> in the <i>Amazon DynamoDB Developer Guide</i>.
173+
/// </para>
174+
/// <para>
175+
/// This value is specific to each call of <c>GetNextSetAsync</c> or <c>GetRemainingAsync</c>.
176+
/// It is not an accumulated value across multiple calls.
177+
/// </para>
178+
/// <para>
179+
/// If you did not use a filter in the request, then <c>ScannedCount</c> is the same as
180+
/// <c>Count</c>.
181+
/// </para>
182+
/// </summary>
183+
int ScannedCount { get; }
184+
166185
/// <summary>
167186
/// Name of the index to query or scan against.
168187
/// </summary>
@@ -258,7 +277,10 @@ internal set
258277
public int Segment { get; set; }
259278

260279
/// <inheritdoc/>
261-
public int Count { get { return GetCount(); } }
280+
public int Count => GetCount();
281+
282+
/// <inheritdoc/>
283+
public int ScannedCount => scannedCount;
262284

263285
/// <inheritdoc/>
264286
public string IndexName { get; internal set; }
@@ -345,6 +367,7 @@ internal List<Document> GetNextSetHelper()
345367
}
346368

347369
NextKey = scanResult.LastEvaluatedKey;
370+
scannedCount = scanResult.ScannedCount.GetValueOrDefault();
348371
if (NextKey == null || NextKey.Count == 0)
349372
{
350373
IsDone = true;
@@ -399,6 +422,7 @@ internal List<Document> GetNextSetHelper()
399422
}
400423

401424
NextKey = queryResult.LastEvaluatedKey;
425+
scannedCount = queryResult.ScannedCount.GetValueOrDefault();
402426
if (NextKey == null || NextKey.Count == 0)
403427
{
404428
IsDone = true;
@@ -467,6 +491,8 @@ internal async Task<List<Document>> GetNextSetHelperAsync(CancellationToken canc
467491
}
468492

469493
NextKey = scanResult.LastEvaluatedKey;
494+
scannedCount = scanResult.ScannedCount.GetValueOrDefault();
495+
470496
if (NextKey == null || NextKey.Count == 0)
471497
{
472498
IsDone = true;
@@ -512,6 +538,8 @@ internal async Task<List<Document>> GetNextSetHelperAsync(CancellationToken canc
512538
}
513539
}
514540
NextKey = queryResult.LastEvaluatedKey;
541+
scannedCount = queryResult.ScannedCount.GetValueOrDefault();
542+
515543
if (NextKey == null || NextKey.Count == 0)
516544
{
517545
IsDone = true;
@@ -532,10 +560,12 @@ internal List<Document> GetRemainingHelper()
532560

533561
while (!IsDone)
534562
{
563+
var previousScannedCount = scannedCount;
535564
foreach (Document doc in GetNextSetHelper())
536565
{
537566
ret.Add(doc);
538567
}
568+
scannedCount += previousScannedCount;
539569
}
540570

541571
return ret;
@@ -548,10 +578,12 @@ internal async Task<List<Document>> GetRemainingHelperAsync(CancellationToken ca
548578

549579
while (!IsDone)
550580
{
581+
var previousScannedCount = scannedCount;
551582
foreach (Document doc in await GetNextSetHelperAsync(cancellationToken).ConfigureAwait(false))
552583
{
553584
ret.Add(doc);
554585
}
586+
scannedCount += previousScannedCount;
555587
}
556588

557589
return ret;
@@ -560,6 +592,8 @@ internal async Task<List<Document>> GetRemainingHelperAsync(CancellationToken ca
560592

561593
private int count;
562594

595+
private int scannedCount;
596+
563597
private SearchType SearchMethod { get; set; }
564598

565599
internal Table SourceTable { get; set; }
@@ -668,6 +702,8 @@ private int GetCount()
668702

669703
var scanResult = internalClient.Scan(scanReq);
670704
count = Matches.Count + scanResult.Count.GetValueOrDefault();
705+
scannedCount = scanResult.ScannedCount.GetValueOrDefault();
706+
671707
return count;
672708
case SearchType.Query:
673709
QueryRequest queryReq = new QueryRequest
@@ -693,6 +729,8 @@ private int GetCount()
693729

694730
var queryResult = internalClient.Query(queryReq);
695731
count = Matches.Count + queryResult.Count.GetValueOrDefault();
732+
scannedCount = queryResult.ScannedCount.GetValueOrDefault();
733+
696734
return count;
697735
default:
698736
throw new InvalidOperationException("Unknown Search Method");
@@ -707,6 +745,7 @@ private int GetCount()
707745
internal void Reset()
708746
{
709747
count = -1;
748+
scannedCount = 0;
710749
IsDone = false;
711750
NextKey = null;
712751
Matches = new List<Document>();

sdk/src/Services/DynamoDBv2/Properties/AssemblyInfo.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,8 @@
1919
#error Unknown platform constant - unable to set correct AssemblyDescription
2020
#endif
2121

22+
[assembly: InternalsVisibleTo("AWSSDK.UnitTests.DynamoDBv2.NetFramework, PublicKey=0024000004800000940000000602000000240000525341310004000001000100db5f59f098d27276c7833875a6263a3cc74ab17ba9a9df0b52aedbe7252745db7274d5271fd79c1f08f668ecfa8eaab5626fa76adc811d3c8fc55859b0d09d3bc0a84eecd0ba891f2b8a2fc55141cdcc37c2053d53491e650a479967c3622762977900eddbf1252ed08a2413f00a28f3a0752a81203f03ccb7f684db373518b4")]
23+
[assembly: InternalsVisibleTo("AWSSDK.UnitTests.NetFramework, PublicKey=0024000004800000940000000602000000240000525341310004000001000100db5f59f098d27276c7833875a6263a3cc74ab17ba9a9df0b52aedbe7252745db7274d5271fd79c1f08f668ecfa8eaab5626fa76adc811d3c8fc55859b0d09d3bc0a84eecd0ba891f2b8a2fc55141cdcc37c2053d53491e650a479967c3622762977900eddbf1252ed08a2413f00a28f3a0752a81203f03ccb7f684db373518b4")]
2224
[assembly: AssemblyConfiguration("")]
2325
[assembly: AssemblyProduct("Amazon Web Services SDK for .NET")]
2426
[assembly: AssemblyCompany("Amazon.com, Inc")]

sdk/test/Services/ACMPCA/UnitTests/AWSSDK.UnitTests.ACMPCA.NetFramework.csproj

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,19 @@
3434
<PropertyGroup Condition="'$(TargetFramework)' != 'net8.0'">
3535
<LangVersion>9.0</LangVersion>
3636
</PropertyGroup>
37+
<Choose>
38+
<When Condition=" '$(AWSKeyFile)' == '' ">
39+
<PropertyGroup>
40+
<AssemblyOriginatorKeyFile>../../../awssdk.dll.snk</AssemblyOriginatorKeyFile>
41+
</PropertyGroup>
42+
</When>
43+
<Otherwise>
44+
<PropertyGroup>
45+
<AssemblyOriginatorKeyFile>$(AWSKeyFile)</AssemblyOriginatorKeyFile>
46+
</PropertyGroup>
47+
</Otherwise>
48+
</Choose>
49+
3750
<ItemGroup>
3851
<Compile Remove="**/obj/**"/>
3952
<None Remove="**/obj/**" />

sdk/test/Services/APIGateway/UnitTests/AWSSDK.UnitTests.APIGateway.NetFramework.csproj

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,19 @@
3434
<PropertyGroup Condition="'$(TargetFramework)' != 'net8.0'">
3535
<LangVersion>9.0</LangVersion>
3636
</PropertyGroup>
37+
<Choose>
38+
<When Condition=" '$(AWSKeyFile)' == '' ">
39+
<PropertyGroup>
40+
<AssemblyOriginatorKeyFile>../../../awssdk.dll.snk</AssemblyOriginatorKeyFile>
41+
</PropertyGroup>
42+
</When>
43+
<Otherwise>
44+
<PropertyGroup>
45+
<AssemblyOriginatorKeyFile>$(AWSKeyFile)</AssemblyOriginatorKeyFile>
46+
</PropertyGroup>
47+
</Otherwise>
48+
</Choose>
49+
3750
<ItemGroup>
3851
<Compile Remove="**/obj/**"/>
3952
<None Remove="**/obj/**" />

0 commit comments

Comments
 (0)