[CSHARP-3440] Implement builder for $count accumulator Created: 01/Mar/21  Updated: 27/May/22  Resolved: 13/May/21

Status: Closed
Project: C# Driver
Component/s: None
Affects Version/s: None
Fix Version/s: None

Type: Improvement Priority: Major - P3
Reporter: Esha Bhargava Assignee: Mikalai Mazurenka (Inactive)
Resolution: Won't Fix Votes: 0
Labels: FY22Q2
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Issue Links:
Issue split
Server Compat: 4.9
Quarter: FY22Q2

 Comments   
Comment by Mikalai Mazurenka (Inactive) [ 12/May/21 ]

While .NET driver has the aggregate pipeline builder, it is implemented via LINQ translation and Count operation (along with LongCount) is already supported via $sum accumulator, e.g. AggregateGroupTranslatorTests .Should_translate_count.
The $count accumulator operator itself is already supported in BSON form and can be specified in a BsonDocument-constructed ProjectionDefinition within group stage without additional changes to the driver, since this form of projection is passed to the server without transformation on the driver's side.
What could potentially be done is translating Count LINQ operator to "$count : {}" instead of "$sum : { 1 }", but that would create an unnecessary overhead of evaluating server version without providing advantages.

Generated at Wed Feb 07 21:45:17 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.