Repository: ignite Updated Branches: refs/heads/master 9c7853164 -> 8fd4f747d
IGNITE-6122: Propagated SqlFieldsQuery.lazy property for C++. Project: http://git-wip-us.apache.org/repos/asf/ignite/repo Commit: http://git-wip-us.apache.org/repos/asf/ignite/commit/8fd4f747 Tree: http://git-wip-us.apache.org/repos/asf/ignite/tree/8fd4f747 Diff: http://git-wip-us.apache.org/repos/asf/ignite/diff/8fd4f747 Branch: refs/heads/master Commit: 8fd4f747d736b34df8c62567786ac89331e229c7 Parents: 9c78531 Author: Igor Sapego <[email protected]> Authored: Tue Aug 29 16:59:50 2017 +0300 Committer: Igor Sapego <[email protected]> Committed: Tue Aug 29 16:59:50 2017 +0300 ---------------------------------------------------------------------- .../platform/cache/PlatformCache.java | 2 + .../ignite/cache/query/query_sql_fields.h | 71 +++++++++++++++----- .../Apache.Ignite.Core/Impl/Cache/CacheImpl.cs | 1 + 3 files changed, 57 insertions(+), 17 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/ignite/blob/8fd4f747/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 ef914a9..0e227f5 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 @@ -1310,6 +1310,7 @@ public class PlatformCache extends PlatformAbstractTarget { boolean distrJoins = reader.readBoolean(); boolean enforceJoinOrder = reader.readBoolean(); + boolean lazy = reader.readBoolean(); int timeout = reader.readInt(); boolean replicated = reader.readBoolean(); boolean collocated = reader.readBoolean(); @@ -1321,6 +1322,7 @@ public class PlatformCache extends PlatformAbstractTarget { .setLocal(loc) .setDistributedJoins(distrJoins) .setEnforceJoinOrder(enforceJoinOrder) + .setLazy(lazy) .setTimeout(timeout, TimeUnit.MILLISECONDS) .setReplicatedOnly(replicated) .setCollocated(collocated) http://git-wip-us.apache.org/repos/asf/ignite/blob/8fd4f747/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 c44b762..519b2ed 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 @@ -54,6 +54,7 @@ namespace ignite loc(false), distributedJoins(false), enforceJoinOrder(false), + lazy(false), args() { // No-op. @@ -72,6 +73,7 @@ namespace ignite loc(false), distributedJoins(false), enforceJoinOrder(false), + lazy(false), args() { // No-op. @@ -89,6 +91,7 @@ namespace ignite loc(other.loc), distributedJoins(other.distributedJoins), enforceJoinOrder(other.enforceJoinOrder), + lazy(other.lazy), args() { args.reserve(other.args.size()); @@ -144,6 +147,7 @@ namespace ignite swap(loc, other.loc); swap(distributedJoins, other.distributedJoins); swap(enforceJoinOrder, other.enforceJoinOrder); + swap(lazy, other.lazy); swap(args, other.args); } } @@ -209,6 +213,38 @@ namespace ignite } /** + * Gets lazy query execution flag. + * + * See SetLazy(bool) for more information. + * + * @return Lazy flag. + */ + bool IsLazy() const + { + return lazy; + } + + /** + * Sets lazy query execution flag. + * + * By default Ignite attempts to fetch the whole query result set to memory and send it to the client. + * For small and medium result sets this provides optimal performance and minimize duration of internal + * database locks, thus increasing concurrency. + * + * If result set is too big to fit in available memory this could lead to excessive GC pauses and even + * OutOfMemoryError. Use this flag as a hint for Ignite to fetch result set lazily, thus minimizing + * memory consumption at the cost of moderate performance hit. + * + * Defaults to @c false, meaning that the whole result set is fetched to memory eagerly. + * + * @param lazy Lazy query execution flag. + */ + void SetLazy(bool lazy) + { + this->lazy = lazy; + } + + /** * Checks if join order of tables if enforced. * * @return Flag value. @@ -220,13 +256,11 @@ namespace ignite /** * Sets flag to enforce join order of tables in the query. - * If set to true query optimizer will not reorder tables in - * join. By default is false. * - * It is not recommended to enable this property unless you are - * sure that your indexes and the query itself are correct and - * tuned as much as possible but query optimizer still produces - * wrong join order. + * If set to true query optimizer will not reorder tables in join. By default is false. + * + * It is not recommended to enable this property unless you are sure that your indexes and the query + * itself are correct and tuned as much as possible but query optimizer still produces wrong join order. * * @param enforce Flag value. */ @@ -261,9 +295,8 @@ namespace ignite /** * Add argument. * - * Template argument type should be copy-constructable and - * assignable. Also BinaryType class template should be specialized - * for this type. + * Template argument type should be copy-constructable and assignable. Also BinaryType class template + * should be specialized for this type. * * @param arg Argument. */ @@ -298,9 +331,9 @@ namespace ignite /** * Set schema name for the query. - * If not set, current cache name is used, which means you can - * omit schema name for tables within the current cache. - * + * If not set, current cache name is used, which means you can omit schema name for tables within the + * current cache. + * * @param schema Schema. Empty string to unset. */ void SetSchema(const std::string& schema) @@ -311,8 +344,8 @@ namespace ignite /** * Get schema name for the query. * - * If not set, current cache name is used, which means you can - * omit schema name for tables within the current cache. + * If not set, current cache name is used, which means you can omit schema name for tables within the + * current cache. * * @return Schema. Empty string if not set. */ @@ -341,9 +374,10 @@ namespace ignite writer.WriteBool(distributedJoins); writer.WriteBool(enforceJoinOrder); - writer.WriteInt32(0); // Timeout, ms - writer.WriteBool(false); // ReplicatedOnly - writer.WriteBool(false); // Colocated + writer.WriteBool(lazy); + writer.WriteInt32(0); // Timeout, ms + writer.WriteBool(false); // ReplicatedOnly + writer.WriteBool(false); // Colocated if (schema.empty()) writer.WriteNull(); @@ -370,6 +404,9 @@ namespace ignite /** Enforce join order flag. */ bool enforceJoinOrder; + /** Lazy flag. */ + bool lazy; + /** Arguments. */ std::vector<impl::cache::query::QueryArgumentBase*> args; }; http://git-wip-us.apache.org/repos/asf/ignite/blob/8fd4f747/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 5789c8f..06d01c0 100644 --- a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Cache/CacheImpl.cs +++ b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Cache/CacheImpl.cs @@ -1087,6 +1087,7 @@ namespace Apache.Ignite.Core.Impl.Cache writer.WriteBoolean(qry.EnableDistributedJoins); writer.WriteBoolean(qry.EnforceJoinOrder); + writer.WriteBoolean(false); // Lazy flag. writer.WriteInt((int) qry.Timeout.TotalMilliseconds); writer.WriteBoolean(qry.ReplicatedOnly); writer.WriteBoolean(qry.Colocated);
