Return-Path: X-Original-To: archive-asf-public-internal@cust-asf2.ponee.io Delivered-To: archive-asf-public-internal@cust-asf2.ponee.io Received: from cust-asf.ponee.io (cust-asf.ponee.io [163.172.22.183]) by cust-asf2.ponee.io (Postfix) with ESMTP id 3B0D6200C28 for ; Mon, 13 Mar 2017 10:46:22 +0100 (CET) Received: by cust-asf.ponee.io (Postfix) id 39F12160B8B; Mon, 13 Mar 2017 09:46:22 +0000 (UTC) Delivered-To: archive-asf-public@cust-asf.ponee.io Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by cust-asf.ponee.io (Postfix) with SMTP id 25508160BAC for ; Mon, 13 Mar 2017 10:46:19 +0100 (CET) Received: (qmail 48087 invoked by uid 500); 13 Mar 2017 09:46:19 -0000 Mailing-List: contact commits-help@ignite.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@ignite.apache.org Delivered-To: mailing list commits@ignite.apache.org Received: (qmail 46488 invoked by uid 99); 13 Mar 2017 09:46:17 -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; Mon, 13 Mar 2017 09:46:17 +0000 Received: by git1-us-west.apache.org (ASF Mail Server at git1-us-west.apache.org, from userid 33) id 383A9F4B7E; Mon, 13 Mar 2017 09:46:16 +0000 (UTC) Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit From: sboikov@apache.org To: commits@ignite.apache.org Date: Mon, 13 Mar 2017 09:47:00 -0000 Message-Id: <5744b2a4a33646aab2d24c80ed20690c@git.apache.org> In-Reply-To: <0d138500d6cf4c6889423f6869daf0a4@git.apache.org> References: <0d138500d6cf4c6889423f6869daf0a4@git.apache.org> X-Mailer: ASF-Git Admin Mailer Subject: [46/50] [abbrv] ignite git commit: Minor refactoring in GridQueryProcessor. archived-at: Mon, 13 Mar 2017 09:46:22 -0000 Minor refactoring in GridQueryProcessor. Project: http://git-wip-us.apache.org/repos/asf/ignite/repo Commit: http://git-wip-us.apache.org/repos/asf/ignite/commit/86fad982 Tree: http://git-wip-us.apache.org/repos/asf/ignite/tree/86fad982 Diff: http://git-wip-us.apache.org/repos/asf/ignite/diff/86fad982 Branch: refs/heads/ignite-4705-2 Commit: 86fad9823dff03d486abe86b9040f809bd7be25b Parents: 6fda2c2 Author: devozerov Authored: Fri Mar 10 15:28:41 2017 +0300 Committer: devozerov Committed: Fri Mar 10 15:28:41 2017 +0300 ---------------------------------------------------------------------- .../processors/query/GridQueryProcessor.java | 38 ++++++-------------- 1 file changed, 11 insertions(+), 27 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/ignite/blob/86fad982/modules/core/src/main/java/org/apache/ignite/internal/processors/query/GridQueryProcessor.java ---------------------------------------------------------------------- diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/query/GridQueryProcessor.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/query/GridQueryProcessor.java index 176178c..8223fef 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/query/GridQueryProcessor.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/query/GridQueryProcessor.java @@ -663,12 +663,10 @@ public class GridQueryProcessor extends GridProcessorAdapter { try { final GridCacheContext cctx = ctx.cache().internalCache(space).context(); - return executeQuery(GridCacheQueryType.SQL_FIELDS, clause, cctx, new IgniteOutClosureX>>() { + return executeQuery(GridCacheQueryType.SQL_FIELDS, clause, cctx, + new IgniteOutClosureX>>() { @Override public GridCloseableIterator> applyx() throws IgniteCheckedException { - QueryTypeDescriptorImpl type = typesByName.get(new QueryTypeNameKey(space, resType)); - - if (type == null || !type.registered()) - throw new CacheException("Failed to find SQL table for type: " + resType); + QueryTypeDescriptorImpl type = type(space, resType); return idx.queryLocalSql(space, clause, null, params, type, filters); } @@ -754,13 +752,7 @@ public class GridQueryProcessor extends GridProcessorAdapter { String sqlQry = qry.getSql(); Object[] params = qry.getArgs(); - QueryTypeDescriptorImpl typeDesc = typesByName.get( - new QueryTypeNameKey( - space, - type)); - - if (typeDesc == null || !typeDesc.registered()) - throw new CacheException("Failed to find SQL table for type: " + type); + QueryTypeDescriptorImpl typeDesc = type(space, type); final GridCloseableIterator> i = idx.queryLocalSql( space, @@ -1056,16 +1048,9 @@ public class GridQueryProcessor extends GridProcessorAdapter { return executeQuery(GridCacheQueryType.TEXT, clause, cctx, new IgniteOutClosureX>>() { @Override public GridCloseableIterator> applyx() throws IgniteCheckedException { - QueryTypeDescriptorImpl type = typesByName.get(new QueryTypeNameKey(space, resType)); + QueryTypeDescriptorImpl type = type(space, resType); - if (type == null || !type.registered()) - throw new CacheException("Failed to find SQL table for type: " + resType); - - return idx.queryLocalText( - space, - clause, - type, - filters); + return idx.queryLocalText(space, clause, type, filters); } }, true); } @@ -1629,8 +1614,7 @@ public class GridQueryProcessor extends GridProcessorAdapter { * @return Descriptors. */ public Collection types(@Nullable String space) { - Collection spaceTypes = new ArrayList<>( - Math.min(10, types.size())); + Collection spaceTypes = new ArrayList<>(); for (Map.Entry e : types.entrySet()) { QueryTypeDescriptorImpl desc = e.getValue(); @@ -1650,11 +1634,11 @@ public class GridQueryProcessor extends GridProcessorAdapter { * @return Type descriptor. * @throws IgniteCheckedException If failed. */ - public GridQueryTypeDescriptor type(@Nullable String space, String typeName) throws IgniteCheckedException { + public QueryTypeDescriptorImpl type(@Nullable String space, String typeName) throws IgniteCheckedException { QueryTypeDescriptorImpl type = typesByName.get(new QueryTypeNameKey(space, typeName)); if (type == null || !type.registered()) - throw new IgniteCheckedException("Failed to find type descriptor for type name: " + typeName); + throw new IgniteCheckedException("Failed to find SQL table for type: " + typeName); return type; } @@ -1666,8 +1650,8 @@ public class GridQueryProcessor extends GridProcessorAdapter { * @param clo Closure. * @param complete Complete. */ - public R executeQuery(GridCacheQueryType qryType, String qry, GridCacheContext cctx, IgniteOutClosureX clo, boolean complete) - throws IgniteCheckedException { + public R executeQuery(GridCacheQueryType qryType, String qry, GridCacheContext cctx, + IgniteOutClosureX clo, boolean complete) throws IgniteCheckedException { final long startTime = U.currentTimeMillis(); Throwable err = null;