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 E3EB6200C2C for ; Fri, 3 Mar 2017 13:37:38 +0100 (CET) Received: by cust-asf.ponee.io (Postfix) id E287E160B6D; Fri, 3 Mar 2017 12:37:38 +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 36FA9160B57 for ; Fri, 3 Mar 2017 13:37:38 +0100 (CET) Received: (qmail 89574 invoked by uid 500); 3 Mar 2017 12:37:37 -0000 Mailing-List: contact issues-help@carbondata.incubator.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@carbondata.incubator.apache.org Delivered-To: mailing list issues@carbondata.incubator.apache.org Received: (qmail 89565 invoked by uid 99); 3 Mar 2017 12:37:37 -0000 Received: from pnap-us-west-generic-nat.apache.org (HELO spamd4-us-west.apache.org) (209.188.14.142) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 03 Mar 2017 12:37:37 +0000 Received: from localhost (localhost [127.0.0.1]) by spamd4-us-west.apache.org (ASF Mail Server at spamd4-us-west.apache.org) with ESMTP id EE91DC214A for ; Fri, 3 Mar 2017 12:37:36 +0000 (UTC) X-Virus-Scanned: Debian amavisd-new at spamd4-us-west.apache.org X-Spam-Flag: NO X-Spam-Score: -7.019 X-Spam-Level: X-Spam-Status: No, score=-7.019 tagged_above=-999 required=6.31 tests=[KAM_LAZY_DOMAIN_SECURITY=1, RCVD_IN_DNSWL_HI=-5, RCVD_IN_MSPIKE_H3=-0.01, RCVD_IN_MSPIKE_WL=-0.01, RP_MATCHES_RCVD=-2.999] autolearn=disabled Received: from mx1-lw-us.apache.org ([10.40.0.8]) by localhost (spamd4-us-west.apache.org [10.40.0.11]) (amavisd-new, port 10024) with ESMTP id PnldAPwfxEH7 for ; Fri, 3 Mar 2017 12:37:35 +0000 (UTC) Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by mx1-lw-us.apache.org (ASF Mail Server at mx1-lw-us.apache.org) with SMTP id 6FE2A5FC81 for ; Fri, 3 Mar 2017 12:37:35 +0000 (UTC) Received: (qmail 89556 invoked by uid 99); 3 Mar 2017 12:37:19 -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, 03 Mar 2017 12:37:19 +0000 Received: by git1-us-west.apache.org (ASF Mail Server at git1-us-west.apache.org, from userid 33) id 0B229DFCA1; Fri, 3 Mar 2017 12:37:19 +0000 (UTC) From: sounakr To: issues@carbondata.incubator.apache.org Reply-To: issues@carbondata.incubator.apache.org References: In-Reply-To: Subject: [GitHub] incubator-carbondata pull request #604: [CARBONDATA-691] After Compaction re... Content-Type: text/plain Message-Id: <20170303123719.0B229DFCA1@git1-us-west.apache.org> Date: Fri, 3 Mar 2017 12:37:19 +0000 (UTC) archived-at: Fri, 03 Mar 2017 12:37:39 -0000 Github user sounakr commented on a diff in the pull request: https://github.com/apache/incubator-carbondata/pull/604#discussion_r104145140 --- Diff: hadoop/src/main/java/org/apache/carbondata/hadoop/util/CarbonInputSplitTaskInfo.java --- @@ -0,0 +1,129 @@ +/* + * 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.carbondata.hadoop.util; + +import java.io.IOException; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.HashSet; +import java.util.List; +import java.util.Map; +import java.util.Objects; +import java.util.Set; +import java.util.TreeMap; + +import org.apache.carbondata.core.datastore.block.Distributable; +import org.apache.carbondata.hadoop.CarbonInputSplit; + +public class CarbonInputSplitTaskInfo implements Distributable { + + private final List carbonBlockInfoList; + + private final String taskId; + + public String getTaskId() { + return taskId; + } + + public List getCarbonInputSplitList() { + return carbonBlockInfoList; + } + + public CarbonInputSplitTaskInfo(String taskId, List carbonSplitListInfo) { + this.taskId = taskId; + this.carbonBlockInfoList = carbonSplitListInfo; + } + + @Override public String[] getLocations() { + Set locations = new HashSet(); + for (CarbonInputSplit splitInfo : carbonBlockInfoList) { + try { + locations.addAll(Arrays.asList(splitInfo.getLocations())); + } catch (IOException e) { + e.printStackTrace(); + } + } + locations.toArray(new String[locations.size()]); + List nodes = CarbonInputSplitTaskInfo.maxNoNodes(carbonBlockInfoList); + return nodes.toArray(new String[nodes.size()]); + } + + @Override public int compareTo(Distributable o) { + return taskId.compareTo(((CarbonInputSplitTaskInfo) o).getTaskId()); + } + + /** + * Finding which node has the maximum number of blocks for it. + * + * @param blockList + * @return + */ + public static List maxNoNodes(List splitList) { + boolean useIndex = true; + Integer maxOccurence = 0; + String maxNode = null; + Map nodeAndOccurenceMapping = new TreeMap<>(); + + // populate the map of node and number of occurences of that node. + for (CarbonInputSplit split : splitList) { + try { + for (String node : split.getLocations()) { + Integer nodeOccurence = nodeAndOccurenceMapping.get(node); + if (null == nodeOccurence) { + nodeAndOccurenceMapping.put(node, 1); + } else { + nodeOccurence++; + } + } + } catch (IOException e) { + e.printStackTrace(); --- End diff -- Done. Throwing Exception. --- 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. ---