![]() |
VOOZH | about |
dotnet add package SharpJuice.ClickHouse --version 1.0.7
NuGet\Install-Package SharpJuice.ClickHouse -Version 1.0.7
<PackageReference Include="SharpJuice.ClickHouse" Version="1.0.7" />
<PackageVersion Include="SharpJuice.ClickHouse" Version="1.0.7" />Directory.Packages.props
<PackageReference Include="SharpJuice.ClickHouse" />Project file
paket add SharpJuice.ClickHouse --version 1.0.7
#r "nuget: SharpJuice.ClickHouse, 1.0.7"
#:package SharpJuice.ClickHouse@1.0.7
#addin nuget:?package=SharpJuice.ClickHouse&version=1.0.7Install as a Cake Addin
#tool nuget:?package=SharpJuice.ClickHouse&version=1.0.7Install as a Cake Tool
Octonica.ClickHouseClient extension for easily writing objects to ClickHouse using bulk insert and ArrayPool for high performance and low memory allocation.
ClickHouseConnectionSettings connectionSettings = ...;
services.AddSingleton<IClickHouseConnectionFactory>(new ClickHouseConnectionFactory(connectionSettings));
services.AddSingleton<ITableWriterBuilder, TableWriterBuilder>();
services.AddSingleton<ClickHouseRepository>();
public sealed class ClickHouseRepository
{
private readonly ITableWriter<Order> _tableWriter;
public ClickHouseRepository(ITableWriterBuilder tableWriterBuilder)
{
_tableWriter = tableWriterBuilder
.For<Order>("table_name")
.AddColumn("order_id", a => a.OrderId)
.AddColumn("user_id", a => a.UserId)
.AddColumn("created_at", a => a.CreatedAt)
.Build();
}
public async Task Add(IReadOnlyCollection<Order> orders, CancellationToken token)
{
...
await _tableWriter.Insert(orders, token);
...
}
}
public sealed class ClickHouseRepository
{
private readonly ITableWriter<Order> _tableWriter;
public ClickHouseRepository(ITableWriterBuilder tableWriterBuilder)
{
_tableWriter = tableWriterBuilder
.For<Order>("table_name")
.AddColumn("order_id", a => a.OrderId)
.AddColumn("date", a => a.Date)
.AddNestedColumn("item", x => x.Items, c => c
.AddColumn("id", x => x.Id)
.AddColumn("quantity", x => x.Quantity)
.AddColumn("name", x => x.Name)
.AddColumn("price", x => x.Price))
.AddNestedColumn(x => x.Discounts, c => c
.AddColumn("discount.id", x => x.Id)
.AddColumn("discount.name", x => x.Name)
.AddColumn("discount.value", x => x.Value))
.Build();
}
public async Task Add(IReadOnlyCollection<Order> orders, CancellationToken token)
{
...
await _tableWriter.Insert(orders, token);
...
}
}
public sealed class ClickHouseRepository
{
private readonly ITableWriter<Order> _tableWriter;
public ClickHouseRepository(ITableWriterBuilder tableWriterBuilder)
{
_tableWriter = tableWriterBuilder
.For<Order>("table_name")
.AddColumn("order_id", a => a.OrderId)
.AddColumn("date", a => a.Date)
.ArrayJoin(a => a.Items, c => c
.AddColumn("item_id", x => x.Id)
.AddColumn("item_quantity", x => x.Quantity)
.AddColumn("item_name", x => x.Name)
.AddColumn("item_price", x => x.Price))
.Build();
}
public async Task Add(IReadOnlyCollection<Order> orders, CancellationToken token)
{
...
await _tableWriter.Insert(orders, token);
...
}
}
| Method | ObjectsCount | Mean | Error | StdDev | Gen0 | Gen1 | Gen2 | Allocated |
|---|---|---|---|---|---|---|---|---|
| NestedObject_Writer | 1000 | 71.87 ms | 1.425 ms | 2.176 ms | - | - | - | 1148.29 KB |
| FlatObject_Writer | 1000 | 73.33 ms | 1.159 ms | 1.028 ms | 375.0000 | 250.0000 | - | 2837.81 KB |
| ClickhouseClient_ColumnWriter | 1000 | 78.63 ms | 1.631 ms | 4.731 ms | 428.5714 | 142.8571 | - | 2948.86 KB |
| NestedObject_Writer | 100 | 101.91 ms | 1.629 ms | 1.523 ms | - | - | - | 205 KB |
| ClickhouseClient_ColumnWriter | 100 | 102.99 ms | 2.008 ms | 2.749 ms | - | - | - | 368.33 KB |
| FlatObject_Writer | 100 | 103.24 ms | 2.025 ms | 2.633 ms | - | - | - | 358.71 KB |
| NestedObject_Writer | 10000 | 281.58 ms | 10.143 ms | 29.102 ms | 1000.0000 | - | - | 9140.61 KB |
| ClickhouseClient_ColumnWriter | 10000 | 284.90 ms | 9.745 ms | 27.325 ms | 4000.0000 | 1000.0000 | - | 27643.59 KB |
| FlatObject_Writer | 10000 | 302.62 ms | 13.242 ms | 38.836 ms | 4000.0000 | 1000.0000 | - | 26020.02 KB |
| NestedObject_Writer | 30000 | 712.17 ms | 23.182 ms | 67.622 ms | 2000.0000 | 1000.0000 | - | 14370.6 KB |
| ClickhouseClient_ColumnWriter | 30000 | 775.75 ms | 22.886 ms | 66.396 ms | 11000.0000 | 5000.0000 | 2000.0000 | 69326.91 KB |
| FlatObject_Writer | 30000 | 781.20 ms | 24.974 ms | 72.057 ms | 10000.0000 | 3000.0000 | - | 65002.87 KB |
Thanks to @deniskuzmin and @LegaNoga
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net6.0 net6.0 is compatible. net6.0-android net6.0-android was computed. net6.0-ios net6.0-ios was computed. net6.0-maccatalyst net6.0-maccatalyst was computed. net6.0-macos net6.0-macos was computed. net6.0-tvos net6.0-tvos was computed. net6.0-windows net6.0-windows was computed. net7.0 net7.0 was computed. net7.0-android net7.0-android was computed. net7.0-ios net7.0-ios was computed. net7.0-maccatalyst net7.0-maccatalyst was computed. net7.0-macos net7.0-macos was computed. net7.0-tvos net7.0-tvos was computed. net7.0-windows net7.0-windows was computed. net8.0 net8.0 is compatible. net8.0-android net8.0-android was computed. net8.0-browser net8.0-browser was computed. net8.0-ios net8.0-ios was computed. net8.0-maccatalyst net8.0-maccatalyst was computed. net8.0-macos net8.0-macos was computed. net8.0-tvos net8.0-tvos was computed. net8.0-windows net8.0-windows was computed. net9.0 net9.0 was computed. net9.0-android net9.0-android was computed. net9.0-browser net9.0-browser was computed. net9.0-ios net9.0-ios was computed. net9.0-maccatalyst net9.0-maccatalyst was computed. net9.0-macos net9.0-macos was computed. net9.0-tvos net9.0-tvos was computed. net9.0-windows net9.0-windows was computed. net10.0 net10.0 was computed. net10.0-android net10.0-android was computed. net10.0-browser net10.0-browser was computed. net10.0-ios net10.0-ios was computed. net10.0-maccatalyst net10.0-maccatalyst was computed. net10.0-macos net10.0-macos was computed. net10.0-tvos net10.0-tvos was computed. net10.0-windows net10.0-windows was computed. |
This package is not used by any NuGet packages.
This package is not used by any popular GitHub repositories.