Skip to content

Commit 0bb791c

Browse files
committed
last fix
1 parent 1c28862 commit 0bb791c

File tree

3 files changed

+23
-8
lines changed

3 files changed

+23
-8
lines changed

src/Ydb.Sdk/src/Ado/BulkUpsert/BulkUpsertImporter.cs

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -17,19 +17,18 @@ public sealed class BulkUpsertImporter : IBulkUpsertImporter
1717
private StructType? _structType;
1818
private int _currentBytes;
1919

20-
public BulkUpsertImporter(
20+
internal BulkUpsertImporter(
2121
IDriver driver,
2222
string tableName,
2323
IReadOnlyList<string> columns,
24-
CancellationToken cancellationToken = default,
25-
int maxBytes = 64 * 1024 * 1024)
24+
int maxBytes,
25+
CancellationToken cancellationToken = default)
2626
{
2727
_driver = driver;
2828
_tablePath = tableName;
2929
_columns = columns;
30-
_maxBytes = maxBytes;
31-
_cancellationToken = cancellationToken;
3230
_maxBytes = maxBytes / 2;
31+
_cancellationToken = cancellationToken;
3332
}
3433

3534
public async ValueTask AddRowAsync(object?[] values)

src/Ydb.Sdk/src/Ado/YdbConnection.cs

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -56,8 +56,7 @@ public YdbConnection(YdbConnectionStringBuilder connectionStringBuilder)
5656
public IBulkUpsertImporter BeginBulkUpsertImport(
5757
string name,
5858
IReadOnlyList<string> columns,
59-
CancellationToken cancellationToken = default
60-
)
59+
CancellationToken cancellationToken = default)
6160
{
6261
ThrowIfConnectionClosed();
6362
if (CurrentTransaction is { Completed: false })
@@ -66,7 +65,9 @@ public IBulkUpsertImporter BeginBulkUpsertImport(
6665
var database = ConnectionStringBuilder.Database.TrimEnd('/');
6766
var tablePath = string.IsNullOrEmpty(database) ? name : $"{database}/{name}";
6867

69-
return new BulkUpsertImporter(Session.Driver, tablePath, columns, cancellationToken);
68+
var maxBytes = ConnectionStringBuilder.BulkUpsertMaxBytes;
69+
70+
return new BulkUpsertImporter(Session.Driver, tablePath, columns, maxBytes, cancellationToken);
7071
}
7172

7273
protected override YdbTransaction BeginDbTransaction(IsolationLevel isolationLevel)

src/Ydb.Sdk/src/Ado/YdbConnectionStringBuilder.cs

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@ private void InitDefaultValues()
4242
_maxReceiveMessageSize = GrpcDefaultSettings.MaxReceiveMessageSize;
4343
_disableDiscovery = GrpcDefaultSettings.DisableDiscovery;
4444
_disableServerBalancer = false;
45+
_bulkUpsertMaxBytes = 64 * 1024 * 1024;
4546
}
4647

4748
public string Host
@@ -291,6 +292,20 @@ public int MaxReceiveMessageSize
291292
}
292293

293294
private int _maxReceiveMessageSize;
295+
296+
private int _bulkUpsertMaxBytes;
297+
298+
public int BulkUpsertMaxBytes
299+
{
300+
get => _bulkUpsertMaxBytes;
301+
set
302+
{
303+
if (value <= 0)
304+
throw new ArgumentOutOfRangeException(nameof(value), value, "BulkUpsertMaxBytes must be positive.");
305+
_bulkUpsertMaxBytes = value;
306+
SaveValue(nameof(BulkUpsertMaxBytes), value);
307+
}
308+
}
294309

295310
public bool DisableServerBalancer
296311
{

0 commit comments

Comments
 (0)