INNER CODE UNIT · C#
Bytes
ZoneTree/ZoneTree · benchmarks/zonetree-scan-lab/Program.cs:953
static byte[] Bytes(string value) =>
Encoding.GetBytes(value);
static byte[] UserIdKey(long userId) =>
UserIdValue(userId);
static byte[] UserIdValue(long userId)
{
var bytes = new byte[sizeof(long)];
BinaryPrimitives.WriteInt64BigEndian(bytes, userId);
return bytes;
}
static long ParseUserId(byte[] value)
{
if (value.Length != sizeof(long))
throw new FormatException($"Expected an 8-byte Int64 value, but received {value.Length} bytes.");
return BinaryPrimitives.ReadInt64BigEndian(value);