public static void InPlaceUpdater(KeyStruct *key, InputStruct *input, ValueStruct *value) { ValueStruct.AcquireWriteLock(value); value->vfield1 += input->ifield1; value->vfield2 += input->ifield2; ValueStruct.ReleaseWriteLock(value); }
static unsafe void Main(string[] args) { var fht = FASTERFactory.Create <KeyStruct, ValueStruct, InputStruct, OutputStruct, Empty, Functions, ICustomFaster> (128, FASTERFactory.CreateLogDevice(""), LogMutableFraction: 0.5); fht.StartSession(); OutputStruct output = default(OutputStruct); var key1 = new KeyStruct { kfield1 = 13, kfield2 = 14 }; var value = new ValueStruct { vfield1 = 23, vfield2 = 24 }; // Upsert item into store, and read it back fht.Upsert(&key1, &value, null, 0); fht.Read(&key1, null, &output, null, 0); if ((output.value.vfield1 != value.vfield1) || (output.value.vfield2 != value.vfield2)) { Console.WriteLine("Error!"); } else { Console.WriteLine("Success!"); } var key2 = new KeyStruct { kfield1 = 15, kfield2 = 16 }; var input = new InputStruct { ifield1 = 25, ifield2 = 26 }; // Two read-modify-write (RMW) operations (sum aggregator) // Followed by read of result fht.RMW(&key2, &input, null, 0); fht.RMW(&key2, &input, null, 0); fht.Read(&key2, null, &output, null, 0); if ((output.value.vfield1 != input.ifield1 * 2) || (output.value.vfield2 != input.ifield2 * 2)) { Console.WriteLine("Error!"); } else { Console.WriteLine("Success!"); } fht.StopSession(); Console.ReadLine(); }
public static void InitialUpdater(KeyStruct *key, InputStruct *input, ValueStruct *value) { ValueStruct.Copy((ValueStruct *)input, value); }
public static int InitialValueLength(KeyStruct *key, InputStruct *input) { return(ValueStruct.GetLength(default(ValueStruct *))); }
public static void ConcurrentWriter(KeyStruct *key, ValueStruct *src, ValueStruct *dst) { ValueStruct.AcquireWriteLock(dst); ValueStruct.Copy(src, dst); ValueStruct.ReleaseWriteLock(dst); }
public static void SingleWriter(KeyStruct *key, ValueStruct *src, ValueStruct *dst) { ValueStruct.Copy(src, dst); }
public static void ConcurrentReader(KeyStruct *key, InputStruct *input, ValueStruct *value, OutputStruct *dst) { ValueStruct.AcquireReadLock(value); ValueStruct.Copy(value, (ValueStruct *)dst); ValueStruct.ReleaseReadLock(value); }
public static void SingleReader(KeyStruct *key, InputStruct *input, ValueStruct *value, OutputStruct *dst) { ValueStruct.Copy(value, (ValueStruct *)dst); }