-
Notifications
You must be signed in to change notification settings - Fork 567
/
Copy pathCollectionItemResult.cs
96 lines (81 loc) · 2.75 KB
/
CollectionItemResult.cs
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
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT license.
namespace Garnet.server
{
/// <summary>
/// Result of item retrieved from observed collection
/// </summary>
internal readonly struct CollectionItemResult
{
public CollectionItemResult(GarnetStatus status)
{
Status = status;
}
public CollectionItemResult(byte[] key, byte[] item)
{
Key = key;
Item = item;
Status = key == default ? GarnetStatus.NOTFOUND : GarnetStatus.OK;
}
public CollectionItemResult(byte[] key, byte[][] items)
{
Key = key;
Items = items;
Status = key == default ? GarnetStatus.NOTFOUND : GarnetStatus.OK;
}
public CollectionItemResult(byte[] key, double score, byte[] item)
{
Key = key;
Item = item;
Score = score;
Status = key == default ? GarnetStatus.NOTFOUND : GarnetStatus.OK;
}
public CollectionItemResult(byte[] key, double[] scores, byte[][] items)
{
Key = key;
Items = items;
Scores = scores;
Status = key == default ? GarnetStatus.NOTFOUND : GarnetStatus.OK;
}
private CollectionItemResult(bool isForceUnblocked)
{
IsForceUnblocked = isForceUnblocked;
}
/// <summary>
/// Result status
/// </summary>
internal GarnetStatus Status { get; }
/// <summary>
/// Key of collection from which item was retrieved
/// </summary>
internal byte[] Key { get; }
/// <summary>
/// Item retrieved from collection
/// </summary>
internal byte[] Item { get; }
/// <summary>
/// Score associated with the item retrieved from the collection
/// </summary>
internal double Score { get; }
/// <summary>
/// Item retrieved from collection
/// </summary>
internal byte[][] Items { get; }
/// <summary>
/// Scores associated with the items retrieved from the collection
/// </summary>
internal double[] Scores { get; }
/// <summary>
/// Gets a value indicating whether the item retrieval was force unblocked.
/// </summary>
internal readonly bool IsForceUnblocked { get; }
/// <summary>
/// Instance of empty result
/// </summary>
internal static readonly CollectionItemResult Empty = new(null, item: null);
/// <summary>
/// Instance representing an Force Unblocked result.
/// </summary>
internal static readonly CollectionItemResult ForceUnblocked = new(true);
}
}