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
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ ArrowDb is a fast, lightweight, and type-safe key-value database designed for .N

* Super-Lightweight (dll size is ~19KB - approximately 9X smaller than [UltraLiteDb](https://github.com/rejemy/UltraLiteDB))
* Ultra-Fast (1,000,000 random operations / ~98ms on M2 MacBook Pro)
* Minimal-Allocation (constant ~520 bytes for serialization any db size)
* Minimal-Allocation (constant ~520 bytes for serialization of any db size)
* Thread-Safe and Concurrent
* ACID compliant on transaction level
* Type-Safe (no reflection - compile-time enforced via source-generated `JsonSerializerContext`)
Expand Down
4 changes: 2 additions & 2 deletions src/ArrowDbCore/ArrowDb.cs
Original file line number Diff line number Diff line change
Expand Up @@ -63,12 +63,12 @@ private void OnChangeInternal(ArrowDbChangeEventArgs args) {
/// <summary>
/// Thread-safe transaction depth tracker
/// </summary>
internal long TransactionDepth = 0;
internal long TransactionDepth;

/// <summary>
/// A state epoch used to detect concurrent <see cref="RollbackAsync"/> operations in hot write paths.
/// </summary>
internal long StateEpoch = 0;
internal long StateEpoch;

/// <summary>
/// Private Ctor
Expand Down
6 changes: 5 additions & 1 deletion src/ArrowDbCore/ArrowDbCore.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,10 @@
<EmbedUntrackedSources>true</EmbedUntrackedSources>
</PropertyGroup>

<PropertyGroup>
<NoWarn>$(NoWarn);CA1001</NoWarn>
</PropertyGroup>

<PropertyGroup>
<Authors>David Shnayder</Authors>
<Copyright>David Shnayder</Copyright>
Expand Down Expand Up @@ -59,4 +63,4 @@
</AssemblyAttribute>
</ItemGroup>

</Project>
</Project>
2 changes: 2 additions & 0 deletions src/ArrowDbCore/ArrowDbTransactionScope.cs
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,9 @@ public async ValueTask DisposeAsync() {
/// Disposes the scope and calls <see cref="ArrowDb.SerializeAsync"/> in a blocking operation
/// </summary>
public void Dispose() {
#pragma warning disable CA2012
var task = DisposeAsync();
#pragma warning restore CA2012
if (task.IsCompleted) {
return;
}
Expand Down
2 changes: 1 addition & 1 deletion src/ArrowDbCore/ChangeEventArgs.cs
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ public sealed class ArrowDbChangeEventArgs : EventArgs {
/// <summary>
/// The type of change that occurred
/// </summary>
public readonly ArrowDbChangeType ChangeType;
public ArrowDbChangeType ChangeType { get; init; }

private ArrowDbChangeEventArgs(ArrowDbChangeType changeType) {
ChangeType = changeType;
Expand Down
2 changes: 1 addition & 1 deletion src/ArrowDbCore/Readme.Nuget.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ A fast, lightweight, and type-safe key-value database designed for .NET.

* Super-Lightweight (dll size is ~19KB - approximately 9X smaller than [UltraLiteDb](https://github.com/rejemy/UltraLiteDB))
* Ultra-Fast (1,000,000 random operations / ~98ms on M2 MacBook Pro)
* Minimal-Allocation (constant ~520 bytes for serialization any db size)
* Minimal-Allocation (constant ~520 bytes for serialization of any db size)
* Thread-Safe and Concurrent
* ACID compliant on transaction level
* Type-Safe (no reflection - compile-time enforced via source-generated `JsonSerializerContext`)
Expand Down
14 changes: 12 additions & 2 deletions src/ArrowDbCore/Serializers/BaseFileSerializer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,11 @@ namespace ArrowDbCore.Serializers;
/// <summary>
/// Provides a base implementation for file-based serializers that ensures atomic and multi-process safe writes.
/// </summary>
public abstract class BaseFileSerializer : IDbSerializer {
public abstract class BaseFileSerializer : IDbSerializer, IDisposable {
private readonly string _dbFilePath;
private readonly string _tempFilePath;
private readonly Mutex _mutex;
private bool _disposed;

/// <summary>
/// Initializes a new instance of the <see cref="BaseFileSerializer"/> class.
Expand All @@ -25,7 +26,7 @@ protected BaseFileSerializer(string path) {
/// Finalizer to ensure the system-wide mutex is released when the serializer is garbage collected.
/// </summary>
~BaseFileSerializer() {
_mutex.Dispose();
Dispose();
}

/// <inheritdoc />
Expand Down Expand Up @@ -71,4 +72,13 @@ public ValueTask SerializeAsync(ConcurrentDictionary<string, byte[]> data) {
/// <param name="stream">The stream to read the data from.</param>
/// <returns>The deserialized dictionary.</returns>
protected abstract ValueTask<ConcurrentDictionary<string, byte[]>> DeserializeData(Stream stream);

/// <inheritdoc/>
public void Dispose() {
if (_disposed) return;

_mutex.Dispose();
_disposed = true;
GC.SuppressFinalize(this);
}
}