Return-Path: X-Original-To: apmail-ignite-commits-archive@minotaur.apache.org Delivered-To: apmail-ignite-commits-archive@minotaur.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id D842B177C8 for ; Fri, 17 Apr 2015 14:36:53 +0000 (UTC) Received: (qmail 21180 invoked by uid 500); 17 Apr 2015 14:36:53 -0000 Delivered-To: apmail-ignite-commits-archive@ignite.apache.org Received: (qmail 21151 invoked by uid 500); 17 Apr 2015 14:36:53 -0000 Mailing-List: contact commits-help@ignite.incubator.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@ignite.incubator.apache.org Delivered-To: mailing list commits@ignite.incubator.apache.org Received: (qmail 21142 invoked by uid 99); 17 Apr 2015 14:36:53 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 17 Apr 2015 14:36:53 +0000 X-ASF-Spam-Status: No, hits=-0.0 required=5.0 tests=SPF_PASS X-Spam-Check-By: apache.org Received-SPF: pass (athena.apache.org: local policy) Received: from [54.164.171.186] (HELO mx1-us-east.apache.org) (54.164.171.186) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 17 Apr 2015 14:36:49 +0000 Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by mx1-us-east.apache.org (ASF Mail Server at mx1-us-east.apache.org) with SMTP id 9F52C45400 for ; Fri, 17 Apr 2015 14:36:06 +0000 (UTC) Received: (qmail 16180 invoked by uid 99); 17 Apr 2015 14:36:06 -0000 Received: from git1-us-west.apache.org (HELO git1-us-west.apache.org) (140.211.11.23) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 17 Apr 2015 14:36:06 +0000 Received: by git1-us-west.apache.org (ASF Mail Server at git1-us-west.apache.org, from userid 33) id F2433DFC12; Fri, 17 Apr 2015 14:36:05 +0000 (UTC) Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit From: akuznetsov@apache.org To: commits@ignite.incubator.apache.org Date: Fri, 17 Apr 2015 14:36:06 -0000 Message-Id: <4d15eb76c0ca4997b1cf5145cda2591e@git.apache.org> In-Reply-To: References: X-Mailer: ASF-Git Admin Mailer Subject: [02/50] [abbrv] incubator-ignite git commit: #ignite-738: rename GridCacheQueriesEx to CacheQueries. X-Virus-Checked: Checked by ClamAV on apache.org #ignite-738: rename GridCacheQueriesEx to CacheQueries. Project: http://git-wip-us.apache.org/repos/asf/incubator-ignite/repo Commit: http://git-wip-us.apache.org/repos/asf/incubator-ignite/commit/0920bcfe Tree: http://git-wip-us.apache.org/repos/asf/incubator-ignite/tree/0920bcfe Diff: http://git-wip-us.apache.org/repos/asf/incubator-ignite/diff/0920bcfe Branch: refs/heads/ignite-755 Commit: 0920bcfeda1dc49a50f20fb889af280e2d552c0c Parents: 540299b Author: ivasilinets Authored: Tue Apr 14 10:23:56 2015 +0300 Committer: ivasilinets Committed: Tue Apr 14 10:23:56 2015 +0300 ---------------------------------------------------------------------- .../apache/ignite/cache/query/QueryMetrics.java | 2 +- .../processors/cache/CacheProjection.java | 2 +- .../processors/cache/GridCacheAdapter.java | 6 +- .../cache/GridCacheProjectionImpl.java | 8 +- .../processors/cache/GridCacheProxyImpl.java | 8 +- .../processors/cache/IgniteCacheProxy.java | 2 +- .../processors/cache/query/CacheQueries.java | 103 ++++++++++ .../cache/query/CacheQueriesImpl.java | 150 ++++++++++++++ .../cache/query/CacheQueriesProxy.java | 200 ++++++++++++++++++ .../processors/cache/query/CacheQuery.java | 4 +- .../cache/query/GridCacheQueriesEx.java | 103 ---------- .../cache/query/GridCacheQueriesImpl.java | 150 -------------- .../cache/query/GridCacheQueriesProxy.java | 201 ------------------- .../jdbc/GridCacheQueryJdbcMetadataTask.java | 2 +- .../visor/cache/VisorCacheMetadataTask.java | 2 +- .../GridCacheAbstractFieldsQuerySelfTest.java | 14 +- .../cache/GridCacheCrossCacheQuerySelfTest.java | 10 +- 17 files changed, 482 insertions(+), 485 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/0920bcfe/modules/core/src/main/java/org/apache/ignite/cache/query/QueryMetrics.java ---------------------------------------------------------------------- diff --git a/modules/core/src/main/java/org/apache/ignite/cache/query/QueryMetrics.java b/modules/core/src/main/java/org/apache/ignite/cache/query/QueryMetrics.java index e7518bf..d178fe0 100644 --- a/modules/core/src/main/java/org/apache/ignite/cache/query/QueryMetrics.java +++ b/modules/core/src/main/java/org/apache/ignite/cache/query/QueryMetrics.java @@ -22,7 +22,7 @@ import org.apache.ignite.internal.processors.cache.query.*; /** * Cache query metrics used to obtain statistics on query. You can get metrics for * particular query via {@link CacheQuery#metrics()} method or accumulated metrics - * for all queries via {@link GridCacheQueriesEx#metrics()}. + * for all queries via {@link CacheQueries#metrics()}. */ public interface QueryMetrics { /** http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/0920bcfe/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/CacheProjection.java ---------------------------------------------------------------------- diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/CacheProjection.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/CacheProjection.java index 4499281..87af7fa 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/CacheProjection.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/CacheProjection.java @@ -205,7 +205,7 @@ public interface CacheProjection extends Iterable> { * @return Queries facade responsible for creating various SQL, TEXT, or SCAN queries. */ - public GridCacheQueriesEx queries(); + public CacheQueries queries(); /** * @param skipStore Skip store flag. http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/0920bcfe/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheAdapter.java ---------------------------------------------------------------------- diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheAdapter.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheAdapter.java index 19513ae..71d3c0d 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheAdapter.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheAdapter.java @@ -170,7 +170,7 @@ public abstract class GridCacheAdapter implements GridCache, protected IgniteLogger log; /** Queries impl. */ - private GridCacheQueriesEx qry; + private CacheQueries qry; /** Affinity impl. */ private Affinity aff; @@ -275,7 +275,7 @@ public abstract class GridCacheAdapter implements GridCache, init(); - qry = new GridCacheQueriesImpl<>(ctx, null); + qry = new CacheQueriesImpl<>(ctx, null); aff = new GridCacheAffinityImpl<>(ctx); } @@ -356,7 +356,7 @@ public abstract class GridCacheAdapter implements GridCache, public abstract GridCachePreloader preloader(); /** {@inheritDoc} */ - @Override public GridCacheQueriesEx queries() { + @Override public CacheQueries queries() { return qry; } http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/0920bcfe/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheProjectionImpl.java ---------------------------------------------------------------------- diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheProjectionImpl.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheProjectionImpl.java index d8b554a..52fc8e6 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheProjectionImpl.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheProjectionImpl.java @@ -53,7 +53,7 @@ public class GridCacheProjectionImpl implements GridCacheProjectionEx cctx; /** Queries impl. */ - private GridCacheQueriesEx qry; + private CacheQueries qry; /** Skip store. */ @GridToStringInclude @@ -101,7 +101,7 @@ public class GridCacheProjectionImpl implements GridCacheProjectionEx(cctx, this); + qry = new CacheQueriesImpl<>(cctx, this); this.keepPortable = keepPortable; @@ -138,7 +138,7 @@ public class GridCacheProjectionImpl implements GridCacheProjectionEx queries() { + @Override public CacheQueries queries() { return qry; } @@ -754,7 +754,7 @@ public class GridCacheProjectionImpl implements GridCacheProjectionEx(cctx, this); + qry = new CacheQueriesImpl<>(cctx, this); keepPortable = in.readBoolean(); } http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/0920bcfe/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheProxyImpl.java ---------------------------------------------------------------------- diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheProxyImpl.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheProxyImpl.java index 84053ee..2b968bd 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheProxyImpl.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheProxyImpl.java @@ -66,7 +66,7 @@ public class GridCacheProxyImpl implements GridCacheProxy, Externali private GridCacheProjectionImpl prj; /** Cache queries. */ - private GridCacheQueriesEx qry; + private CacheQueries qry; /** Affinity. */ private Affinity aff; @@ -95,7 +95,7 @@ public class GridCacheProxyImpl implements GridCacheProxy, Externali gate = ctx.gate(); cache = ctx.cache(); - qry = new GridCacheQueriesProxy<>(ctx, prj, (GridCacheQueriesEx)delegate.queries()); + qry = new CacheQueriesProxy<>(ctx, prj, delegate.queries()); aff = new GridCacheAffinityProxy<>(ctx, ctx.cache().affinity()); } @@ -143,7 +143,7 @@ public class GridCacheProxyImpl implements GridCacheProxy, Externali } /** {@inheritDoc} */ - @Override public GridCacheQueriesEx queries() { + @Override public CacheQueries queries() { return qry; } @@ -1577,7 +1577,7 @@ public class GridCacheProxyImpl implements GridCacheProxy, Externali gate = ctx.gate(); cache = ctx.cache(); - qry = new GridCacheQueriesProxy<>(ctx, prj, (GridCacheQueriesEx)delegate.queries()); + qry = new CacheQueriesProxy<>(ctx, prj, delegate.queries()); aff = new GridCacheAffinityProxy<>(ctx, ctx.cache().affinity()); } http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/0920bcfe/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/IgniteCacheProxy.java ---------------------------------------------------------------------- diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/IgniteCacheProxy.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/IgniteCacheProxy.java index f1c2614..b890407 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/IgniteCacheProxy.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/IgniteCacheProxy.java @@ -335,7 +335,7 @@ public class IgniteCacheProxy extends AsyncSupportAdapter { + /** + * Creates user's SQL fields query for given clause. For more information refer to + * {@link CacheQuery} documentation. + * + * @param qry Query. + * @return Created query. + */ + public CacheQuery> createSqlFieldsQuery(String qry); + + /** + * Creates user's full text query, queried class, and query clause. + * For more information refer to {@link CacheQuery} documentation. + * + * @param clsName Query class name. + * @param search Search clause. + * @return Created query. + */ + public CacheQuery> createFullTextQuery(String clsName, String search); + + /** + * Creates user's predicate based scan query. + * + * @param filter Scan filter. + * @return Created query. + */ + public CacheQuery> createScanQuery(@Nullable IgniteBiPredicate filter); + + /** + * Accumulated metrics for all queries executed for this cache. + * + * @return Cache query metrics. + */ + public QueryMetrics metrics(); + + /** + * Gets SQL metadata. + * + * @return SQL metadata. + * @throws IgniteCheckedException In case of error. + */ + public Collection sqlMetadata() throws IgniteCheckedException; + + /** + * Creates SQL fields query which will include results metadata if needed. + * + * @param qry SQL query. + * @param incMeta Whether to include results metadata. + * @return Created query. + */ + public CacheQuery> createSqlFieldsQuery(String qry, boolean incMeta); + + /** + * Creates SPI query. + * + * @return Query. + */ + public CacheQuery createSpiQuery(); + + /** + * @param space Space name. + * @param qry Query. + * @return Cursor. + */ + public QueryCursor> execute(String space, GridCacheTwoStepQuery qry); + + /** + * @param space Space. + * @param sqlQry Query. + * @param params Parameters. + * @return Cursor. + */ + public QueryCursor> executeTwoStepQuery(String space, String sqlQry, Object... params); +} http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/0920bcfe/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/query/CacheQueriesImpl.java ---------------------------------------------------------------------- diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/query/CacheQueriesImpl.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/query/CacheQueriesImpl.java new file mode 100644 index 0000000..7abd97d --- /dev/null +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/query/CacheQueriesImpl.java @@ -0,0 +1,150 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.apache.ignite.internal.processors.cache.query; + +import org.apache.ignite.*; +import org.apache.ignite.cache.query.*; +import org.apache.ignite.internal.processors.cache.*; +import org.apache.ignite.internal.util.typedef.internal.*; +import org.apache.ignite.lang.*; +import org.apache.ignite.spi.indexing.*; +import org.jetbrains.annotations.*; + +import java.io.*; +import java.util.*; + +import static org.apache.ignite.internal.processors.cache.query.GridCacheQueryType.*; + +/** + * {@link CacheQueries} implementation. + */ +public class CacheQueriesImpl implements CacheQueries { + /** */ + private static final long serialVersionUID = 0L; + + /** */ + private GridCacheContext ctx; + + /** */ + private GridCacheProjectionImpl prj; + + /** + * Required by {@link Externalizable}. + */ + public CacheQueriesImpl() { + // No-op. + } + + /** + * @param ctx Context. + * @param prj Projection. + */ + public CacheQueriesImpl(GridCacheContext ctx, @Nullable GridCacheProjectionImpl prj) { + assert ctx != null; + + this.ctx = ctx; + this.prj = prj; + } + + /** {@inheritDoc} */ + @Override public CacheQuery> createSqlFieldsQuery(String qry) { + A.notNull(qry, "qry"); + + return new GridCacheQueryAdapter<>(ctx, + SQL_FIELDS, + null, + qry, + null, + false, + prj != null && prj.isKeepPortable()); + } + + /** {@inheritDoc} */ + @Override public CacheQuery> createFullTextQuery(String clsName, String search) { + A.notNull("clsName", clsName); + A.notNull("search", search); + + return new GridCacheQueryAdapter<>(ctx, + TEXT, + clsName, + search, + null, + false, + prj != null && prj.isKeepPortable()); + } + + /** {@inheritDoc} */ + @SuppressWarnings("unchecked") + @Override public CacheQuery> createScanQuery(@Nullable IgniteBiPredicate filter) { + return new GridCacheQueryAdapter<>(ctx, + SCAN, + null, + null, + (IgniteBiPredicate)filter, + false, + prj != null && prj.isKeepPortable()); + } + + /** + * Query for {@link IndexingSpi}. + * + * @return Query. + */ + @Override public CacheQuery createSpiQuery() { + return new GridCacheQueryAdapter<>(ctx, + SPI, + null, + null, + null, + false, + prj != null && prj.isKeepPortable()); + } + + /** {@inheritDoc} */ + @Override public QueryCursor> execute(String space, GridCacheTwoStepQuery qry) { + return ctx.kernalContext().query().queryTwoStep(space, qry); + } + + /** {@inheritDoc} */ + @Override public QueryCursor> executeTwoStepQuery(String space, String sqlQry, Object[] params) { + return ctx.kernalContext().query().queryTwoStep(ctx, new SqlFieldsQuery(sqlQry).setArgs(params)); + } + + /** {@inheritDoc} */ + @Override public QueryMetrics metrics() { + return ctx.queries().metrics(); + } + + /** {@inheritDoc} */ + @Override public Collection sqlMetadata() throws IgniteCheckedException { + return ctx.queries().sqlMetadata(); + } + + /** {@inheritDoc} */ + @Override public CacheQuery> createSqlFieldsQuery(String qry, boolean incMeta) { + assert qry != null; + + return new GridCacheQueryAdapter<>(ctx, + SQL_FIELDS, + null, + qry, + null, + incMeta, + prj != null && prj.isKeepPortable()); + } +} http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/0920bcfe/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/query/CacheQueriesProxy.java ---------------------------------------------------------------------- diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/query/CacheQueriesProxy.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/query/CacheQueriesProxy.java new file mode 100644 index 0000000..a04f9e1 --- /dev/null +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/query/CacheQueriesProxy.java @@ -0,0 +1,200 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.apache.ignite.internal.processors.cache.query; + +import org.apache.ignite.*; +import org.apache.ignite.cache.query.*; +import org.apache.ignite.internal.processors.cache.*; +import org.apache.ignite.lang.*; +import org.jetbrains.annotations.*; + +import java.io.*; +import java.util.*; + +/** + * Per-projection queries object returned to user. + */ +public class CacheQueriesProxy implements CacheQueries, Externalizable { + /** */ + private static final long serialVersionUID = 0L; + + /** */ + private GridCacheGateway gate; + + /** */ + private GridCacheProjectionImpl prj; + + /** */ + private CacheQueries delegate; + + /** + * Required by {@link Externalizable}. + */ + public CacheQueriesProxy() { + // No-op. + } + + /** + * Create cache queries implementation. + * + * @param cctx Context. + * @param prj Optional cache projection. + * @param delegate Delegate object. + */ + public CacheQueriesProxy(GridCacheContext cctx, @Nullable GridCacheProjectionImpl prj, + CacheQueries delegate) { + assert cctx != null; + assert delegate != null; + + gate = cctx.gate(); + + this.prj = prj; + this.delegate = delegate; + } + + /** + * Gets cache projection. + * + * @return Cache projection. + */ + public CacheProjection projection() { + return prj; + } + + /** {@inheritDoc} */ + @Override public CacheQuery> createSqlFieldsQuery(String qry) { + GridCacheProjectionImpl prev = gate.enter(prj); + + try { + return delegate.createSqlFieldsQuery(qry); + } + finally { + gate.leave(prev); + } + } + + /** {@inheritDoc} */ + @Override public CacheQuery> createFullTextQuery(String clsName, String search) { + GridCacheProjectionImpl prev = gate.enter(prj); + + try { + return delegate.createFullTextQuery(clsName, search); + } + finally { + gate.leave(prev); + } + } + + /** {@inheritDoc} */ + @Override public CacheQuery> createScanQuery(@Nullable IgniteBiPredicate filter) { + GridCacheProjectionImpl prev = gate.enter(prj); + + try { + return delegate.createScanQuery(filter); + } + finally { + gate.leave(prev); + } + } + + /** {@inheritDoc} */ + @Override public CacheQuery createSpiQuery() { + GridCacheProjectionImpl prev = gate.enter(prj); + + try { + return delegate.createSpiQuery(); + } + finally { + gate.leave(prev); + } + } + + /** {@inheritDoc} */ + @Override public QueryCursor> execute(String space, GridCacheTwoStepQuery qry) { + GridCacheProjectionImpl prev = gate.enter(prj); + + try { + return delegate.execute(space, qry); + } + finally { + gate.leave(prev); + } + } + + /** {@inheritDoc} */ + @Override public QueryCursor> executeTwoStepQuery(String space, String sqlQry, Object[] params) { + GridCacheProjectionImpl prev = gate.enter(prj); + + try { + return delegate.executeTwoStepQuery(space, sqlQry, params); + } + finally { + gate.leave(prev); + } + } + + /** {@inheritDoc} */ + @Override public QueryMetrics metrics() { + GridCacheProjectionImpl prev = gate.enter(prj); + + try { + return delegate.metrics(); + } + finally { + gate.leave(prev); + } + } + + /** {@inheritDoc} */ + @Override public Collection sqlMetadata() throws IgniteCheckedException { + GridCacheProjectionImpl prev = gate.enter(prj); + + try { + return delegate.sqlMetadata(); + } + finally { + gate.leave(prev); + } + } + + /** {@inheritDoc} */ + @Override public CacheQuery> createSqlFieldsQuery(String qry, boolean incMeta) { + GridCacheProjectionImpl prev = gate.enter(prj); + + try { + return delegate.createSqlFieldsQuery(qry, incMeta); + } + finally { + gate.leave(prev); + } + } + + /** {@inheritDoc} */ + @Override public void writeExternal(ObjectOutput out) throws IOException { + out.writeObject(prj); + out.writeObject(delegate); + } + + /** {@inheritDoc} */ + @Override public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException { + prj = (GridCacheProjectionImpl)in.readObject(); + delegate = (CacheQueries)in.readObject(); + + gate = prj.context().gate(); + } +} http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/0920bcfe/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/query/CacheQuery.java ---------------------------------------------------------------------- diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/query/CacheQuery.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/query/CacheQuery.java index c086a0e..93576ab 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/query/CacheQuery.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/query/CacheQuery.java @@ -26,7 +26,7 @@ import org.jetbrains.annotations.*; /** * Main API for configuring and executing cache queries. *

- * Cache queries are created from {@link GridCacheQueriesEx} API via any of the available + * Cache queries are created from {@link CacheQueries} API via any of the available * {@code createXXXQuery(...)} methods. *

SQL Queries

* {@code SQL} query allows to execute distributed cache @@ -60,7 +60,7 @@ import org.jetbrains.annotations.*; * Sometimes when it is known in advance that SQL query will cause a full data scan, or whenever data set * is relatively small, the full scan query may be used. This query will iterate over all cache * entries, skipping over entries that don't pass the optionally provided key-value filter - * (see {@link GridCacheQueriesEx#createScanQuery(org.apache.ignite.lang.IgniteBiPredicate)} method). + * (see {@link CacheQueries#createScanQuery(org.apache.ignite.lang.IgniteBiPredicate)} method). *

Limitations

* Data in Ignite cache is usually distributed across several nodes, * so some queries may not work as expected. Keep in mind following limitations http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/0920bcfe/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/query/GridCacheQueriesEx.java ---------------------------------------------------------------------- diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/query/GridCacheQueriesEx.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/query/GridCacheQueriesEx.java deleted file mode 100644 index 5840070..0000000 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/query/GridCacheQueriesEx.java +++ /dev/null @@ -1,103 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.apache.ignite.internal.processors.cache.query; - -import org.apache.ignite.*; -import org.apache.ignite.cache.query.*; -import org.apache.ignite.lang.*; -import org.jetbrains.annotations.*; - -import java.util.*; - -/** - * Extended queries interface. - */ -public interface GridCacheQueriesEx { - /** - * Creates user's SQL fields query for given clause. For more information refer to - * {@link CacheQuery} documentation. - * - * @param qry Query. - * @return Created query. - */ - public CacheQuery> createSqlFieldsQuery(String qry); - - /** - * Creates user's full text query, queried class, and query clause. - * For more information refer to {@link CacheQuery} documentation. - * - * @param clsName Query class name. - * @param search Search clause. - * @return Created query. - */ - public CacheQuery> createFullTextQuery(String clsName, String search); - - /** - * Creates user's predicate based scan query. - * - * @param filter Scan filter. - * @return Created query. - */ - public CacheQuery> createScanQuery(@Nullable IgniteBiPredicate filter); - - /** - * Accumulated metrics for all queries executed for this cache. - * - * @return Cache query metrics. - */ - public QueryMetrics metrics(); - - /** - * Gets SQL metadata. - * - * @return SQL metadata. - * @throws IgniteCheckedException In case of error. - */ - public Collection sqlMetadata() throws IgniteCheckedException; - - /** - * Creates SQL fields query which will include results metadata if needed. - * - * @param qry SQL query. - * @param incMeta Whether to include results metadata. - * @return Created query. - */ - public CacheQuery> createSqlFieldsQuery(String qry, boolean incMeta); - - /** - * Creates SPI query. - * - * @return Query. - */ - public CacheQuery createSpiQuery(); - - /** - * @param space Space name. - * @param qry Query. - * @return Cursor. - */ - public QueryCursor> execute(String space, GridCacheTwoStepQuery qry); - - /** - * @param space Space. - * @param sqlQry Query. - * @param params Parameters. - * @return Cursor. - */ - public QueryCursor> executeTwoStepQuery(String space, String sqlQry, Object... params); -} http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/0920bcfe/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/query/GridCacheQueriesImpl.java ---------------------------------------------------------------------- diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/query/GridCacheQueriesImpl.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/query/GridCacheQueriesImpl.java deleted file mode 100644 index 91ac680..0000000 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/query/GridCacheQueriesImpl.java +++ /dev/null @@ -1,150 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.apache.ignite.internal.processors.cache.query; - -import org.apache.ignite.*; -import org.apache.ignite.cache.query.*; -import org.apache.ignite.internal.processors.cache.*; -import org.apache.ignite.internal.util.typedef.internal.*; -import org.apache.ignite.lang.*; -import org.apache.ignite.spi.indexing.*; -import org.jetbrains.annotations.*; - -import java.io.*; -import java.util.*; - -import static org.apache.ignite.internal.processors.cache.query.GridCacheQueryType.*; - -/** - * {@link GridCacheQueriesEx} implementation. - */ -public class GridCacheQueriesImpl implements GridCacheQueriesEx { - /** */ - private static final long serialVersionUID = 0L; - - /** */ - private GridCacheContext ctx; - - /** */ - private GridCacheProjectionImpl prj; - - /** - * Required by {@link Externalizable}. - */ - public GridCacheQueriesImpl() { - // No-op. - } - - /** - * @param ctx Context. - * @param prj Projection. - */ - public GridCacheQueriesImpl(GridCacheContext ctx, @Nullable GridCacheProjectionImpl prj) { - assert ctx != null; - - this.ctx = ctx; - this.prj = prj; - } - - /** {@inheritDoc} */ - @Override public CacheQuery> createSqlFieldsQuery(String qry) { - A.notNull(qry, "qry"); - - return new GridCacheQueryAdapter<>(ctx, - SQL_FIELDS, - null, - qry, - null, - false, - prj != null && prj.isKeepPortable()); - } - - /** {@inheritDoc} */ - @Override public CacheQuery> createFullTextQuery(String clsName, String search) { - A.notNull("clsName", clsName); - A.notNull("search", search); - - return new GridCacheQueryAdapter<>(ctx, - TEXT, - clsName, - search, - null, - false, - prj != null && prj.isKeepPortable()); - } - - /** {@inheritDoc} */ - @SuppressWarnings("unchecked") - @Override public CacheQuery> createScanQuery(@Nullable IgniteBiPredicate filter) { - return new GridCacheQueryAdapter<>(ctx, - SCAN, - null, - null, - (IgniteBiPredicate)filter, - false, - prj != null && prj.isKeepPortable()); - } - - /** - * Query for {@link IndexingSpi}. - * - * @return Query. - */ - @Override public CacheQuery createSpiQuery() { - return new GridCacheQueryAdapter<>(ctx, - SPI, - null, - null, - null, - false, - prj != null && prj.isKeepPortable()); - } - - /** {@inheritDoc} */ - @Override public QueryCursor> execute(String space, GridCacheTwoStepQuery qry) { - return ctx.kernalContext().query().queryTwoStep(space, qry); - } - - /** {@inheritDoc} */ - @Override public QueryCursor> executeTwoStepQuery(String space, String sqlQry, Object[] params) { - return ctx.kernalContext().query().queryTwoStep(ctx, new SqlFieldsQuery(sqlQry).setArgs(params)); - } - - /** {@inheritDoc} */ - @Override public QueryMetrics metrics() { - return ctx.queries().metrics(); - } - - /** {@inheritDoc} */ - @Override public Collection sqlMetadata() throws IgniteCheckedException { - return ctx.queries().sqlMetadata(); - } - - /** {@inheritDoc} */ - @Override public CacheQuery> createSqlFieldsQuery(String qry, boolean incMeta) { - assert qry != null; - - return new GridCacheQueryAdapter<>(ctx, - SQL_FIELDS, - null, - qry, - null, - incMeta, - prj != null && prj.isKeepPortable()); - } -} http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/0920bcfe/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/query/GridCacheQueriesProxy.java ---------------------------------------------------------------------- diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/query/GridCacheQueriesProxy.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/query/GridCacheQueriesProxy.java deleted file mode 100644 index da34602..0000000 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/query/GridCacheQueriesProxy.java +++ /dev/null @@ -1,201 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.apache.ignite.internal.processors.cache.query; - -import org.apache.ignite.*; -import org.apache.ignite.cache.query.*; -import org.apache.ignite.internal.*; -import org.apache.ignite.internal.processors.cache.*; -import org.apache.ignite.lang.*; -import org.jetbrains.annotations.*; - -import java.io.*; -import java.util.*; - -/** - * Per-projection queries object returned to user. - */ -public class GridCacheQueriesProxy implements GridCacheQueriesEx, Externalizable { - /** */ - private static final long serialVersionUID = 0L; - - /** */ - private GridCacheGateway gate; - - /** */ - private GridCacheProjectionImpl prj; - - /** */ - private GridCacheQueriesEx delegate; - - /** - * Required by {@link Externalizable}. - */ - public GridCacheQueriesProxy() { - // No-op. - } - - /** - * Create cache queries implementation. - * - * @param cctx Context. - * @param prj Optional cache projection. - * @param delegate Delegate object. - */ - public GridCacheQueriesProxy(GridCacheContext cctx, @Nullable GridCacheProjectionImpl prj, - GridCacheQueriesEx delegate) { - assert cctx != null; - assert delegate != null; - - gate = cctx.gate(); - - this.prj = prj; - this.delegate = delegate; - } - - /** - * Gets cache projection. - * - * @return Cache projection. - */ - public CacheProjection projection() { - return prj; - } - - /** {@inheritDoc} */ - @Override public CacheQuery> createSqlFieldsQuery(String qry) { - GridCacheProjectionImpl prev = gate.enter(prj); - - try { - return delegate.createSqlFieldsQuery(qry); - } - finally { - gate.leave(prev); - } - } - - /** {@inheritDoc} */ - @Override public CacheQuery> createFullTextQuery(String clsName, String search) { - GridCacheProjectionImpl prev = gate.enter(prj); - - try { - return delegate.createFullTextQuery(clsName, search); - } - finally { - gate.leave(prev); - } - } - - /** {@inheritDoc} */ - @Override public CacheQuery> createScanQuery(@Nullable IgniteBiPredicate filter) { - GridCacheProjectionImpl prev = gate.enter(prj); - - try { - return delegate.createScanQuery(filter); - } - finally { - gate.leave(prev); - } - } - - /** {@inheritDoc} */ - @Override public CacheQuery createSpiQuery() { - GridCacheProjectionImpl prev = gate.enter(prj); - - try { - return delegate.createSpiQuery(); - } - finally { - gate.leave(prev); - } - } - - /** {@inheritDoc} */ - @Override public QueryCursor> execute(String space, GridCacheTwoStepQuery qry) { - GridCacheProjectionImpl prev = gate.enter(prj); - - try { - return delegate.execute(space, qry); - } - finally { - gate.leave(prev); - } - } - - /** {@inheritDoc} */ - @Override public QueryCursor> executeTwoStepQuery(String space, String sqlQry, Object[] params) { - GridCacheProjectionImpl prev = gate.enter(prj); - - try { - return delegate.executeTwoStepQuery(space, sqlQry, params); - } - finally { - gate.leave(prev); - } - } - - /** {@inheritDoc} */ - @Override public QueryMetrics metrics() { - GridCacheProjectionImpl prev = gate.enter(prj); - - try { - return delegate.metrics(); - } - finally { - gate.leave(prev); - } - } - - /** {@inheritDoc} */ - @Override public Collection sqlMetadata() throws IgniteCheckedException { - GridCacheProjectionImpl prev = gate.enter(prj); - - try { - return delegate.sqlMetadata(); - } - finally { - gate.leave(prev); - } - } - - /** {@inheritDoc} */ - @Override public CacheQuery> createSqlFieldsQuery(String qry, boolean incMeta) { - GridCacheProjectionImpl prev = gate.enter(prj); - - try { - return delegate.createSqlFieldsQuery(qry, incMeta); - } - finally { - gate.leave(prev); - } - } - - /** {@inheritDoc} */ - @Override public void writeExternal(ObjectOutput out) throws IOException { - out.writeObject(prj); - out.writeObject(delegate); - } - - /** {@inheritDoc} */ - @Override public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException { - prj = (GridCacheProjectionImpl)in.readObject(); - delegate = (GridCacheQueriesEx)in.readObject(); - - gate = prj.context().gate(); - } -} http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/0920bcfe/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/query/jdbc/GridCacheQueryJdbcMetadataTask.java ---------------------------------------------------------------------- diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/query/jdbc/GridCacheQueryJdbcMetadataTask.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/query/jdbc/GridCacheQueryJdbcMetadataTask.java index 2013757..bdab2bc 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/query/jdbc/GridCacheQueryJdbcMetadataTask.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/query/jdbc/GridCacheQueryJdbcMetadataTask.java @@ -107,7 +107,7 @@ public class GridCacheQueryJdbcMetadataTask extends ComputeTaskAdapter metas = ((GridCacheQueriesEx)cache.queries()).sqlMetadata(); + Collection metas = cache.queries().sqlMetadata(); Map>> schemasMap = U.newHashMap(metas.size()); http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/0920bcfe/modules/core/src/main/java/org/apache/ignite/internal/visor/cache/VisorCacheMetadataTask.java ---------------------------------------------------------------------- diff --git a/modules/core/src/main/java/org/apache/ignite/internal/visor/cache/VisorCacheMetadataTask.java b/modules/core/src/main/java/org/apache/ignite/internal/visor/cache/VisorCacheMetadataTask.java index de67b83..9d98eae 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/visor/cache/VisorCacheMetadataTask.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/visor/cache/VisorCacheMetadataTask.java @@ -61,7 +61,7 @@ public class VisorCacheMetadataTask extends VisorOneNodeTask cache = ignite.cachex(cacheName); if (cache != null) { - GridCacheQueriesEx queries = (GridCacheQueriesEx)cache.queries(); + CacheQueries queries = cache.queries(); return F.first(queries.sqlMetadata()); } http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/0920bcfe/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheAbstractFieldsQuerySelfTest.java ---------------------------------------------------------------------- diff --git a/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheAbstractFieldsQuerySelfTest.java b/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheAbstractFieldsQuerySelfTest.java index a2046ab..fc58929 100644 --- a/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheAbstractFieldsQuerySelfTest.java +++ b/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheAbstractFieldsQuerySelfTest.java @@ -182,7 +182,7 @@ public abstract class GridCacheAbstractFieldsQuerySelfTest extends GridCommonAbs try { Collection metas = - ((GridCacheQueriesEx)((IgniteKernal)grid(0)).getCache(null).queries()).sqlMetadata(); + ((IgniteKernal)grid(0)).getCache(null).queries().sqlMetadata(); assert metas != null; assertEquals("Invalid meta: " + metas, 3, metas.size()); @@ -364,7 +364,7 @@ public abstract class GridCacheAbstractFieldsQuerySelfTest extends GridCommonAbs /** @throws Exception If failed. */ public void testExecuteWithMetaData() throws Exception { - CacheQuery> qry = ((GridCacheQueriesEx)((IgniteKernal)grid(0)).getCache(null).queries()).createSqlFieldsQuery( + CacheQuery> qry = ((IgniteKernal)grid(0)).getCache(null).queries().createSqlFieldsQuery( "select p._KEY, p.name, p.age, o.name " + "from Person p, Organization o where p.orgId = o.id", true); @@ -465,7 +465,7 @@ public abstract class GridCacheAbstractFieldsQuerySelfTest extends GridCommonAbs /** @throws Exception If failed. */ public void testSelectAllJoined() throws Exception { - CacheQuery> qry = ((GridCacheQueriesEx)((IgniteKernal)grid(0)).getCache(null).queries()).createSqlFieldsQuery( + CacheQuery> qry = ((IgniteKernal)grid(0)).getCache(null).queries().createSqlFieldsQuery( "select * from Person p, Organization o where p.orgId = o.id", true); @@ -630,7 +630,7 @@ public abstract class GridCacheAbstractFieldsQuerySelfTest extends GridCommonAbs /** @throws Exception If failed. */ public void testEmptyResult() throws Exception { - CacheQuery> qry = ((GridCacheQueriesEx)((IgniteKernal)grid(0)).getCache(null).queries()).createSqlFieldsQuery( + CacheQuery> qry = ((IgniteKernal)grid(0)).getCache(null).queries().createSqlFieldsQuery( "select name from Person where age = 0", true); CacheQueryFuture> fut = qry.execute(); @@ -675,7 +675,7 @@ public abstract class GridCacheAbstractFieldsQuerySelfTest extends GridCommonAbs /** @throws Exception If failed. */ public void testQueryIntegersWithJoin() throws Exception { - CacheQuery> qry = ((GridCacheQueriesEx)((IgniteKernal)grid(0)).getCache(null).queries()).createSqlFieldsQuery( + CacheQuery> qry = ((IgniteKernal)grid(0)).getCache(null).queries().createSqlFieldsQuery( "select i._KEY, i._VAL, j._KEY, j._VAL from Integer i join Integer j where i._VAL >= 100", true) .projection(grid(0).cluster()); @@ -786,7 +786,7 @@ public abstract class GridCacheAbstractFieldsQuerySelfTest extends GridCommonAbs cache.getAndPut("key", "val"); - Collection metas = ((GridCacheQueriesEx)cache.queries()).sqlMetadata(); + Collection metas = cache.queries().sqlMetadata(); assertEquals(1, metas.size()); @@ -813,7 +813,7 @@ public abstract class GridCacheAbstractFieldsQuerySelfTest extends GridCommonAbs cache.getAndPut(key, val); - Collection metas = ((GridCacheQueriesEx)cache.queries()).sqlMetadata(); + Collection metas = cache.queries().sqlMetadata(); assertEquals(1, metas.size()); http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/0920bcfe/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheCrossCacheQuerySelfTest.java ---------------------------------------------------------------------- diff --git a/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheCrossCacheQuerySelfTest.java b/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheCrossCacheQuerySelfTest.java index aebecf7..ec3b1e9 100644 --- a/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheCrossCacheQuerySelfTest.java +++ b/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheCrossCacheQuerySelfTest.java @@ -117,9 +117,8 @@ public class GridCacheCrossCacheQuerySelfTest extends GridCommonAbstractTest { public void _testTwoStep() throws Exception { String cache = "partitioned"; - GridCacheQueriesEx qx = - (GridCacheQueriesEx)((IgniteKernal)ignite) - .getCache(cache).queries(); + CacheQueries qx = + ((IgniteKernal)ignite).getCache(cache).queries(); // for (Map.Entry e : qx.createSqlQuery(FactPurchase.class, "1 = 1").execute().get()) // X.println("___ " + e); @@ -137,9 +136,8 @@ public class GridCacheCrossCacheQuerySelfTest extends GridCommonAbstractTest { * @throws Exception If failed. */ public void testTwoStepGroupAndAggregates() throws Exception { - GridCacheQueriesEx qx = - (GridCacheQueriesEx)((IgniteKernal)ignite) - .getCache("partitioned").queries(); + CacheQueries qx = + ((IgniteKernal)ignite).getCache("partitioned").queries(); Set set1 = new HashSet<>();