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 907FB200BC1 for ; Wed, 2 Nov 2016 03:19:12 +0100 (CET) Received: by cust-asf.ponee.io (Postfix) id 8EF53160B07; Wed, 2 Nov 2016 02:19:12 +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 DAE6A160B02 for ; Wed, 2 Nov 2016 03:19:11 +0100 (CET) Received: (qmail 90762 invoked by uid 500); 2 Nov 2016 02:19:10 -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 89209 invoked by uid 99); 2 Nov 2016 02:19:09 -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, 02 Nov 2016 02:19:09 +0000 Received: by git1-us-west.apache.org (ASF Mail Server at git1-us-west.apache.org, from userid 33) id E3362E0FC4; Wed, 2 Nov 2016 02:19:08 +0000 (UTC) From: sohami To: dev@drill.apache.org Reply-To: dev@drill.apache.org References: In-Reply-To: Subject: [GitHub] drill pull request #639: DRILL-4706: Fragment planning causes Drillbits to r... Content-Type: text/plain Message-Id: <20161102021908.E3362E0FC4@git1-us-west.apache.org> Date: Wed, 2 Nov 2016 02:19:08 +0000 (UTC) archived-at: Wed, 02 Nov 2016 02:19:12 -0000 Github user sohami commented on a diff in the pull request: https://github.com/apache/drill/pull/639#discussion_r86060309 --- Diff: exec/java-exec/src/main/java/org/apache/drill/exec/store/parquet/ParquetGroupScan.java --- @@ -822,10 +838,103 @@ private void getFiles(String path, List fileStatuses) throws IOExcep } } + /* + * Figure out the best node to scan each of the rowGroups and update the preferredEndpoint. + * Based on this, update the total work units assigned to the endpoint in the endpointAffinity. + */ + private void computeRowGroupAssignment() { + Map numEndpointAssignments = Maps.newHashMap(); + Map numAssignedBytes = Maps.newHashMap(); + + // Do this for 2 iterations to adjust node assignments after first iteration. + int numIterartions = 2; + + while (numIterartions-- > 0) { + + for (RowGroupInfo rowGroupInfo : rowGroupInfos) { + EndpointByteMap endpointByteMap = rowGroupInfo.getByteMap(); + + // This can be empty for local file system or if drilbit is not running + // on hosts which have data. + if (endpointByteMap.isEmpty()) { + continue; + } + + // Get the list of endpoints which have maximum (equal) data. + List topEndpoints = endpointByteMap.getTopEndpoints(); + + long minBytes = 0, numBytes = 0; + DrillbitEndpoint nodePicked = rowGroupInfo.preferredEndpoint; + if (nodePicked != null && numAssignedBytes.containsKey(nodePicked)) { + minBytes = numAssignedBytes.get(nodePicked); + } + + DrillbitEndpoint previousNodePicked = nodePicked; + + for (DrillbitEndpoint endpoint : topEndpoints) { + if (nodePicked == null) { + nodePicked = endpoint; + if (numAssignedBytes.containsKey(nodePicked)) { + minBytes = numAssignedBytes.get(nodePicked); + } + } + + if (numAssignedBytes.containsKey(endpoint)) { + numBytes = numAssignedBytes.get(endpoint); + } else { + numBytes = 0; + } + + if (numBytes < minBytes) { + nodePicked = endpoint; + minBytes = numBytes; + } + } + + if (nodePicked != null && nodePicked != previousNodePicked) { + numAssignedBytes.put(nodePicked, minBytes + endpointByteMap.get(nodePicked)); + if (numEndpointAssignments.containsKey(nodePicked)) { + numEndpointAssignments.put(nodePicked, numEndpointAssignments.get(nodePicked) + 1); + } else { + numEndpointAssignments.put(nodePicked, 1); + } + + // If a different node is picked in second iteration, update. + if (previousNodePicked != null) { + numAssignedBytes.put(previousNodePicked, + numAssignedBytes.get(previousNodePicked) - endpointByteMap.get(previousNodePicked)); + numEndpointAssignments.put(previousNodePicked, numEndpointAssignments.get(previousNodePicked) - 1); + } + } + rowGroupInfo.preferredEndpoint = nodePicked; + } + } + + // Set the number of local work units for each endpoint in the endpointAffinity. + for (EndpointAffinity epAff : endpointAffinities) { + DrillbitEndpoint endpoint = epAff.getEndpoint(); + if (numEndpointAssignments.containsKey(endpoint)) { + epAff.setNumLocalWorkUnits(numEndpointAssignments.get(endpoint)); + } else { + epAff.setNumLocalWorkUnits(0); --- End diff -- "else" condition is not required since by default it will be set to 0 --- 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. ---