Following query can never return the last element with KeySelector.LastLessOrEqual is uses, it is off by 1 or 2 elements.
If KeySelector FirstGreaterOrEqual is used for the beginExclusive parameter, the last element is off by 2 elements
Example:
var beginRepr = new byte[8];
var endRepr = new byte[8];
UInt64? result = null;
await db.ReadAsync(async tr =>
{
BinaryPrimitives.WriteUInt64BigEndian(beginRepr, 0);
BinaryPrimitives.WriteUInt64BigEndian(endRepr, 7);
var begin = KeySelector.FirstGreaterThan(TuPack.Pack(("SampleTs", beginRepr)));
var end = KeySelector.LastLessOrEqual(TuPack.Pack(("SampleTs", endRepr)));
var range = await tr.GetRangeAsync(begin, end, FdbRangeOptions.KeysOnly);
if (!range.IsEmpty)
{
var bytes = TuPack.Unpack(range.Last().Key.Span).Get<byte[]>(1);
result = BinaryPrimitives.ReadUInt64BigEndian(bytes);
// result = 6 (5, if FirstGreaterOrEqual)
}
...
This is how I'm writing the values:
BinaryPrimitives. WriteUInt64BigEndian(intRepr,x);
tr.Set(TuPack.Pack(("SampleTs", intRepr)), Encoding.UTF8.GetBytes(x.ToString()));
<PackageVersion Include="FoundationDB.Client" Version="7.3.2" />
<PackageVersion Include="FoundationDB.Client.Native" Version="7.3.68" />
Following query can never return the last element with KeySelector.LastLessOrEqual is uses, it is off by 1 or 2 elements.
If KeySelector FirstGreaterOrEqual is used for the beginExclusive parameter, the last element is off by 2 elements
Example:
This is how I'm writing the values: