forked from microsoft/FASTER
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathBlittableOrders.cs
73 lines (55 loc) · 2.89 KB
/
BlittableOrders.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
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT license.
using FASTER.core;
using System;
namespace FasterPSFSample
{
public struct BlittableOrders : IOrders
{
public int Id { get; set; }
// Colors, strings, and enums are not blittable so we use int
public int SizeInt { get; set; }
public int ColorArgb { get; set; }
public int Count { get; set; }
public override string ToString() => $"{(Constants.Size)this.SizeInt}, {Constants.ColorDict[this.ColorArgb].Name}, {Count}";
public class Functions : IFunctions<Key, BlittableOrders, Input<BlittableOrders>, Output<BlittableOrders>, Context<BlittableOrders>>
{
#region Read
public void ConcurrentReader(ref Key key, ref Input<BlittableOrders> input, ref BlittableOrders value, ref Output<BlittableOrders> dst)
=> dst.Value = value;
public void SingleReader(ref Key key, ref Input<BlittableOrders> input, ref BlittableOrders value, ref Output<BlittableOrders> dst)
=> dst.Value = value;
public void ReadCompletionCallback(ref Key key, ref Input<BlittableOrders> input, ref Output<BlittableOrders> output, Context<BlittableOrders> context, Status status)
{ /* Output is not set by pending operations */ }
#endregion Read
#region Upsert
public bool ConcurrentWriter(ref Key key, ref BlittableOrders src, ref BlittableOrders dst)
{
dst = src;
return true;
}
public void SingleWriter(ref Key key, ref BlittableOrders src, ref BlittableOrders dst)
=> dst = src;
public void UpsertCompletionCallback(ref Key key, ref BlittableOrders value, Context<BlittableOrders> context)
{ }
#endregion Upsert
#region RMW
public void CopyUpdater(ref Key key, ref Input<BlittableOrders> input, ref BlittableOrders oldValue, ref BlittableOrders newValue)
=> throw new NotImplementedException();
public void InitialUpdater(ref Key key, ref Input<BlittableOrders> input, ref BlittableOrders value)
=> value = input.InitialUpdateValue;
public bool InPlaceUpdater(ref Key key, ref Input<BlittableOrders> input, ref BlittableOrders value)
{
value.ColorArgb = input.IPUColorInt;
return true;
}
public void RMWCompletionCallback(ref Key key, ref Input<BlittableOrders> input, Context<BlittableOrders> context, Status status)
{ }
#endregion RMW
public void CheckpointCompletionCallback(string sessionId, CommitPoint commitPoint)
{ }
public void DeleteCompletionCallback(ref Key key, Context<BlittableOrders> context)
{ }
}
}
}