blob: ec319358280c1708e6e03ac17e9e9a324ff11913 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
|
/*******************************************************************************
* Copyright (c) 2006 IBM Corporation.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
* IBM Corporation - Jeff Briggs, Henry Hughes, Ryan Morse
*******************************************************************************/
package org.eclipse.linuxtools.systemtap.graphing.core.aggregates;
import org.eclipse.linuxtools.systemtap.graphing.core.structures.NumberType;
public class SumAggregate implements IDataAggregate {
/**
* Ensure column isn't empty, then get the sum total of all the column's values.
*
* @param column The column to total.
*
* @return The sum total of all the column's values.
*/
@Override
public Number aggregate(Number[] column) {
if(column == null || column.length == 0) {
return null;
}
double num = 0;
for(int i=0; i<column.length; i++) {
num += column[i].doubleValue();
}
return NumberType.getNumber(column[0], num);
}
@Override
public String getID() {
return ID;
}
public static final String ID = "org.eclipse.linuxtools.systemtap.graphing.core.aggregates.SumAggregate"; //$NON-NLS-1$
}
|