Skip to content

Commit

Permalink
Delete more unused code
Browse files Browse the repository at this point in the history
  • Loading branch information
halgari committed Mar 27, 2024
1 parent ec158ae commit 8dbd76f
Show file tree
Hide file tree
Showing 9 changed files with 0 additions and 231 deletions.
55 changes: 0 additions & 55 deletions src/NexusMods.EventSourcing.Abstractions/Datom.cs

This file was deleted.

7 changes: 0 additions & 7 deletions src/NexusMods.EventSourcing.Abstractions/IAttribute.cs
Original file line number Diff line number Diff line change
Expand Up @@ -36,13 +36,6 @@ public interface IAttribute

bool IsIndexed { get; }

/// <summary>
/// Converts the datom to a typed datom
/// </summary>
/// <param name="datom"></param>
/// <returns></returns>
IReadDatom Resolve(Datom datom);

/// <summary>
/// Converts the given values into a typed datom
/// </summary>
Expand Down
32 changes: 0 additions & 32 deletions src/NexusMods.EventSourcing.Abstractions/IBlobColumn.cs

This file was deleted.

6 changes: 0 additions & 6 deletions src/NexusMods.EventSourcing.Abstractions/IDatomStore.cs
Original file line number Diff line number Diff line change
Expand Up @@ -36,12 +36,6 @@ public interface IDatomStore : IDisposable

IAttributeRegistry Registry { get; }

/// <summary>
/// Resolves the given datoms to typed datoms.
/// </summary>
/// <param name="datoms"></param>
IEnumerable<IReadDatom> Resolved(IEnumerable<Datom> datoms);

/// <summary>
/// Registers new attributes with the store. These should already have been transacted into the store.
/// </summary>
Expand Down
19 changes: 0 additions & 19 deletions src/NexusMods.EventSourcing.Abstractions/IEnumerableExtensions.cs

This file was deleted.

14 changes: 0 additions & 14 deletions src/NexusMods.EventSourcing.Abstractions/ScalarAttribute.cs
Original file line number Diff line number Diff line change
Expand Up @@ -80,20 +80,6 @@ public void SetSerializer(IValueSerializer serializer)
/// <inheritdoc />
public Symbol Id { get; }

/// <inheritdoc />
public IReadDatom Resolve(Datom datom)
{
throw new NotImplementedException();
_serializer.Read(datom.V.Span, out var read);
return new ReadDatom
{
E = datom.E,
V = read,
T = datom.T,
};
}


/// <inheritdoc />
public IReadDatom Resolve(EntityId entityId, AttributeId attributeId, ReadOnlySpan<byte> value, TxId tx, bool isRetract)
{
Expand Down
71 changes: 0 additions & 71 deletions src/NexusMods.EventSourcing.Storage/AttributeRegistry.cs
Original file line number Diff line number Diff line change
Expand Up @@ -67,14 +67,6 @@ public void Populate(DbAttribute[] attributes)
_attributesByAttributeId[id] = attr;
}
}
public void WriteValue<TWriter, TVal>(TVal val, in TWriter writer)
where TWriter : IBufferWriter<byte>
{
if (!_valueSerializersByNativeType.TryGetValue(typeof(TVal), out var serializer))
throw new InvalidOperationException($"No serializer found for type {typeof(TVal)}");

((IValueSerializer<TVal>)serializer).Serialize(val, writer);
}

public AttributeId GetAttributeId<TAttr>()
where TAttr : IAttribute
Expand Down Expand Up @@ -111,15 +103,6 @@ public IReadDatom Resolve(ReadOnlySpan<byte> datom)
}
}


public int CompareValues(in Datom a, in Datom b)
{
var attr = _dbAttributesByEntityId[a.A];
var type = _valueSerializersByUniqueId[attr.ValueTypeId];
return type.Compare(a.V.Span, b.V.Span);
}


public Expression GetReadExpression(Type attributeType, Expression valueSpan, out AttributeId attributeId)
{
var attr = _attributesByType[attributeType];
Expand All @@ -138,17 +121,6 @@ private sealed class CompareCache
}

private CompareCache _compareCache = new();
public int CompareValues<T>(T datomsValues, AttributeId attributeId, int a, int b) where T : IBlobColumn
{
var cache = _compareCache;
if (cache.AttributeId == attributeId)
return cache.Serializer.Compare(datomsValues[a].Span, datomsValues[b].Span);

var attr = _dbAttributesByEntityId[attributeId];
var type = _valueSerializersByUniqueId[attr.ValueTypeId];
_compareCache = new CompareCache {AttributeId = attributeId, Serializer = type};
return type.Compare(datomsValues[a].Span, datomsValues[b].Span);
}

public int CompareValues(AttributeId id, ReadOnlySpan<byte> a, ReadOnlySpan<byte> b)
{
Expand Down Expand Up @@ -186,49 +158,6 @@ public Symbol GetSymbolForAttribute(Type attribute)
return attr.Id;
}

public IReadDatom Resolve(Datom datom)
{
if (!_dbAttributesByEntityId.TryGetValue(datom.A, out var dbAttr))
throw new InvalidOperationException($"No attribute found for entity ID {datom.A}");

if (!_attributesById.TryGetValue(dbAttr.UniqueId, out var attr))
throw new InvalidOperationException($"No attribute found for unique ID {dbAttr.UniqueId}");

return attr.Resolve(datom);
}

public IReadDatom Resolve(EntityId entityId, AttributeId attributeId, ReadOnlySpan<byte> value, TxId tx, bool isRetract = false)
{
if (!_attributesByAttributeId.TryGetValue(attributeId, out var attr))
throw new InvalidOperationException($"No attribute found for AttributeId {attributeId}");

return attr.Resolve(entityId, attributeId, value, tx, isRetract);
}

public bool IsReference(AttributeId attributeId)
{
var dbAttr = _dbAttributesByEntityId[attributeId];
var attrobj = _attributesById[dbAttr.UniqueId];
return attrobj.IsReference;
}

public IValueSerializer<TValueType> GetSerializer<TValueType>()
{
if (!_valueSerializersByNativeType.TryGetValue(typeof(TValueType), out var serializer))
throw new InvalidOperationException($"No serializer found for type {typeof(TValueType)}");

return (IValueSerializer<TValueType>)serializer;
}

public TValue Read<TAttr, TValue>(ReadOnlySpan<byte> tValueSpan) where TAttr : IAttribute<TValue>
{
var attr = _attributesByType[typeof(TAttr)];
var dbAttr = _dbAttributesByUniqueId[attr.Id];
var serializer = (IValueSerializer<TValue>)_valueSerializersByUniqueId[dbAttr.ValueTypeId];
serializer.Read(tValueSpan, out var val);
return val;
}

public Type GetReadDatomType(Type attribute)
{
var attr = _attributesByType[attribute];
Expand Down
22 changes: 0 additions & 22 deletions src/NexusMods.EventSourcing.Storage/AttributeRegistryExtensions.cs

This file was deleted.

5 changes: 0 additions & 5 deletions src/NexusMods.EventSourcing.Storage/DatomStore.cs
Original file line number Diff line number Diff line change
Expand Up @@ -187,11 +187,6 @@ public async Task<StoreResult> Transact(IEnumerable<IWriteDatom> datoms)

public IObservable<(TxId TxId, ISnapshot Snapshot)> TxLog => _updatesSubject;

public IEnumerable<IReadDatom> Resolved(IEnumerable<Datom> datoms)
{
return datoms.Select(datom => _registry.Resolve(datom));
}

public async Task RegisterAttributes(IEnumerable<DbAttribute> newAttrs)
{
var datoms = new List<IWriteDatom>();
Expand Down

0 comments on commit 8dbd76f

Please sign in to comment.