ignite-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From sboi...@apache.org
Subject [5/6] ignite git commit: IGNITE-5257 .NET: SQL query timeouts
Date Tue, 23 May 2017 12:06:37 GMT
IGNITE-5257 .NET: SQL query timeouts

This closes #1985


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

Branch: refs/heads/ignite-5075
Commit: ca94cf3d6c708218ef22aa40c07c436c75360bc6
Parents: c4bb996
Author: Pavel Tupitsyn <ptupitsyn@apache.org>
Authored: Mon May 22 17:45:10 2017 +0300
Committer: Pavel Tupitsyn <ptupitsyn@apache.org>
Committed: Mon May 22 17:45:10 2017 +0300

----------------------------------------------------------------------
 .../platform/cache/PlatformCache.java           | 28 +++++++--
 .../core/include/ignite/cache/query/query_sql.h |  2 +
 .../ignite/cache/query/query_sql_fields.h       |  3 +
 .../Cache/Query/CacheLinqTest.cs                | 36 ++++++++++--
 .../Cache/Query/CacheQueriesTest.cs             | 60 +++++++++++++++++---
 .../Cache/Query/SqlFieldsQuery.cs               | 29 +++++++++-
 .../Apache.Ignite.Core/Cache/Query/SqlQuery.cs  | 31 ++++++++++
 .../Apache.Ignite.Core/Impl/Cache/CacheImpl.cs  |  3 +
 .../Apache.Ignite.Linq/CacheExtensions.cs       | 10 ++++
 .../Impl/CacheFieldsQueryExecutor.cs            | 42 ++++++--------
 .../Apache.Ignite.Linq/Impl/CacheQueryable.cs   |  3 +-
 .../dotnet/Apache.Ignite.Linq/QueryOptions.cs   | 23 ++++++++
 12 files changed, 224 insertions(+), 46 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ignite/blob/ca94cf3d/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/cache/PlatformCache.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/cache/PlatformCache.java
b/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/cache/PlatformCache.java
index c61b75e..13a8ca1 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/cache/PlatformCache.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/cache/PlatformCache.java
@@ -1282,8 +1282,16 @@ public class PlatformCache extends PlatformAbstractTarget {
         Object[] args = readQueryArgs(reader);
 
         boolean distrJoins = reader.readBoolean();
-
-        return new SqlQuery(typ, sql).setPageSize(pageSize).setArgs(args).setLocal(loc).setDistributedJoins(distrJoins);
+        int timeout = reader.readInt();
+        boolean replicated = reader.readBoolean();
+
+        return new SqlQuery(typ, sql)
+                .setPageSize(pageSize)
+                .setArgs(args)
+                .setLocal(loc)
+                .setDistributedJoins(distrJoins)
+                .setTimeout(timeout, TimeUnit.MILLISECONDS)
+                .setReplicatedOnly(replicated);
     }
 
     /**
@@ -1301,9 +1309,19 @@ public class PlatformCache extends PlatformAbstractTarget {
 
         boolean distrJoins = reader.readBoolean();
         boolean enforceJoinOrder = reader.readBoolean();
-
-        return new SqlFieldsQuery(sql).setPageSize(pageSize).setArgs(args).setLocal(loc)
-            .setDistributedJoins(distrJoins).setEnforceJoinOrder(enforceJoinOrder);
+        int timeout = reader.readInt();
+        boolean replicated = reader.readBoolean();
+        boolean collocated = reader.readBoolean();
+
+        return new SqlFieldsQuery(sql)
+                .setPageSize(pageSize)
+                .setArgs(args)
+                .setLocal(loc)
+                .setDistributedJoins(distrJoins)
+                .setEnforceJoinOrder(enforceJoinOrder)
+                .setTimeout(timeout, TimeUnit.MILLISECONDS)
+                .setReplicatedOnly(replicated)
+                .setCollocated(collocated);
     }
 
     /**

http://git-wip-us.apache.org/repos/asf/ignite/blob/ca94cf3d/modules/platforms/cpp/core/include/ignite/cache/query/query_sql.h
----------------------------------------------------------------------
diff --git a/modules/platforms/cpp/core/include/ignite/cache/query/query_sql.h b/modules/platforms/cpp/core/include/ignite/cache/query/query_sql.h
index d733476..eb0606a 100644
--- a/modules/platforms/cpp/core/include/ignite/cache/query/query_sql.h
+++ b/modules/platforms/cpp/core/include/ignite/cache/query/query_sql.h
@@ -272,6 +272,8 @@ namespace ignite
                         (*it)->Write(writer);
 
                     writer.WriteBool(distributedJoins);
+                    writer.WriteInt32(0);  // Timeout, ms
+                    writer.WriteBool(false);  // ReplicatedOnly
                 }
 
             private:

http://git-wip-us.apache.org/repos/asf/ignite/blob/ca94cf3d/modules/platforms/cpp/core/include/ignite/cache/query/query_sql_fields.h
----------------------------------------------------------------------
diff --git a/modules/platforms/cpp/core/include/ignite/cache/query/query_sql_fields.h b/modules/platforms/cpp/core/include/ignite/cache/query/query_sql_fields.h
index 954cf43..db26fc4 100644
--- a/modules/platforms/cpp/core/include/ignite/cache/query/query_sql_fields.h
+++ b/modules/platforms/cpp/core/include/ignite/cache/query/query_sql_fields.h
@@ -295,6 +295,9 @@ namespace ignite
 
                     writer.WriteBool(distributedJoins);
                     writer.WriteBool(enforceJoinOrder);
+                    writer.WriteInt32(0);  // Timeout, ms
+                    writer.WriteBool(false);  // ReplicatedOnly
+                    writer.WriteBool(false);  // Colocated
                 }
 
             private:

http://git-wip-us.apache.org/repos/asf/ignite/blob/ca94cf3d/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 265a149..cb3fece 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
@@ -1273,7 +1273,10 @@ namespace Apache.Ignite.Core.Tests.Cache.Query
             {
                 Local = true,
                 PageSize = 999,
-                EnforceJoinOrder = true
+                EnforceJoinOrder = true,
+                Timeout = TimeSpan.FromSeconds(2.5),
+                ReplicatedOnly = true,
+                Colocated = true
             }).Where(x => x.Key > 10);
 
             Assert.AreEqual(cache.Name, query.CacheName);
@@ -1288,12 +1291,16 @@ namespace Apache.Ignite.Core.Tests.Cache.Query
             Assert.AreEqual(999, fq.PageSize);
             Assert.IsFalse(fq.EnableDistributedJoins);
             Assert.IsTrue(fq.EnforceJoinOrder);
+            Assert.IsTrue(fq.ReplicatedOnly);
+            Assert.IsTrue(fq.Colocated);
+            Assert.AreEqual(TimeSpan.FromSeconds(2.5), fq.Timeout);
 
             var str = query.ToString();
             Assert.AreEqual("CacheQueryable [CacheName=person_org, TableName=Person, Query=SqlFieldsQuery
" +
                             "[Sql=select _T0._key, _T0._val from \"person_org\".Person as
_T0 where " +
                             "(_T0._key > ?), Arguments=[10], " +
-                            "Local=True, PageSize=999, EnableDistributedJoins=False, EnforceJoinOrder=True]]",
str);
+                            "Local=True, PageSize=999, EnableDistributedJoins=False, EnforceJoinOrder=True,
" +
+                            "Timeout=00:00:02.5000000, ReplicatedOnly=True, Colocated=True]]",
str);
 
             // Check fields query
             var fieldsQuery = (ICacheQueryable) cache.AsCacheQueryable().Select(x => x.Value.Name);
@@ -1311,7 +1318,8 @@ namespace Apache.Ignite.Core.Tests.Cache.Query
             str = fieldsQuery.ToString();
             Assert.AreEqual("CacheQueryable [CacheName=person_org, TableName=Person, Query=SqlFieldsQuery
" +
                             "[Sql=select _T0.Name from \"person_org\".Person as _T0, Arguments=[],
Local=False, " +
-                            "PageSize=1024, EnableDistributedJoins=False, EnforceJoinOrder=False]]",
str);
+                            "PageSize=1024, EnableDistributedJoins=False, EnforceJoinOrder=False,
" +
+                            "Timeout=00:00:00, ReplicatedOnly=False, Colocated=False]]",
str);
             
             // Check distributed joins flag propagation
             var distrQuery = cache.AsCacheQueryable(new QueryOptions {EnableDistributedJoins
= true})
@@ -1326,7 +1334,8 @@ namespace Apache.Ignite.Core.Tests.Cache.Query
                             "[Sql=select _T0._key, _T0._val from \"person_org\".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);
+                            "PageSize=1024, EnableDistributedJoins=True, EnforceJoinOrder=False,
" +
+                            "Timeout=00:00:00, ReplicatedOnly=False, Colocated=False]]",
str);
         }
 
         /// <summary>
@@ -1396,6 +1405,25 @@ namespace Apache.Ignite.Core.Tests.Cache.Query
         }
 
         /// <summary>
+        /// Tests the query timeout.
+        /// </summary>
+        [Test]
+        public void TestTimeout()
+        {
+            var persons = GetPersonCache().AsCacheQueryable(new QueryOptions
+            {
+                Timeout = TimeSpan.FromMilliseconds(1),
+                EnableDistributedJoins = true
+            });
+
+            // ReSharper disable once ReturnValueOfPureMethodIsNotUsed
+            var ex = Assert.Throws<CacheException>(() =>
+                persons.SelectMany(p => GetRoleCache().AsCacheQueryable()).ToArray());
+
+            Assert.IsTrue(ex.ToString().Contains("QueryCancelledException: The query was
cancelled while executing."));
+        }
+
+        /// <summary>
         /// Gets the person cache.
         /// </summary>
         /// <returns></returns>

http://git-wip-us.apache.org/repos/asf/ignite/blob/ca94cf3d/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Cache/Query/CacheQueriesTest.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Cache/Query/CacheQueriesTest.cs
b/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Cache/Query/CacheQueriesTest.cs
index 01277e1..60d2fdf 100644
--- a/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Cache/Query/CacheQueriesTest.cs
+++ b/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Cache/Query/CacheQueriesTest.cs
@@ -105,8 +105,7 @@ namespace Apache.Ignite.Core.Tests.Cache.Query
 
             for (int i = 0; i < GridCnt; i++)
             {
-                for (int j = 0; j < MaxItemCnt; j++)
-                    cache.Remove(j);
+                cache.Clear();
 
                 Assert.IsTrue(cache.IsEmpty());
             }
@@ -352,9 +351,15 @@ namespace Apache.Ignite.Core.Tests.Cache.Query
             // 2. Validate results.
             var qry = new SqlQuery(typeof(QueryPerson), "age < 50", loc)
             {
-                EnableDistributedJoins = distrJoin
+                EnableDistributedJoins = distrJoin,
+                ReplicatedOnly = false,
+                Timeout = TimeSpan.FromSeconds(3)
             };
 
+            Assert.AreEqual(string.Format("SqlQuery [Sql=age < 50, Arguments=[], Local={0},
" +
+                                          "PageSize=1024, EnableDistributedJoins={1}, Timeout={2},
" +
+                                          "ReplicatedOnly=False]", loc, distrJoin, qry.Timeout),
qry.ToString());
+
             ValidateQueryResults(cache, qry, exp, keepBinary);
         }
 
@@ -376,7 +381,10 @@ namespace Apache.Ignite.Core.Tests.Cache.Query
             var qry = new SqlFieldsQuery("SELECT name, age FROM QueryPerson WHERE age <
50", loc)
             {
                 EnableDistributedJoins = distrJoin,
-                EnforceJoinOrder = enforceJoinOrder
+                EnforceJoinOrder = enforceJoinOrder,
+                Colocated = !distrJoin,
+                ReplicatedOnly = false,
+                Timeout = TimeSpan.FromSeconds(2)
             };
 
             using (IQueryCursor<IList> cursor = cache.QueryFields(qry))
@@ -673,6 +681,44 @@ namespace Apache.Ignite.Core.Tests.Cache.Query
         }
 
         /// <summary>
+        /// Tests query timeouts.
+        /// </summary>
+        [Test]
+        public void TestSqlQueryTimeout()
+        {
+            var cache = Cache();
+            PopulateCache(cache, false, 20000, x => true);
+
+            var sqlQry = new SqlQuery(typeof(QueryPerson), "WHERE age < 500 AND name like
'%1%'")
+            {
+                Timeout = TimeSpan.FromMilliseconds(2)
+            };
+
+            // ReSharper disable once ReturnValueOfPureMethodIsNotUsed
+            var ex = Assert.Throws<CacheException>(() => cache.Query(sqlQry).ToArray());
+            Assert.IsTrue(ex.ToString().Contains("QueryCancelledException: The query was
cancelled while executing."));
+        }
+
+        /// <summary>
+        /// Tests fields query timeouts.
+        /// </summary>
+        [Test]
+        public void TestSqlFieldsQueryTimeout()
+        {
+            var cache = Cache();
+            PopulateCache(cache, false, 20000, x => true);
+
+            var fieldsQry = new SqlFieldsQuery("SELECT * FROM QueryPerson WHERE age <
5000 AND name like '%0%'")
+            {
+                Timeout = TimeSpan.FromMilliseconds(3)
+            };
+
+            // ReSharper disable once ReturnValueOfPureMethodIsNotUsed
+            var ex = Assert.Throws<CacheException>(() => cache.QueryFields(fieldsQry).ToArray());
+            Assert.IsTrue(ex.ToString().Contains("QueryCancelledException: The query was
cancelled while executing."));
+        }
+
+        /// <summary>
         /// Validates the query results.
         /// </summary>
         /// <param name="cache">Cache.</param>
@@ -820,7 +866,7 @@ namespace Apache.Ignite.Core.Tests.Cache.Query
 
             for (var i = 0; i < cnt; i++)
             {
-                var val = rand.Next(100);
+                var val = rand.Next(cnt);
 
                 cache.Put(val, new QueryPerson(val.ToString(), val));
 
@@ -845,8 +891,8 @@ namespace Apache.Ignite.Core.Tests.Cache.Query
         public QueryPerson(string name, int age)
         {
             Name = name;
-            Age = age;
-            Birthday = DateTime.UtcNow.AddYears(-age);
+            Age = age % 2000;
+            Birthday = DateTime.UtcNow.AddYears(-Age);
         }
 
         /// <summary>

http://git-wip-us.apache.org/repos/asf/ignite/blob/ca94cf3d/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 aab2bfe..4809574 100644
--- a/modules/platforms/dotnet/Apache.Ignite.Core/Cache/Query/SqlFieldsQuery.cs
+++ b/modules/platforms/dotnet/Apache.Ignite.Core/Cache/Query/SqlFieldsQuery.cs
@@ -17,6 +17,7 @@
 
 namespace Apache.Ignite.Core.Cache.Query
 {
+    using System;
     using System.Diagnostics.CodeAnalysis;
     using System.Linq;
 
@@ -105,6 +106,28 @@ namespace Apache.Ignite.Core.Cache.Query
         public bool EnforceJoinOrder { get; set; }
 
         /// <summary>
+        /// Gets or sets the query timeout. Query will be automatically cancelled if the
execution timeout is exceeded.
+        /// Default is <see cref="TimeSpan.Zero"/>, which means no timeout.
+        /// </summary>
+        public TimeSpan Timeout { get; set; }
+
+        /// <summary>
+        /// Gets or sets a value indicating whether this query contains only replicated tables.
+        /// This is a hint for potentially more effective execution.
+        /// </summary>
+        public bool ReplicatedOnly { get; set; }
+
+        /// <summary>
+        /// Gets or sets a value indicating whether this query operates on colocated data.
+        /// <para />
+        /// Whenever Ignite executes a distributed query, it sends sub-queries to individual
cluster members.
+        /// If you know in advance that the elements of your query selection are colocated
together on the same
+        /// node and you group by colocated key (primary or affinity key), then Ignite can
make significant
+        /// performance and network optimizations by grouping data on remote nodes.
+        /// </summary>
+        public bool Colocated { get; set; }
+
+        /// <summary>
         /// Returns a <see cref="string" /> that represents this instance.
         /// </summary>
         /// <returns>
@@ -115,8 +138,10 @@ namespace Apache.Ignite.Core.Cache.Query
             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);
+                                 "EnableDistributedJoins={4}, EnforceJoinOrder={5}, Timeout={6},
ReplicatedOnly={7}" +
+                                 ", Colocated={8}]", Sql, args, Local,
+                                 PageSize, EnableDistributedJoins, EnforceJoinOrder, Timeout,
ReplicatedOnly,
+                                 Colocated);
         }
     }
 }

http://git-wip-us.apache.org/repos/asf/ignite/blob/ca94cf3d/modules/platforms/dotnet/Apache.Ignite.Core/Cache/Query/SqlQuery.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core/Cache/Query/SqlQuery.cs b/modules/platforms/dotnet/Apache.Ignite.Core/Cache/Query/SqlQuery.cs
index 70e08b2..7d8e8fb 100644
--- a/modules/platforms/dotnet/Apache.Ignite.Core/Cache/Query/SqlQuery.cs
+++ b/modules/platforms/dotnet/Apache.Ignite.Core/Cache/Query/SqlQuery.cs
@@ -19,6 +19,7 @@ namespace Apache.Ignite.Core.Cache.Query
 {
     using System;
     using System.Diagnostics.CodeAnalysis;
+    using System.Linq;
     using Apache.Ignite.Core.Impl.Binary;
     using Apache.Ignite.Core.Impl.Cache;
     using Apache.Ignite.Core.Impl.Common;
@@ -108,6 +109,18 @@ namespace Apache.Ignite.Core.Cache.Query
         /// </value>
         public bool EnableDistributedJoins { get; set; }
 
+        /// <summary>
+        /// Gets or sets the query timeout. Query will be automatically cancelled if the
execution timeout is exceeded.
+        /// Default is <see cref="TimeSpan.Zero"/>, which means no timeout.
+        /// </summary>
+        public TimeSpan Timeout { get; set; }
+
+        /// <summary>
+        /// Gets or sets a value indicating whether this query contains only replicated tables.
+        /// This is a hint for potentially more effective execution.
+        /// </summary>
+        public bool ReplicatedOnly { get; set; }
+
         /** <inheritDoc /> */
         internal override void Write(BinaryWriter writer, bool keepBinary)
         {
@@ -126,6 +139,8 @@ namespace Apache.Ignite.Core.Cache.Query
             WriteQueryArgs(writer, Arguments);
 
             writer.WriteBoolean(EnableDistributedJoins);
+            writer.WriteInt((int) Timeout.TotalMilliseconds);
+            writer.WriteBoolean(ReplicatedOnly);
         }
 
         /** <inheritDoc /> */
@@ -133,5 +148,21 @@ namespace Apache.Ignite.Core.Cache.Query
         {
             get { return CacheOp.QrySql; }
         }
+
+        /// <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("SqlQuery [Sql={0}, Arguments=[{1}], Local={2}, PageSize={3},
" +
+                                 "EnableDistributedJoins={4}, Timeout={5}, ReplicatedOnly={6}]",
Sql, args, Local,
+                PageSize, EnableDistributedJoins, Timeout, ReplicatedOnly);
+        }
+
     }
 }

http://git-wip-us.apache.org/repos/asf/ignite/blob/ca94cf3d/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Cache/CacheImpl.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Cache/CacheImpl.cs b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Cache/CacheImpl.cs
index 749409c..95787eb 100644
--- a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Cache/CacheImpl.cs
+++ b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Cache/CacheImpl.cs
@@ -1086,6 +1086,9 @@ namespace Apache.Ignite.Core.Impl.Cache
 
                 writer.WriteBoolean(qry.EnableDistributedJoins);
                 writer.WriteBoolean(qry.EnforceJoinOrder);
+                writer.WriteInt((int) qry.Timeout.TotalMilliseconds);
+                writer.WriteBoolean(qry.ReplicatedOnly);
+                writer.WriteBoolean(qry.Colocated);
             });
         
             return new FieldsQueryCursor<T>(cursor, Marshaller, _flagKeepBinary, readerFunc);

http://git-wip-us.apache.org/repos/asf/ignite/blob/ca94cf3d/modules/platforms/dotnet/Apache.Ignite.Linq/CacheExtensions.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Linq/CacheExtensions.cs b/modules/platforms/dotnet/Apache.Ignite.Linq/CacheExtensions.cs
index 4b536f4..2c609c6 100644
--- a/modules/platforms/dotnet/Apache.Ignite.Linq/CacheExtensions.cs
+++ b/modules/platforms/dotnet/Apache.Ignite.Linq/CacheExtensions.cs
@@ -20,6 +20,7 @@ namespace Apache.Ignite.Linq
     using System.Linq;
     using Apache.Ignite.Core.Cache;
     using Apache.Ignite.Core.Cache.Configuration;
+    using Apache.Ignite.Core.Impl.Common;
     using Apache.Ignite.Linq.Impl;
 
     /// <summary>
@@ -43,6 +44,8 @@ namespace Apache.Ignite.Linq
         public static IQueryable<ICacheEntry<TKey, TValue>> AsCacheQueryable<TKey,
TValue>(
             this ICache<TKey, TValue> cache)
         {
+            IgniteArgumentCheck.NotNull(cache, "cache");
+
             return cache.AsCacheQueryable(false, null);
         }
 
@@ -64,6 +67,8 @@ namespace Apache.Ignite.Linq
         public static IQueryable<ICacheEntry<TKey, TValue>> AsCacheQueryable<TKey,
TValue>(
             this ICache<TKey, TValue> cache, bool local)
         {
+            IgniteArgumentCheck.NotNull(cache, "cache");
+
             return cache.AsCacheQueryable(local, null);
         }
 
@@ -92,6 +97,8 @@ namespace Apache.Ignite.Linq
         public static IQueryable<ICacheEntry<TKey, TValue>> AsCacheQueryable<TKey,
TValue>(
             this ICache<TKey, TValue> cache, bool local, string tableName)
         {
+            IgniteArgumentCheck.NotNull(cache, "cache");
+
             return cache.AsCacheQueryable(new QueryOptions {Local = local, TableName = tableName});
         }
 
@@ -114,6 +121,9 @@ namespace Apache.Ignite.Linq
         public static IQueryable<ICacheEntry<TKey, TValue>> AsCacheQueryable<TKey,
TValue>(
             this ICache<TKey, TValue> cache, QueryOptions queryOptions)
         {
+            IgniteArgumentCheck.NotNull(cache, "cache");
+            IgniteArgumentCheck.NotNull(queryOptions, "queryOptions");
+
             return new CacheQueryable<TKey, TValue>(cache, queryOptions);
         }
     }

http://git-wip-us.apache.org/repos/asf/ignite/blob/ca94cf3d/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 8dfddc7..27082bd 100644
--- a/modules/platforms/dotnet/Apache.Ignite.Linq/Impl/CacheFieldsQueryExecutor.cs
+++ b/modules/platforms/dotnet/Apache.Ignite.Linq/Impl/CacheFieldsQueryExecutor.cs
@@ -38,41 +38,26 @@ namespace Apache.Ignite.Linq.Impl
     {
         /** */
         private readonly ICacheInternal _cache;
+        
+        /** */
+        private readonly QueryOptions _options;
 
         /** */
         private static readonly CopyOnWriteConcurrentDictionary<ConstructorInfo, object>
CtorCache =
             new CopyOnWriteConcurrentDictionary<ConstructorInfo, object>();
 
-        /** */
-        private readonly bool _local;
-
-        /** */
-        private readonly int _pageSize;
-
-        /** */
-        private readonly bool _enableDistributedJoins;
-
-        /** */
-        private readonly bool _enforceJoinOrder;
-
         /// <summary>
         /// Initializes a new instance of the <see cref="CacheFieldsQueryExecutor" />
class.
         /// </summary>
         /// <param name="cache">The executor function.</param>
-        /// <param name="local">Local flag.</param>
-        /// <param name="pageSize">Size of the page.</param>
-        /// <param name="enableDistributedJoins">Distributed joins flag.</param>
-        /// <param name="enforceJoinOrder">Enforce join order flag.</param>
-        public CacheFieldsQueryExecutor(ICacheInternal cache, bool local, int pageSize, bool
enableDistributedJoins,
-            bool enforceJoinOrder)
+        /// <param name="options">Query options.</param>
+        public CacheFieldsQueryExecutor(ICacheInternal cache, QueryOptions options)
         {
             Debug.Assert(cache != null);
+            Debug.Assert(options != null);
 
             _cache = cache;
-            _local = local;
-            _pageSize = pageSize;
-            _enableDistributedJoins = enableDistributedJoins;
-            _enforceJoinOrder = enforceJoinOrder;
+            _options = options;
         }
 
         /** <inheritdoc /> */
@@ -252,11 +237,16 @@ namespace Apache.Ignite.Linq.Impl
         /// </summary>
         internal SqlFieldsQuery GetFieldsQuery(string text, object[] args)
         {
-            return new SqlFieldsQuery(text, _local, args)
+            return new SqlFieldsQuery(text)
             {
-                EnableDistributedJoins = _enableDistributedJoins,
-                PageSize = _pageSize,
-                EnforceJoinOrder = _enforceJoinOrder
+                EnableDistributedJoins = _options.EnableDistributedJoins,
+                PageSize = _options.PageSize,
+                EnforceJoinOrder = _options.EnforceJoinOrder,
+                Timeout = _options.Timeout,
+                ReplicatedOnly = _options.ReplicatedOnly,
+                Colocated = _options.Colocated,
+                Local = _options.Local,
+                Arguments = args
             };
         }
 

http://git-wip-us.apache.org/repos/asf/ignite/blob/ca94cf3d/modules/platforms/dotnet/Apache.Ignite.Linq/Impl/CacheQueryable.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Linq/Impl/CacheQueryable.cs b/modules/platforms/dotnet/Apache.Ignite.Linq/Impl/CacheQueryable.cs
index 7372776..e271363 100644
--- a/modules/platforms/dotnet/Apache.Ignite.Linq/Impl/CacheQueryable.cs
+++ b/modules/platforms/dotnet/Apache.Ignite.Linq/Impl/CacheQueryable.cs
@@ -33,8 +33,7 @@ namespace Apache.Ignite.Linq.Impl
         /// <param name="queryOptions">The query options.</param>
         public CacheQueryable(ICache<TKey, TValue> cache, QueryOptions queryOptions)
             : base(new CacheFieldsQueryProvider(CacheQueryParser.Instance,
-                new CacheFieldsQueryExecutor((ICacheInternal) cache, queryOptions.Local,
queryOptions.PageSize,
-                    queryOptions.EnableDistributedJoins, queryOptions.EnforceJoinOrder),

+                new CacheFieldsQueryExecutor((ICacheInternal) cache, queryOptions), 
                 cache.Ignite, cache.GetConfiguration(), queryOptions.TableName, typeof(TValue)))
         {
             // No-op.

http://git-wip-us.apache.org/repos/asf/ignite/blob/ca94cf3d/modules/platforms/dotnet/Apache.Ignite.Linq/QueryOptions.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Linq/QueryOptions.cs b/modules/platforms/dotnet/Apache.Ignite.Linq/QueryOptions.cs
index c70152e..17b3705 100644
--- a/modules/platforms/dotnet/Apache.Ignite.Linq/QueryOptions.cs
+++ b/modules/platforms/dotnet/Apache.Ignite.Linq/QueryOptions.cs
@@ -17,6 +17,7 @@
 
 namespace Apache.Ignite.Linq
 {
+    using System;
     using System.ComponentModel;
     using Apache.Ignite.Core.Cache.Configuration;
     using Apache.Ignite.Core.Cache.Query;
@@ -87,5 +88,27 @@ namespace Apache.Ignite.Linq
         ///   <c>true</c> if join order should be enforced; otherwise, <c>false</c>.
         /// </value>
         public bool EnforceJoinOrder { get; set; }
+
+        /// <summary>
+        /// Gets or sets the query timeout. Query will be automatically cancelled if the
execution timeout is exceeded.
+        /// Default is <see cref="TimeSpan.Zero"/>, which means no timeout.
+        /// </summary>
+        public TimeSpan Timeout { get; set; }
+
+        /// <summary>
+        /// Gets or sets a value indicating whether this query contains only replicated tables.
+        /// This is a hint for potentially more effective execution.
+        /// </summary>
+        public bool ReplicatedOnly { get; set; }
+
+        /// <summary>
+        /// Gets or sets a value indicating whether this query operates on colocated data.
+        /// <para />
+        /// Whenever Ignite executes a distributed query, it sends sub-queries to individual
cluster members.
+        /// If you know in advance that the elements of your query selection are colocated
together on the same
+        /// node and you group by colocated key (primary or affinity key), then Ignite can
make significant
+        /// performance and network optimizations by grouping data on remote nodes.
+        /// </summary>
+        public bool Colocated { get; set; }
     }
 }


Mime
View raw message