BTDB.SourceGenerator
32.13.0
See the version list below for details.
dotnet add package BTDB.SourceGenerator --version 32.13.0
NuGet\Install-Package BTDB.SourceGenerator -Version 32.13.0
<PackageReference Include="BTDB.SourceGenerator" Version="32.13.0" />
paket add BTDB.SourceGenerator --version 32.13.0
#r "nuget: BTDB.SourceGenerator, 32.13.0"
// Install BTDB.SourceGenerator as a Cake Addin #addin nuget:?package=BTDB.SourceGenerator&version=32.13.0 // Install BTDB.SourceGenerator as a Cake Tool #tool nuget:?package=BTDB.SourceGenerator&version=32.13.0
BTDB
Currently this project these parts:
- Key Value Database
- Wrapped Dynamic IL generation with debugging + extensions
- IOC Container (SourceGenerator based)
- Object Database with Relations
- Snappy Compression
- Event Storage
- Bon (Binary object notation)
- Incremental SourceGenerator for IOC Container factory generation
All code written in C# 11 and licensed under very permissive MIT license. Targeting .Net 8.0, main code has just 1 dependency (Microsoft.Extensions.Primitives). Code is tested using xUnit Framework. Used in production on Windows and Linux, on MacOS works as well. Please is you find it useful or have questions, write me e-mail boris.letocha@gmail.com so I know that it is used. It is available in Nuget http://www.nuget.org/packages/BTDB. Source code drops are Github releases.
Key Value Database
Features
- This is Key Value store written in C# with 2 implementation old on managed heap and new on native heap (has also prefix compression).
- It is easily embeddable.
- One storage is just one directory.
- It has ACID properties with MVCC.
- At one time there could be multiple read only transactions and one read/write transaction.
- Export/Import to stream - could be used for compaction, snapshotting
- Automatic compaction
- Customizable compression
- Relatively Fast DB Open due to key index file - though it still needs to load all keys to memory
- Inspired by Bitcask [https://github.com/basho/bitcask/blob/develop/doc/bitcask-intro.pdf]
Design limits
- All keys data needs to fit in RAM
- Maximum Key length is limited by 31bits (2GB).
- Maximum value length is limited by 31bits (2GB).
Sample code
using (var fileCollection = new InMemoryFileCollection())
using (IKeyValueDB db = new KeyValueDB(fileCollection))
{
using (var tr = db.StartTransaction())
{
tr.CreateOrUpdateKeyValue(new byte[] { 1 }, new byte[100000]);
tr.Commit();
}
}
Roadmap
- Everything is there just use it
Wrapped Dynamic IL generation with debugging + extensions
This help you to write fluent code which generates IL code in runtime. It is used in Object Database part.
Sample code
var method = ILBuilder.Instance.NewMethod<Func<Nested>>("SampleCall");
var il = method.Generator;
var local = il.DeclareLocal(typeof(Nested), "n");
il
.Newobj(() => new Nested())
.Dup()
.Stloc(local)
.Ldstr("Test")
.Call(() => ((Nested)null).Fun(""))
.Ldloc(local)
.Ret();
var action = method.Create();
Roadmap
- Add support for all IL instructions as needed
- Deprecate this by replacing its usages by Source Generator
Object Database
Features
- Builds on top of Key Value Database and Reflection.Emit extensions.
- It stores Plain .Net Objects and only their public properties with getters and setters.
- All ACID and MVCC properties are preserved of course.
- Automatic upgrading of model on read with dynamically generated optimal IL code.
- Automatic versioning of model changes.
- Enumeration of all objects
- Each object type could store its "singleton" - very useful for root objects
- Relations - Table with primary key and multiple secondary keys
- By default objects are stored inline in parent object, use IIndirect for objects with Oid which will load lazily
Documentation: [https://github.com/Bobris/BTDB/blob/master/Doc/ODBDictionary.md]
Relations doc: [https://github.com/Bobris/BTDB/blob/master/Doc/Relations.md]
Sample code
public class Person
{
public string Name { get; set; }
public uint Age { get; set; }
}
using (var tr = _db.StartTransaction())
{
tr.Store(new Person { Name = "Bobris", Age = 35 });
tr.Commit();
}
using (var tr = _db.StartTransaction())
{
var p = tr.Enumerate<Person>().First();
Assert.AreEqual("Bobris", p.Name);
Assert.AreEqual(35, p.Age);
}
Roadmap
- Support more types of properties
- Free text search (far future if ever)
Event storage
Features
- Optimal serialization with metadata
- Deserialization also to dynamic
- Storage is transactional
- As storage could be used Azure Page Blobs
- EventStorage2 is specialized to be used with Kafka, metadata are stored in separate topic
Bon
Bon
Binary object notation is allows creating and reading JavaScript/C# values with extensions like Dictionary/Map into binary notation. It is much faster to parse, write, skip, search by keys than JSON, size will be also smaller in most cases, in some cases much more smaller.
Snappy Compression
Features
- Ported and inspired mainly by Go version of Snappy Compression [http://code.google.com/p/snappy/]
- Fully compatible with original
- Fully managed and safe implementation
- Compression is aborted when target buffer size is not big enough
Roadmap
- Some speed optimizations around Spans would help
Learn more about Target Frameworks and .NET Standard.
-
.NETStandard 2.0
- No dependencies.
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.
Version | Downloads | Last updated |
---|---|---|
32.16.4 | 6,773 | 11/6/2024 |
32.16.3 | 78 | 10/25/2024 |
32.16.2 | 9,687 | 10/14/2024 |
32.16.1 | 6,284 | 10/11/2024 |
32.16.0 | 3,098 | 10/4/2024 |
32.15.1 | 106 | 8/29/2024 |
32.15.0 | 95 | 8/29/2024 |
32.14.1 | 159 | 8/17/2024 |
32.14.0 | 78 | 8/4/2024 |
32.13.1 | 29,221 | 7/31/2024 |
32.13.0 | 2,082 | 7/26/2024 |
32.12.1 | 100 | 7/21/2024 |
32.12.0 | 98 | 7/18/2024 |
32.11.0 | 3,835 | 7/6/2024 |
32.10.0 | 3,856 | 6/20/2024 |
32.9.0 | 105 | 6/15/2024 |
32.8.0 | 9,970 | 6/14/2024 |
32.7.1 | 16,396 | 5/15/2024 |
32.7.0 | 108 | 5/14/2024 |
32.6.2 | 3,550 | 5/6/2024 |
32.6.1 | 102 | 5/6/2024 |
32.6.0 | 143 | 5/1/2024 |
32.5.0 | 33,594 | 2/29/2024 |
32.4.29 | 504 | 2/26/2024 |
32.4.28 | 187 | 2/26/2024 |
32.4.26 | 17,676 | 2/21/2024 |
32.4.25 | 2,079 | 2/20/2024 |
32.4.24 | 543 | 2/19/2024 |
32.4.23 | 3,743 | 2/14/2024 |
32.4.22 | 154 | 2/13/2024 |
32.4.21 | 3,867 | 2/12/2024 |
32.4.20 | 247 | 2/7/2024 |
32.4.19 | 192 | 2/7/2024 |
32.4.18 | 269 | 2/1/2024 |
32.4.17 | 128 | 1/31/2024 |
32.4.16 | 129 | 1/30/2024 |
32.4.15 | 289 | 1/29/2024 |
32.4.14 | 134 | 1/29/2024 |
32.4.13 | 156 | 1/27/2024 |
32.4.12 | 169 | 1/26/2024 |
32.4.11 | 149 | 1/26/2024 |
32.4.10 | 167 | 1/26/2024 |
32.4.9 | 159 | 1/26/2024 |
32.4.8 | 159 | 1/26/2024 |
32.4.7 | 147 | 1/25/2024 |
32.4.6 | 106 | 1/25/2024 |
32.4.5 | 180 | 1/25/2024 |
32.4.4 | 176 | 1/24/2024 |
32.4.3 | 152 | 1/23/2024 |
32.4.2 | 190 | 1/23/2024 |
32.4.1 | 150 | 1/22/2024 |
32.4.0 | 152 | 1/21/2024 |
32.3.2 | 129 | 1/19/2024 |
32.3.1 | 143 | 1/18/2024 |
32.3.0 | 185 | 1/18/2024 |
32.2.0 | 166 | 1/17/2024 |
32.1.0 | 166 | 1/14/2024 |
32.0.3 | 190 | 1/8/2024 |
32.0.2 | 130 | 1/2/2024 |
32.0.1 | 123 | 1/2/2024 |
32.0.0 | 147 | 1/1/2024 |