ignite-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ptupit...@apache.org
Subject ignite git commit: IGNITE-3755 .NET: LINQ - user-friendly CacheQueryable.ToString()
Date Thu, 25 Aug 2016 07:33:36 GMT
Repository: ignite
Updated Branches:
  refs/heads/master a2fecaf5f -> 22d3b1e94


IGNITE-3755 .NET: LINQ - user-friendly CacheQueryable.ToString()


Project: http://git-wip-us.apache.org/repos/asf/ignite/repo
Commit: http://git-wip-us.apache.org/repos/asf/ignite/commit/22d3b1e9
Tree: http://git-wip-us.apache.org/repos/asf/ignite/tree/22d3b1e9
Diff: http://git-wip-us.apache.org/repos/asf/ignite/diff/22d3b1e9

Branch: refs/heads/master
Commit: 22d3b1e941e2d37a3c13763d07908eaec9427298
Parents: a2fecaf
Author: Pavel Tupitsyn <ptupitsyn@apache.org>
Authored: Thu Aug 25 10:33:25 2016 +0300
Committer: Pavel Tupitsyn <ptupitsyn@apache.org>
Committed: Thu Aug 25 10:33:25 2016 +0300

----------------------------------------------------------------------
 .../Cache/Query/CacheLinqTest.cs                | 21 ++++++++++++++++++--
 .../Cache/Query/SqlFieldsQuery.cs               | 16 +++++++++++++++
 .../Impl/CacheFieldsQueryExecutor.cs            |  2 +-
 .../Impl/CacheQueryableBase.cs                  | 10 +++-------
 4 files changed, 39 insertions(+), 10 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ignite/blob/22d3b1e9/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Cache/Query/CacheLinqTest.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Cache/Query/CacheLinqTest.cs
b/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Cache/Query/CacheLinqTest.cs
index 6d3af67..1ac7fa7 100644
--- a/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Cache/Query/CacheLinqTest.cs
+++ b/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Cache/Query/CacheLinqTest.cs
@@ -28,7 +28,6 @@ namespace Apache.Ignite.Core.Tests.Cache.Query
 {
     using System;
     using System.Collections;
-    using System.Diagnostics.CodeAnalysis;
     using System.Linq;
     using System.Linq.Expressions;
     using System.Text.RegularExpressions;
@@ -1171,6 +1170,11 @@ namespace Apache.Ignite.Core.Tests.Cache.Query
             Assert.IsFalse(fq.EnableDistributedJoins);
             Assert.IsTrue(fq.EnforceJoinOrder);
 
+            var str = query.ToString();
+            Assert.AreEqual("CacheQueryable [CacheName=, TableName=Person, Query=SqlFieldsQuery
[Sql=select " +
+                            "_T0._key, _T0._val from \"\".Person as _T0 where (_T0._key >
?), Arguments=[10], " +
+                            "Local=True, PageSize=999, EnableDistributedJoins=False, EnforceJoinOrder=True]]",
str);
+
             // Check fields query
             var fieldsQuery = (ICacheQueryable) cache.AsCacheQueryable().Select(x => x.Value.Name);
 
@@ -1184,11 +1188,24 @@ namespace Apache.Ignite.Core.Tests.Cache.Query
             Assert.IsFalse(fq.EnableDistributedJoins);
             Assert.IsFalse(fq.EnforceJoinOrder);
 
+            str = fieldsQuery.ToString();
+            Assert.AreEqual("CacheQueryable [CacheName=, TableName=Person, Query=SqlFieldsQuery
[Sql=select " +
+                            "_T0.Name from \"\".Person as _T0, Arguments=[], Local=False,
PageSize=1024, " +
+                            "EnableDistributedJoins=False, EnforceJoinOrder=False]]", str);
+            
             // Check distributed joins flag propagation
             var distrQuery = cache.AsCacheQueryable(new QueryOptions {EnableDistributedJoins
= true})
-                .Where(x => x.Key > 10);
+                .Where(x => x.Key > 10 && x.Value.Age > 20 && x.Value.Name.Contains("x"));
+
             query = (ICacheQueryable) distrQuery;
+
             Assert.IsTrue(query.GetFieldsQuery().EnableDistributedJoins);
+
+            str = distrQuery.ToString();
+            Assert.AreEqual("CacheQueryable [CacheName=, TableName=Person, Query=SqlFieldsQuery
[Sql=select " +
+                            "_T0._key, _T0._val from \"\".Person as _T0 where (((_T0._key
> ?) and (_T0.age1 > ?)) " +
+                            "and (_T0.Name like \'%\' || ? || \'%\') ), Arguments=[10, 20,
x], Local=False, " +
+                            "PageSize=1024, EnableDistributedJoins=True, EnforceJoinOrder=False]]",
str);
         }
 
         /// <summary>

http://git-wip-us.apache.org/repos/asf/ignite/blob/22d3b1e9/modules/platforms/dotnet/Apache.Ignite.Core/Cache/Query/SqlFieldsQuery.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core/Cache/Query/SqlFieldsQuery.cs b/modules/platforms/dotnet/Apache.Ignite.Core/Cache/Query/SqlFieldsQuery.cs
index ed9d0eb..1d896b8 100644
--- a/modules/platforms/dotnet/Apache.Ignite.Core/Cache/Query/SqlFieldsQuery.cs
+++ b/modules/platforms/dotnet/Apache.Ignite.Core/Cache/Query/SqlFieldsQuery.cs
@@ -18,6 +18,7 @@
 namespace Apache.Ignite.Core.Cache.Query
 {
     using System.Diagnostics.CodeAnalysis;
+    using System.Linq;
 
     /// <summary>
     /// SQL fields query.
@@ -102,5 +103,20 @@ namespace Apache.Ignite.Core.Cache.Query
         ///   <c>true</c> if join order should be enforced; otherwise, <c>false</c>.
         /// </value>
         public bool EnforceJoinOrder { get; set; }
+
+        /// <summary>
+        /// Returns a <see cref="string" /> that represents this instance.
+        /// </summary>
+        /// <returns>
+        /// A <see cref="string" /> that represents this instance.
+        /// </returns>
+        public override string ToString()
+        {
+            var args = string.Join(", ", Arguments.Select(x => x == null ? "null" : x.ToString()));
+
+            return string.Format("SqlFieldsQuery [Sql={0}, Arguments=[{1}], Local={2}, PageSize={3},
" +
+                                 "EnableDistributedJoins={4}, EnforceJoinOrder={5}]", Sql,
args, Local,
+                                 PageSize, EnableDistributedJoins, EnforceJoinOrder);
+        }
     }
 }

http://git-wip-us.apache.org/repos/asf/ignite/blob/22d3b1e9/modules/platforms/dotnet/Apache.Ignite.Linq/Impl/CacheFieldsQueryExecutor.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Linq/Impl/CacheFieldsQueryExecutor.cs
b/modules/platforms/dotnet/Apache.Ignite.Linq/Impl/CacheFieldsQueryExecutor.cs
index 3d48f41..0c9d4a2 100644
--- a/modules/platforms/dotnet/Apache.Ignite.Linq/Impl/CacheFieldsQueryExecutor.cs
+++ b/modules/platforms/dotnet/Apache.Ignite.Linq/Impl/CacheFieldsQueryExecutor.cs
@@ -282,7 +282,7 @@ namespace Apache.Ignite.Linq.Impl
         /// <summary>
         /// Gets the fields query.
         /// </summary>
-        private SqlFieldsQuery GetFieldsQuery(string text, object[] args)
+        internal SqlFieldsQuery GetFieldsQuery(string text, object[] args)
         {
             return new SqlFieldsQuery(text, _local, args)
             {

http://git-wip-us.apache.org/repos/asf/ignite/blob/22d3b1e9/modules/platforms/dotnet/Apache.Ignite.Linq/Impl/CacheQueryableBase.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Linq/Impl/CacheQueryableBase.cs b/modules/platforms/dotnet/Apache.Ignite.Linq/Impl/CacheQueryableBase.cs
index 5dc40ab..21a7850 100644
--- a/modules/platforms/dotnet/Apache.Ignite.Linq/Impl/CacheQueryableBase.cs
+++ b/modules/platforms/dotnet/Apache.Ignite.Linq/Impl/CacheQueryableBase.cs
@@ -66,12 +66,7 @@ namespace Apache.Ignite.Linq.Impl
             var data = GetQueryData();
             var executor = CacheQueryProvider.Executor;
 
-            return new SqlFieldsQuery(data.QueryText, executor.Local, data.Parameters.ToArray())
-            {
-                EnableDistributedJoins = executor.EnableDistributedJoins,
-                EnforceJoinOrder = executor.EnforceJoinOrder,
-                PageSize = executor.PageSize
-            };
+            return executor.GetFieldsQuery(data.QueryText, data.Parameters.ToArray());
         }
 
         /** <inheritdoc /> */
@@ -143,7 +138,8 @@ namespace Apache.Ignite.Linq.Impl
         /// </returns>
         public override string ToString()
         {
-            return GetQueryData().ToString();
+            return string.Format("CacheQueryable [CacheName={0}, TableName={1}, Query={2}]",

+                CacheName, TableName, GetFieldsQuery());
         }
     }
 }
\ No newline at end of file


Mime
View raw message