IGNITE-7229 .NET: Rename ICache.QueryFields to Query, add FieldNames This closes #3247
Project: http://git-wip-us.apache.org/repos/asf/ignite/repo Commit: http://git-wip-us.apache.org/repos/asf/ignite/commit/8f327a18 Tree: http://git-wip-us.apache.org/repos/asf/ignite/tree/8f327a18 Diff: http://git-wip-us.apache.org/repos/asf/ignite/diff/8f327a18 Branch: refs/heads/ignite-zk Commit: 8f327a18bea8cd4efda0d9ffea1acf7a11d56f90 Parents: a2b195c Author: Pavel Tupitsyn <ptupit...@apache.org> Authored: Tue Dec 19 10:20:08 2017 +0300 Committer: Pavel Tupitsyn <ptupit...@apache.org> Committed: Tue Dec 19 10:20:08 2017 +0300 ---------------------------------------------------------------------- .../query/PlatformAbstractQueryCursor.java | 9 +++ .../cache/query/PlatformFieldsQueryCursor.java | 24 ++++++- .../ExpiryCacheHolderTest.cs | 5 ++ .../Binary/BinaryFooterTest.cs | 2 +- .../Binary/Serializable/SqlDmlTest.cs | 6 +- .../Cache/CacheTestAsyncWrapper.cs | 7 ++ .../Cache/Query/CacheDmlQueriesTest.cs | 18 ++--- .../Query/CacheQueriesCodeConfigurationTest.cs | 2 +- .../Cache/Query/CacheQueriesTest.cs | 69 +++++++++++++++----- .../Query/Linq/CacheLinqTest.Introspection.cs | 2 +- .../Client/Cache/SqlQueryTest.cs | 4 +- .../dotnet/Apache.Ignite.Core/Cache/ICache.cs | 8 +++ .../Impl/Binary/BinaryReaderExtensions.cs | 2 +- .../Apache.Ignite.Core/Impl/Cache/CacheImpl.cs | 29 +++++--- .../Impl/Cache/ICacheInternal.cs | 2 +- .../Impl/Cache/Query/FieldsQueryCursor.cs | 39 +++++++++++ .../Impl/Cache/Query/PlatformQueryQursorBase.cs | 8 +++ .../Impl/Client/Cache/CacheClient.cs | 2 +- .../Cache/Query/ClientFieldsQueryCursor.cs | 12 +--- .../NuGet/LINQPad/BinaryModeExample.linq | 2 +- .../NuGet/LINQPad/QueryExample.linq | 2 +- .../Apache.Ignite.Linq/CacheLinqExtensions.cs | 10 +-- .../Impl/CacheFieldsQueryExecutor.cs | 10 +-- modules/platforms/dotnet/Apache.Ignite.ndproj | 2 +- .../Datagrid/BinaryModeExample.cs | 5 +- .../Datagrid/QueryDmlExample.cs | 18 ++--- .../Datagrid/QueryExample.cs | 5 +- .../dotnet/examples/dotnetcore/SqlExample.cs | 2 +- 28 files changed, 224 insertions(+), 82 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/ignite/blob/8f327a18/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/cache/query/PlatformAbstractQueryCursor.java ---------------------------------------------------------------------- diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/cache/query/PlatformAbstractQueryCursor.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/cache/query/PlatformAbstractQueryCursor.java index 20e98fc..aef8e59 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/cache/query/PlatformAbstractQueryCursor.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/cache/query/PlatformAbstractQueryCursor.java @@ -176,6 +176,15 @@ public abstract class PlatformAbstractQueryCursor<T> extends PlatformAbstractTar protected abstract void write(BinaryRawWriterEx writer, T val); /** + * Gets the cursor. + * + * @return Cursor. + */ + public QueryCursorEx<T> cursor() { + return cursor; + } + + /** * Query cursor consumer. */ private static class Consumer<T> implements QueryCursorEx.Consumer<T> { http://git-wip-us.apache.org/repos/asf/ignite/blob/8f327a18/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/cache/query/PlatformFieldsQueryCursor.java ---------------------------------------------------------------------- diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/cache/query/PlatformFieldsQueryCursor.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/cache/query/PlatformFieldsQueryCursor.java index 25f86f2..15561b0 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/cache/query/PlatformFieldsQueryCursor.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/cache/query/PlatformFieldsQueryCursor.java @@ -17,15 +17,21 @@ package org.apache.ignite.internal.processors.platform.cache.query; -import java.util.List; +import org.apache.ignite.IgniteCheckedException; +import org.apache.ignite.cache.query.FieldsQueryCursor; import org.apache.ignite.internal.binary.BinaryRawWriterEx; import org.apache.ignite.internal.processors.cache.query.QueryCursorEx; import org.apache.ignite.internal.processors.platform.PlatformContext; +import java.util.List; + /** * Interop cursor for fields query. */ public class PlatformFieldsQueryCursor extends PlatformAbstractQueryCursor<List<?>> { + /** Gets field names. */ + private static final int OP_GET_FIELD_NAMES = 7; + /** * Constructor. * @@ -52,4 +58,20 @@ public class PlatformFieldsQueryCursor extends PlatformAbstractQueryCursor<List< writer.writeInt(rowSizePos, rowEndPos - rowSizePos); } + + /** {@inheritDoc} */ + @Override public void processOutStream(int type, final BinaryRawWriterEx writer) throws IgniteCheckedException { + if (type == OP_GET_FIELD_NAMES) { + FieldsQueryCursor fq = (FieldsQueryCursor) cursor(); + + int cnt = fq.getColumnsCount(); + writer.writeInt(cnt); + + for (int i = 0; i < cnt; i++) { + writer.writeString(fq.getFieldName(i)); + } + } else { + super.processOutStream(type, writer); + } + } } http://git-wip-us.apache.org/repos/asf/ignite/blob/8f327a18/modules/platforms/dotnet/Apache.Ignite.AspNet.Tests/ExpiryCacheHolderTest.cs ---------------------------------------------------------------------- diff --git a/modules/platforms/dotnet/Apache.Ignite.AspNet.Tests/ExpiryCacheHolderTest.cs b/modules/platforms/dotnet/Apache.Ignite.AspNet.Tests/ExpiryCacheHolderTest.cs index 2fe3309..93e3a53 100644 --- a/modules/platforms/dotnet/Apache.Ignite.AspNet.Tests/ExpiryCacheHolderTest.cs +++ b/modules/platforms/dotnet/Apache.Ignite.AspNet.Tests/ExpiryCacheHolderTest.cs @@ -419,6 +419,11 @@ namespace Apache.Ignite.AspNet.Tests throw new NotImplementedException(); } + public IFieldsQueryCursor Query(SqlFieldsQuery qry) + { + throw new NotImplementedException(); + } + public IQueryCursor<IList> QueryFields(SqlFieldsQuery qry) { throw new NotImplementedException(); http://git-wip-us.apache.org/repos/asf/ignite/blob/8f327a18/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Binary/BinaryFooterTest.cs ---------------------------------------------------------------------- diff --git a/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Binary/BinaryFooterTest.cs b/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Binary/BinaryFooterTest.cs index 9fa4538..34df6d7 100644 --- a/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Binary/BinaryFooterTest.cs +++ b/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Binary/BinaryFooterTest.cs @@ -146,7 +146,7 @@ namespace Apache.Ignite.Core.Tests.Binary Assert.AreEqual(dt.Arr, cache[1].Arr); // SQL: read field on Java side to ensure correct offset handling. - var res = cache.QueryFields(new SqlFieldsQuery("select int from OffsetTest")).GetAll()[0][0]; + var res = cache.Query(new SqlFieldsQuery("select int from OffsetTest")).GetAll()[0][0]; Assert.AreEqual(dt.Int, (int) res); } http://git-wip-us.apache.org/repos/asf/ignite/blob/8f327a18/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Binary/Serializable/SqlDmlTest.cs ---------------------------------------------------------------------- diff --git a/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Binary/Serializable/SqlDmlTest.cs b/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Binary/Serializable/SqlDmlTest.cs index 4b77dbe..0ffd068 100644 --- a/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Binary/Serializable/SqlDmlTest.cs +++ b/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Binary/Serializable/SqlDmlTest.cs @@ -107,7 +107,7 @@ namespace Apache.Ignite.Core.Tests.Binary.Serializable // Test DML. var guid = Guid.NewGuid(); - var insertRes = cache.QueryFields(new SqlFieldsQuery( + var insertRes = cache.Query(new SqlFieldsQuery( "insert into SimpleSerializable(_key, Byte, Bool, Short, Int, Long, Float, Double, " + "Decimal, Guid, String) values (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)", 3, 45, true, 43, 33, 99, 4.5f, 6.7, 9.04m, guid, "bar33")).GetAll(); @@ -141,7 +141,7 @@ namespace Apache.Ignite.Core.Tests.Binary.Serializable Assert.AreEqual(uint.MaxValue, cache[1].Uint); // Test SQL. - var sqlRes = cache.QueryFields(new SqlFieldsQuery( + var sqlRes = cache.Query(new SqlFieldsQuery( "select uint from DotNetSpecificSerializable where uint <> 0")).GetAll(); Assert.AreEqual(1, sqlRes.Count); @@ -152,7 +152,7 @@ namespace Apache.Ignite.Core.Tests.Binary.Serializable Assert.AreEqual(uint.MaxValue, linqRes); // Test DML. - var dmlRes = cache.QueryFields(new SqlFieldsQuery( + var dmlRes = cache.Query(new SqlFieldsQuery( "insert into DotNetSpecificSerializable(_key, uint) values (?, ?), (?, ?)", 2, uint.MaxValue, 3, 88)).GetAll(); Assert.AreEqual(1, dmlRes.Count); http://git-wip-us.apache.org/repos/asf/ignite/blob/8f327a18/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Cache/CacheTestAsyncWrapper.cs ---------------------------------------------------------------------- diff --git a/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Cache/CacheTestAsyncWrapper.cs b/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Cache/CacheTestAsyncWrapper.cs index 5ba2fc9..0b1af41 100644 --- a/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Cache/CacheTestAsyncWrapper.cs +++ b/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Cache/CacheTestAsyncWrapper.cs @@ -445,6 +445,13 @@ namespace Apache.Ignite.Core.Tests.Cache } /** <inheritDoc /> */ + public IFieldsQueryCursor Query(SqlFieldsQuery qry) + { + return _cache.Query(qry); + } + + /** <inheritDoc /> */ + [Obsolete] public IQueryCursor<IList> QueryFields(SqlFieldsQuery qry) { return _cache.QueryFields(qry); http://git-wip-us.apache.org/repos/asf/ignite/blob/8f327a18/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Cache/Query/CacheDmlQueriesTest.cs ---------------------------------------------------------------------- diff --git a/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Cache/Query/CacheDmlQueriesTest.cs b/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Cache/Query/CacheDmlQueriesTest.cs index 741dff0..f289e56 100644 --- a/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Cache/Query/CacheDmlQueriesTest.cs +++ b/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Cache/Query/CacheDmlQueriesTest.cs @@ -76,7 +76,7 @@ namespace Apache.Ignite.Core.Tests.Cache.Query var cache = Ignition.GetIgnite().CreateCache<int, Foo>(cfg); // Test insert. - var res = cache.QueryFields(new SqlFieldsQuery("insert into foo(_key, id, name) " + + var res = cache.Query(new SqlFieldsQuery("insert into foo(_key, id, name) " + "values (?, ?, ?), (?, ?, ?)", 1, 2, "John", 3, 4, "Mary")).GetAll(); @@ -118,7 +118,7 @@ namespace Apache.Ignite.Core.Tests.Cache.Query var cache = Ignition.GetIgnite().CreateCache<int, Foo>(cfg); - var ex = Assert.Throws<IgniteException>(() => cache.QueryFields(new SqlFieldsQuery( + var ex = Assert.Throws<IgniteException>(() => cache.Query(new SqlFieldsQuery( "insert into foo(_key, name) values (?, ?)", 1, "bar")).GetAll()); Assert.AreEqual("Null value is not allowed for column 'ID'", ex.Message); @@ -133,7 +133,7 @@ namespace Apache.Ignite.Core.Tests.Cache.Query var cfg = new CacheConfiguration("not_null_attr", new QueryEntity(typeof(int), typeof(Foo))); var cache = Ignition.GetIgnite().CreateCache<int, Foo>(cfg); - var ex = Assert.Throws<IgniteException>(() => cache.QueryFields(new SqlFieldsQuery( + var ex = Assert.Throws<IgniteException>(() => cache.Query(new SqlFieldsQuery( "insert into foo(_key, id) values (?, ?)", 1, 2)).GetAll()); Assert.AreEqual("Null value is not allowed for column 'NAME'", ex.Message); @@ -169,7 +169,7 @@ namespace Apache.Ignite.Core.Tests.Cache.Query foreach (var val in vals) { - var res = cache.QueryFields(new SqlFieldsQuery( + var res = cache.Query(new SqlFieldsQuery( "insert into string(_key, _val) values (?, ?)", val, val.ToString())).GetAll(); Assert.AreEqual(1, res.Count); @@ -190,7 +190,7 @@ namespace Apache.Ignite.Core.Tests.Cache.Query var cache = Ignition.GetIgnite().CreateCache<Key, Foo>(cfg); // Test insert. - var res = cache.QueryFields(new SqlFieldsQuery("insert into foo(hi, lo, id, name) " + + var res = cache.Query(new SqlFieldsQuery("insert into foo(hi, lo, id, name) " + "values (-1, 65500, 3, 'John'), (255, 128, 6, 'Mary')")).GetAll(); Assert.AreEqual(1, res.Count); @@ -240,7 +240,7 @@ namespace Apache.Ignite.Core.Tests.Cache.Query var cache = Ignition.GetIgnite().CreateCache<Key2, Foo>(cfg); // Test insert. - var res = cache.QueryFields(new SqlFieldsQuery("insert into foo(hi, lo, str, id, name) " + + var res = cache.Query(new SqlFieldsQuery("insert into foo(hi, lo, str, id, name) " + "values (1, 2, 'ФÑ', 3, 'John'), (4, 5, 'ÐаÑ', 6, 'Mary')")).GetAll(); Assert.AreEqual(1, res.Count); @@ -293,7 +293,7 @@ namespace Apache.Ignite.Core.Tests.Cache.Query var cache = Ignition.GetIgnite().CreateCache<Key, Foo>(cfg); var ex = Assert.Throws<IgniteException>( - () => cache.QueryFields(new SqlFieldsQuery("insert into foo(lo, hi, id, name) " + + () => cache.Query(new SqlFieldsQuery("insert into foo(lo, hi, id, name) " + "values (1, 2, 3, 'John'), (4, 5, 6, 'Mary')"))); Assert.AreEqual("Ownership flag not set for binary property. Have you set 'keyFields' " + @@ -322,7 +322,7 @@ namespace Apache.Ignite.Core.Tests.Cache.Query var cache = Ignition.GetIgnite().CreateCache<object, object>(cfg) .WithKeepBinary<IBinaryObject, IBinaryObject>(); - var res = cache.QueryFields(new SqlFieldsQuery("insert into car(VIN, Id, Make, Year) " + + var res = cache.Query(new SqlFieldsQuery("insert into car(VIN, Id, Make, Year) " + "values ('DLRDMC', 88, 'DeLorean', 1982)")).GetAll(); Assert.AreEqual(1, res.Count); @@ -362,7 +362,7 @@ namespace Apache.Ignite.Core.Tests.Cache.Query }; // Test insert. - var res = cache.QueryFields(new SqlFieldsQuery( + var res = cache.Query(new SqlFieldsQuery( "insert into string(byte, sbyte, short, ushort, int, uint, long, ulong, float, double, decimal, " + "guid, string, key, _val) values (?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)", key.Byte, key.SByte, key.Short, key.UShort, key.Int, key.UInt, key.Long, key.ULong, key.Float, http://git-wip-us.apache.org/repos/asf/ignite/blob/8f327a18/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Cache/Query/CacheQueriesCodeConfigurationTest.cs ---------------------------------------------------------------------- diff --git a/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Cache/Query/CacheQueriesCodeConfigurationTest.cs b/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Cache/Query/CacheQueriesCodeConfigurationTest.cs index 2e24ff6..9768fca 100644 --- a/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Cache/Query/CacheQueriesCodeConfigurationTest.cs +++ b/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Cache/Query/CacheQueriesCodeConfigurationTest.cs @@ -91,7 +91,7 @@ namespace Apache.Ignite.Core.Tests.Cache.Query Assert.AreEqual(2, cursor.GetAll().Single().Key); } - using (var cursor = cache.QueryFields(new SqlFieldsQuery( + using (var cursor = cache.Query(new SqlFieldsQuery( "select _key from CustomTableName where age > ? and birthday < ?", 10, DateTime.UtcNow))) { Assert.AreEqual(2, cursor.GetAll().Single()[0]); http://git-wip-us.apache.org/repos/asf/ignite/blob/8f327a18/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 8134b3d..278d1fd 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 @@ -20,7 +20,6 @@ namespace Apache.Ignite.Core.Tests.Cache.Query { using System; - using System.Collections; using System.Collections.Generic; using System.Diagnostics.CodeAnalysis; using System.Linq; @@ -156,7 +155,7 @@ namespace Apache.Ignite.Core.Tests.Cache.Query public void TestValidationSqlFields() { // 1. No sql. - Assert.Throws<ArgumentException>(() => { Cache().QueryFields(new SqlFieldsQuery(null)); }); + Assert.Throws<ArgumentException>(() => { Cache().Query(new SqlFieldsQuery(null)); }); } /// <summary> @@ -285,11 +284,9 @@ namespace Apache.Ignite.Core.Tests.Cache.Query Cache().Put(3, new QueryPerson("Sidorov", 50)); // 1. Empty result set. - using ( - IQueryCursor<IList> cursor = Cache().QueryFields( - new SqlFieldsQuery("SELECT age FROM QueryPerson WHERE age < ?", 50))) + using (var cursor = Cache().Query(new SqlFieldsQuery("SELECT age FROM QueryPerson WHERE age < ?", 50))) { - foreach (IList entry in cursor.GetAll()) + foreach (var entry in cursor.GetAll()) Assert.IsTrue((int) entry[0] < 50); } } @@ -390,7 +387,7 @@ namespace Apache.Ignite.Core.Tests.Cache.Query Lazy = lazy }; - using (IQueryCursor<IList> cursor = cache.QueryFields(qry)) + using (var cursor = cache.Query(qry)) { HashSet<int> exp0 = new HashSet<int>(exp); @@ -403,9 +400,12 @@ namespace Apache.Ignite.Core.Tests.Cache.Query } Assert.AreEqual(0, exp0.Count); + Assert.AreEqual(new[] {"NAME", "AGE"}, cursor.FieldNames); } - using (IQueryCursor<IList> cursor = cache.QueryFields(qry)) + // Test old API as well. +#pragma warning disable 618 + using (var cursor = cache.QueryFields(qry)) { HashSet<int> exp0 = new HashSet<int>(exp); @@ -418,6 +418,7 @@ namespace Apache.Ignite.Core.Tests.Cache.Query Assert.AreEqual(0, exp0.Count); } +#pragma warning restore 618 } /// <summary> @@ -622,7 +623,7 @@ namespace Apache.Ignite.Core.Tests.Cache.Query strings[1] = "foo"; // Default schema. - var res = doubles.QueryFields(new SqlFieldsQuery( + var res = doubles.Query(new SqlFieldsQuery( "select S._val from double as D join \"strings\".string as S on S._key = D._key")) .Select(x => (string) x[0]) .Single(); @@ -630,7 +631,7 @@ namespace Apache.Ignite.Core.Tests.Cache.Query Assert.AreEqual("foo", res); // Custom schema. - res = doubles.QueryFields(new SqlFieldsQuery( + res = doubles.Query(new SqlFieldsQuery( "select S._val from \"doubles\".double as D join string as S on S._key = D._key") { Schema = strings.Name @@ -667,13 +668,13 @@ namespace Apache.Ignite.Core.Tests.Cache.Query var sql = "select T0.Age from QueryPerson as T0 " + "inner join QueryPerson as T1 on ((? - T1.Age - 1) = T0._key)"; - var res = cache.QueryFields(new SqlFieldsQuery(sql, count)).GetAll().Distinct().Count(); + var res = cache.Query(new SqlFieldsQuery(sql, count)).GetAll().Distinct().Count(); Assert.Greater(res, 0); Assert.Less(res, count); // Test distributed join: returns complete results - res = cache.QueryFields(new SqlFieldsQuery(sql, count) {EnableDistributedJoins = true}) + res = cache.Query(new SqlFieldsQuery(sql, count) {EnableDistributedJoins = true}) .GetAll().Distinct().Count(); Assert.AreEqual(count, res); @@ -709,7 +710,7 @@ namespace Apache.Ignite.Core.Tests.Cache.Query cache[1] = new QueryPerson("Joe", 48); - var row = cache.QueryFields(new SqlFieldsQuery("select * from QueryPerson")).GetAll()[0]; + var row = cache.Query(new SqlFieldsQuery("select * from QueryPerson")).GetAll()[0]; Assert.AreEqual(2, row.Count); Assert.AreEqual(48, row[0]); Assert.AreEqual("Joe", row[1]); @@ -736,7 +737,7 @@ namespace Apache.Ignite.Core.Tests.Cache.Query cache[1] = new QueryPerson("John", 33); - row = cache.QueryFields(new SqlFieldsQuery("select * from QueryPerson")).GetAll()[0]; + row = cache.Query(new SqlFieldsQuery("select * from QueryPerson")).GetAll()[0]; Assert.AreEqual(3, row.Count); Assert.AreEqual(33, row[0]); @@ -746,7 +747,7 @@ namespace Apache.Ignite.Core.Tests.Cache.Query Assert.AreEqual("John", person.Name); // Check explicit select. - row = cache.QueryFields(new SqlFieldsQuery("select FullKey from QueryPerson")).GetAll()[0]; + row = cache.Query(new SqlFieldsQuery("select FullKey from QueryPerson")).GetAll()[0]; Assert.AreEqual(1, row[0]); } @@ -786,11 +787,47 @@ namespace Apache.Ignite.Core.Tests.Cache.Query }; // ReSharper disable once ReturnValueOfPureMethodIsNotUsed - var ex = Assert.Throws<CacheException>(() => cache.QueryFields(fieldsQry).ToArray()); + var ex = Assert.Throws<CacheException>(() => cache.Query(fieldsQry).ToArray()); Assert.IsTrue(ex.ToString().Contains("QueryCancelledException: The query was cancelled while executing.")); } /// <summary> + /// Tests the FieldNames property. + /// </summary> + [Test] + public void TestFieldNames() + { + var cache = Cache(); + PopulateCache(cache, false, 5, x => true); + + // Get before iteration. + var qry = new SqlFieldsQuery("SELECT * FROM QueryPerson"); + var cur = cache.Query(qry); + var names = cur.FieldNames; + + Assert.AreEqual(new[] {"AGE", "NAME" }, names); + + cur.Dispose(); + Assert.AreSame(names, cur.FieldNames); + + Assert.Throws<NotSupportedException>(() => cur.FieldNames.Add("x")); + + // Custom order, key-val, get after iteration. + qry.Sql = "SELECT NAME, _key, AGE, _val FROM QueryPerson"; + cur = cache.Query(qry); + cur.GetAll(); + + Assert.AreEqual(new[] { "NAME", "_KEY", "AGE", "_VAL" }, cur.FieldNames); + + // Get after disposal. + qry.Sql = "SELECT 1, AGE FROM QueryPerson"; + cur = cache.Query(qry); + cur.Dispose(); + + Assert.AreEqual(new[] { "1", "AGE" }, cur.FieldNames); + } + + /// <summary> /// Validates the query results. /// </summary> /// <param name="cache">Cache.</param> http://git-wip-us.apache.org/repos/asf/ignite/blob/8f327a18/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Cache/Query/Linq/CacheLinqTest.Introspection.cs ---------------------------------------------------------------------- diff --git a/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Cache/Query/Linq/CacheLinqTest.Introspection.cs b/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Cache/Query/Linq/CacheLinqTest.Introspection.cs index 6e7483e..aa26548 100644 --- a/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Cache/Query/Linq/CacheLinqTest.Introspection.cs +++ b/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Cache/Query/Linq/CacheLinqTest.Introspection.cs @@ -72,7 +72,7 @@ namespace Apache.Ignite.Core.Tests.Cache.Query.Linq Assert.AreEqual(new[] { 10 }, fq.Arguments); Assert.IsTrue(fq.Local); - Assert.AreEqual(PersonCount - 11, cache.QueryFields(fq).GetAll().Count); + Assert.AreEqual(PersonCount - 11, cache.Query(fq).GetAll().Count); Assert.AreEqual(999, fq.PageSize); Assert.IsFalse(fq.EnableDistributedJoins); Assert.IsTrue(fq.EnforceJoinOrder); http://git-wip-us.apache.org/repos/asf/ignite/blob/8f327a18/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Client/Cache/SqlQueryTest.cs ---------------------------------------------------------------------- diff --git a/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Client/Cache/SqlQueryTest.cs b/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Client/Cache/SqlQueryTest.cs index 6f6df11..b9de090 100644 --- a/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Client/Cache/SqlQueryTest.cs +++ b/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Client/Cache/SqlQueryTest.cs @@ -114,7 +114,9 @@ namespace Apache.Ignite.Core.Tests.Client.Cache // DateTime. qry = new SqlFieldsQuery("select Id, DateTime from Person where DateTime > ?", DateTime.UtcNow.AddDays(9)); - Assert.AreEqual(cache[Count].DateTime, cache.Query(qry).Single().Last()); + cursor = cache.Query(qry); + Assert.AreEqual(new[] {"ID", "DATETIME" }, cursor.FieldNames); + Assert.AreEqual(cache[Count].DateTime, cursor.Single().Last()); // Invalid args. qry.Sql = null; http://git-wip-us.apache.org/repos/asf/ignite/blob/8f327a18/modules/platforms/dotnet/Apache.Ignite.Core/Cache/ICache.cs ---------------------------------------------------------------------- diff --git a/modules/platforms/dotnet/Apache.Ignite.Core/Cache/ICache.cs b/modules/platforms/dotnet/Apache.Ignite.Core/Cache/ICache.cs index f83f279..8a9fe59 100644 --- a/modules/platforms/dotnet/Apache.Ignite.Core/Cache/ICache.cs +++ b/modules/platforms/dotnet/Apache.Ignite.Core/Cache/ICache.cs @@ -705,6 +705,14 @@ namespace Apache.Ignite.Core.Cache /// </summary> /// <param name="qry">SQL fields query.</param> /// <returns>Cursor.</returns> + IFieldsQueryCursor Query(SqlFieldsQuery qry); + + /// <summary> + /// Queries separate entry fields. + /// </summary> + /// <param name="qry">SQL fields query.</param> + /// <returns>Cursor.</returns> + [Obsolete("Use Query(SqlFieldsQuery qry) instead.")] IQueryCursor<IList> QueryFields(SqlFieldsQuery qry); /// <summary> http://git-wip-us.apache.org/repos/asf/ignite/blob/8f327a18/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Binary/BinaryReaderExtensions.cs ---------------------------------------------------------------------- diff --git a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Binary/BinaryReaderExtensions.cs b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Binary/BinaryReaderExtensions.cs index db2f84f..b13318c 100644 --- a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Binary/BinaryReaderExtensions.cs +++ b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Binary/BinaryReaderExtensions.cs @@ -130,7 +130,7 @@ namespace Apache.Ignite.Core.Impl.Binary /// <summary> /// Reads the string collection. /// </summary> - public static ICollection<string> ReadStringCollection(this IBinaryRawReader reader) + public static List<string> ReadStringCollection(this IBinaryRawReader reader) { Debug.Assert(reader != null); http://git-wip-us.apache.org/repos/asf/ignite/blob/8f327a18/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 ca9fb63..6661161 100644 --- a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Cache/CacheImpl.cs +++ b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Cache/CacheImpl.cs @@ -1054,17 +1054,26 @@ namespace Apache.Ignite.Core.Impl.Cache #region Queries /** <inheritDoc /> */ + public IFieldsQueryCursor Query(SqlFieldsQuery qry) + { + var cursor = QueryFieldsInternal(qry); + + return new FieldsQueryCursor(cursor, _flagKeepBinary, + (reader, count) => ReadFieldsArrayList(reader, count)); + } + + /** <inheritDoc /> */ public IQueryCursor<IList> QueryFields(SqlFieldsQuery qry) { - return QueryFields(qry, ReadFieldsArrayList); + return Query(qry, (reader, count) => (IList) ReadFieldsArrayList(reader, count)); } /// <summary> /// Reads the fields array list. /// </summary> - private static IList ReadFieldsArrayList(IBinaryRawReader reader, int count) + private static List<object> ReadFieldsArrayList(IBinaryRawReader reader, int count) { - IList res = new ArrayList(count); + var res = new List<object>(count); for (var i = 0; i < count; i++) res.Add(reader.ReadObject<object>()); @@ -1073,15 +1082,21 @@ namespace Apache.Ignite.Core.Impl.Cache } /** <inheritDoc /> */ - public IQueryCursor<T> QueryFields<T>(SqlFieldsQuery qry, Func<IBinaryRawReader, int, T> readerFunc) + public IQueryCursor<T> Query<T>(SqlFieldsQuery qry, Func<IBinaryRawReader, int, T> readerFunc) + { + var cursor = QueryFieldsInternal(qry); + + return new FieldsQueryCursor<T>(cursor, _flagKeepBinary, readerFunc); + } + + private IPlatformTargetInternal QueryFieldsInternal(SqlFieldsQuery qry) { IgniteArgumentCheck.NotNull(qry, "qry"); - IgniteArgumentCheck.NotNull(readerFunc, "readerFunc"); if (string.IsNullOrEmpty(qry.Sql)) throw new ArgumentException("Sql cannot be null or empty"); - var cursor = DoOutOpObject((int) CacheOp.QrySqlFields, writer => + return DoOutOpObject((int) CacheOp.QrySqlFields, writer => { writer.WriteBoolean(qry.Local); writer.WriteString(qry.Sql); @@ -1097,8 +1112,6 @@ namespace Apache.Ignite.Core.Impl.Cache writer.WriteBoolean(qry.Colocated); writer.WriteString(qry.Schema); // Schema }); - - return new FieldsQueryCursor<T>(cursor, _flagKeepBinary, readerFunc); } /** <inheritDoc /> */ http://git-wip-us.apache.org/repos/asf/ignite/blob/8f327a18/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Cache/ICacheInternal.cs ---------------------------------------------------------------------- diff --git a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Cache/ICacheInternal.cs b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Cache/ICacheInternal.cs index 1ec5341..fb968cf 100644 --- a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Cache/ICacheInternal.cs +++ b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Cache/ICacheInternal.cs @@ -36,7 +36,7 @@ namespace Apache.Ignite.Core.Impl.Cache /// <returns> /// Cursor. /// </returns> - IQueryCursor<T> QueryFields<T>(SqlFieldsQuery qry, Func<IBinaryRawReader, int, T> readerFunc); + IQueryCursor<T> Query<T>(SqlFieldsQuery qry, Func<IBinaryRawReader, int, T> readerFunc); /// <summary> /// Invokes a cache extension. http://git-wip-us.apache.org/repos/asf/ignite/blob/8f327a18/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Cache/Query/FieldsQueryCursor.cs ---------------------------------------------------------------------- diff --git a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Cache/Query/FieldsQueryCursor.cs b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Cache/Query/FieldsQueryCursor.cs index c60e010..c9e64a8 100644 --- a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Cache/Query/FieldsQueryCursor.cs +++ b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Cache/Query/FieldsQueryCursor.cs @@ -18,7 +18,11 @@ namespace Apache.Ignite.Core.Impl.Cache.Query { using System; + using System.Collections.Generic; + using System.Collections.ObjectModel; using Apache.Ignite.Core.Binary; + using Apache.Ignite.Core.Cache.Query; + using Apache.Ignite.Core.Impl.Binary; /// <summary> /// Cursor for entry-based queries. @@ -47,4 +51,39 @@ namespace Apache.Ignite.Core.Impl.Cache.Query // No-op. } } + + /// <summary> + /// Cursor for entry-based queries. + /// </summary> + internal class FieldsQueryCursor : FieldsQueryCursor<IList<object>>, IFieldsQueryCursor + { + /** */ + private const int OpGetFieldNames = 7; + + /** */ + private IList<string> _fieldNames; + + /// <summary> + /// Constructor. + /// </summary> + /// <param name="target">Target.</param> + /// <param name="keepBinary">Keep poratble flag.</param> + /// <param name="readerFunc">The reader function.</param> + public FieldsQueryCursor(IPlatformTargetInternal target, bool keepBinary, + Func<IBinaryRawReader, int, IList<object>> readerFunc) : base(target, keepBinary, readerFunc) + { + // No-op. + } + + /** <inheritdoc /> */ + public IList<string> FieldNames + { + get + { + return _fieldNames ?? + (_fieldNames = new ReadOnlyCollection<string>( + Target.OutStream(OpGetFieldNames, reader => reader.ReadStringCollection()))); + } + } + } } http://git-wip-us.apache.org/repos/asf/ignite/blob/8f327a18/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Cache/Query/PlatformQueryQursorBase.cs ---------------------------------------------------------------------- diff --git a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Cache/Query/PlatformQueryQursorBase.cs b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Cache/Query/PlatformQueryQursorBase.cs index fc78392..3f1e4fc 100644 --- a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Cache/Query/PlatformQueryQursorBase.cs +++ b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Cache/Query/PlatformQueryQursorBase.cs @@ -54,6 +54,14 @@ namespace Apache.Ignite.Core.Impl.Cache.Query _target = target; } + /// <summary> + /// Gets the target. + /// </summary> + public IPlatformTargetInternal Target + { + get { return _target; } + } + /** <inheritdoc /> */ protected override IList<T> GetAllInternal() { http://git-wip-us.apache.org/repos/asf/ignite/blob/8f327a18/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Client/Cache/CacheClient.cs ---------------------------------------------------------------------- diff --git a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Client/Cache/CacheClient.cs b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Client/Cache/CacheClient.cs index 93829c2..2344417 100644 --- a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Client/Cache/CacheClient.cs +++ b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Client/Cache/CacheClient.cs @@ -196,7 +196,7 @@ namespace Apache.Ignite.Core.Impl.Client.Cache } /** <inheritDoc /> */ - public IQueryCursor<T> QueryFields<T>(SqlFieldsQuery sqlFieldsQuery, Func<IBinaryRawReader, int, T> readerFunc) + public IQueryCursor<T> Query<T>(SqlFieldsQuery sqlFieldsQuery, Func<IBinaryRawReader, int, T> readerFunc) { return DoOutInOp(ClientOp.QuerySqlFields, w => WriteSqlFieldsQuery(w, sqlFieldsQuery, false), http://git-wip-us.apache.org/repos/asf/ignite/blob/8f327a18/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Client/Cache/Query/ClientFieldsQueryCursor.cs ---------------------------------------------------------------------- diff --git a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Client/Cache/Query/ClientFieldsQueryCursor.cs b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Client/Cache/Query/ClientFieldsQueryCursor.cs index 2e57863..c8f7e1f 100644 --- a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Client/Cache/Query/ClientFieldsQueryCursor.cs +++ b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Client/Cache/Query/ClientFieldsQueryCursor.cs @@ -22,6 +22,7 @@ namespace Apache.Ignite.Core.Impl.Client.Cache.Query using System.Diagnostics; using Apache.Ignite.Core.Binary; using Apache.Ignite.Core.Cache.Query; + using Apache.Ignite.Core.Impl.Binary; using Apache.Ignite.Core.Impl.Binary.IO; /// <summary> @@ -64,16 +65,9 @@ namespace Apache.Ignite.Core.Impl.Client.Cache.Query /// <summary> /// Reads the columns. /// </summary> - internal static string[] ReadColumns(IBinaryRawReader reader) + internal static List<string> ReadColumns(IBinaryRawReader reader) { - var res = new string[reader.ReadInt()]; - - for (var i = 0; i < res.Length; i++) - { - res[i] = reader.ReadString(); - } - - return res; + return reader.ReadStringCollection(); } } } http://git-wip-us.apache.org/repos/asf/ignite/blob/8f327a18/modules/platforms/dotnet/Apache.Ignite.Core/NuGet/LINQPad/BinaryModeExample.linq ---------------------------------------------------------------------- diff --git a/modules/platforms/dotnet/Apache.Ignite.Core/NuGet/LINQPad/BinaryModeExample.linq b/modules/platforms/dotnet/Apache.Ignite.Core/NuGet/LINQPad/BinaryModeExample.linq index 2220650..4b2291e 100644 --- a/modules/platforms/dotnet/Apache.Ignite.Core/NuGet/LINQPad/BinaryModeExample.linq +++ b/modules/platforms/dotnet/Apache.Ignite.Core/NuGet/LINQPad/BinaryModeExample.linq @@ -90,6 +90,6 @@ using (var ignite = Ignition.Start()) .Dump("Persons with age less than 40:"); // Run SQL fields query. - cache.QueryFields(new SqlFieldsQuery("select name from Person order by name")) + cache.Query(new SqlFieldsQuery("select name from Person order by name")) .Dump("All person names:"); } \ No newline at end of file http://git-wip-us.apache.org/repos/asf/ignite/blob/8f327a18/modules/platforms/dotnet/Apache.Ignite.Core/NuGet/LINQPad/QueryExample.linq ---------------------------------------------------------------------- diff --git a/modules/platforms/dotnet/Apache.Ignite.Core/NuGet/LINQPad/QueryExample.linq b/modules/platforms/dotnet/Apache.Ignite.Core/NuGet/LINQPad/QueryExample.linq index 19d55a3..b3d63ba 100644 --- a/modules/platforms/dotnet/Apache.Ignite.Core/NuGet/LINQPad/QueryExample.linq +++ b/modules/platforms/dotnet/Apache.Ignite.Core/NuGet/LINQPad/QueryExample.linq @@ -66,7 +66,7 @@ void Main() .Dump("Persons working for " + orgName); // Fields query - orgs.QueryFields(new SqlFieldsQuery("select name, size from Organization")).Dump("Fields query"); + orgs.Query(new SqlFieldsQuery("select name, size from Organization")).Dump("Fields query"); // Full text query persons.Query(new TextQuery(typeof(Person), "Chris*")).Dump("Persons starting with 'Chris'"); http://git-wip-us.apache.org/repos/asf/ignite/blob/8f327a18/modules/platforms/dotnet/Apache.Ignite.Linq/CacheLinqExtensions.cs ---------------------------------------------------------------------- diff --git a/modules/platforms/dotnet/Apache.Ignite.Linq/CacheLinqExtensions.cs b/modules/platforms/dotnet/Apache.Ignite.Linq/CacheLinqExtensions.cs index 940b23b..935666f 100644 --- a/modules/platforms/dotnet/Apache.Ignite.Linq/CacheLinqExtensions.cs +++ b/modules/platforms/dotnet/Apache.Ignite.Linq/CacheLinqExtensions.cs @@ -23,6 +23,7 @@ namespace Apache.Ignite.Linq using System.Linq.Expressions; using Apache.Ignite.Core.Cache; using Apache.Ignite.Core.Cache.Configuration; + using Apache.Ignite.Core.Cache.Query; using Apache.Ignite.Core.Impl.Cache; using Apache.Ignite.Core.Impl.Common; using Apache.Ignite.Linq.Impl; @@ -37,8 +38,7 @@ namespace Apache.Ignite.Linq /// Gets an <see cref="IQueryable{T}"/> instance over this cache. /// <para /> /// Resulting query will be translated to cache SQL query and executed over the cache instance - /// via either <see cref="ICache{TK,TV}.Query"/> or <see cref="ICache{TK,TV}.QueryFields"/>, - /// depending on requested result. + /// via <see cref="ICache{TK,TV}.Query(SqlFieldsQuery)"/>. /// <para /> /// Result of this method (and subsequent query) can be cast to <see cref="ICacheQueryable"/> /// for introspection, or converted with <see cref="ToCacheQueryable{T}"/> extension method. @@ -59,7 +59,7 @@ namespace Apache.Ignite.Linq /// Gets an <see cref="IQueryable{T}"/> instance over this cache. /// <para /> /// Resulting query will be translated to cache SQL query and executed over the cache instance - /// via either <see cref="ICache{TK,TV}.Query"/> or <see cref="ICache{TK,TV}.QueryFields"/>, + /// via <see cref="ICache{TK,TV}.Query(SqlFieldsQuery)"/>. /// depending on requested result. /// <para /> /// Result of this method (and subsequent query) can be cast to <see cref="ICacheQueryable"/> for introspection. @@ -82,7 +82,7 @@ namespace Apache.Ignite.Linq /// Gets an <see cref="IQueryable{T}" /> instance over this cache. /// <para /> /// Resulting query will be translated to cache SQL query and executed over the cache instance - /// via either <see cref="ICache{TK,TV}.Query" /> or <see cref="ICache{TK,TV}.QueryFields" />, + /// via <see cref="ICache{TK,TV}.Query(SqlFieldsQuery)"/>. /// depending on requested result. /// <para /> /// Result of this method (and subsequent query) can be cast to <see cref="ICacheQueryable" /> for introspection. @@ -112,7 +112,7 @@ namespace Apache.Ignite.Linq /// Gets an <see cref="IQueryable{T}" /> instance over this cache. /// <para /> /// Resulting query will be translated to cache SQL query and executed over the cache instance - /// via either <see cref="ICache{TK,TV}.Query" /> or <see cref="ICache{TK,TV}.QueryFields" />, + /// via <see cref="ICache{TK,TV}.Query(SqlFieldsQuery)"/>. /// depending on requested result. /// <para /> /// Result of this method (and subsequent query) can be cast to <see cref="ICacheQueryable" /> for introspection. http://git-wip-us.apache.org/repos/asf/ignite/blob/8f327a18/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 fb34270..9d0edd7 100644 --- a/modules/platforms/dotnet/Apache.Ignite.Linq/Impl/CacheFieldsQueryExecutor.cs +++ b/modules/platforms/dotnet/Apache.Ignite.Linq/Impl/CacheFieldsQueryExecutor.cs @@ -89,7 +89,7 @@ namespace Apache.Ignite.Linq.Impl var selector = GetResultSelector<T>(queryModel.SelectClause.Selector); - return _cache.QueryFields(qry, selector); + return _cache.Query(qry, selector); } /// <summary> @@ -102,7 +102,7 @@ namespace Apache.Ignite.Linq.Impl var qryText = GetQueryData(queryModel).QueryText; var selector = GetResultSelector<T>(queryModel.SelectClause.Selector); - return args => _cache.QueryFields(GetFieldsQuery(qryText, args), selector); + return args => _cache.Query(GetFieldsQuery(qryText, args), selector); } /// <summary> @@ -144,7 +144,7 @@ namespace Apache.Ignite.Linq.Impl // Simple case: lambda with no parameters. Only embedded parameters are used. if (!queryLambda.Parameters.Any()) { - return argsUnused => _cache.QueryFields(GetFieldsQuery(qryText, qryParams), selector); + return argsUnused => _cache.Query(GetFieldsQuery(qryText, qryParams), selector); } // These are in order of usage in query @@ -157,7 +157,7 @@ namespace Apache.Ignite.Linq.Impl if (qryOrderArgs.Length == qryParams.Length && qryOrderArgs.SequenceEqual(userOrderArgs)) { - return args => _cache.QueryFields(GetFieldsQuery(qryText, args), selector); + return args => _cache.Query(GetFieldsQuery(qryText, args), selector); } // General case: embedded args and lambda args are mixed; same args can be used multiple times. @@ -172,7 +172,7 @@ namespace Apache.Ignite.Linq.Impl return -1; }).ToArray(); - return args => _cache.QueryFields( + return args => _cache.Query( GetFieldsQuery(qryText, MapQueryArgs(args, qryParams, mapping)), selector); } http://git-wip-us.apache.org/repos/asf/ignite/blob/8f327a18/modules/platforms/dotnet/Apache.Ignite.ndproj ---------------------------------------------------------------------- diff --git a/modules/platforms/dotnet/Apache.Ignite.ndproj b/modules/platforms/dotnet/Apache.Ignite.ndproj index 5ed9e3c..ae99617 100644 --- a/modules/platforms/dotnet/Apache.Ignite.ndproj +++ b/modules/platforms/dotnet/Apache.Ignite.ndproj @@ -2029,7 +2029,7 @@ select new { // is equal to 3 minutes per derived class used by the base class + // 3 minutes per member of a derived class used by the base class. //</HowToFix>]]></Query> - <Query Active="True" DisplayList="True" DisplayStat="False" DisplaySelectionView="False" IsCriticalRule="False"><![CDATA[// <Name>Class shouldn't be too deep in inheritance tree</Name> + <Query Active="False" DisplayList="True" DisplayStat="False" DisplaySelectionView="False" IsCriticalRule="False"><![CDATA[// <Name>Class shouldn't be too deep in inheritance tree</Name> warnif count > 0 from t in JustMyCode.Types where t.IsClass http://git-wip-us.apache.org/repos/asf/ignite/blob/8f327a18/modules/platforms/dotnet/examples/Apache.Ignite.Examples/Datagrid/BinaryModeExample.cs ---------------------------------------------------------------------- diff --git a/modules/platforms/dotnet/examples/Apache.Ignite.Examples/Datagrid/BinaryModeExample.cs b/modules/platforms/dotnet/examples/Apache.Ignite.Examples/Datagrid/BinaryModeExample.cs index 1cc406b..89021e6 100644 --- a/modules/platforms/dotnet/examples/Apache.Ignite.Examples/Datagrid/BinaryModeExample.cs +++ b/modules/platforms/dotnet/examples/Apache.Ignite.Examples/Datagrid/BinaryModeExample.cs @@ -18,7 +18,6 @@ namespace Apache.Ignite.Examples.Datagrid { using System; - using System.Collections; using Apache.Ignite.Core; using Apache.Ignite.Core.Binary; using Apache.Ignite.Core.Cache; @@ -196,12 +195,12 @@ namespace Apache.Ignite.Examples.Datagrid /// <param name="cache">Cache.</param> private static void SqlFieldsQueryExample(ICache<int, IBinaryObject> cache) { - var qry = cache.QueryFields(new SqlFieldsQuery("select name from Person order by name")); + var qry = cache.Query(new SqlFieldsQuery("select name from Person order by name")); Console.WriteLine(); Console.WriteLine(">>> All person names:"); - foreach (IList row in qry) + foreach (var row in qry) Console.WriteLine(">>> " + row[0]); } http://git-wip-us.apache.org/repos/asf/ignite/blob/8f327a18/modules/platforms/dotnet/examples/Apache.Ignite.Examples/Datagrid/QueryDmlExample.cs ---------------------------------------------------------------------- diff --git a/modules/platforms/dotnet/examples/Apache.Ignite.Examples/Datagrid/QueryDmlExample.cs b/modules/platforms/dotnet/examples/Apache.Ignite.Examples/Datagrid/QueryDmlExample.cs index 10bf1dd..00486bd 100644 --- a/modules/platforms/dotnet/examples/Apache.Ignite.Examples/Datagrid/QueryDmlExample.cs +++ b/modules/platforms/dotnet/examples/Apache.Ignite.Examples/Datagrid/QueryDmlExample.cs @@ -98,7 +98,7 @@ namespace Apache.Ignite.Examples.Datagrid EnableDistributedJoins = true }; - using (var cursor = employeeCache.QueryFields(qry)) + using (var cursor = employeeCache.Query(qry)) { foreach (var row in cursor) { @@ -116,25 +116,25 @@ namespace Apache.Ignite.Examples.Datagrid { // Insert organizations. var qry = new SqlFieldsQuery("insert into Organization (_key, name) values (?, ?)", 1, "ASF"); - organizationCache.QueryFields(qry); + organizationCache.Query(qry); qry.Arguments = new object[] {2, "Eclipse"}; - organizationCache.QueryFields(qry); + organizationCache.Query(qry); // Insert employees. qry = new SqlFieldsQuery("insert into Employee (_key, name, organizationId, salary) values (?, ?, ?, ?)"); qry.Arguments = new object[] {1, "John Doe", 1, 4000}; - employeeCache.QueryFields(qry); + employeeCache.Query(qry); qry.Arguments = new object[] {2, "Jane Roe", 1, 5000}; - employeeCache.QueryFields(qry); + employeeCache.Query(qry); qry.Arguments = new object[] {3, "Mary Major", 2, 2000}; - employeeCache.QueryFields(qry); + employeeCache.Query(qry); qry.Arguments = new object[] {4, "Richard Miles", 2, 3000}; - employeeCache.QueryFields(qry); + employeeCache.Query(qry); } /// <summary> @@ -145,7 +145,7 @@ namespace Apache.Ignite.Examples.Datagrid { var qry = new SqlFieldsQuery("update Employee set salary = salary * 1.1 where organizationId = ?", 1); - employeeCache.QueryFields(qry); + employeeCache.Query(qry); } /// <summary> @@ -159,7 +159,7 @@ namespace Apache.Ignite.Examples.Datagrid "select emp._key from Employee emp, \"{0}\".Organization org " + "where org.Name != ? and org._key = emp.organizationId)", OrganizationCacheName), "ASF"); - employeeCache.QueryFields(qry); + employeeCache.Query(qry); } } } http://git-wip-us.apache.org/repos/asf/ignite/blob/8f327a18/modules/platforms/dotnet/examples/Apache.Ignite.Examples/Datagrid/QueryExample.cs ---------------------------------------------------------------------- diff --git a/modules/platforms/dotnet/examples/Apache.Ignite.Examples/Datagrid/QueryExample.cs b/modules/platforms/dotnet/examples/Apache.Ignite.Examples/Datagrid/QueryExample.cs index 98f9f50..23736ea 100644 --- a/modules/platforms/dotnet/examples/Apache.Ignite.Examples/Datagrid/QueryExample.cs +++ b/modules/platforms/dotnet/examples/Apache.Ignite.Examples/Datagrid/QueryExample.cs @@ -18,7 +18,6 @@ namespace Apache.Ignite.Examples.Datagrid { using System; - using System.Collections; using Apache.Ignite.Core; using Apache.Ignite.Core.Cache; using Apache.Ignite.Core.Cache.Affinity; @@ -182,12 +181,12 @@ namespace Apache.Ignite.Examples.Datagrid /// <param name="cache">Cache.</param> private static void SqlFieldsQueryExample(ICache<int, Employee> cache) { - var qry = cache.QueryFields(new SqlFieldsQuery("select name, salary from Employee")); + var qry = cache.Query(new SqlFieldsQuery("select name, salary from Employee")); Console.WriteLine(); Console.WriteLine(">>> Employee names and their salaries:"); - foreach (IList row in qry) + foreach (var row in qry) Console.WriteLine(">>> [Name=" + row[0] + ", salary=" + row[1] + ']'); } http://git-wip-us.apache.org/repos/asf/ignite/blob/8f327a18/modules/platforms/dotnet/examples/dotnetcore/SqlExample.cs ---------------------------------------------------------------------- diff --git a/modules/platforms/dotnet/examples/dotnetcore/SqlExample.cs b/modules/platforms/dotnet/examples/dotnetcore/SqlExample.cs index 1fb2e90..1fe6a74 100644 --- a/modules/platforms/dotnet/examples/dotnetcore/SqlExample.cs +++ b/modules/platforms/dotnet/examples/dotnetcore/SqlExample.cs @@ -139,7 +139,7 @@ namespace Apache.Ignite.Examples /// <param name="cache">Cache.</param> private static void SqlFieldsQueryExample(ICache<int, Employee> cache) { - var qry = cache.QueryFields(new SqlFieldsQuery("select name, salary from Employee")); + var qry = cache.Query(new SqlFieldsQuery("select name, salary from Employee")); Console.WriteLine(); Console.WriteLine(">>> Employee names and their salaries:");