-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Batch by size, Closures and Detached items are computed differently (#…
…164) * Can debug dependencies * Different exceptions * Uses root id only after we found it to signal the end * DataChunks are created later and need to be accounted for * format * use app ids in tests and references * check sqlite cache after serialize * use dummy to go through channels to end * fmt * Extend channel lib to batch by size * fmt * build fix * adjust limits * FIx sending * Optimize reference generation * more * remove tolist * rework closures to be constant and serializer only deals with current....references bases are cached * fix chunk creation * another bug fix * clean up with factories * add deserializer factory * Needed to reference interface * move around streamId * some clean up * Use StringBuilder pool on serialization to reduce memory pressure * remove extra * remove extra clears * Fix a flaw in batchsize * use default complete * format * loader should use 1 writer that is batched * remove redundant ref gen * Fix graphql commands by adding project id
- Loading branch information
1 parent
43445bc
commit 715bb72
Showing
33 changed files
with
396 additions
and
327 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
21 changes: 21 additions & 0 deletions
21
src/Speckle.Sdk.Dependencies/Serialization/ChannelExtensions.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
using System.Threading.Channels; | ||
using Open.ChannelExtensions; | ||
using Speckle.Sdk.Dependencies.Serialization; | ||
|
||
namespace Speckle.Sdk.Serialisation.V2.Send; | ||
|
||
public static class ChannelExtensions | ||
{ | ||
public static BatchingChannelReader<BaseItem, List<BaseItem>> BatchBySize( | ||
this ChannelReader<BaseItem> source, | ||
int batchSize, | ||
bool singleReader = false, | ||
bool allowSynchronousContinuations = false | ||
) => | ||
new SizeBatchingChannelReader( | ||
source ?? throw new ArgumentNullException(nameof(source)), | ||
batchSize, | ||
singleReader, | ||
allowSynchronousContinuations | ||
); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
63 changes: 17 additions & 46 deletions
63
src/Speckle.Sdk.Dependencies/Serialization/ChannelSaver.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
36 changes: 36 additions & 0 deletions
36
src/Speckle.Sdk.Dependencies/Serialization/SizeBatchingChannelReader.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
using System.Threading.Channels; | ||
using Open.ChannelExtensions; | ||
using Speckle.Sdk.Dependencies.Serialization; | ||
|
||
namespace Speckle.Sdk.Serialisation.V2.Send; | ||
|
||
public class SizeBatchingChannelReader( | ||
ChannelReader<BaseItem> source, | ||
int batchSize, | ||
bool singleReader, | ||
bool syncCont = false | ||
) : BatchingChannelReader<BaseItem, List<BaseItem>>(source, batchSize, singleReader, syncCont) | ||
{ | ||
private readonly int _batchSize = batchSize; | ||
|
||
protected override List<BaseItem> CreateBatch(int capacity) => new(); | ||
|
||
protected override void TrimBatch(List<BaseItem> batch) => batch.TrimExcess(); | ||
|
||
protected override void AddBatchItem(List<BaseItem> batch, BaseItem item) => batch.Add(item); | ||
|
||
protected override int GetBatchSize(List<BaseItem> batch) | ||
{ | ||
int size = 0; | ||
foreach (BaseItem item in batch) | ||
{ | ||
size += item.Size; | ||
} | ||
|
||
if (size >= _batchSize) | ||
{ | ||
return _batchSize; | ||
} | ||
return size; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.