Skip to content

Commit

Permalink
NCBC-3307: Implement ByteLimit, ItemLimit and TimeLimit.
Browse files Browse the repository at this point in the history
Motivation
----------
Implementation already mostly done in main range scan patch.

Changes
-------
*Doc change
*Fixed typo
*Exposed TimeLimit in ScanOptions

Change-Id: Id285d46f9bbd83d1b87c5996c15e15e7c6cf4ea4
Reviewed-on: https://review.couchbase.org/c/couchbase-net-client/+/184612
Tested-by: Build Bot <[email protected]>
Reviewed-by: Richard Ponton <[email protected]>
  • Loading branch information
emilienbev authored and jeffrymorris committed Feb 2, 2023
1 parent 45ba570 commit a6a1335
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 3 deletions.
4 changes: 3 additions & 1 deletion src/Couchbase/KeyValue/RangeScan/PartitionScan.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@

namespace Couchbase.KeyValue.RangeScan;

internal record PartitionScan
internal class PartitionScan
{
public PartitionScan(IOperationConfigurator operationConfigurator, BucketBase bucket, ICouchbaseCollection collection, ILogger<GetResult> getLogger, ScanOptions options, IScanType scanType, short partitionId)
{
Expand Down Expand Up @@ -71,6 +71,7 @@ public async Task<PartitionScan> ScanAsync()
Uuid = _uuid.Value,
IdsOnly = _options.IdsOnlyValue,
Logger = _getLogger,
TimeLimit = _options.BatchTimeLimit,
ItemLimit = _options.BatchItemLimit,
ByteLimit = _options.BatchByteLimit
};
Expand All @@ -96,6 +97,7 @@ public async Task<PartitionScan> ScanAsync()
Uuid = _uuid.Value,
IdsOnly = _options.IdsOnlyValue,
Logger = _getLogger,
TimeLimit = _options.BatchTimeLimit,
ItemLimit = _options.BatchItemLimit,
ByteLimit = _options.BatchByteLimit
};
Expand Down
17 changes: 15 additions & 2 deletions src/Couchbase/KeyValue/RangeScan/ScanOptions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -39,9 +39,11 @@ static ScanOptions()

internal CancellationToken TokenValue { get; private set; }

internal uint BatchItemLimit { get; set; }
internal uint BatchItemLimit { get; set; } = 0;

internal uint BatchByteLimit { get; set; }
internal uint BatchByteLimit { get; set; } = 0;

internal uint BatchTimeLimit { get; set; } = 0;

ITypeTranscoder? ITranscoderOverrideOptions.Transcoder => TranscoderValue;

Expand Down Expand Up @@ -167,6 +169,17 @@ public ScanOptions ByteLimit(uint limit)
return this;
}

/// <summary>
/// Sets the Time Limit in milliseconds for the scan to keep returning documents. This will be applied to each stream individually.
/// </summary>
/// <param name="limit"></param>
/// <returns>A <see cref="ScanOptions"/> instance for chaining.</returns>
public ScanOptions TimeLimit(uint limit)
{
BatchTimeLimit = limit;
return this;
}

#endregion
}
}

0 comments on commit a6a1335

Please sign in to comment.