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 A2EEC200B0F for ; Fri, 17 Jun 2016 22:08:01 +0200 (CEST) Received: by cust-asf.ponee.io (Postfix) id A181E160A61; Fri, 17 Jun 2016 20:08:01 +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 E968F160A4C for ; Fri, 17 Jun 2016 22:08:00 +0200 (CEST) Received: (qmail 30290 invoked by uid 500); 17 Jun 2016 20:07:55 -0000 Mailing-List: contact dev-help@drill.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@drill.apache.org Delivered-To: mailing list dev@drill.apache.org Received: (qmail 30279 invoked by uid 99); 17 Jun 2016 20:07:54 -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 Jun 2016 20:07:54 +0000 Received: by git1-us-west.apache.org (ASF Mail Server at git1-us-west.apache.org, from userid 33) id A9980E049D; Fri, 17 Jun 2016 20:07:54 +0000 (UTC) From: jinfengni To: dev@drill.apache.org Reply-To: dev@drill.apache.org References: In-Reply-To: Subject: [GitHub] drill pull request #519: DRILL-4530: Optimize partition pruning with metadat... Content-Type: text/plain Message-Id: <20160617200754.A9980E049D@git1-us-west.apache.org> Date: Fri, 17 Jun 2016 20:07:54 +0000 (UTC) archived-at: Fri, 17 Jun 2016 20:08:01 -0000 Github user jinfengni commented on a diff in the pull request: https://github.com/apache/drill/pull/519#discussion_r67567993 --- Diff: exec/java-exec/src/main/java/org/apache/drill/exec/planner/logical/partition/PruneScanRule.java --- @@ -269,13 +283,54 @@ protected void doOnMatch(RelOptRuleCall call, Filter filterRel, Project projectR int recordCount = 0; int qualifiedCount = 0; - // Inner loop: within each batch iterate over the PartitionLocations - for(PartitionLocation part: partitions){ - if(!output.getAccessor().isNull(recordCount) && output.getAccessor().get(recordCount) == 1){ - newPartitions.add(part); - qualifiedCount++; + if (checkForSingle && + partitions.get(0).isCompositePartition() /* apply single partition check only for composite partitions */) { + // Inner loop: within each batch iterate over the PartitionLocations + for (PartitionLocation part : partitions) { + assert part.isCompositePartition(); + if(!output.getAccessor().isNull(recordCount) && output.getAccessor().get(recordCount) == 1) { + newPartitions.add(part); + if (isSinglePartition) { // only need to do this if we are already single partition + // compose the array of partition values for the directories that are referenced by filter: + // e.g suppose the dir hierarchy is year/quarter/month and the query is: + // SELECT * FROM T WHERE dir0=2015 AND dir1 = 'Q1', + // then for 2015/Q1/Feb, this will have ['2015', 'Q1', null] + // Note that we are not using the PartitionLocation here but composing a different list because + // we are only interested in the directory columns that are referenced in the filter condition. not + // the SELECT list or other parts of the query. + Pair p = composePartition(referencedDirsBitSet, partitionMap, vectors, recordCount); + String[] parts = p.getLeft(); + int tmpIndex = p.getRight(); + if (spInfo == null) { + spInfo = parts; + maxIndex = tmpIndex; + } else if (maxIndex != tmpIndex) { + isSinglePartition = false; + break; + } else { + // we only want to compare until the maxIndex inclusive since subsequent values would be null + for (int j = 0; j <= maxIndex; j++) { + if (spInfo[j] == null // prefixes should be non-null --- End diff -- Form Line 305-306, spInfo and maxIndex are in sync. Why will we have spInfo[j] == null, when j <= maxIndex? I thought maxIndex is obtained such that element in spInfo is not null. --- If your project is set up for it, you can reply to this email and have your reply appear on GitHub as well. If your project does not have this feature enabled and wishes so, or if the feature is enabled but not working, please contact infrastructure at infrastructure@apache.org or file a JIRA ticket with INFRA. ---