This is an automated email from the ASF dual-hosted git repository. ptupitsyn pushed a commit to branch ignite-27278 in repository https://gitbox.apache.org/repos/asf/ignite-3.git
commit bc543a3b1f01c634e759d138775f3bd4e1c17a12 Author: Pavel Tupitsyn <[email protected]> AuthorDate: Tue Dec 23 13:46:45 2025 +0200 Streamline RowReaderFactory to use metadata --- .../dotnet/Apache.Ignite/Internal/Sql/ResultSet.cs | 5 +++-- .../dotnet/Apache.Ignite/Internal/Sql/RowReader.cs | 6 ++---- .../dotnet/Apache.Ignite/Internal/Sql/RowReaderFactory.cs | 7 ++----- modules/platforms/dotnet/Apache.Ignite/Internal/Sql/Sql.cs | 14 +++++++------- 4 files changed, 14 insertions(+), 18 deletions(-) diff --git a/modules/platforms/dotnet/Apache.Ignite/Internal/Sql/ResultSet.cs b/modules/platforms/dotnet/Apache.Ignite/Internal/Sql/ResultSet.cs index a40938e901d..d4c02fb586e 100644 --- a/modules/platforms/dotnet/Apache.Ignite/Internal/Sql/ResultSet.cs +++ b/modules/platforms/dotnet/Apache.Ignite/Internal/Sql/ResultSet.cs @@ -76,8 +76,9 @@ namespace Apache.Ignite.Internal.Sql WasApplied = reader.ReadBoolean(); AffectedRows = reader.ReadInt64(); - Metadata = HasRowSet ? ReadMeta(ref reader) : null; - _rowReader = Metadata != null ? rowReaderFactory(Metadata.Columns) : null; + ResultSetMetadata? meta = HasRowSet ? ReadMeta(ref reader) : null; + Metadata = meta; + _rowReader = meta != null ? rowReaderFactory(Metadata.Columns) : null; if (HasRowSet) { diff --git a/modules/platforms/dotnet/Apache.Ignite/Internal/Sql/RowReader.cs b/modules/platforms/dotnet/Apache.Ignite/Internal/Sql/RowReader.cs index d0034df9c8f..8072cd8b2b4 100644 --- a/modules/platforms/dotnet/Apache.Ignite/Internal/Sql/RowReader.cs +++ b/modules/platforms/dotnet/Apache.Ignite/Internal/Sql/RowReader.cs @@ -17,15 +17,13 @@ namespace Apache.Ignite.Internal.Sql; -using System.Collections.Generic; -using Ignite.Sql; using Proto.BinaryTuple; /// <summary> /// Row reader delegate. /// </summary> -/// <param name="cols">Columns.</param> +/// <param name="metadata">Metadata.</param> /// <param name="tupleReader">Tuple reader.</param> /// <typeparam name="T">Result type.</typeparam> /// <returns>Resulting row.</returns> -internal delegate T RowReader<out T>(IReadOnlyList<IColumnMetadata> cols, ref BinaryTupleReader tupleReader); +internal delegate T RowReader<out T>(ResultSetMetadata metadata, ref BinaryTupleReader tupleReader); diff --git a/modules/platforms/dotnet/Apache.Ignite/Internal/Sql/RowReaderFactory.cs b/modules/platforms/dotnet/Apache.Ignite/Internal/Sql/RowReaderFactory.cs index 7f1b2070361..73889c97ec7 100644 --- a/modules/platforms/dotnet/Apache.Ignite/Internal/Sql/RowReaderFactory.cs +++ b/modules/platforms/dotnet/Apache.Ignite/Internal/Sql/RowReaderFactory.cs @@ -17,13 +17,10 @@ namespace Apache.Ignite.Internal.Sql; -using System.Collections.Generic; -using Ignite.Sql; - /// <summary> /// Row reader factory. /// </summary> -/// <param name="cols">Columns.</param> +/// <param name="metadata">Metadata.</param> /// <typeparam name="T">Result type.</typeparam> /// <returns>Resulting row.</returns> -internal delegate RowReader<T> RowReaderFactory<out T>(IReadOnlyList<IColumnMetadata> cols); +internal delegate RowReader<T> RowReaderFactory<out T>(ResultSetMetadata metadata); diff --git a/modules/platforms/dotnet/Apache.Ignite/Internal/Sql/Sql.cs b/modules/platforms/dotnet/Apache.Ignite/Internal/Sql/Sql.cs index 67afc62332e..986d345e1e0 100644 --- a/modules/platforms/dotnet/Apache.Ignite/Internal/Sql/Sql.cs +++ b/modules/platforms/dotnet/Apache.Ignite/Internal/Sql/Sql.cs @@ -43,7 +43,7 @@ namespace Apache.Ignite.Internal.Sql internal sealed class Sql : ISql { private static readonly RowReader<IIgniteTuple> TupleReader = - static (IReadOnlyList<IColumnMetadata> cols, ref BinaryTupleReader reader) => ReadTuple(cols, ref reader); + static (ResultSetMetadata metadata, ref BinaryTupleReader reader) => ReadTuple(metadata.Columns, ref reader); private static readonly RowReaderFactory<IIgniteTuple> TupleReaderFactory = static _ => TupleReader; @@ -71,7 +71,7 @@ namespace Apache.Ignite.Internal.Sql await ExecuteAsyncInternal( transaction, statement, - static cols => GetReaderFactory<T>(cols), + static meta => GetReaderFactory<T>(meta), args, cancellationToken) .ConfigureAwait(false); @@ -85,11 +85,11 @@ namespace Apache.Ignite.Internal.Sql params object?[]? args) { // TODO: Cache or avoid allocation? - RowReaderFactory<T> rowReaderFactory = cols => + RowReaderFactory<T> rowReaderFactory = _ => { - return (IReadOnlyList<IColumnMetadata> list, ref BinaryTupleReader reader) => + return (ResultSetMetadata meta, ref BinaryTupleReader reader) => { - var mapperCols = list.Cast<IMapperColumn>().ToList(); + var mapperCols = meta.Columns.Cast<IMapperColumn>().ToList(); var mapperReader = new RowReader(ref reader, mapperCols); return mapper.Read(ref mapperReader, new MapperSchema(mapperCols)); @@ -338,8 +338,8 @@ namespace Apache.Ignite.Internal.Sql } [RequiresUnreferencedCode(ReflectionUtils.TrimWarning)] - private static RowReader<T> GetReaderFactory<T>(IReadOnlyList<IColumnMetadata> cols) => - ResultSelector.Get<T>(cols, selectorExpression: null, ResultSelectorOptions.None); + private static RowReader<T> GetReaderFactory<T>(ResultSetMetadata metadata) => + ResultSelector.Get<T>(metadata.Columns, selectorExpression: null, ResultSelectorOptions.None); private static void WriteBatchArgs(PooledArrayBuffer writer, IEnumerable<IEnumerable<object?>> args) {
