Return-Path: Delivered-To: apmail-lucene-hadoop-dev-archive@locus.apache.org Received: (qmail 99054 invoked from network); 19 Sep 2007 16:52:39 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.2) by minotaur.apache.org with SMTP; 19 Sep 2007 16:52:39 -0000 Received: (qmail 92593 invoked by uid 500); 19 Sep 2007 16:52:31 -0000 Delivered-To: apmail-lucene-hadoop-dev-archive@lucene.apache.org Received: (qmail 92262 invoked by uid 500); 19 Sep 2007 16:52:30 -0000 Mailing-List: contact hadoop-dev-help@lucene.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: hadoop-dev@lucene.apache.org Delivered-To: mailing list hadoop-dev@lucene.apache.org Received: (qmail 92253 invoked by uid 99); 19 Sep 2007 16:52:30 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 19 Sep 2007 09:52:30 -0700 X-ASF-Spam-Status: No, hits=-100.0 required=10.0 tests=ALL_TRUSTED X-Spam-Check-By: apache.org Received: from [140.211.11.4] (HELO brutus.apache.org) (140.211.11.4) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 19 Sep 2007 16:54:35 +0000 Received: from brutus (localhost [127.0.0.1]) by brutus.apache.org (Postfix) with ESMTP id 91C2B7141FE for ; Wed, 19 Sep 2007 09:52:15 -0700 (PDT) Message-ID: <29471602.1190220735592.JavaMail.jira@brutus> Date: Wed, 19 Sep 2007 09:52:15 -0700 (PDT) From: "Alejandro Abdelnur (JIRA)" To: hadoop-dev@lucene.apache.org Subject: [jira] Commented: (HADOOP-1915) adding counters methods using String (as opposed to Enum) In-Reply-To: <30076103.1190132923612.JavaMail.jira@brutus> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit X-Virus-Checked: Checked by ClamAV on apache.org [ https://issues.apache.org/jira/browse/HADOOP-1915?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#action_12528818 ] Alejandro Abdelnur commented on HADOOP-1915: -------------------------------------------- As far as I know you can not subclass Enum. An Enum 'constants' are constants, cannot be added. The trick I've done until now is to have an Enum class like the following: --------------------- public enum X { A,B,C, D, E, F; private String name; public String toString() { return name; } private static int next = 0; public static synchronized Enum getEnum(String name) { X x = X.values()[next++]; x.name = name; return x; } } --------------------- Everytime I need a new counter I invoke getEnum($NAME$). By doing this I can set to the Enum the dynamic name and then from the running job I just get it by the dynamic name. The problem i see now is the ordinal. I was not aware until your response that it is being use for collection instead the string value of the counter. as the counters are not declared up front but added dynamically it can be the case that in different tasks they are used in different order. So, to be able to use String the ordinal would have to be removed from the serialized counter. Or, when aggregating counters from different task the names should be used instead the ordinal. > adding counters methods using String (as opposed to Enum) > --------------------------------------------------------- > > Key: HADOOP-1915 > URL: https://issues.apache.org/jira/browse/HADOOP-1915 > Project: Hadoop > Issue Type: New Feature > Environment: all > Reporter: Alejandro Abdelnur > Priority: Minor > Fix For: 0.15.0 > > > Currently to use the counters from within Map/Reduce code Enums have to be used, the Enum class defines the group and the Enum itself the counter. Internally they are converted to Strings (the class name and the enum toString) and you can retrieve them as strings from the client API. > Using dynamic counters (driven by configuration of the map/reduce) is not easy with the counters Enum based API. For example, currently I have an Enum class with 50 enums and we have to map the cardinality to the counter name on the client. This is cumbersome. > This could be easily improve by adding a String based counter method increment(String group, String counter, long count) to allow use of the counters without Enums. > Internally this method already exists, so the changes are minimal. -- This message is automatically generated by JIRA. - You can reply to this email to add a comment to the issue online.