Skip to content

Commit

Permalink
Fix the tests
Browse files Browse the repository at this point in the history
  • Loading branch information
halgari committed Feb 20, 2024
1 parent 985badc commit 2ae09a0
Show file tree
Hide file tree
Showing 15 changed files with 35 additions and 138 deletions.
7 changes: 4 additions & 3 deletions benchmarks/NexusMods.EventSourcing.Benchmarks/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,15 @@

using System;
using System.Diagnostics;
using BenchmarkDotNet.Running;
using NexusMods.EventSourcing.Benchmarks.Benchmarks;


#if DEBUG

var benchmark = new ReadTests();
benchmark.Count = 1000;
var benchmark = new ReadTests
{
Count = 1000
};

var sw = Stopwatch.StartNew();
benchmark.Setup();
Expand Down
31 changes: 20 additions & 11 deletions src/NexusMods.EventSourcing.Abstractions/Datom.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,26 @@ namespace NexusMods.EventSourcing.Abstractions;

public interface IDatom

Check warning on line 5 in src/NexusMods.EventSourcing.Abstractions/Datom.cs

View workflow job for this annotation

GitHub Actions / Qodana Community for .NET

Missing XML comment for publicly visible type or member

Missing XML comment for publicly visible type or member 'NexusMods.EventSourcing.Abstractions.IDatom'
{
ulong E { get; }
/// <summary>
/// The entity id of the datom
/// </summary>
ulong Entity { get; }

Check notice on line 10 in src/NexusMods.EventSourcing.Abstractions/Datom.cs

View workflow job for this annotation

GitHub Actions / Qodana Community for .NET

Type member is never accessed via base type: Non-private accessibility

Only implementations of property 'Entity' are used

/// <summary>
/// The attribute of the datom
/// </summary>
Type Attribute { get; }

Check notice on line 15 in src/NexusMods.EventSourcing.Abstractions/Datom.cs

View workflow job for this annotation

GitHub Actions / Qodana Community for .NET

Type member is never accessed via base type: Non-private accessibility

Only implementations of property 'Attribute' are used

/// <summary>
/// The value of the datom
/// </summary>
Type ValueType { get; }

Check notice on line 20 in src/NexusMods.EventSourcing.Abstractions/Datom.cs

View workflow job for this annotation

GitHub Actions / Qodana Community for .NET

Type member is never used: Non-private accessibility

Property 'ValueType' is never used

/// <summary>
/// Sends the datom to the sink
/// </summary>
/// <param name="sink"></param>
/// <typeparam name="TSink"></typeparam>
void Emit<TSink>(ref TSink sink) where TSink : IDatomSink;

/// <summary>
Expand All @@ -25,7 +42,7 @@ public interface IDatomWithTx : IDatom
public class AssertDatom<TAttr, TVal>(ulong e, TVal v) : IDatom

Check warning on line 42 in src/NexusMods.EventSourcing.Abstractions/Datom.cs

View workflow job for this annotation

GitHub Actions / Qodana Community for .NET

Missing XML comment for publicly visible type or member

Missing XML comment for publicly visible type or member 'NexusMods.EventSourcing.Abstractions.AssertDatom<TAttr,TVal>'
where TAttr : IAttribute<TVal>
{
public ulong E => e;
public ulong Entity => e;

Check warning on line 45 in src/NexusMods.EventSourcing.Abstractions/Datom.cs

View workflow job for this annotation

GitHub Actions / Qodana Community for .NET

Missing XML comment for publicly visible type or member

Missing XML comment for publicly visible type or member 'NexusMods.EventSourcing.Abstractions.AssertDatom<TAttr,TVal>.Entity'

public TVal V => v;

Check warning on line 47 in src/NexusMods.EventSourcing.Abstractions/Datom.cs

View workflow job for this annotation

GitHub Actions / Qodana Community for .NET

Missing XML comment for publicly visible type or member

Missing XML comment for publicly visible type or member 'NexusMods.EventSourcing.Abstractions.AssertDatom<TAttr,TVal>.V'
public Type Attribute => typeof(TAttr);

Check warning on line 48 in src/NexusMods.EventSourcing.Abstractions/Datom.cs

View workflow job for this annotation

GitHub Actions / Qodana Community for .NET

Missing XML comment for publicly visible type or member

Missing XML comment for publicly visible type or member 'NexusMods.EventSourcing.Abstractions.AssertDatom<TAttr,TVal>.Attribute'
Expand Down Expand Up @@ -70,14 +87,6 @@ public AssertDatomWithTx(ulong e, TVal v, TxId tx) : base(e, v)

public override string ToString()

Check warning on line 88 in src/NexusMods.EventSourcing.Abstractions/Datom.cs

View workflow job for this annotation

GitHub Actions / Qodana Community for .NET

Missing XML comment for publicly visible type or member

Missing XML comment for publicly visible type or member 'NexusMods.EventSourcing.Abstractions.AssertDatomWithTx<TAttr,TVal>.ToString'
{
return $"(assert! {E}, {Attribute.Namespace}/{Attribute.Name}, {V}, {Tx})";
}
}


public static class Datom {
public static IDatom Assert<TAttr, TVal>(ulong e, TVal v) where TAttr : IAttribute<TVal>
{
return new AssertDatom<TAttr, TVal>(e, v);
return $"(assert! {Entity}, {Attribute.Namespace}/{Attribute.Name}, {V}, {Tx})";
}
}
11 changes: 0 additions & 11 deletions src/NexusMods.EventSourcing.Abstractions/IAttribute.cs
Original file line number Diff line number Diff line change
Expand Up @@ -37,11 +37,6 @@ public interface IAttribute
/// <summary>
/// Reads the value from the buffer and returns all the data as a Datom
/// </summary>
/// <param name="entity"></param>
/// <param name="tx"></param>
/// <param name="isAssert"></param>
/// <param name="buffer"></param>
/// <returns></returns>
public IDatom Read(ulong entity, ulong tx, bool isAssert, ReadOnlySpan<byte> buffer);
}

Expand All @@ -56,17 +51,11 @@ public interface IAttribute<TVal> : IAttribute
/// <summary>
/// Reads the value from the buffer and returns the value
/// </summary>
/// <param name="buffer"></param>
/// <returns></returns>
public TVal Read(ReadOnlySpan<byte> buffer);


/// <summary>
/// Creates a new assertion datom for the given entity and value
/// </summary>
/// <param name="tx"></param>
/// <param name="entity"></param>
/// <param name="value"></param>
public static abstract void Add(ITransaction tx, EntityId entity, TVal value);

Check notice on line 60 in src/NexusMods.EventSourcing.Abstractions/IAttribute.cs

View workflow job for this annotation

GitHub Actions / Qodana Community for .NET

Type member is never accessed via base type: Non-private accessibility

Only implementations of method 'Add' are used

}
5 changes: 0 additions & 5 deletions src/NexusMods.EventSourcing.Abstractions/IDb.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,6 @@ public interface IDb
/// </summary>
TxId BasisTxId { get; }

public IIterator Where<TAttr>()
where TAttr : IAttribute;

public IIterator Where(EntityId id);

/// <summary>
/// Returns a read model for each of the given entity ids.
/// </summary>
Expand Down
27 changes: 0 additions & 27 deletions src/NexusMods.EventSourcing.Abstractions/ISeekableIterator.cs

This file was deleted.

11 changes: 0 additions & 11 deletions src/NexusMods.EventSourcing.Abstractions/ITxLogDatomSink.cs

This file was deleted.

8 changes: 8 additions & 0 deletions src/NexusMods.EventSourcing.Abstractions/Models/IReadModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,5 +7,13 @@
/// </summary>
public interface IReadModel
{
/// <summary>
/// The entity id of the read model.
/// </summary>
public EntityId Id { get; }

Check notice on line 13 in src/NexusMods.EventSourcing.Abstractions/Models/IReadModel.cs

View workflow job for this annotation

GitHub Actions / Qodana Community for .NET

Type member is never accessed via base type: Non-private accessibility

Only implementations of property 'Id' are used

/// <summary>
/// The attached db instance of the read model.
/// </summary>
public IDb Db { get; }

Check notice on line 18 in src/NexusMods.EventSourcing.Abstractions/Models/IReadModel.cs

View workflow job for this annotation

GitHub Actions / Qodana Community for .NET

Type member is never accessed via base type: Non-private accessibility

Only implementations of property 'Db' are used
}
4 changes: 0 additions & 4 deletions src/NexusMods.EventSourcing.DatomStore/BuiltInAttributes.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,6 @@ namespace NexusMods.EventSourcing.DatomStore;

public static class BuiltInAttributes
{
public static void AddBuiltInAttributes(this IServiceCollection services) =>
services.AddAttribute<UniqueId>()
.AddAttribute<ValueSerializerId>();

/// <summary>
/// The unique identifier of the entity, used to link attributes across application restarts and model changes.
/// </summary>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,6 @@ public class BoolSerializer : IValueSerializer<bool>
/// <inheritdoc />
public UInt128 UniqueId => Id;

/// <inheritdoc />
public bool TryGetFixedSize(out int size)
{
size = 1;
return true;
}

/// <inheritdoc />
public int Compare(ReadOnlySpan<byte> a, ReadOnlySpan<byte> b)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,13 +18,6 @@ public class UInt128Serializer : IValueSerializer<UInt128>
/// <inheritdoc />
public UInt128 UniqueId => Id;

/// <inheritdoc />
public bool TryGetFixedSize(out int size)
{
size = 16;
return true;
}

/// <inheritdoc />
public int Compare(ReadOnlySpan<byte> a, ReadOnlySpan<byte> b)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ public void Init(RocksDb db)
ColumnFamilyHandle = db.CreateColumnFamily(_options, ColumnFamilyName);
}

public string ColumnFamilyName { get; } = columnFamilyName;
private string ColumnFamilyName { get; } = columnFamilyName;

public void Dispose()
{
Expand All @@ -63,20 +63,8 @@ public void Dispose()
}
}

public static unsafe int Compare(TOuter outer, KeyHeader* a, uint aLength, KeyHeader* b, uint bLength)
{
throw new NotImplementedException();
}

public void Put(WriteBatch batch, ReadOnlySpan<byte> span)
{
batch.Put(span, ReadOnlySpan<byte>.Empty, ColumnFamilyHandle);
}

public Iterator NewIterator()
{
var options = new ReadOptions();
options.SetTotalOrderSeek(true);
return Db.NewIterator(ColumnFamilyHandle, options);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ public bool Next()

_current = (KeyHeader*)Native.Instance.rocksdb_iter_key(_iterator.Handle, out _currentLength);

Debug.Assert(_currentLength < KeyHeader.Size, "Key length is less than KeyHeader.Size");
Debug.Assert(_currentLength >= KeyHeader.Size, "Key length is less than KeyHeader.Size");

if (_current->AttributeId != _key->AttributeId)
return false;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@ public bool Next()

_current = (KeyHeader*)Native.Instance.rocksdb_iter_key(_iterator.Handle, out _currentLength);

Debug.Assert(_currentLength < KeyHeader.Size, "Key length is less than KeyHeader.Size");
Debug.Assert(_currentLength >= KeyHeader.Size, "Key length is less than KeyHeader.Size");

if (_current->Entity != _key->Entity)
return false;
Expand Down
18 changes: 0 additions & 18 deletions src/NexusMods.EventSourcing.DatomStore/Indexes/TxIndex.cs

This file was deleted.

19 changes: 0 additions & 19 deletions tests/NexusMods.EventSourcing.TestModel/ModAttributes.cs

This file was deleted.

0 comments on commit 2ae09a0

Please sign in to comment.