Skip to content

Commit

Permalink
pacify C# re. BsatnRowListCount
Browse files Browse the repository at this point in the history
  • Loading branch information
Centril committed Sep 30, 2024
1 parent a7b6f6b commit 05f83e6
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions src/SpacetimeDBClient.cs
Original file line number Diff line number Diff line change
Expand Up @@ -245,6 +245,8 @@ private static int BsatnRowListCount(BsatnRowList list)
return list.RowsData.Length / size;
case RowSizeHint.RowOffsets(var offsets):
return offsets.Count;
default:
throw new InvalidOperationException();
}
}

Expand All @@ -266,7 +268,7 @@ private static IEnumerable<byte[]> BsatnRowListIter(BsatnRowList list)
}
case RowSizeHint.RowOffsets(var offsets):
{
start = offsets[index];
start = (int) offsets[index];
// The end is either the start of the next element or the end.
int end;
if (index + 1 == count)
Expand All @@ -275,7 +277,7 @@ private static IEnumerable<byte[]> BsatnRowListIter(BsatnRowList list)
}
else
{
end = offsets[index + 1];
end = (int) offsets[index + 1];
}
elemLen = end - start;
yield return new ReadOnlySpan<byte>(list.RowsData, start, elemLen).ToArray();
Expand Down Expand Up @@ -328,7 +330,8 @@ HashSet<byte[]> GetInsertHashSet(System.Type tableType, int tableSize)
switch (message)
{
case ServerMessage.InitialSubscription(var initialSubscription):
subscriptionInserts = new(capacity: initialSubscription.DatabaseUpdate.Tables.Sum(a => a.NumRows));
ulong cap = initialSubscription.DatabaseUpdate.Tables.Select(a => a.NumRows).Sum();

Check failure on line 333 in src/SpacetimeDBClient.cs

View workflow job for this annotation

GitHub Actions / build

'IEnumerable<ulong>' does not contain a definition for 'Sum' and the best extension method overload 'Enumerable.Sum(IEnumerable<decimal>)' requires a receiver of type 'System.Collections.Generic.IEnumerable<decimal>'

Check failure on line 333 in src/SpacetimeDBClient.cs

View workflow job for this annotation

GitHub Actions / build

'IEnumerable<ulong>' does not contain a definition for 'Sum' and the best extension method overload 'Enumerable.Sum(IEnumerable<decimal>)' requires a receiver of type 'System.Collections.Generic.IEnumerable<decimal>'
subscriptionInserts = new(capacity: (int) cap);

// First apply all of the state
foreach (var update in initialSubscription.DatabaseUpdate.Tables)
Expand All @@ -341,7 +344,7 @@ HashSet<byte[]> GetInsertHashSet(System.Type tableType, int tableSize)
continue;
}

var hashSet = GetInsertHashSet(table.ClientTableType, update.NumRows);
var hashSet = GetInsertHashSet(table.ClientTableType, (int) update.NumRows);

foreach (var cqu in update.Updates)
{
Expand Down

0 comments on commit 05f83e6

Please sign in to comment.