Skip to content

Commit ba40db6

Browse files
committed
CSHARP-1541: Add support for $comment for profiling
1 parent 388e126 commit ba40db6

File tree

102 files changed

+5505
-69
lines changed

Some content is hidden

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

102 files changed

+5505
-69
lines changed

src/MongoDB.Driver.Core/Core/Operations/AggregateExplainOperation.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -162,7 +162,7 @@ internal BsonDocument CreateCommand()
162162
{ "maxTimeMS", () => MaxTimeHelper.ToMaxTimeMS(_maxTime.Value), _maxTime.HasValue },
163163
{ "collation", () => _collation.ToBsonDocument(), _collation != null },
164164
{ "hint", () => _hint, _hint != null },
165-
{ "comment", () => _comment, _comment != null }
165+
{ "comment", _comment, _comment != null }
166166
};
167167
}
168168

src/MongoDB.Driver.Core/Core/Operations/AggregateOperation.cs

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,6 @@
2727
using MongoDB.Driver.Core.Events;
2828
using MongoDB.Driver.Core.Misc;
2929
using MongoDB.Driver.Core.WireProtocol.Messages.Encoders;
30-
using MongoDB.Shared;
3130

3231
namespace MongoDB.Driver.Core.Operations
3332
{
@@ -42,7 +41,7 @@ public class AggregateOperation<TResult> : IReadOperation<IAsyncCursor<TResult>>
4241
private int? _batchSize;
4342
private Collation _collation;
4443
private readonly CollectionNamespace _collectionNamespace;
45-
private string _comment;
44+
private BsonValue _comment;
4645
private readonly DatabaseNamespace _databaseNamespace;
4746
private BsonValue _hint;
4847
private BsonDocument _let;
@@ -140,7 +139,7 @@ public CollectionNamespace CollectionNamespace
140139
/// <value>
141140
/// The comment.
142141
/// </value>
143-
public string Comment
142+
public BsonValue Comment
144143
{
145144
get { return _comment; }
146145
set { _comment = value; }
@@ -355,9 +354,9 @@ internal BsonDocument CreateCommand(ConnectionDescription connectionDescription,
355354
{ "allowDiskUse", () => _allowDiskUse.Value, _allowDiskUse.HasValue },
356355
{ "maxTimeMS", () => MaxTimeHelper.ToMaxTimeMS(_maxTime.Value), _maxTime.HasValue },
357356
{ "collation", () => _collation.ToBsonDocument(), _collation != null },
358-
{ "hint", () => _hint, _hint != null },
359-
{ "let", () => _let, _let != null },
360-
{ "comment", () => _comment, _comment != null },
357+
{ "hint", _hint, _hint != null },
358+
{ "let", _let, _let != null },
359+
{ "comment", _comment, _comment != null },
361360
{ "readConcern", readConcern, readConcern != null },
362361
{
363362
"cursor",

src/MongoDB.Driver.Core/Core/Operations/AggregateToCollectionOperation.cs

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,6 @@
2525
using MongoDB.Driver.Core.Misc;
2626
using MongoDB.Driver.Core.Servers;
2727
using MongoDB.Driver.Core.WireProtocol.Messages.Encoders;
28-
using MongoDB.Shared;
2928

3029
namespace MongoDB.Driver.Core.Operations
3130
{
@@ -39,7 +38,7 @@ public class AggregateToCollectionOperation : IWriteOperation<BsonDocument>
3938
private bool? _bypassDocumentValidation;
4039
private Collation _collation;
4140
private readonly CollectionNamespace _collectionNamespace;
42-
private string _comment;
41+
private BsonValue _comment;
4342
private readonly DatabaseNamespace _databaseNamespace;
4443
private BsonValue _hint;
4544
private BsonDocument _let;
@@ -133,7 +132,7 @@ public CollectionNamespace CollectionNamespace
133132
/// <value>
134133
/// The comment.
135134
/// </value>
136-
public string Comment
135+
public BsonValue Comment
137136
{
138137
get { return _comment; }
139138
set { _comment = value; }
@@ -295,9 +294,9 @@ internal BsonDocument CreateCommand(ICoreSessionHandle session, ConnectionDescri
295294
{ "readConcern", readConcern, readConcern != null },
296295
{ "writeConcern", writeConcern, writeConcern != null },
297296
{ "cursor", new BsonDocument() },
298-
{ "hint", () => _hint, _hint != null },
299-
{ "let", () => _let, _let != null },
300-
{ "comment", () => _comment, _comment != null }
297+
{ "hint", _hint, _hint != null },
298+
{ "let", _let, _let != null },
299+
{ "comment", _comment, _comment != null }
301300
};
302301
}
303302

src/MongoDB.Driver.Core/Core/Operations/BulkDeleteOperation.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@ protected override IRetryableWriteOperation<BsonDocument> CreateBatchOperation(B
4444
{
4545
return new RetryableDeleteCommandOperation(CollectionNamespace, batch.Requests, MessageEncoderSettings)
4646
{
47+
Comment = Comment,
4748
IsOrdered = IsOrdered,
4849
Let = _let,
4950
MaxBatchCount = MaxBatchCount,

src/MongoDB.Driver.Core/Core/Operations/BulkInsertOperation.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ protected override IRetryableWriteOperation<BsonDocument> CreateBatchOperation(B
3838
return new RetryableInsertCommandOperation<InsertRequest>(CollectionNamespace, batch.Requests, InsertRequestSerializer.Instance, MessageEncoderSettings)
3939
{
4040
BypassDocumentValidation = BypassDocumentValidation,
41+
Comment = Comment,
4142
IsOrdered = IsOrdered,
4243
MaxBatchCount = MaxBatchCount,
4344
RetryRequested = RetryRequested,

src/MongoDB.Driver.Core/Core/Operations/BulkMixedWriteOperation.cs

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ public class BulkMixedWriteOperation : IWriteOperation<BulkWriteOperationResult>
3535
// fields
3636
private bool? _bypassDocumentValidation;
3737
private readonly CollectionNamespace _collectionNamespace;
38+
private BsonValue _comment;
3839
private bool _isOrdered = true;
3940
private BsonDocument _let;
4041
private int? _maxBatchCount;
@@ -102,6 +103,18 @@ public CollectionNamespace CollectionNamespace
102103
get { return _collectionNamespace; }
103104
}
104105

106+
/// <summary>
107+
/// Gets or sets the comment.
108+
/// </summary>
109+
/// <value>
110+
/// The comment.
111+
/// </value>
112+
public BsonValue Comment
113+
{
114+
get { return _comment; }
115+
set { _comment = value; }
116+
}
117+
105118
/// <summary>
106119
/// Gets or sets a value indicating whether the writes must be performed in order.
107120
/// </summary>
@@ -261,6 +274,7 @@ private IExecutableInRetryableWriteContext<BulkWriteOperationResult> CreateBulkD
261274
var requests = batch.Requests.Cast<DeleteRequest>();
262275
return new BulkDeleteOperation(_collectionNamespace, requests, _messageEncoderSettings)
263276
{
277+
Comment = _comment,
264278
IsOrdered = _isOrdered,
265279
Let = _let,
266280
MaxBatchCount = _maxBatchCount,
@@ -276,6 +290,7 @@ private IExecutableInRetryableWriteContext<BulkWriteOperationResult> CreateBulkI
276290
return new BulkInsertOperation(_collectionNamespace, requests, _messageEncoderSettings)
277291
{
278292
BypassDocumentValidation = _bypassDocumentValidation,
293+
Comment = _comment,
279294
IsOrdered = _isOrdered,
280295
MaxBatchCount = _maxBatchCount,
281296
MaxBatchLength = _maxBatchLength,
@@ -291,6 +306,7 @@ private IExecutableInRetryableWriteContext<BulkWriteOperationResult> CreateBulkU
291306
return new BulkUpdateOperation(_collectionNamespace, requests, _messageEncoderSettings)
292307
{
293308
BypassDocumentValidation = _bypassDocumentValidation,
309+
Comment = _comment,
294310
IsOrdered = _isOrdered,
295311
Let = _let,
296312
MaxBatchCount = _maxBatchCount,

src/MongoDB.Driver.Core/Core/Operations/BulkUnmixedWriteOperationBase.cs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ internal abstract class BulkUnmixedWriteOperationBase<TWriteRequest> : IWriteOpe
3232
// fields
3333
private bool? _bypassDocumentValidation;
3434
private CollectionNamespace _collectionNamespace;
35+
private BsonValue _comment;
3536
private bool _isOrdered = true;
3637
private int? _maxBatchCount;
3738
private int? _maxBatchLength;
@@ -71,6 +72,12 @@ public CollectionNamespace CollectionNamespace
7172
get { return _collectionNamespace; }
7273
}
7374

75+
public BsonValue Comment
76+
{
77+
get { return _comment; }
78+
set { _comment = value; }
79+
}
80+
7481
public bool IsOrdered
7582
{
7683
get { return _isOrdered; }

src/MongoDB.Driver.Core/Core/Operations/BulkUpdateOperation.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@ protected override IRetryableWriteOperation<BsonDocument> CreateBatchOperation(B
4444
return new RetryableUpdateCommandOperation(CollectionNamespace, batch.Requests, MessageEncoderSettings)
4545
{
4646
BypassDocumentValidation = BypassDocumentValidation,
47+
Comment = Comment,
4748
IsOrdered = IsOrdered,
4849
Let = _let,
4950
MaxBatchCount = MaxBatchCount,

src/MongoDB.Driver.Core/Core/Operations/ChangeStreamOperation.cs

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,7 @@ public class ChangeStreamOperation<TResult> : IChangeStreamOperation<TResult>
8585
// private fields
8686
private int? _batchSize;
8787
private Collation _collation;
88+
private BsonValue _comment;
8889
private readonly CollectionNamespace _collectionNamespace;
8990
private readonly DatabaseNamespace _databaseNamespace;
9091
private ChangeStreamFullDocumentOption _fullDocument = ChangeStreamFullDocumentOption.Default;
@@ -174,6 +175,15 @@ public Collation Collation
174175
set { _collation = value; }
175176
}
176177

178+
/// <summary>
179+
/// Gets or sets the comment.
180+
/// </summary>
181+
public BsonValue Comment
182+
{
183+
get { return _comment; }
184+
set { _comment = value; }
185+
}
186+
177187
/// <summary>
178188
/// Gets the collection namespace.
179189
/// </summary>
@@ -395,6 +405,7 @@ private AggregateOperation<RawBsonDocument> CreateAggregateOperation()
395405

396406
operation.BatchSize = _batchSize;
397407
operation.Collation = _collation;
408+
operation.Comment = _comment;
398409
operation.MaxAwaitTime = _maxAwaitTime;
399410
operation.ReadConcern = _readConcern;
400411

src/MongoDB.Driver.Core/Core/Operations/CountDocumentsOperation.cs

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ public class CountDocumentsOperation : IReadOperation<long>
3434
// private fields
3535
private Collation _collation;
3636
private readonly CollectionNamespace _collectionNamespace;
37+
private BsonValue _comment;
3738
private BsonDocument _filter;
3839
private BsonValue _hint;
3940
private long? _limit;
@@ -67,6 +68,19 @@ public Collation Collation
6768
get { return _collation; }
6869
set { _collation = value; }
6970
}
71+
72+
/// <summary>
73+
/// Gets or sets the comment.
74+
/// </summary>
75+
/// <value>
76+
/// The comment.
77+
/// </value>
78+
public BsonValue Comment
79+
{
80+
get { return _comment; }
81+
set { _comment = value; }
82+
}
83+
7084
/// <summary>
7185
/// Gets the collection namespace.
7286
/// </summary>
@@ -201,6 +215,7 @@ private AggregateOperation<BsonDocument> CreateOperation()
201215
var operation = new AggregateOperation<BsonDocument>(_collectionNamespace, pipeline, BsonDocumentSerializer.Instance, _messageEncoderSettings)
202216
{
203217
Collation = _collation,
218+
Comment = _comment,
204219
Hint = _hint,
205220
MaxTime = _maxTime,
206221
ReadConcern = _readConcern,

src/MongoDB.Driver.Core/Core/Operations/CountOperation.cs

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,6 @@
2222
using MongoDB.Driver.Core.Connections;
2323
using MongoDB.Driver.Core.Misc;
2424
using MongoDB.Driver.Core.WireProtocol.Messages.Encoders;
25-
using MongoDB.Shared;
2625

2726
namespace MongoDB.Driver.Core.Operations
2827
{
@@ -34,6 +33,7 @@ public class CountOperation : IReadOperation<long>, IExecutableInRetryableReadCo
3433
// fields
3534
private Collation _collation;
3635
private readonly CollectionNamespace _collectionNamespace;
36+
private BsonValue _comment;
3737
private BsonDocument _filter;
3838
private BsonValue _hint;
3939
private long? _limit;
@@ -78,6 +78,18 @@ public CollectionNamespace CollectionNamespace
7878
get { return _collectionNamespace; }
7979
}
8080

81+
/// <summary>
82+
/// Gets or sets the comment.
83+
/// </summary>
84+
/// <value>
85+
/// The comment.
86+
/// </value>
87+
public BsonValue Comment
88+
{
89+
get { return _comment; }
90+
set { _comment = value; }
91+
}
92+
8193
/// <summary>
8294
/// Gets or sets the filter.
8395
/// </summary>
@@ -184,6 +196,7 @@ internal BsonDocument CreateCommand(ConnectionDescription connectionDescription,
184196
{ "hint", _hint, _hint != null },
185197
{ "maxTimeMS", () => MaxTimeHelper.ToMaxTimeMS(_maxTime.Value), _maxTime.HasValue },
186198
{ "collation", () => _collation.ToBsonDocument(), _collation != null },
199+
{ "comment", _comment, _comment != null },
187200
{ "readConcern", readConcern, readConcern != null }
188201
};
189202
}

src/MongoDB.Driver.Core/Core/Operations/CreateCollectionOperation.cs

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ public class CreateCollectionOperation : IWriteOperation<BsonDocument>
3535
private bool? _capped;
3636
private Collation _collation;
3737
private readonly CollectionNamespace _collectionNamespace;
38+
private BsonValue _comment;
3839
private TimeSpan? _expireAfter;
3940
private BsonDocument _indexOptionDefaults;
4041
private long? _maxDocuments;
@@ -101,6 +102,18 @@ public Collation Collation
101102
set { _collation = value; }
102103
}
103104

105+
/// <summary>
106+
/// Gets or sets the comment.
107+
/// </summary>
108+
/// <value>
109+
/// The comment.
110+
/// </value>
111+
public BsonValue Comment
112+
{
113+
get { return _comment; }
114+
set { _comment = value; }
115+
}
116+
104117
/// <summary>
105118
/// Gets the collection namespace.
106119
/// </summary>
@@ -281,12 +294,13 @@ internal BsonDocument CreateCommand(ICoreSessionHandle session, ConnectionDescri
281294
{ "size", () => _maxSize.Value, _maxSize.HasValue },
282295
{ "max", () => _maxDocuments.Value, _maxDocuments.HasValue },
283296
{ "flags", () => (int)flags.Value, flags.HasValue },
284-
{ "storageEngine", () => _storageEngine, _storageEngine != null },
297+
{ "storageEngine", _storageEngine, _storageEngine != null },
285298
{ "indexOptionDefaults", _indexOptionDefaults, _indexOptionDefaults != null },
286299
{ "validator", _validator, _validator != null },
287300
{ "validationAction", () => _validationAction.Value.ToString().ToLowerInvariant(), _validationAction.HasValue },
288301
{ "validationLevel", () => _validationLevel.Value.ToString().ToLowerInvariant(), _validationLevel.HasValue },
289302
{ "collation", () => _collation.ToBsonDocument(), _collation != null },
303+
{ "comment", _comment, _comment != null },
290304
{ "writeConcern", writeConcern, writeConcern != null },
291305
{ "expireAfterSeconds", () => _expireAfter.Value.TotalSeconds, _expireAfter.HasValue },
292306
{ "timeseries", () => _timeSeriesOptions.ToBsonDocument(), _timeSeriesOptions != null }

src/MongoDB.Driver.Core/Core/Operations/CreateIndexesOperation.cs

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ public class CreateIndexesOperation : IWriteOperation<BsonDocument>
3434
// fields
3535
private readonly CollectionNamespace _collectionNamespace;
3636
private CreateIndexCommitQuorum _commitQuorum;
37+
private BsonValue _comment;
3738
private TimeSpan? _maxTime;
3839
private readonly MessageEncoderSettings _messageEncoderSettings;
3940
private readonly IEnumerable<CreateIndexRequest> _requests;
@@ -68,6 +69,15 @@ public CollectionNamespace CollectionNamespace
6869
get { return _collectionNamespace; }
6970
}
7071

72+
/// <summary>
73+
/// Gets or sets the comment.
74+
/// </summary>
75+
public BsonValue Comment
76+
{
77+
get { return _comment; }
78+
set { _comment = value; }
79+
}
80+
7181
/// <summary>
7282
/// Gets or sets the commit quorum.
7383
/// </summary>
@@ -155,6 +165,7 @@ internal IWriteOperation<BsonDocument> CreateOperation()
155165
{
156166
return new CreateIndexesUsingCommandOperation(_collectionNamespace, _requests, _messageEncoderSettings)
157167
{
168+
Comment = _comment,
158169
CommitQuorum = _commitQuorum,
159170
MaxTime = _maxTime,
160171
WriteConcern = _writeConcern

0 commit comments

Comments
 (0)