Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

#384 Initial Changes for confirmation #393

Draft
wants to merge 4 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions src/Paprika/Store/DataPage.cs
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,11 @@ public Page DeleteByPrefix(in NibblePath prefix, IBatchContext batch)
buckets[prefix.Nibble0] = batch.GetAddress(child);
}
}
else
{
batch.RegisterForFutureReuse(page);
return batch.NullPage;
}
}
else
{
Expand Down
2 changes: 2 additions & 0 deletions src/Paprika/Store/IBatchContext.cs
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,8 @@ Page EnsureWritableCopy(ref DbAddress addr)
Page TryGetPageAlloc(ref DbAddress addr, PageType pageType);

BatchStats? Stats { get; }

public unsafe Page NullPage => new Page((byte*)0);
}

public class BatchStats : IBatchStats
Expand Down
5 changes: 5 additions & 0 deletions src/Paprika/Store/LeafOverflowPage.cs
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,11 @@ public Page DeleteByPrefix(in NibblePath prefix, IBatchContext batch)
var writable = batch.GetWritableCopy(page);
return new LeafOverflowPage(writable).DeleteByPrefix(prefix, batch);
}
if (prefix.IsEmpty)
{
batch.RegisterForFutureReuse(page);
return batch.NullPage;
}

Map.DeleteByPrefix(prefix);

Expand Down
4 changes: 2 additions & 2 deletions src/Paprika/Store/PagedDb.cs
Original file line number Diff line number Diff line change
Expand Up @@ -519,8 +519,8 @@ class Batch : BatchContextBase, IBatch
private readonly RootPage _root;
private readonly uint _reusePagesOlderThanBatchId;
private bool _verify = false;
private bool _disposed;

private bool _disposed;
private readonly Context _ctx;

/// <summary>
Expand Down
6 changes: 6 additions & 0 deletions src/Paprika/Store/StateRootPage.cs
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,12 @@ public Page DeleteByPrefix(in NibblePath prefix, IBatchContext batch)
return new StateRootPage(writable).DeleteByPrefix(prefix, batch);
}

if (prefix.IsEmpty)
{
batch.RegisterForFutureReuse(page);
return batch.NullPage;
}

Debug.Assert(prefix.Length > ConsumedNibbles, "Removing prefix at the root? Something went wrong.");

var index = GetIndex(prefix);
Expand Down
6 changes: 6 additions & 0 deletions src/Paprika/Store/StorageFanOut.cs
Original file line number Diff line number Diff line change
Expand Up @@ -188,6 +188,12 @@ public Page DeleteByPrefix(in NibblePath prefix, IBatchContext batch)
var writable = batch.GetWritableCopy(page);
return new Level1Page(writable).DeleteByPrefix(prefix, batch);
}
if (prefix.IsEmpty)
{
batch.RegisterForFutureReuse(page);
return batch.NullPage;
}


var index = GetIndex(prefix, Type.Storage, out var sliced);

Expand Down