From commits-return-23545-archive-asf-public=cust-asf.ponee.io@phoenix.apache.org Wed Oct 17 21:40:03 2018 Return-Path: X-Original-To: archive-asf-public@cust-asf.ponee.io Delivered-To: archive-asf-public@cust-asf.ponee.io Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by mx-eu-01.ponee.io (Postfix) with SMTP id A014618061A for ; Wed, 17 Oct 2018 21:40:01 +0200 (CEST) Received: (qmail 50864 invoked by uid 500); 17 Oct 2018 19:40:00 -0000 Mailing-List: contact commits-help@phoenix.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@phoenix.apache.org Delivered-To: mailing list commits@phoenix.apache.org Received: (qmail 50525 invoked by uid 99); 17 Oct 2018 19:40:00 -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; Wed, 17 Oct 2018 19:40:00 +0000 Received: by git1-us-west.apache.org (ASF Mail Server at git1-us-west.apache.org, from userid 33) id EC67AE11C1; Wed, 17 Oct 2018 19:39:59 +0000 (UTC) Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit From: pboado@apache.org To: commits@phoenix.apache.org Date: Wed, 17 Oct 2018 19:40:15 -0000 Message-Id: <657c4e49a268425183377425f578076c@git.apache.org> In-Reply-To: <5b2ef51309dd406893ad7cfcf81942c5@git.apache.org> References: <5b2ef51309dd406893ad7cfcf81942c5@git.apache.org> X-Mailer: ASF-Git Admin Mailer Subject: [17/32] phoenix git commit: Revert "PHOENIX-4790 Simplify check for client side delete" Revert "PHOENIX-4790 Simplify check for client side delete" This reverts commit 5cc9a25a185e596a39e4f2916f90b4c576f4f82f. Project: http://git-wip-us.apache.org/repos/asf/phoenix/repo Commit: http://git-wip-us.apache.org/repos/asf/phoenix/commit/a8c2adbe Tree: http://git-wip-us.apache.org/repos/asf/phoenix/tree/a8c2adbe Diff: http://git-wip-us.apache.org/repos/asf/phoenix/diff/a8c2adbe Branch: refs/heads/4.14-cdh5.13 Commit: a8c2adbee755b2e8b71f4357b3c7124400fb7336 Parents: 045f4c6 Author: James Taylor Authored: Fri Jul 13 04:01:41 2018 +0100 Committer: Pedro Boado Committed: Wed Oct 17 20:36:13 2018 +0100 ---------------------------------------------------------------------- .../apache/phoenix/compile/DeleteCompiler.java | 24 ++++++++++++++++---- 1 file changed, 19 insertions(+), 5 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/phoenix/blob/a8c2adbe/phoenix-core/src/main/java/org/apache/phoenix/compile/DeleteCompiler.java ---------------------------------------------------------------------- diff --git a/phoenix-core/src/main/java/org/apache/phoenix/compile/DeleteCompiler.java b/phoenix-core/src/main/java/org/apache/phoenix/compile/DeleteCompiler.java index 78b2db9..5f9c76c 100644 --- a/phoenix-core/src/main/java/org/apache/phoenix/compile/DeleteCompiler.java +++ b/phoenix-core/src/main/java/org/apache/phoenix/compile/DeleteCompiler.java @@ -46,6 +46,7 @@ import org.apache.phoenix.execute.AggregatePlan; import org.apache.phoenix.execute.MutationState; import org.apache.phoenix.execute.MutationState.MultiRowMutationState; import org.apache.phoenix.execute.MutationState.RowMutationState; +import org.apache.phoenix.filter.SkipScanFilter; import org.apache.phoenix.hbase.index.ValueGetter; import org.apache.phoenix.hbase.index.covered.update.ColumnReference; import org.apache.phoenix.hbase.index.util.ImmutableBytesPtr; @@ -480,7 +481,6 @@ public class DeleteCompiler { projectedColumns.add(column); aliasedNodes.add(FACTORY.aliasedNode(null, FACTORY.column(null, '"' + column.getName().getString() + '"', null))); } - boolean noQueryReqd = true; // Project all non PK indexed columns so that we can do the proper index maintenance for (PTable index : table.getIndexes()) { IndexMaintainer maintainer = index.getIndexMaintainer(table, connection); @@ -492,8 +492,6 @@ public class DeleteCompiler { boolean hasNoColumnFamilies = table.getColumnFamilies().isEmpty(); PColumn column = hasNoColumnFamilies ? table.getColumnForColumnName(columnName) : table.getColumnFamily(familyName).getPColumnForColumnName(columnName); if(!projectedColumns.contains(column)) { - // We must run a query if any index contains a non pk column - noQueryReqd = false; projectedColumns.add(column); aliasedNodes.add(FACTORY.aliasedNode(null, FACTORY.column(hasNoColumnFamilies ? null : TableName.create(null, familyName), '"' + columnName + '"', null))); } @@ -513,7 +511,7 @@ public class DeleteCompiler { select = StatementNormalizer.normalize(transformedSelect, resolverToBe); } final boolean hasPreOrPostProcessing = hasPreProcessing || hasPostProcessing; - noQueryReqd &= !hasPreOrPostProcessing; + boolean noQueryReqd = !hasPreOrPostProcessing; // No limit and no sub queries, joins, etc in where clause // Can't run on same server for transactional data, as we need the row keys for the data // that is being upserted for conflict detection purposes. @@ -552,8 +550,24 @@ public class DeleteCompiler { } runOnServer &= queryPlans.get(0).getTableRef().getTable().getType() != PTableType.INDEX; - + + // We need to have all indexed columns available in all immutable indexes in order + // to generate the delete markers from the query. We also cannot have any filters + // except for our SkipScanFilter for point lookups. + // A simple check of the non existence of a where clause in the parse node is not sufficient, as the where clause + // may have been optimized out. Instead, we check that there's a single SkipScanFilter + // If we can generate a plan for every index, that means all the required columns are available in every index, + // hence we can drive the delete from any of the plans. noQueryReqd &= queryPlans.size() == 1 + clientSideIndexes.size(); + int queryPlanIndex = 0; + while (noQueryReqd && queryPlanIndex < queryPlans.size()) { + QueryPlan plan = queryPlans.get(queryPlanIndex++); + StatementContext context = plan.getContext(); + noQueryReqd &= (!context.getScan().hasFilter() + || context.getScan().getFilter() instanceof SkipScanFilter) + && context.getScanRanges().isPointLookup(); + } + final int maxSize = services.getProps().getInt(QueryServices.MAX_MUTATION_SIZE_ATTRIB,QueryServicesOptions.DEFAULT_MAX_MUTATION_SIZE); final int maxSizeBytes = services.getProps().getInt(QueryServices.MAX_MUTATION_SIZE_BYTES_ATTRIB,QueryServicesOptions.DEFAULT_MAX_MUTATION_SIZE_BYTES);