You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ignite.apache.org by pt...@apache.org on 2025/12/23 11:54:54 UTC

(ignite-3) branch ignite-27278 updated (9959358a886 -> f923e6c67f3)

This is an automated email from the ASF dual-hosted git repository.

ptupitsyn pushed a change to branch ignite-27278
in repository https://gitbox.apache.org/repos/asf/ignite-3.git


    from 9959358a886 Fix RowReader to depend on IMapperColumn only for reuse in SQL
     new bc543a3b1f0 Streamline RowReaderFactory to use metadata
     new f923e6c67f3 ResultSet cleanup

The 2 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.


Summary of changes:
 .../dotnet/Apache.Ignite/Internal/Sql/ResultSet.cs   | 20 ++++++++++----------
 .../dotnet/Apache.Ignite/Internal/Sql/RowReader.cs   |  6 ++----
 .../Apache.Ignite/Internal/Sql/RowReaderFactory.cs   |  7 ++-----
 .../dotnet/Apache.Ignite/Internal/Sql/Sql.cs         | 14 +++++++-------
 4 files changed, 21 insertions(+), 26 deletions(-)


(ignite-3) 01/02: Streamline RowReaderFactory to use metadata

Posted by pt...@apache.org.
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 <pt...@apache.org>
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)
         {


(ignite-3) 02/02: ResultSet cleanup

Posted by pt...@apache.org.
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 f923e6c67f3c0be3b2942c53fc7ff2b53aa4ca69
Author: Pavel Tupitsyn <pt...@apache.org>
AuthorDate: Tue Dec 23 13:54:46 2025 +0200

    ResultSet cleanup
---
 .../dotnet/Apache.Ignite/Internal/Sql/ResultSet.cs  | 21 ++++++++++-----------
 1 file changed, 10 insertions(+), 11 deletions(-)

diff --git a/modules/platforms/dotnet/Apache.Ignite/Internal/Sql/ResultSet.cs b/modules/platforms/dotnet/Apache.Ignite/Internal/Sql/ResultSet.cs
index d4c02fb586e..0036cdc87a9 100644
--- a/modules/platforms/dotnet/Apache.Ignite/Internal/Sql/ResultSet.cs
+++ b/modules/platforms/dotnet/Apache.Ignite/Internal/Sql/ResultSet.cs
@@ -44,6 +44,8 @@ namespace Apache.Ignite.Internal.Sql
 
         private readonly bool _hasMorePages;
 
+        private readonly ResultSetMetadata? _metadata;
+
         private readonly RowReader<T>? _rowReader;
 
         private readonly CancellationToken _cancellationToken;
@@ -76,9 +78,8 @@ namespace Apache.Ignite.Internal.Sql
             WasApplied = reader.ReadBoolean();
             AffectedRows = reader.ReadInt64();
 
-            ResultSetMetadata? meta = HasRowSet ? ReadMeta(ref reader) : null;
-            Metadata = meta;
-            _rowReader = meta != null ? rowReaderFactory(Metadata.Columns) : null;
+            _metadata = HasRowSet ? ReadMeta(ref reader) : null;
+            _rowReader = _metadata != null ? rowReaderFactory(_metadata) : null;
 
             if (HasRowSet)
             {
@@ -103,7 +104,7 @@ namespace Apache.Ignite.Internal.Sql
         }
 
         /// <inheritdoc/>
-        public IResultSetMetadata? Metadata { get; }
+        public IResultSetMetadata? Metadata => _metadata;
 
         /// <inheritdoc/>
         public bool HasRowSet { get; }
@@ -157,7 +158,6 @@ namespace Apache.Ignite.Internal.Sql
             ValidateAndSetIteratorState();
 
             // First page is included in the initial response.
-            var cols = Metadata!.Columns;
             var hasMore = _hasMorePages;
             TResult? res = default;
 
@@ -184,7 +184,7 @@ namespace Apache.Ignite.Internal.Sql
 
                 for (var rowIdx = 0; rowIdx < pageSize; rowIdx++)
                 {
-                    var row = ReadRow(cols, ref reader);
+                    var row = ReadRow(ref reader);
                     accumulator(res, row);
                 }
 
@@ -319,17 +319,16 @@ namespace Apache.Ignite.Internal.Sql
             return new ResultSetMetadata(columns);
         }
 
-        private T ReadRow(IReadOnlyList<IColumnMetadata> cols, ref MsgPackReader reader)
+        private T ReadRow(ref MsgPackReader reader)
         {
-            var tupleReader = new BinaryTupleReader(reader.ReadBinary(), cols.Count);
+            var tupleReader = new BinaryTupleReader(reader.ReadBinary(), _metadata!.Columns.Count);
 
-            return _rowReader!(cols, ref tupleReader);
+            return _rowReader!(_metadata, ref tupleReader);
         }
 
         private async IAsyncEnumerable<T> EnumerateRows()
         {
             var hasMore = _hasMorePages;
-            var cols = Metadata!.Columns;
             var offset = 0;
 
             // First page.
@@ -368,7 +367,7 @@ namespace Apache.Ignite.Internal.Sql
                     // Can't use ref struct reader from above inside iterator block (CS4013).
                     // Use a new reader for every row (stack allocated).
                     var rowReader = buf.GetReader(offset);
-                    var row = ReadRow(cols, ref rowReader);
+                    var row = ReadRow(ref rowReader);
 
                     offset += rowReader.Consumed;
                     yield return row;