1/*2 * Licensed to the Apache Software Foundation (ASF) under one3 * or more contributor license agreements. See the NOTICE file4 * distributed with this work for additional information5 * regarding copyright ownership. The ASF licenses this file6 * to you under the Apache License, Version 2.0 (the7 * "License"); you may not use this file except in compliance8 * with the License. You may obtain a copy of the License at9 *10 * http://www.apache.org/licenses/LICENSE-2.011 *12 * Unless required by applicable law or agreed to in writing, software13 * distributed under the License is distributed on an "AS IS" BASIS,14 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.15 * See the License for the specific language governing permissions and16 * limitations under the License.17 */1819package org.apache.giraph.metrics;
2021/**22 * Aggregator over metrics with long values23 */24publicfinalclassAggregatedMetricLongextends AggregatedMetric<Long> {
25/**26 * Constructor27 */28publicAggregatedMetricLong() {
29 min = new ValueWithHostname<>(Long.MAX_VALUE);
30 max = new ValueWithHostname<>(Long.MIN_VALUE);
31 sum = (long) 0;
32 }
3334 @Override
35publicvoid addItem(Long value, String hostnamePartitionId) {
36if (value < min.getValue()) {
37 min.set(value, hostnamePartitionId);
38 }
39if (value > max.getValue()) {
40 max.set(value, hostnamePartitionId);
41 }
42 sum += value;
43 count++;
44 }
4546 @Override
47publicdouble mean() {
48return sum / (double) count;
49 }
50 }