Skip to content

Commit

Permalink
Initial checkin
Browse files Browse the repository at this point in the history
  • Loading branch information
badrishc committed May 16, 2019
1 parent 256dfc0 commit 484c674
Showing 1 changed file with 79 additions and 0 deletions.
79 changes: 79 additions & 0 deletions cs/src/core/Async/AsyncFasterKv.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
using System;
using System.Collections.Generic;
using System.Text;
using System.Threading.Tasks;

namespace FASTER.core.async
{
/// <summary>
///
/// </summary>
/// <typeparam name="Key"></typeparam>
/// <typeparam name="Value"></typeparam>
/// <typeparam name="Input"></typeparam>
/// <typeparam name="Output"></typeparam>
/// <typeparam name="Functions"></typeparam>
public class AsyncFasterKV<Key, Value, Input, Output, Functions>
where Key : new()
where Value : new()
where Functions : IFunctions<Key, Value, Input, Output, Empty>
{
private readonly FasterKV<Key, Value, Input, Output, Empty, Functions> fht;

/// <summary>
///
/// </summary>
/// <param name="size"></param>
/// <param name="functions"></param>
/// <param name="logSettings"></param>
/// <param name="checkpointSettings"></param>
/// <param name="serializerSettings"></param>
/// <param name="comparer"></param>
/// <param name="variableLengthStructSettings"></param>
public AsyncFasterKV(long size, Functions functions, LogSettings logSettings, CheckpointSettings checkpointSettings = null, SerializerSettings<Key, Value> serializerSettings = null, IFasterEqualityComparer<Key> comparer = null, VariableLengthStructSettings<Key, Value> variableLengthStructSettings = null)
{
fht = new FasterKV<Key, Value, Input, Output, Empty, Functions>(size, functions, logSettings, checkpointSettings, serializerSettings, comparer, variableLengthStructSettings);

}

/// <summary>
/// Read
/// </summary>
/// <param name="key"></param>
/// <param name="input"></param>
/// <param name="output"></param>
/// <param name="monotonicSerialNum"></param>
/// <returns></returns>
public async Task<Output> Read(Key key, Input input, Output output, long monotonicSerialNum)
{
var status = fht.Read(ref key, ref input, ref output, Empty.Default, monotonicSerialNum);
if (status != Status.PENDING)
return output;
var tcs = new TaskCompletionSource<Output>();

return await tcs.Task;
}

/// <summary>
///
/// </summary>
/// <param name="key"></param>
/// <param name="desiredValue"></param>
/// <param name="monotonicSerialNum"></param>
/// <returns></returns>
public async Task Upsert(Key key, Value desiredValue, long monotonicSerialNum)
{
var status = fht.Upsert(ref key, ref desiredValue, Empty.Default, monotonicSerialNum);
if (status != Status.PENDING)
return;
var tcs = new TaskCompletionSource<Output>();
await tcs.Task;
}


public async Task<Guid> TakeCheckpoint(long untilSN = -1)
{
throw new Exception();
}
}
}

0 comments on commit 484c674

Please sign in to comment.