R
- the full accumulated data (result type)T
- partial data that can be added inpublic class Accumulable<R,T>
extends Object
implements java.io.Serializable
R
, may be different from the element type being added, T
.
You must define how to add data, and how to merge two of these together. For some data types,
such as a counter, these might be the same operation. In that case, you can use the simpler
Accumulator
. They won't always be the same, though -- e.g., imagine you are
accumulating a set. You will add items to the set, and you will union two sets together.
Operations are not thread-safe.
param: id ID of this accumulator; for internal use only.
param: initialValue initial value of accumulator
param: param helper object defining how to add elements of type R
and T
param: name human-readable name for use in Spark's web UI
param: countFailedValues whether to accumulate values from failed tasks. This is set to true
for system and time metrics like serialization time or bytes spilled,
and false for things with absolute values like number of input rows.
This should be used for internal metrics only.
Constructor and Description |
---|
Accumulable(R initialValue,
AccumulableParam<R,T> param)
Deprecated.
|
Modifier and Type | Method and Description |
---|---|
void |
add(T term)
Deprecated.
Add more data to this accumulator / accumulable
|
long |
id()
Deprecated.
|
R |
localValue()
Deprecated.
Get the current value of this accumulator from within a task.
|
void |
merge(R term)
Deprecated.
Merge two accumulable objects together
|
scala.Option<String> |
name()
Deprecated.
|
void |
setValue(R newValue)
Deprecated.
Set the accumulator's value.
|
String |
toString()
Deprecated.
|
R |
value()
Deprecated.
Access the accumulator's current value; only allowed on driver.
|
R |
zero()
Deprecated.
|
public Accumulable(R initialValue, AccumulableParam<R,T> param)
public void add(T term)
term
- the data to addpublic long id()
public R localValue()
This is NOT the global value of the accumulator. To get the global value after a
completed operation on the dataset, call value
.
The typical use of this method is to directly mutate the local value, eg., to add an element to a Set.
public void merge(R term)
Normally, a user will not want to use this version, but will instead call add
.
term
- the other R
that will get merged with thispublic scala.Option<String> name()
public void setValue(R newValue)
newValue
- (undocumented)public String toString()
toString
in class Object
public R value()
public R zero()