Skip to content

Commit

Permalink
Wire status into remote v2 (#657)
Browse files Browse the repository at this point in the history
Add NotFound API for status
  • Loading branch information
badrishc authored Feb 20, 2022
1 parent f0f826a commit 3698b24
Show file tree
Hide file tree
Showing 12 changed files with 166 additions and 108 deletions.
6 changes: 3 additions & 3 deletions cs/remote/samples/FixedLenClient/Functions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,13 @@ public override void ReadCompletionCallback(ref long key, ref long input, ref lo
if (ctx == 0)
{
var expected = key + 10000;
if (status != Status.OK || expected != output)
if (!status.Found || expected != output)
throw new Exception($"Incorrect read result for key {key}; expected = {expected}, actual = {output}");
}
else if (ctx == 1)
{
var expected = key + 10000 + 25 + 25;
if (status != Status.OK || expected != output)
if (!status.Found || expected != output)
throw new Exception($"Incorrect read result for key {key}; expected = {expected}, actual = {output}");
}
else
Expand All @@ -40,7 +40,7 @@ public override void RMWCompletionCallback(ref long key, ref long input, ref lon
if (ctx == 1)
{
var expected = key + 10000 + 25 + 25 + 25;
if (status != Status.OK || expected != output)
if (!status.Found || expected != output)
throw new Exception($"Incorrect read result for key {key}; expected = {expected}, actual = {output}");
}
}
Expand Down
16 changes: 8 additions & 8 deletions cs/remote/samples/FixedLenClient/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ static async Task AsyncSamples(ClientSession<long, long, long, long, byte, Funct
// By default, we flush async operations as soon as they are issued
// To instead flush manually, set forceFlush = false in calls below
var (status, output) = await session.ReadAsync(23);
if (status != Status.OK || output != 23 + 10000)
if (!status.Found || output != 23 + 10000)
throw new Exception("Error!");

// Measure read latency
Expand All @@ -153,35 +153,35 @@ static async Task AsyncSamples(ClientSession<long, long, long, long, byte, Funct

long key = 25;
(status, _) = await session.ReadAsync(key);
if (status != Status.NOTFOUND)
if (!status.NotFound)
throw new Exception($"Error! Key = {key}; Status = expected NOTFOUND, actual {status}");

key = 9999;
(status, _) = await session.ReadAsync(9999);
if (status != Status.NOTFOUND)
if (!status.NotFound)
throw new Exception($"Error! Key = {key}; Status = expected NOTFOUND, actual {status}");

key = 9998;
await session.DeleteAsync(key);

(status, _) = await session.ReadAsync(9998);
if (status != Status.NOTFOUND)
if (!status.NotFound)
throw new Exception($"Error! Key = {key}; Status = expected NOTFOUND, actual {status}");

(status, output) = await session.RMWAsync(9998, 10);
if (status != Status.NOTFOUND || output != 10)
if (!status.Found || output != 10)
throw new Exception($"Error! Key = {key}; Status = expected NOTFOUND, actual {status}; output = expected {10}, actual {output}");

(status, output) = await session.ReadAsync(key);
if (status != Status.OK || output != 10)
if (!status.Found || output != 10)
throw new Exception($"Error! Key = {key}; Status = expected OK, actual {status}; output = expected {10}, actual {output}");

(status, output) = await session.RMWAsync(key, 10);
if (status != Status.OK || output != 20)
if (!status.Found || output != 20)
throw new Exception($"Error! Key = {key}; Status = expected OK, actual {status} output = expected {10}, actual {output}");

(status, output) = await session.ReadAsync(key);
if (status != Status.OK || output != 20)
if (!status.Found || output != 20)
throw new Exception($"Error! Key = {key}; Status = expected OK, actual {status}, output = expected {10}, actual {output}");
}
}
Expand Down
4 changes: 2 additions & 2 deletions cs/remote/samples/VarLenClient/CustomTypeFunctions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,12 @@ public override void ReadCompletionCallback(ref CustomType key, ref CustomType i
{
if (ctx == 0)
{
if (status != Status.OK || key.payload + 10000 != output.payload)
if (!status.Found || key.payload + 10000 != output.payload)
throw new Exception("Incorrect read result");
}
else if (ctx == 1)
{
if (status != Status.OK || key.payload + 10000 + 25 + 25 != output.payload)
if (!status.Found || key.payload + 10000 + 25 + 25 != output.payload)
throw new Exception("Incorrect read result");
}
else
Expand Down
6 changes: 3 additions & 3 deletions cs/remote/samples/VarLenClient/CustomTypeSamples.cs
Original file line number Diff line number Diff line change
Expand Up @@ -114,17 +114,17 @@ async Task AsyncVarLenSamples(ClientSession<CustomType, CustomType, CustomType,
session.Upsert(new CustomType(25), new CustomType(25 + 10000));

var (status, output) = await session.ReadAsync(new CustomType(25));
if (status != Status.OK || output.payload != 25 + 10000)
if (!status.Found || output.payload != 25 + 10000)
throw new Exception("Error!");

await session.DeleteAsync(new CustomType(25));

(status, _) = await session.ReadAsync(new CustomType(25));
if (status != Status.NOTFOUND)
if (!status.NotFound)
throw new Exception("Error!");

(status, _) = await session.ReadAsync(new CustomType(9999));
if (status != Status.NOTFOUND)
if (!status.NotFound)
throw new Exception("Error!");
}
}
Expand Down
6 changes: 3 additions & 3 deletions cs/remote/samples/VarLenClient/MemoryFunctions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -18,13 +18,13 @@ public override void ReadCompletionCallback(ref ReadOnlyMemory<int> key, ref Rea
if (ctx == 0)
{
expected.Span.Fill(key.Span[0] + 10000);
if (status != Status.OK || !expected.Span.SequenceEqual(output.Item1.Memory.Span.Slice(0, output.Item2)))
if (!status.Found || !expected.Span.SequenceEqual(output.Item1.Memory.Span.Slice(0, output.Item2)))
throw new Exception("Incorrect read result");
}
else if (ctx == 1)
{
expected.Span.Fill(key.Span[0] + 10000 + 25 + 25);
if (status != Status.OK || !expected.Span.SequenceEqual(output.Item1.Memory.Span.Slice(0, output.Item2)))
if (!status.Found || !expected.Span.SequenceEqual(output.Item1.Memory.Span.Slice(0, output.Item2)))
throw new Exception("Incorrect read result");
}
else
Expand All @@ -47,7 +47,7 @@ public override void ReadCompletionCallback(ref ReadOnlyMemory<byte> key, ref Re
{
if (ctx == 0)
{
if (status != Status.OK || !key.Span.SequenceEqual(output.Item1.Memory.Span.Slice(0, output.Item2)))
if (!status.Found || !key.Span.SequenceEqual(output.Item1.Memory.Span.Slice(0, output.Item2)))
throw new Exception("Incorrect read result");
}
else
Expand Down
6 changes: 3 additions & 3 deletions cs/remote/samples/VarLenClient/MemorySamples.cs
Original file line number Diff line number Diff line change
Expand Up @@ -69,19 +69,19 @@ async Task AsyncMemorySamples(ClientSession<ReadOnlyMemory<int>, ReadOnlyMemory<
session.Upsert(key, value);

var (status, output) = await session.ReadAsync(key);
if (status != Status.OK || !output.Item1.Memory.Span.Slice(0, output.Item2).SequenceEqual(value.Span))
if (!status.Found || !output.Item1.Memory.Span.Slice(0, output.Item2).SequenceEqual(value.Span))
throw new Exception("Error!");

await session.DeleteAsync(key);

(status, _) = await session.ReadAsync(key);
if (status != Status.NOTFOUND)
if (!status.NotFound)
throw new Exception("Error!");

key.Span.Fill(9999);

(status, _) = await session.ReadAsync(key);
if (status != Status.NOTFOUND)
if (!status.NotFound)
throw new Exception("Error!");
}
}
Expand Down
Loading

0 comments on commit 3698b24

Please sign in to comment.