Reformat / cleanup
All checks were successful
NuGet Publish / build-and-pack (push) Successful in 46s
NuGet Publish / publish-to-gitea (push) Successful in 56s

This commit is contained in:
Joseph Doherty
2026-02-21 08:10:36 -05:00
parent 4c6aaa5a3f
commit a70d8befae
176 changed files with 50555 additions and 49587 deletions

View File

@@ -1,5 +1,6 @@
using System.IO.Compression;
using System.IO.MemoryMappedFiles;
using System.Text;
using ZB.MOM.WW.CBDD.Core.Compression;
using ZB.MOM.WW.CBDD.Core.Storage;
using ZB.MOM.WW.CBDD.Shared;
@@ -9,12 +10,12 @@ namespace ZB.MOM.WW.CBDD.Tests;
public class CompressionOverflowTests
{
/// <summary>
/// Tests insert compressed document spanning overflow pages should round trip.
/// Tests insert compressed document spanning overflow pages should round trip.
/// </summary>
[Fact]
public void Insert_CompressedDocumentSpanningOverflowPages_ShouldRoundTrip()
{
var dbPath = NewDbPath();
string dbPath = NewDbPath();
var options = new CompressionOptions
{
EnableCompression = true,
@@ -28,7 +29,7 @@ public class CompressionOverflowTests
{
using var db = new TestDbContext(dbPath, TinyPageConfig(), options);
var payload = BuildPayload(300_000);
string payload = BuildPayload(300_000);
var id = db.Users.Insert(new User { Name = payload, Age = 40 });
db.SaveChanges();
@@ -47,12 +48,12 @@ public class CompressionOverflowTests
}
/// <summary>
/// Tests update should transition across compression thresholds.
/// Tests update should transition across compression thresholds.
/// </summary>
[Fact]
public void Update_ShouldTransitionAcrossCompressionThresholds()
{
var dbPath = NewDbPath();
string dbPath = NewDbPath();
var options = new CompressionOptions
{
EnableCompression = true,
@@ -123,13 +124,13 @@ public class CompressionOverflowTests
for (ushort slotIndex = 0; slotIndex < header.SlotCount; slotIndex++)
{
var slotOffset = SlottedPageHeader.Size + (slotIndex * SlotEntry.Size);
int slotOffset = SlottedPageHeader.Size + slotIndex * SlotEntry.Size;
var slot = SlotEntry.ReadFrom(buffer.AsSpan(slotOffset, SlotEntry.Size));
if ((slot.Flags & SlotFlags.Deleted) != 0)
continue;
var isCompressed = (slot.Flags & SlotFlags.Compressed) != 0;
var hasOverflow = (slot.Flags & SlotFlags.HasOverflow) != 0;
bool isCompressed = (slot.Flags & SlotFlags.Compressed) != 0;
bool hasOverflow = (slot.Flags & SlotFlags.HasOverflow) != 0;
if (isCompressed)
compressed++;
if (isCompressed && hasOverflow)
@@ -152,7 +153,7 @@ public class CompressionOverflowTests
private static string BuildPayload(int approxLength)
{
var builder = new System.Text.StringBuilder(approxLength + 256);
var builder = new StringBuilder(approxLength + 256);
var i = 0;
while (builder.Length < approxLength)
{
@@ -166,14 +167,16 @@ public class CompressionOverflowTests
}
private static string NewDbPath()
=> Path.Combine(Path.GetTempPath(), $"compression_overflow_{Guid.NewGuid():N}.db");
{
return Path.Combine(Path.GetTempPath(), $"compression_overflow_{Guid.NewGuid():N}.db");
}
private static void CleanupFiles(string dbPath)
{
var walPath = Path.ChangeExtension(dbPath, ".wal");
string walPath = Path.ChangeExtension(dbPath, ".wal");
var markerPath = $"{dbPath}.compact.state";
if (File.Exists(dbPath)) File.Delete(dbPath);
if (File.Exists(walPath)) File.Delete(walPath);
if (File.Exists(markerPath)) File.Delete(markerPath);
}
}
}