summaryrefslogtreecommitdiffstats
path: root/statistics/src/main/java/com/yahoo/statistics/Sum.java
blob: 5661e82cf1b505841d8376a7402b233345f3d798 (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
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
// Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
package com.yahoo.statistics;

import java.util.List;


/**
 * The innermost part of a histogram, a bucket which only contains a
 * counter.
 *
 * @author  <a href="mailto:steinar@yahoo-inc.com">Steinar Knutsen</a>
 */
@Deprecated
class Sum implements Bucket {
    private long sum = 0L;
    private double lower;
    private double upper;

    Sum(double lower, double upper) {
        this.lower = lower;
        this.upper = upper;
    }

    /**
     * Increment this bucket.
     */
    public void put(double[] value, int dim) {
        sum += 1;
    }

    /**
     * Set this bucket's count to 0.
     */
    public void reset() {
        sum = 0L;
    }

    /**
     * The lower limit for values counted by this bucket.
     */
    public double lowerLimit() {
        return lower;
    }

    /**
     * The upper limit for values counted by this bucket.
     */
    public double upperLimit() {
        return upper;
    }

    public String toString() {
        return Long.toString(sum);
    }

    @Override
    public List<Bucket> getBuckets() {
        return null;
    }

    @Override
    public boolean isLeaf() {
        return true;
    }

    @Override
    public long getSum() {
        return sum;
    }

    @Override
    public void add(long n) {
        sum += n;
    }
}