Skip to content
Merged
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
7 changes: 2 additions & 5 deletions src/SharpCoreDB/DataStructures/HashIndex.cs
Original file line numberDiff line numberDiff line change
Expand Up@@ -335,12 +335,9 @@ internal void RemoveBatchKeys(object?[] keys, long[] positions)

if (deferred != null)
{
foreach (var kvp in deferred)
foreach (var kvp in deferred.Where(static kvp => kvp.Value is not null))
{
if (kvp.Value is not null)
{
CompactPositionList(kvp.Key, kvp.Value);
}
CompactPositionList(kvp.Key, kvp.Value!);
}
}
}
Expand Down
12 changes: 4 additions & 8 deletions src/SharpCoreDB/DataStructures/Table.Compaction.cs
Original file line numberDiff line numberDiff line change
Expand Up@@ -300,14 +300,10 @@ private void RebuildAllIndexesFromFile()
hashIndex.Clear();
}

var loadedHashIndexes = new List<HashIndex>();
foreach (var kvp in hashIndexes)
{
if (loadedIndexes.Contains(kvp.Key))
{
loadedHashIndexes.Add(kvp.Value);
}
}
var loadedHashIndexes = hashIndexes
.Where(kvp => loadedIndexes.Contains(kvp.Key))
.Select(kvp => kvp.Value)
.ToList();

foreach (var (position, data) in engine.GetAllRecords(Name))
{
Expand Down
7 changes: 2 additions & 5 deletions src/SharpCoreDB/DataStructures/Table.Serialization.cs
Original file line numberDiff line numberDiff line change
Expand Up@@ -481,12 +481,9 @@ private void RebuildOverflowArenaFreeListFromDisk()
return;
}

foreach (var offset in _overflowArena.GetAllOffsets().ToList())
foreach (var offset in _overflowArena.GetAllOffsets().Where(offset => !live.Contains(offset)).ToList())
{
if (!live.Contains(offset))
{
_overflowArena.Free(offset);
}
_overflowArena.Free(offset);
}
}

Expand Down
4 changes: 2 additions & 2 deletions src/SharpCoreDB/Services/Storage.Append.cs
Original file line numberDiff line numberDiff line change
Expand Up@@ -326,9 +326,9 @@ private void WriteRecordInPlace(string path, long offset, ReadOnlySpan<byte> len
/// </summary>
public void CloseWriteHandles()
{
foreach (var (key, handle) in _writeHandleCache)
foreach (var (handleKey, handle) in _writeHandleCache)
{
if (_writeHandleCache.TryRemove(key, out _))
if (_writeHandleCache.TryRemove(handleKey, out _))
{
handle.Dispose();
}
Expand Down
Original file line numberDiff line numberDiff line change
Expand Up@@ -21,6 +21,8 @@ internal static class FixedWidthBenchmark
private const int VariableUpdates = 1_000;
private const int SelectRows = 100_000;
private const int SelectRounds = 30;
private const string FixedWidthLabel = "fixed-width";
private const string LegacyLabel = "legacy ";

public static void Run()
{
Expand DownExpand Up@@ -104,7 +106,7 @@ private static void RunGrowingUpdates(DatabaseFactory factory)
// overflow arena, which the auto-compaction (1000-update threshold) keeps bounded.
foreach (var fixedWidth in new[] { true, false })
{
var label = fixedWidth ? "fixed-width" : "legacy ";
var label = fixedWidth ? FixedWidthLabel : LegacyLabel;
var (db, dir) = CreateDatabase(factory, fixedWidth);
try
{
Expand DownExpand Up@@ -132,7 +134,7 @@ private static void RunGrowingUpdates(DatabaseFactory factory)
finally
{
(db as IDisposable)?.Dispose();
try { Directory.Delete(dir, true); } catch { }
try { Directory.Delete(dir, true); } catch { /* best-effort temp-dir cleanup */ }
}
}
}
Expand All@@ -141,7 +143,7 @@ private static void RunVariableUpdates(DatabaseFactory factory)
{
foreach (var fixedWidth in new[] { true, false })
{
var label = fixedWidth ? "fixed-width" : "legacy ";
var label = fixedWidth ? FixedWidthLabel : LegacyLabel;
var (db, dir) = CreateDatabase(factory, fixedWidth);
try
{
Expand DownExpand Up@@ -173,7 +175,7 @@ private static void RunVariableUpdates(DatabaseFactory factory)
finally
{
(db as IDisposable)?.Dispose();
try { Directory.Delete(dir, true); } catch { }
try { Directory.Delete(dir, true); } catch { /* best-effort temp-dir cleanup */ }
}
}
}
Expand All@@ -182,7 +184,7 @@ private static void RunSelectWhere(DatabaseFactory factory)
{
foreach (var fixedWidth in new[] { true, false })
{
var label = fixedWidth ? "fixed-width" : "legacy ";
var label = fixedWidth ? FixedWidthLabel : LegacyLabel;
var (db, dir) = CreateDatabase(factory, fixedWidth);
try
{
Expand DownExpand Up@@ -220,7 +222,7 @@ private static void RunSelectWhere(DatabaseFactory factory)
finally
{
(db as IDisposable)?.Dispose();
try { Directory.Delete(dir, true); } catch { }
try { Directory.Delete(dir, true); } catch { /* best-effort temp-dir cleanup */ }
}
}
}
Expand All@@ -232,7 +234,7 @@ private static void RunInsertThroughput(DatabaseFactory factory)

foreach (var fixedWidth in new[] { true, false })
{
var label = fixedWidth ? "fixed-width" : "legacy ";
var label = fixedWidth ? FixedWidthLabel : LegacyLabel;
var (db, dir) = CreateDatabase(factory, fixedWidth);
try
{
Expand DownExpand Up@@ -272,7 +274,7 @@ private static void RunInsertThroughput(DatabaseFactory factory)
finally
{
(db as IDisposable)?.Dispose();
try { Directory.Delete(dir, true); } catch { }
try { Directory.Delete(dir, true); } catch { /* best-effort temp-dir cleanup */ }
}
}
}
Expand Down
Loading
Loading