Skip to content
Draft
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
31 changes: 30 additions & 1 deletion sdks/csharp/examples~/regression-tests/client/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,8 @@ void ValidateBTreeIndexes(IRemoteDbContext conn)
Log.Debug("Checking indexes...");
foreach (var data in conn.Db.ExampleData.Iter())
{
Debug.Assert(conn.Db.ExampleData.Indexed.Filter(data.Id).Contains(data));
Log.Debug($"{data}: [{string.Join(", ", conn.Db.ExampleData.Indexed.Filter(data.Indexed))}]");
Debug.Assert(conn.Db.ExampleData.Indexed.Filter(data.Indexed).Contains(data));
}
var outOfIndex = conn.Db.ExampleData.Iter().ToHashSet();

Expand All @@ -107,10 +108,38 @@ void OnSubscriptionApplied(SubscriptionEventContext context)
waiting++;
context.Reducers.Add(1, 1);

Log.Debug("Calling Add");
waiting++;
context.Reducers.Add(2, 1);

Log.Debug("Calling Add");
waiting++;
context.Reducers.Add(3, 1);

Log.Debug("Calling Add");
waiting++;
context.Reducers.Add(4, 2);

Log.Debug("Calling Add");
waiting++;
context.Reducers.Add(6, 2);

Log.Debug("Calling Add");
waiting++;
context.Reducers.Add(5, 2);

Log.Debug("Calling Delete");
waiting++;
context.Reducers.Delete(1);

Log.Debug("Calling Delete");
waiting++;
context.Reducers.Delete(2);

Log.Debug("Calling Delete");
waiting++;
context.Reducers.Delete(3);

Log.Debug("Calling Add");
waiting++;
context.Reducers.Add(1, 1);
Expand Down
10 changes: 2 additions & 8 deletions sdks/csharp/src/MultiDictionary.cs
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ namespace SpacetimeDB
/// <typeparam name="TKey"></typeparam>
/// <typeparam name="TValue"></typeparam>
internal struct MultiDictionary<TKey, TValue> : IEquatable<MultiDictionary<TKey, TValue>>
where TValue : struct
{
// The actual data.
readonly Dictionary<TKey, (TValue Value, uint Multiplicity)> RawDict;
Expand Down Expand Up @@ -66,10 +67,6 @@ public static MultiDictionary<TKey, TValue> FromEnumerable(IEnumerable<KeyValueP
/// <returns>Whether the key is entirely new to the dictionary. If it was already present, we assert that the old value is equal to the new value.</returns>
public bool Add(TKey key, TValue value)
{
if (value == null)
{
throw new NullReferenceException("Null values are forbidden in multidictionary");
}
Debug.Assert(RawDict != null);
Debug.Assert(key != null);
if (RawDict.TryGetValue(key, out var result))
Expand Down Expand Up @@ -362,6 +359,7 @@ public override string ToString()
/// <typeparam name="TKey"></typeparam>
/// <typeparam name="TValue"></typeparam>
internal struct MultiDictionaryDelta<TKey, TValue> : IEquatable<MultiDictionaryDelta<TKey, TValue>>
where TValue : struct
{
/// <summary>
/// A change to an individual value associated to a key.
Expand Down Expand Up @@ -638,10 +636,6 @@ public MultiDictionaryDelta(IEqualityComparer<TKey> keyComparer, IEqualityCompar
/// <param name="item"></param>
public void Add(TKey key, TValue value)
{
if (value == null)
{
throw new NullReferenceException("Null values are forbidden in multidictionary");
}
Debug.Assert(RawDict != null);
Debug.Assert(key != null);
KeyDelta result;
Expand Down
Loading
Loading