Classes in this File | Line Coverage | Branch Coverage | Complexity | ||||
Aggregator |
|
| 1.0;1 |
1 | /* | |
2 | * Licensed to the Apache Software Foundation (ASF) under one | |
3 | * or more contributor license agreements. See the NOTICE file | |
4 | * distributed with this work for additional information | |
5 | * regarding copyright ownership. The ASF licenses this file | |
6 | * to you under the Apache License, Version 2.0 (the | |
7 | * "License"); you may not use this file except in compliance | |
8 | * with the License. You may obtain a copy of the License at | |
9 | * | |
10 | * http://www.apache.org/licenses/LICENSE-2.0 | |
11 | * | |
12 | * Unless required by applicable law or agreed to in writing, software | |
13 | * 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 and | |
16 | * limitations under the License. | |
17 | */ | |
18 | ||
19 | package org.apache.giraph.graph; | |
20 | ||
21 | import org.apache.hadoop.io.Writable; | |
22 | ||
23 | /** | |
24 | * Interface for Aggregator. Allows aggregate operations for all vertices | |
25 | * in a given superstep. | |
26 | * | |
27 | * @param <A> Aggregated value | |
28 | */ | |
29 | public interface Aggregator<A extends Writable> { | |
30 | /** | |
31 | * Add a new value. | |
32 | * Needs to be commutative and associative | |
33 | * | |
34 | * @param value Value to be aggregated. | |
35 | */ | |
36 | void aggregate(A value); | |
37 | ||
38 | /** | |
39 | * Return new aggregated value which is neutral to aggregate operation. | |
40 | * Must be changeable without affecting internals of Aggregator | |
41 | * | |
42 | * @return Neutral value | |
43 | */ | |
44 | A createInitialValue(); | |
45 | ||
46 | /** | |
47 | * Return current aggregated value. | |
48 | * Needs to be initialized if aggregate or setAggregatedValue | |
49 | * have not been called before. | |
50 | * | |
51 | * @return Aggregated | |
52 | */ | |
53 | A getAggregatedValue(); | |
54 | ||
55 | /** | |
56 | * Set aggregated value. | |
57 | * Can be used for initialization or reset. | |
58 | * | |
59 | * @param value Value to be set. | |
60 | */ | |
61 | void setAggregatedValue(A value); | |
62 | ||
63 | /** | |
64 | * Reset the value of aggregator to neutral value | |
65 | */ | |
66 | void reset(); | |
67 | } |