Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
30 commits
Select commit Hold shift + click to select a range
b6bf0d5
Add BulkUpsert implementation
LiamHamsters Jul 23, 2025
261d342
hot fix
LiamHamsters Jul 23, 2025
8173dd0
hot fix 2
LiamHamsters Jul 23, 2025
8d170b8
fix issues
LiamHamsters Jul 24, 2025
5ac5127
feat: make BulkUpsert API more user-friendly
LiamHamsters Jul 24, 2025
3db706d
Implement simple BulkUpsert in YdbConnection and YdbDataSource (delet…
LiamHamsters Jul 25, 2025
a2aa86b
refactor: use array-based rows for BulkUpsert, remove dictionary
LiamHamsters Jul 25, 2025
bff5137
fix: format
LiamHamsters Jul 25, 2025
924da51
last hot fix
LiamHamsters Jul 25, 2025
5e52cc1
fix issues
LiamHamsters Jul 25, 2025
3c219ef
rebase + SessionImpl -> Session
LiamHamsters Jul 25, 2025
4af5c80
fast fix
LiamHamsters Jul 25, 2025
18060cd
BulkUpsert: forbid usage inside transaction, add test
LiamHamsters Jul 25, 2025
f207b69
fix + edit CHANGELOG.md
LiamHamsters Jul 25, 2025
816dc9c
add BulkUpsertProtoImporter
LiamHamsters Jul 29, 2025
7ffa2ee
hot fix
LiamHamsters Jul 29, 2025
1879bca
bulk upsert: add object[] support, simplify implementation
LiamHamsters Jul 29, 2025
14a2bfe
fix: handle exceptions in BulkUpsertImporter DisposeAsync, update tests
LiamHamsters Jul 29, 2025
5cee465
fix
LiamHamsters Jul 30, 2025
b203781
hot fix
LiamHamsters Jul 30, 2025
eec3d12
remove Type argument
LiamHamsters Jul 30, 2025
8c32732
hot fix
LiamHamsters Jul 30, 2025
c9fdbb5
fix inspections and autoformat
LiamHamsters Jul 30, 2025
6463d36
feat: switch BulkUpsertImporter to plain proto, remove extra wrappers…
LiamHamsters Jul 31, 2025
bfc6cf5
refactor: correct batch bytes check and flush logic in BulkUpsertImpo…
LiamHamsters Jul 31, 2025
1c28862
fix
LiamHamsters Jul 31, 2025
0bb791c
last fix
LiamHamsters Jul 31, 2025
beec0e0
Finally
LiamHamsters Jul 31, 2025
b08ebd5
change ct in Flush
LiamHamsters Jul 31, 2025
96fef4a
edit: tablePath calculation in YdbConnection
LiamHamsters Aug 1, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 4 additions & 5 deletions src/Ydb.Sdk/src/Ado/BulkUpsert/BulkUpsertImporter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -17,19 +17,18 @@ public sealed class BulkUpsertImporter : IBulkUpsertImporter
private StructType? _structType;
private int _currentBytes;

public BulkUpsertImporter(
internal BulkUpsertImporter(
IDriver driver,
string tableName,
IReadOnlyList<string> columns,
CancellationToken cancellationToken = default,
int maxBytes = 64 * 1024 * 1024)
int maxBytes,
CancellationToken cancellationToken = default)
{
_driver = driver;
_tablePath = tableName;
_columns = columns;
_maxBytes = maxBytes;
_cancellationToken = cancellationToken;
_maxBytes = maxBytes / 2;
_cancellationToken = cancellationToken;
}

public async ValueTask AddRowAsync(object?[] values)
Expand Down
7 changes: 4 additions & 3 deletions src/Ydb.Sdk/src/Ado/YdbConnection.cs
Original file line number Diff line number Diff line change
Expand Up @@ -56,8 +56,7 @@ public YdbConnection(YdbConnectionStringBuilder connectionStringBuilder)
public IBulkUpsertImporter BeginBulkUpsertImport(
string name,
IReadOnlyList<string> columns,
CancellationToken cancellationToken = default
)
CancellationToken cancellationToken = default)
{
ThrowIfConnectionClosed();
if (CurrentTransaction is { Completed: false })
Expand All @@ -66,7 +65,9 @@ public IBulkUpsertImporter BeginBulkUpsertImport(
var database = ConnectionStringBuilder.Database.TrimEnd('/');
var tablePath = string.IsNullOrEmpty(database) ? name : $"{database}/{name}";

return new BulkUpsertImporter(Session.Driver, tablePath, columns, cancellationToken);
var maxBytes = ConnectionStringBuilder.BulkUpsertMaxBytes;

return new BulkUpsertImporter(Session.Driver, tablePath, columns, maxBytes, cancellationToken);
}

protected override YdbTransaction BeginDbTransaction(IsolationLevel isolationLevel)
Expand Down
15 changes: 15 additions & 0 deletions src/Ydb.Sdk/src/Ado/YdbConnectionStringBuilder.cs
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ private void InitDefaultValues()
_maxReceiveMessageSize = GrpcDefaultSettings.MaxReceiveMessageSize;
_disableDiscovery = GrpcDefaultSettings.DisableDiscovery;
_disableServerBalancer = false;
_bulkUpsertMaxBytes = 64 * 1024 * 1024;
}

public string Host
Expand Down Expand Up @@ -291,6 +292,20 @@ public int MaxReceiveMessageSize
}

private int _maxReceiveMessageSize;

private int _bulkUpsertMaxBytes;

public int BulkUpsertMaxBytes
{
get => _bulkUpsertMaxBytes;
set
{
if (value <= 0)
throw new ArgumentOutOfRangeException(nameof(value), value, "BulkUpsertMaxBytes must be positive.");
_bulkUpsertMaxBytes = value;
SaveValue(nameof(BulkUpsertMaxBytes), value);
}
}

public bool DisableServerBalancer
{
Expand Down
Loading