[CSHARP-1117] Add a few methods to IBsonStream and make it a fully functional stream Created: 20/Nov/14 Updated: 02/Apr/15 Resolved: 09/Mar/15 |
|
| Status: | Closed |
| Project: | C# Driver |
| Component/s: | BSON |
| Affects Version/s: | None |
| Fix Version/s: | 2.0 |
| Type: | Improvement | Priority: | Major - P3 |
| Reporter: | Robert Stam | Assignee: | Robert Stam |
| Resolution: | Done | Votes: | 0 |
| Labels: | None | ||
| Remaining Estimate: | Not Specified | ||
| Time Spent: | Not Specified | ||
| Original Estimate: | Not Specified | ||
| Description |
|
We currently have an IBsonStream interface that has specialized method to read and write BSON primitive data types. If we added just a few methods to it (Read, ReadByte, Write, WriteBytes, etc...) it could act as a fully functional stream. Our I/O methods are built upon a stream, and if it so happens that the stream we are provided implements IBsonStream, then we use the more efficiently implemented methods from IBsonStream, otherwise we fall back on using the provided stream's Read and Write methods (which requires us to allocate some short lived byte arrays). If IBsonStream were a fully functional stream (where fully functional is defined as what we need), then internally we could work only with an IBsonStream. We would end up with probably two implementations of IBsonStream: 1. BsonStream (wraps a standard Stream and implements IBsonStream on top of it) The first would allow us to work with any Stream at all, with some additional overhead because of the need to create intermediate byte arrays when reading and writing some BSON primitives. The second would be efficiently implemented on top of an ISegmentedBuffer in a way that reduces allocation of temporary byte arrays, thus reducing GC pressure. The benefit internally is that we would only have to check in one place whether a Stream passed in to us implements IBsonStream or not. If it does, good, otherwise we wrap it in a BsonStream (which implemens IBsonStream). This eliminates multiple checks for whether the interface is implemented and will likely reduce the levels of indirection as well. This would also allow us to get rid of the current BsonStreamReader and BsonStreamWriter classes, since the functionality they currently provide is already provided by IBsonStream. |
| Comments |
| Comment by Githook User [ 12/Mar/15 ] |
|
Author: {u'username': u'rstam', u'name': u'rstam', u'email': u'robert@robertstam.org'}Message: |
| Comment by Githook User [ 09/Mar/15 ] |
|
Author: {u'username': u'rstam', u'name': u'rstam', u'email': u'robert@robertstam.org'}Message: |
| Comment by Githook User [ 09/Mar/15 ] |
|
Author: {u'username': u'rstam', u'name': u'rstam', u'email': u'robert@robertstam.org'}Message: |
| Comment by Githook User [ 09/Mar/15 ] |
|
Author: {u'username': u'rstam', u'name': u'rstam', u'email': u'robert@robertstam.org'}Message: |
| Comment by Githook User [ 09/Mar/15 ] |
|
Author: {u'username': u'rstam', u'name': u'rstam', u'email': u'robert@robertstam.org'}Message: |
| Comment by Githook User [ 09/Mar/15 ] |
|
Author: {u'username': u'rstam', u'name': u'rstam', u'email': u'robert@robertstam.org'}Message: |
| Comment by Githook User [ 09/Mar/15 ] |
|
Author: {u'username': u'rstam', u'name': u'rstam', u'email': u'robert@robertstam.org'}Message: |
| Comment by Githook User [ 09/Mar/15 ] |
|
Author: {u'username': u'rstam', u'name': u'rstam', u'email': u'robert@robertstam.org'}Message: |
| Comment by Githook User [ 09/Mar/15 ] |
|
Author: {u'username': u'rstam', u'name': u'rstam', u'email': u'robert@robertstam.org'}Message: |
| Comment by Githook User [ 09/Mar/15 ] |
|
Author: {u'username': u'rstam', u'name': u'rstam', u'email': u'robert@robertstam.org'}Message: |
| Comment by Githook User [ 09/Mar/15 ] |
|
Author: {u'username': u'rstam', u'name': u'rstam', u'email': u'robert@robertstam.org'}Message: |
| Comment by Githook User [ 09/Mar/15 ] |
|
Author: {u'username': u'rstam', u'name': u'rstam', u'email': u'robert@robertstam.org'}Message: |
| Comment by Githook User [ 09/Mar/15 ] |
|
Author: {u'username': u'rstam', u'name': u'rstam', u'email': u'robert@robertstam.org'}Message: |
| Comment by Githook User [ 09/Mar/15 ] |
|
Author: {u'username': u'rstam', u'name': u'rstam', u'email': u'robert@robertstam.org'}Message: |
| Comment by Githook User [ 09/Mar/15 ] |
|
Author: {u'username': u'rstam', u'name': u'rstam', u'email': u'robert@robertstam.org'}Message: |
| Comment by Githook User [ 09/Mar/15 ] |
|
Author: {u'username': u'rstam', u'name': u'rstam', u'email': u'robert@robertstam.org'}Message: |
| Comment by Githook User [ 09/Mar/15 ] |
|
Author: {u'username': u'rstam', u'name': u'rstam', u'email': u'robert@robertstam.org'}Message: |
| Comment by Githook User [ 09/Mar/15 ] |
|
Author: {u'username': u'rstam', u'name': u'rstam', u'email': u'robert@robertstam.org'}Message: |
| Comment by Githook User [ 09/Mar/15 ] |
|
Author: {u'username': u'rstam', u'name': u'rstam', u'email': u'robert@robertstam.org'}Message: |
| Comment by Githook User [ 09/Mar/15 ] |
|
Author: {u'username': u'rstam', u'name': u'rstam', u'email': u'robert@robertstam.org'}Message: |