-
Notifications
You must be signed in to change notification settings - Fork 4.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[BEAM-1672] Accumulable MetricsContainers. #2649
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
- Loading branch information
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -17,17 +17,29 @@ | |
*/ | ||
package org.apache.beam.sdk.metrics; | ||
|
||
import java.io.Serializable; | ||
import org.apache.beam.sdk.annotations.Experimental; | ||
import org.apache.beam.sdk.annotations.Experimental.Kind; | ||
|
||
/** | ||
* A {@link MetricCell} is used for accumulating in-memory changes to a metric. It represents a | ||
* specific metric name in a single context. | ||
* | ||
* @param <UserT> The type of the user interface for reporting changes to this cell. | ||
* @param <DataT> The type of metric data stored (and extracted) from this cell. | ||
*/ | ||
@Experimental(Kind.METRICS) | ||
public interface MetricCell<DataT> { | ||
public interface MetricCell<UserT extends Metric, DataT> extends Serializable { | ||
|
||
/** | ||
* Update value of this cell. | ||
*/ | ||
void update(DataT data); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Does this do a set or a merge with the given data? If it does a set, then the method below should be called There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It does a set, which is why I chose There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'd be tempted to call this There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The thing is it isn't a |
||
|
||
/** | ||
* Update value of this cell by merging the value of another cell. | ||
*/ | ||
void update(MetricCell<UserT, DataT> other); | ||
|
||
/** | ||
* Return the {@link DirtyState} tracking whether this metric cell contains uncommitted changes. | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could also solve this using the approach taken in Sum Long CombineFn. Specifically, instead of
MetricCell<Counter, Long>
make thisMetricCell<Counter, long[]>
, where the array is expected to be one element. This avoids the boxing/unboxing.Alternative, the boxing/unboxing here may be OK as long as we aren't using a
Long
as the accumulator/value holder.