Github user cloud-fan commented on a diff in the pull request:
https://github.com/apache/spark/pull/9215#discussion_r42929484
--- Diff:
sql/core/src/main/scala/org/apache/spark/sql/execution/metric/SQLMetrics.scala
---
@@ -62,7 +67,19 @@ private[sql] trait SQLMetricValue[T] extends
Serializable {
private[sql] class LongSQLMetricValue(private var _value : Long) extends
SQLMetricValue[Long] {
def add(incr: Long): LongSQLMetricValue = {
- _value += incr
+ // Some LongSQLMetric will use -1 as initial value, so if the
accumulator is never updated,
+ // we can filter it out later. However, when `add` is called, the
accumulator is valid, we
+ // should turn -1 to 0.
+ if (_value < 0) {
+ _value = 0
+ }
+
+ // Some LongSQLMetric will use -1 as initial value, when we merge
accumulator updates at driver
+ // side, we should ignore these -1 values.
+ if (incr > 0) {
+ _value += incr
+ }
+
--- End diff --
I was trying to reuse current codebase and didn't create a new
SQLMetric(including new MetricValue, MetricParam, etc.). Is it worth to create
a new one so that we won't hurt performance for numRows?
---
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 [email protected] or file a JIRA ticket
with INFRA.
---
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]