BTDB 32.15.1

There is a newer version of this package available.
See the version list below for details.
dotnet add package BTDB --version 32.15.1                
NuGet\Install-Package BTDB -Version 32.15.1                
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="BTDB" Version="32.15.1" />                
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add BTDB --version 32.15.1                
#r "nuget: BTDB, 32.15.1"                
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
// Install BTDB as a Cake Addin
#addin nuget:?package=BTDB&version=32.15.1

// Install BTDB as a Cake Tool
#tool nuget:?package=BTDB&version=32.15.1                

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
Product Compatible and additional computed target framework versions.
.NET net8.0 is compatible.  net8.0-android was computed.  net8.0-browser was computed.  net8.0-ios was computed.  net8.0-maccatalyst was computed.  net8.0-macos was computed.  net8.0-tvos was computed.  net8.0-windows was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages (1)

Showing the top 1 NuGet packages that depend on BTDB:

Package Downloads
Bbcore.Lib

Package Description

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last updated
32.16.4 3,902 11/6/2024
32.16.3 316 10/25/2024
32.16.2 9,480 10/14/2024
32.16.1 6,077 10/11/2024
32.16.0 7,308 10/4/2024
32.15.1 731 8/29/2024
32.15.0 98 8/29/2024
32.14.1 1,112 8/17/2024
32.14.0 147 8/4/2024
32.13.1 29,879 7/31/2024
32.13.0 2,105 7/26/2024
32.12.1 256 7/21/2024
32.12.0 159 7/18/2024
32.11.0 3,972 7/6/2024
32.10.0 4,349 6/20/2024
32.9.0 175 6/15/2024
32.8.0 10,011 6/14/2024
32.7.1 17,481 5/15/2024
32.7.0 120 5/14/2024
32.6.2 3,660 5/6/2024
32.6.1 117 5/6/2024
32.6.0 201 5/1/2024
32.5.0 54,158 2/29/2024
32.4.29 457 2/26/2024
32.4.28 110 2/26/2024
32.4.26 17,292 2/21/2024
32.4.25 2,043 2/20/2024
32.4.24 495 2/19/2024
32.4.23 3,540 2/14/2024
32.4.22 126 2/13/2024
32.4.21 3,863 2/12/2024
32.4.20 270 2/7/2024
32.4.19 178 2/7/2024
32.4.18 257 2/1/2024
32.4.17 116 1/31/2024
32.4.16 113 1/30/2024
32.4.15 243 1/29/2024
32.4.14 119 1/29/2024
32.4.13 121 1/27/2024
32.4.12 120 1/26/2024
32.4.11 116 1/26/2024
32.4.10 106 1/26/2024
32.4.9 113 1/26/2024
32.4.8 110 1/26/2024
32.4.7 100 1/25/2024
32.4.6 111 1/25/2024
32.4.5 128 1/25/2024
32.4.4 109 1/24/2024
32.4.3 117 1/23/2024
32.4.2 108 1/23/2024
32.4.1 112 1/22/2024
32.4.0 124 1/21/2024
32.3.2 131 1/19/2024
32.3.1 119 1/18/2024
32.3.0 124 1/18/2024
32.2.0 130 1/17/2024
32.1.0 139 1/14/2024
32.0.3 148 1/8/2024
32.0.2 576 1/2/2024
32.0.1 136 1/2/2024
32.0.0 149 1/1/2024
31.15.0 9,795 1/22/2024
31.14.0 24,037 11/23/2023
31.13.0 4,383 11/21/2023
31.12.7 1,631 11/16/2023
31.12.6 252 11/16/2023
31.12.5 217 11/13/2023 31.12.5 is deprecated because it has critical bugs.
31.12.4 640 11/12/2023
31.12.3 8,908 10/30/2023
31.12.2 4,675 10/16/2023
31.12.1 5,110 10/5/2023
31.12.0 243 9/17/2023
31.11.3 30,142 8/10/2023
31.11.2 192 8/9/2023
31.11.1 173 8/8/2023
31.11.0 4,954 8/8/2023
31.10.0 1,052 8/3/2023
31.9.0 207 8/1/2023
31.8.2 2,752 8/1/2023
31.8.1 172 8/1/2023
31.8.0 25,030 6/8/2023
31.7.0 10,296 5/23/2023
31.6.0 212 5/21/2023
31.5.2 1,670 5/16/2023
31.5.1 17,636 4/13/2023
31.5.0 8,879 3/28/2023
31.4.3 3,693 3/24/2023
31.4.2 3,807 3/21/2023
31.4.1 284 3/21/2023
31.4.0 313 3/21/2023
31.3.2 17,037 2/20/2023
31.3.1 648 2/17/2023
31.3.0 315 2/15/2023
31.2.1 328 2/15/2023
31.2.0 1,998 2/15/2023
31.1.1 27,146 2/4/2023
31.1.0 362 2/3/2023
31.0.0 366 2/3/2023
30.5.0 13,912 1/10/2023
30.4.0 561 1/9/2023
30.3.0 6,777 1/3/2023
30.2.2 10,359 1/2/2023
30.2.1 411 1/2/2023
30.2.0 429 1/1/2023
30.1.0 372 12/21/2022
30.0.0 23,062 11/14/2022
29.12.1 485 11/3/2022
29.12.0 907 11/2/2022
29.11.0 522 9/7/2022
29.10.1 528 8/1/2022
29.10.0 510 8/1/2022
29.9.1 527 7/22/2022
29.9.0 544 7/17/2022
29.8.0 551 6/13/2022
29.7.0 542 6/8/2022
29.6.0 538 6/5/2022
29.5.0 557 5/18/2022
29.4.0 552 5/17/2022
29.3.0 546 5/13/2022
29.2.0 575 5/3/2022
29.1.1 8,763 3/29/2022
29.1.0 561 3/28/2022
29.0.0 597 2/28/2022
28.3.2 615 1/21/2022
28.3.1 561 1/21/2022
28.3.0 420 1/4/2022
28.2.0 429 12/19/2021
28.1.2 446 12/7/2021
28.1.1 380 12/6/2021
28.1.0 401 11/29/2021
28.0.0 422 11/17/2021
27.0.3 477 11/17/2021
27.0.2 1,682 11/7/2021
27.0.0 434 11/2/2021
26.2.1 718 5/8/2021
24.0.2 21,214 6/15/2020
24.0.1 817 6/13/2020
24.0.0 675 6/13/2020
23.1.0 839 5/23/2020
23.0.0 668 5/18/2020
22.2.2 677 5/14/2020
22.2.1 651 5/14/2020
22.2.0 631 5/13/2020
22.1.0 649 5/12/2020
22.0.0 671 5/10/2020
21.0.0 699 5/6/2020
20.3.0 739 5/2/2020
20.0.0 786 4/25/2020
19.5.0 1,235 3/10/2020
19.4.0 1,684 11/30/2019
19.3.0 1,104 11/6/2019
19.2.0 786 11/3/2019
19.1.0 972 10/13/2019
19.0.0 813 10/6/2019
18.2.2 1,091 9/19/2019
18.2.1 860 9/16/2019
18.2.0 887 9/8/2019
18.1.0 910 9/2/2019
18.0.0 795 9/1/2019
17.10.0 828 8/28/2019
17.9.0 1,989 7/24/2019
17.8.0 1,718 7/13/2019
17.7.0 1,460 6/9/2019
17.6.0 1,367 5/10/2019
17.5.2 1,391 5/9/2019
17.5.1 1,408 5/9/2019
17.5.0 1,433 4/16/2019
17.4.2 1,555 2/12/2019
17.4.1 1,476 2/6/2019
17.4.0 1,472 2/6/2019
17.3.0 1,475 1/25/2019
17.2.0 1,525 1/8/2019
17.1.0 1,450 12/24/2018
17.0.1 1,517 12/20/2018
17.0.0 1,525 12/16/2018
16.2.1 1,569 12/11/2018
14.12.2 1,689 10/15/2018
14.7.0 1,871 8/16/2018
14.6.0 1,657 8/2/2018
14.5.2 1,778 7/9/2018
14.5.1 1,740 6/20/2018
14.5.0 1,744 6/13/2018
14.4.0 1,779 6/10/2018
14.3.0 1,826 6/10/2018
14.2.1 1,771 6/7/2018
14.2.0 1,677 6/6/2018
14.1.0 1,659 6/6/2018
14.0.0 1,728 6/5/2018
13.1.0 1,760 6/3/2018
13.0.0 1,788 5/7/2018
12.7.0 1,866 4/15/2018
12.6.1 1,834 3/23/2018
12.6.0 1,842 3/18/2018
12.5.1 1,804 2/26/2018
12.5.0 1,841 2/12/2018
12.4.0 1,866 1/31/2018
12.3.0 1,799 1/29/2018
12.2.0 1,822 1/9/2018
12.1.0 1,878 12/10/2017
12.0.0 1,764 12/3/2017
11.10.1 1,942 11/20/2017
11.10.0 1,957 11/3/2017
11.9.1 1,940 11/2/2017
11.9.0 1,910 10/31/2017
11.8.1 1,906 10/30/2017
11.8.0 1,914 10/28/2017
11.7.0 1,943 10/26/2017
11.6.5 1,958 10/24/2017
11.6.4 1,961 10/23/2017
11.6.3 1,981 10/20/2017
11.6.2 1,930 10/19/2017
11.6.1 1,936 10/18/2017
11.6.0 1,937 10/15/2017
11.5.0 1,927 10/8/2017
11.4.0 2,178 9/6/2017
11.3.0 1,944 9/4/2017
11.2.0 1,752 8/20/2017
11.1.0 1,708 8/9/2017
11.0.4 1,767 7/30/2017
11.0.3 1,787 7/24/2017
11.0.2 1,887 7/21/2017
11.0.1 1,744 7/21/2017
11.0.0 1,814 7/19/2017
10.6.0 1,800 6/27/2017
10.5.2 1,863 6/23/2017
10.5.1 1,830 6/22/2017
10.5.0 1,791 6/17/2017
10.4.3 1,781 5/31/2017
10.4.2 1,750 5/25/2017
10.4.1 1,816 5/22/2017
10.4.0 1,757 5/19/2017
10.3.0 1,766 5/11/2017
10.2.0 1,773 4/21/2017
10.1.2 1,748 4/14/2017
10.1.1 1,746 4/12/2017
10.1.0 1,777 4/7/2017
10.0.2 1,733 3/28/2017
10.0.1 1,758 3/26/2017
10.0.0 1,786 3/20/2017
9.4.0 1,751 3/12/2017
9.3.1 1,775 3/9/2017
9.3.0 1,784 3/6/2017
9.2.1 1,762 2/28/2017
9.2.0 1,843 2/21/2017
9.1.1 1,783 2/15/2017
9.1.0 1,889 2/8/2017
9.0.4 1,875 1/23/2017
9.0.3 1,829 12/20/2016
9.0.2 1,760 12/18/2016
9.0.0 1,827 12/12/2016
8.0.1 1,828 12/10/2016
8.0.0 1,840 11/28/2016
7.0.0 1,833 11/23/2016
6.0.0 2,150 11/17/2016
5.7.0 2,392 11/3/2016
5.6.4 2,349 11/2/2016
5.6.3 2,051 10/30/2016
5.6.2 2,062 10/26/2016
5.6.1 2,019 10/26/2016
5.6.0 2,040 10/24/2016
5.5.0 2,066 10/22/2016
5.4.0 2,100 10/21/2016
5.3.2 2,098 10/16/2016
5.3.1 2,067 9/14/2016
5.3.0 2,125 9/13/2016
5.2.0 2,062 9/11/2016
5.1.0 2,055 9/9/2016
5.0.0 2,008 9/8/2016
4.0.1 2,027 9/8/2016
4.0.0 2,032 9/7/2016
3.6.0 2,039 9/4/2016
3.5.0 2,071 9/1/2016
3.4.0 2,104 8/8/2016
3.3.0 2,127 7/18/2016
3.2.3 2,112 6/28/2016
3.2.2 2,531 6/15/2016
3.2.1 2,098 6/7/2016
3.2.0 2,082 6/5/2016
3.1.0 2,091 5/30/2016
3.0.0 2,163 5/19/2016
2.12.0 2,206 4/10/2016
2.11.0 2,205 4/9/2016
2.10.1 1,913 3/16/2016
2.10.0 2,188 2/17/2016
2.9.1 2,188 12/13/2015
2.9.0 2,152 12/8/2015
2.8.5 2,228 11/27/2015
2.8.4 2,179 11/27/2015
2.8.2 2,169 11/4/2015
2.8.1 2,117 11/4/2015
2.8.0 2,169 11/1/2015
2.7.0 2,347 6/27/2015
2.6.3 2,213 6/16/2015
2.6.2 2,339 6/14/2015
2.6.1 2,237 5/15/2015
2.6.0 2,298 4/13/2015
2.5.3 2,322 1/26/2015
2.5.2 2,545 12/13/2014
2.5.1 2,449 11/18/2014
2.5.0 2,324 10/13/2014
2.4.5 2,267 10/6/2014
2.4.4 2,449 6/3/2014
2.4.3 2,289 6/2/2014
2.4.2 2,314 5/30/2014
2.4.0 2,651 3/14/2014
2.3.2 2,218 2/3/2014
2.3.1 2,080 12/15/2013
2.3.0 2,056 12/14/2013
2.2.2 2,163 12/12/2013
2.2.1 2,124 12/11/2013
2.2.0 2,175 12/8/2013
2.1.0 2,171 12/8/2013
2.0.2 2,222 12/2/2013
2.0.1 2,208 11/26/2013
2.0.0 2,160 11/14/2013
1.2.1 2,134 11/11/2013
1.1.0 2,193 9/5/2013
1.0.0 2,170 9/1/2013