Skip to content

Instantly share code, notes, and snippets.

@itn3000
Created March 8, 2022 17:54
Show Gist options
  • Save itn3000/5e9ab7ae0b3348177a54a2b053760e3c to your computer and use it in GitHub Desktop.
Save itn3000/5e9ab7ae0b3348177a54a2b053760e3c to your computer and use it in GitHub Desktop.
FasterLog v2pre sandbox
using FASTER.core;
using var x = Devices.CreateLogDevice("xlog");
var flsetting = new FasterLogSettings("hoge");
using var fl = new FasterLog(new FasterLogSettings("hoge")
// {
// FastCommitMode = true,
// LogCommitDir = "xlog-commits"
// }
);
var data = new byte[256];
for (int i = 0; i < 100; i++)
{
fl.Enqueue(data);
}
fl.CommitStrongly(out var tail, out var commitNum);
Console.WriteLine($"{tail},{commitNum}");
fl.CommitStrongly(out tail, out commitNum);
fl.Commit(true);
fl.Commit(true);
using var iter = fl.Scan(fl.BeginAddress, fl.TailAddress);
long totalNum = 0;
long totalBytes = 0;
await foreach(var item in iter.GetAsyncEnumerable())
{
totalNum++;
totalBytes += item.entryLength;
}
Console.WriteLine($"{totalNum}, {totalBytes}");
class Hoge : ILogEnqueueEntry
{
public int SerializedLength => throw new NotImplementedException();
public void SerializeTo(Span<byte> dest)
{
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment