@@ -31,51 +31,58 @@ internal BulkUpsertImporter(
3131 _cancellationToken = cancellationToken ;
3232 }
3333
34- /// <summary>Adds one line to the current BulkUpsert batch.</summary>
35- /// <param name="values">Column values are in array order <c>columns</c>.</param>
36- /// <remarks>Types: <see cref="YdbValue"/> / <see cref="YdbParameter"/> / <see cref="YdbList"/> — as is; others are displayed.</remarks>
37- /// <example><code>// columns: ["Id","Name"]
34+ /// <summary>
35+ /// Add a single row to the current BulkUpsert batch.
36+ /// </summary>
37+ /// <param name="values">Column values in the same order as the configured <c>columns</c>.</param>
38+ /// <remarks>
39+ /// Supported element types: <see cref="YdbValue"/>, <see cref="YdbParameter"/>, <see cref="YdbList"/> (as-is);
40+ /// other CLR values are converted via <see cref="YdbParameter"/>.
41+ /// </remarks>
42+ /// <example>
43+ /// <code>
44+ /// // columns: ["Id", "Name"]
3845 /// await importer.AddRowAsync(1, "Alice");
39- /// </code></example>
40- /// <exception cref="ArgumentException">The number of values is not equal to the number of columns.</exception>
41- /// <exception cref="InvalidOperationException">The value cannot be compared with the YDB type.</exception>
46+ /// </code>
47+ /// </example>
48+ /// <exception cref="ArgumentException">When the number of values doesn't equal the number of columns.</exception>
49+ /// <exception cref="InvalidOperationException">When a value cannot be mapped to a YDB type.</exception>
4250 public async ValueTask AddRowAsync ( params object [ ] values )
4351 {
4452 if ( values . Length != _columns . Count )
45- throw new ArgumentException ( "Values count must match columns count" , nameof ( values ) ) ;
53+ throw new ArgumentException ( "Values count must match columns count. " , nameof ( values ) ) ;
4654
4755 var ydbValues = values . Select ( v => v switch
48- {
49- YdbValue ydbValue => ydbValue . GetProto ( ) ,
50- YdbParameter param => param . TypedValue ,
51- YdbList list => list . ToTypedValue ( ) ,
52- _ => new YdbParameter { Value = v } . TypedValue
53- }
54- ) . ToArray ( ) ;
56+ {
57+ YdbValue ydbValue => ydbValue . GetProto ( ) ,
58+ YdbParameter param => param . TypedValue ,
59+ YdbList list => list . ToTypedValue ( ) ,
60+ _ => new YdbParameter { Value = v } . TypedValue
61+ } ) . ToArray ( ) ;
5562
5663 var protoStruct = new Ydb . Value ( ) ;
57- foreach ( var value in ydbValues ) protoStruct . Items . Add ( value . Value ) ;
64+ foreach ( var value in ydbValues )
65+ protoStruct . Items . Add ( value . Value ) ;
5866
5967 var rowSize = protoStruct . CalculateSize ( ) ;
6068
6169 if ( _currentBytes + rowSize > _maxBatchByteSize && _rows . Count > 0 )
62- {
6370 await FlushAsync ( ) ;
64- }
6571
6672 _rows . Add ( protoStruct ) ;
6773 _currentBytes += rowSize ;
6874
6975 _structType ??= new StructType
70- { Members = { _columns . Select ( ( col , i ) => new StructMember { Name = col , Type = ydbValues [ i ] . Type } ) } } ;
76+ {
77+ Members = { _columns . Select ( ( col , i ) => new StructMember { Name = col , Type = ydbValues [ i ] . Type } ) }
78+ } ;
7179 }
72-
80+
7381 /// <summary>
74- /// Adds a set of strings in the form <see cref="YdbList"/>.
82+ /// Add multiple rows from a single <see cref="YdbList"/> parameter .
7583 /// </summary>
7684 /// <remarks>
77- /// The expected value is of the type <c>List<Struct<...>></c>. Names and order of fields <c>Struct</c>
78- /// they must exactly match the array <c>columns</c> passed when creating the importer..
85+ /// Expects <c>List<Struct<...>></c>; struct member names and order must exactly match the configured <c>columns</c>.
7986 /// Example: <c>columns=["Id","Name"]</c> → <c>List<Struct<Id:Int64, Name:Utf8>></c>.
8087 /// </remarks>
8188 public async ValueTask AddListAsync ( YdbList list )
@@ -120,9 +127,14 @@ public async ValueTask AddListAsync(YdbList list)
120127 }
121128 }
122129
130+ /// <summary>
131+ /// Flush the current batch via BulkUpsert. No-op if the batch is empty.
132+ /// </summary>
123133 public async ValueTask FlushAsync ( )
124134 {
125- if ( _rows . Count == 0 ) return ;
135+ if ( _rows . Count == 0 )
136+ return ;
137+
126138 if ( _structType == null )
127139 throw new InvalidOperationException ( "structType is undefined" ) ;
128140
0 commit comments