Repository navigation
Expand file tree
/
Copy pathIKeyValueView.cs
More file actions
57 lines (52 loc) · 3.97 KB
/
Copy pathIKeyValueView.cs
File metadata and controls
57 lines (52 loc) · 3.97 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
54
55
56
57
namespace KeyLoad.Storage;
/// <summary>Reads a consistent view only inside its owning store action.</summary>
public interface IKeyValueView
{
/// <summary>Gets the provider's actual accepted requested-record ceiling for forward range traversal.</summary>
/// <remarks>Zero means range traversal is unsupported. This is not a cumulative work allowance;
/// examined records, lookahead, bytes and lifetime remain bounded by their original owners.</remarks>
int MaximumRangeRecords
{
get;
}
/// <summary>Copies a found record into an independently owned buffer.</summary>
/// <param name="key">Encoded lookup key.</param>
/// <returns>Owned logical bytes, or null when the key is absent or deleted.</returns>
byte[]? ReadOwnedValue(byte[] key);
/// <summary>Copies a bounded ordered page of matching logical records.</summary>
/// <param name="prefix">Required encoded key prefix.</param>
/// <param name="maxRecords">Maximum live records delivered before lookahead.</param>
/// <param name="afterKey">Optional exclusive lower encoded key bound.</param>
/// <returns>Owned key/value copies and whether another live record exists.</returns>
ScanPage Scan(byte[] prefix, int maxRecords, byte[]? afterKey = null);
/// <summary>Reads borrowed bytes inside the current storage gate, without an intermediate value copy.</summary>
/// <param name="key">Owned lookup key supplied by the caller.</param>
/// <param name="reader">Callback that cannot retain the borrowed span.</param>
/// <param name="observer">Optional work charge before invoking the reader, including missing lookups.</param>
/// <returns>True when a stored value was found.</returns>
bool ReadValue(byte[] key, StorageValueReader reader, StorageReadObserver? observer = null);
/// <summary>Visits ordered records inside the current storage gate and checks work before copying.</summary>
/// <param name="prefix">Required key prefix.</param>
/// <param name="maxRecords">Maximum logical records delivered before lookahead.</param>
/// <param name="visitor">Read-only borrowed-record callback; false stops before another advance. Do not mutate the transaction from this callback.</param>
/// <param name="afterKey">Optional exclusive lower key bound.</param>
/// <param name="untilKey">Optional exclusive upper key bound.</param>
/// <param name="observer">Optional examined-byte charge before callback or lookahead.</param>
/// <param name="cancellationToken">Cancellation checked during traversal.</param>
/// <returns>Delivered record count, stop reason and examined byte count.</returns>
StorageScanResult VisitRange(byte[] prefix, int maxRecords, StorageRecordVisitor visitor,
byte[]? afterKey = null, byte[]? untilKey = null, StorageReadObserver? observer = null,
CancellationToken cancellationToken = default);
/// <summary>Visits descending encoded keys inside the same storage gate without materializing the range.</summary>
/// <param name="prefix">Required key prefix.</param>
/// <param name="maxRecords">Maximum live records delivered before charged lookahead.</param>
/// <param name="visitor">Read-only borrowed callback; false stops before another advance. Do not mutate the transaction.</param>
/// <param name="afterKey">Optional exclusive lower key bound, independent of direction.</param>
/// <param name="untilKey">Optional exclusive upper key bound, independent of direction.</param>
/// <param name="observer">Optional examined-byte charge before callback or lookahead.</param>
/// <param name="cancellationToken">Cancellation checked during traversal.</param>
/// <returns>Delivered count, stop reason and examined logical bytes.</returns>
StorageScanResult VisitReverseRange(byte[] prefix, int maxRecords, StorageRecordVisitor visitor,
byte[]? afterKey = null, byte[]? untilKey = null, StorageReadObserver? observer = null,
CancellationToken cancellationToken = default);
}