org.apache.hadoop.mapred
Class Counters.Group

java.lang.Object
  extended by org.apache.hadoop.mapred.Counters.Group
All Implemented Interfaces:
Iterable<Counters.Counter>, Writable, CounterGroupBase<Counters.Counter>
Enclosing class:
Counters

@InterfaceAudience.Public
@InterfaceStability.Stable
public static class Counters.Group
extends Object
implements CounterGroupBase<Counters.Counter>

Group of counters, comprising of counters from a particular counter Enum class.

Grouphandles localization of the class name and the counter names.


Method Summary
 void addCounter(Counters.Counter counter)
          Add a counter to this group.
 Counters.Counter addCounter(String name, String displayName, long value)
          Add a counter to this group
 boolean equals(Object genericRight)
           
 Counters.Counter findCounter(String counterName)
          Find a counter in the group.
 Counters.Counter findCounter(String counterName, boolean create)
          Find a counter in the group
 Counters.Counter findCounter(String counterName, String displayName)
          Find a counter in the group.
 Counters.Counter getCounter(int id, String name)
          Deprecated. use findCounter(String) instead
 long getCounter(String counterName)
           
 Counters.Counter getCounterForName(String name)
          Get the counter for the given name and create it if it doesn't exist.
 String getDisplayName()
          Get the display name of the group.
 String getName()
          Get the internal name of the group
 CounterGroupBase<Counters.Counter> getUnderlyingGroup()
           
 int hashCode()
           
 void incrAllCounters(CounterGroupBase<Counters.Counter> rightGroup)
          Increment all counters by a group of counters
 Iterator<Counters.Counter> iterator()
           
 String makeEscapedCompactString()
           
 void readFields(DataInput in)
          Deserialize the fields of this object from in.
 void setDisplayName(String displayName)
          Set the display name of the group
 int size()
           
 void write(DataOutput out)
          Serialize the fields of this object to out.
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

getCounter

public long getCounter(String counterName)
Parameters:
counterName - the name of the counter
Returns:
the value of the specified counter, or 0 if the counter does not exist.

makeEscapedCompactString

public String makeEscapedCompactString()
Returns:
the compact stringified version of the group in the format {(actual-name)(display-name)(value)[][][]} where [] are compact strings for the counters within.

getCounter

@Deprecated
public Counters.Counter getCounter(int id,
                                              String name)
Deprecated. use findCounter(String) instead

Get the counter for the given id and create it if it doesn't exist.

Parameters:
id - the numeric id of the counter within the group
name - the internal counter name
Returns:
the counter

getCounterForName

public Counters.Counter getCounterForName(String name)
Get the counter for the given name and create it if it doesn't exist.

Parameters:
name - the internal counter name
Returns:
the counter

write

public void write(DataOutput out)
           throws IOException
Description copied from interface: Writable
Serialize the fields of this object to out.

Specified by:
write in interface Writable
Parameters:
out - DataOuput to serialize this object into.
Throws:
IOException

readFields

public void readFields(DataInput in)
                throws IOException
Description copied from interface: Writable
Deserialize the fields of this object from in.

For efficiency, implementations should attempt to re-use storage in the existing object where possible.

Specified by:
readFields in interface Writable
Parameters:
in - DataInput to deseriablize this object from.
Throws:
IOException

iterator

public Iterator<Counters.Counter> iterator()
Specified by:
iterator in interface Iterable<Counters.Counter>

getName

public String getName()
Description copied from interface: CounterGroupBase
Get the internal name of the group

Specified by:
getName in interface CounterGroupBase<Counters.Counter>
Returns:
the internal name

getDisplayName

public String getDisplayName()
Description copied from interface: CounterGroupBase
Get the display name of the group.

Specified by:
getDisplayName in interface CounterGroupBase<Counters.Counter>
Returns:
the human readable name

setDisplayName

public void setDisplayName(String displayName)
Description copied from interface: CounterGroupBase
Set the display name of the group

Specified by:
setDisplayName in interface CounterGroupBase<Counters.Counter>
Parameters:
displayName - of the group

addCounter

public void addCounter(Counters.Counter counter)
Description copied from interface: CounterGroupBase
Add a counter to this group.

Specified by:
addCounter in interface CounterGroupBase<Counters.Counter>
Parameters:
counter - to add

addCounter

public Counters.Counter addCounter(String name,
                                   String displayName,
                                   long value)
Description copied from interface: CounterGroupBase
Add a counter to this group

Specified by:
addCounter in interface CounterGroupBase<Counters.Counter>
Parameters:
name - of the counter
displayName - of the counter
value - of the counter
Returns:
the counter

findCounter

public Counters.Counter findCounter(String counterName,
                                    String displayName)
Description copied from interface: CounterGroupBase
Find a counter in the group.

Specified by:
findCounter in interface CounterGroupBase<Counters.Counter>
Parameters:
counterName - the name of the counter
displayName - the display name of the counter
Returns:
the counter that was found or added

findCounter

public Counters.Counter findCounter(String counterName,
                                    boolean create)
Description copied from interface: CounterGroupBase
Find a counter in the group

Specified by:
findCounter in interface CounterGroupBase<Counters.Counter>
Parameters:
counterName - the name of the counter
create - create the counter if not found if true
Returns:
the counter that was found or added or null if create is false

findCounter

public Counters.Counter findCounter(String counterName)
Description copied from interface: CounterGroupBase
Find a counter in the group.

Specified by:
findCounter in interface CounterGroupBase<Counters.Counter>
Parameters:
counterName - the name of the counter
Returns:
the counter that was found or added

size

public int size()
Specified by:
size in interface CounterGroupBase<Counters.Counter>
Returns:
the number of counters in this group.

incrAllCounters

public void incrAllCounters(CounterGroupBase<Counters.Counter> rightGroup)
Description copied from interface: CounterGroupBase
Increment all counters by a group of counters

Specified by:
incrAllCounters in interface CounterGroupBase<Counters.Counter>
Parameters:
rightGroup - the group to be added to this group

getUnderlyingGroup

public CounterGroupBase<Counters.Counter> getUnderlyingGroup()
Specified by:
getUnderlyingGroup in interface CounterGroupBase<Counters.Counter>

equals

public boolean equals(Object genericRight)
Overrides:
equals in class Object

hashCode

public int hashCode()
Overrides:
hashCode in class Object


Copyright © 2012 Apache Software Foundation. All Rights Reserved.