29 lines
991 B
C#
29 lines
991 B
C#
|
|
using FASTER.core;
|
|||
|
|
|
|||
|
|
namespace Faster
|
|||
|
|
{
|
|||
|
|
internal class Program
|
|||
|
|
{
|
|||
|
|
static void Main(string[] args)
|
|||
|
|
{
|
|||
|
|
using var settings = new FasterKVSettings<long, long>("c:/temp"); // backing storage device
|
|||
|
|
using var store = new FasterKV<long, long>(settings);
|
|||
|
|
|
|||
|
|
// Create a session per sequence of interactions with FASTER
|
|||
|
|
// We use default callback functions with a custom merger: RMW merges input by adding it to value
|
|||
|
|
using var session = store.NewSession(new SimpleFunctions<long, long>((a, b) => a + b));
|
|||
|
|
|
|||
|
|
long key = 1, value = 1, input = 10, output = 0;
|
|||
|
|
|
|||
|
|
// Upsert and Read
|
|||
|
|
session.Upsert(ref key, ref value);
|
|||
|
|
session.Read(ref key, ref output);
|
|||
|
|
|
|||
|
|
// Read-Modify-Write (add input to value)
|
|||
|
|
session.RMW(ref key, ref input);
|
|||
|
|
session.RMW(ref key, ref input, ref output);
|
|||
|
|
Console.WriteLine("Hello, World!");
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
}
|