Skip to content

Commit 19dc77d

Browse files
committed
fix some warnings
1 parent 3bfed77 commit 19dc77d

36 files changed

Lines changed: 130 additions & 121 deletions

computer-core/src/main/java/com/baidu/hugegraph/computer/core/aggregator/Aggregator.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
import com.baidu.hugegraph.computer.core.common.exception.ComputerException;
2323
import com.baidu.hugegraph.computer.core.graph.value.Value;
2424

25-
public interface Aggregator<V extends Value> {
25+
public interface Aggregator<V extends Value<?>> {
2626

2727
/**
2828
* Used by worker to aggregate a new value when compute a vertex, needs to

computer-core/src/main/java/com/baidu/hugegraph/computer/core/aggregator/Aggregator4Master.java

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -37,33 +37,30 @@ public interface Aggregator4Master {
3737
* Register the aggregator with specified name. The name must be unique.
3838
* Used by algorithm's master-computation to register aggregators.
3939
*/
40-
<V extends Value> void registerAggregator(
41-
String name,
42-
Class<? extends Aggregator<V>> aggregatorClass);
40+
void registerAggregator(String name, Class<? extends Aggregator<Value<?>>>
41+
aggregatorClass);
4342

4443
/**
4544
* Register aggregator with specified value type and a combiner which can
4645
* combine values with specified value type. The name must be unique.
4746
* Used by algorithm's master-computation to register aggregators.
4847
*/
49-
<V extends Value> void registerAggregator(
50-
String name,
51-
ValueType type,
52-
Class<? extends Combiner<V>> combinerClass);
48+
void registerAggregator(String name, ValueType type,
49+
Class<? extends Combiner<Value<?>>> combinerClass);
5350

5451
/**
5552
* Set the aggregated value by master-computation. The value will be
5653
* received by workers at next superstep.
5754
* Throws ComputerException if master does not register the aggregator
5855
* with specified name.
5956
*/
60-
<V extends Value> void aggregatedValue(String name, V value);
57+
<V extends Value<?>> void aggregatedValue(String name, V value);
6158

6259
/**
6360
* Get the aggregated value. The aggregated value is aggregated from
6461
* workers at this superstep.
6562
* Throws ComputerException if master does not register the aggregator
6663
* with specified name.
6764
*/
68-
<V extends Value> V aggregatedValue(String name);
65+
<V extends Value<?>> V aggregatedValue(String name);
6966
}

computer-core/src/main/java/com/baidu/hugegraph/computer/core/aggregator/Aggregator4Worker.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,13 +36,13 @@ public interface Aggregator4Worker {
3636
* with specified name.
3737
* @param value The value to be aggregated
3838
*/
39-
<V extends Value> void aggregateValue(String name, V value);
39+
<V extends Value<?>> void aggregateValue(String name, V value);
4040

4141
/**
4242
* Get the aggregated value before a superstep start. The value is
4343
* aggregated by master at previous superstep.
4444
* Throws ComputerException if master does not register the aggregator
4545
* with specified name.
4646
*/
47-
<V extends Value> V aggregatedValue(String name);
47+
<V extends Value<?>> V aggregatedValue(String name);
4848
}

computer-core/src/main/java/com/baidu/hugegraph/computer/core/bsp/EtcdClient.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -439,7 +439,7 @@ protected KV getKv() {
439439
}
440440

441441
private static List<byte[]> getResponseValues(GetResponse response) {
442-
List<byte[]> values = new ArrayList((int) response.getCount());
442+
List<byte[]> values = new ArrayList<>((int) response.getCount());
443443
for (KeyValue kv : response.getKvs()) {
444444
values.add(kv.getValue().getBytes());
445445
}
@@ -468,8 +468,8 @@ public V await(long timeout, long logInterval, Runnable logFunc)
468468
while (remaining > 0) {
469469
logInterval = Math.min(remaining, logInterval);
470470
if (this.barrierEvent.await(logInterval)) {
471-
assert result != null;
472-
return result;
471+
assert this.result != null;
472+
return this.result;
473473
} else {
474474
logFunc.run();
475475
}

computer-core/src/main/java/com/baidu/hugegraph/computer/core/combiner/Combiner.java

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,14 @@ default String name() {
3131
return this.getClass().getName();
3232
}
3333

34+
/**
35+
* Combine v1 and v2, return the combined value. The combined value may
36+
* take use v1 or v2. The value of v1 and v2 may be updated. Should not
37+
* use v1 and v2 after combine them.
38+
*/
39+
T combine(T v1, T v2);
40+
41+
3442
public static <T> T combineAll(Combiner<T> combiner, Iterator<T> values) {
3543
if (!values.hasNext()) {
3644
return null;
@@ -41,11 +49,4 @@ public static <T> T combineAll(Combiner<T> combiner, Iterator<T> values) {
4149
}
4250
return result;
4351
}
44-
45-
/**
46-
* Combine v1 and v2, return the combined value. The combined value may
47-
* take use v1 or v2. The value of v1 and v2 may be updated. Should not
48-
* use v1 and v2 after combine them.
49-
*/
50-
T combine(T v1, T v2);
5152
}

computer-core/src/main/java/com/baidu/hugegraph/computer/core/combiner/MergeNewPropertiesCombiner.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -35,9 +35,9 @@ public class MergeNewPropertiesCombiner implements PropertiesCombiner {
3535
public Properties combine(Properties v1, Properties v2) {
3636
E.checkArgumentNotNull(v1, "The combine parameter v1 can't be null");
3737
E.checkArgumentNotNull(v2, "The combine parameter v2 can't be null");
38-
Map<String, Value> v1Map = v1.get();
39-
Map<String, Value> v2Map = v2.get();
40-
for (Map.Entry<String, Value> entry : v2Map.entrySet()) {
38+
Map<String, Value<?>> v1Map = v1.get();
39+
Map<String, Value<?>> v2Map = v2.get();
40+
for (Map.Entry<String, Value<?>> entry : v2Map.entrySet()) {
4141
v1Map.putIfAbsent(entry.getKey(), entry.getValue());
4242
}
4343
return v1;

computer-core/src/main/java/com/baidu/hugegraph/computer/core/combiner/MergeOldPropertiesCombiner.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -35,9 +35,9 @@ public class MergeOldPropertiesCombiner implements PropertiesCombiner {
3535
public Properties combine(Properties v1, Properties v2) {
3636
E.checkArgumentNotNull(v1, "The combine parameter v1 can't be null");
3737
E.checkArgumentNotNull(v2, "The combine parameter v2 can't be null");
38-
Map<String, Value> v1Map = v1.get();
39-
Map<String, Value> v2Map = v2.get();
40-
for (Map.Entry<String, Value> entry : v1Map.entrySet()) {
38+
Map<String, Value<?>> v1Map = v1.get();
39+
Map<String, Value<?>> v2Map = v2.get();
40+
for (Map.Entry<String, Value<?>> entry : v1Map.entrySet()) {
4141
v2Map.putIfAbsent(entry.getKey(), entry.getValue());
4242
}
4343
return v2;

computer-core/src/main/java/com/baidu/hugegraph/computer/core/combiner/ValueMaxCombiner.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,13 +22,14 @@
2222
import com.baidu.hugegraph.computer.core.graph.value.Value;
2323
import com.baidu.hugegraph.util.E;
2424

25-
public class ValueMaxCombiner <T extends Value> implements Combiner<T> {
25+
public class ValueMaxCombiner<T extends Value<?>> implements Combiner<T> {
2626

2727
@Override
28+
@SuppressWarnings("unchecked")
2829
public T combine(T v1, T v2) {
2930
E.checkArgumentNotNull(v1, "The combine parameter v1 can't be null");
3031
E.checkArgumentNotNull(v2, "The combine parameter v2 can't be null");
31-
if (v1.compareTo(v2) >= 0) {
32+
if (((Value<Object>) v1).compareTo(v2) >= 0) {
3233
return v1;
3334
} else {
3435
return v2;

computer-core/src/main/java/com/baidu/hugegraph/computer/core/combiner/ValueMinCombiner.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,13 +22,14 @@
2222
import com.baidu.hugegraph.computer.core.graph.value.Value;
2323
import com.baidu.hugegraph.util.E;
2424

25-
public class ValueMinCombiner<T extends Value> implements Combiner<T> {
25+
public class ValueMinCombiner<T extends Value<?>> implements Combiner<T> {
2626

2727
@Override
28+
@SuppressWarnings("unchecked")
2829
public T combine(T v1, T v2) {
2930
E.checkArgumentNotNull(v1, "The combine parameter v1 can't be null");
3031
E.checkArgumentNotNull(v2, "The combine parameter v2 can't be null");
31-
if (v1.compareTo(v2) <= 0) {
32+
if (((Value<Object>) v1).compareTo(v2) <= 0) {
3233
return v1;
3334
} else {
3435
return v2;

computer-core/src/main/java/com/baidu/hugegraph/computer/core/config/Config.java

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -24,20 +24,16 @@
2424

2525
import org.apache.commons.collections.CollectionUtils;
2626
import org.apache.commons.configuration.MapConfiguration;
27-
import org.slf4j.Logger;
2827

2928
import com.baidu.hugegraph.computer.core.common.exception.ComputerException;
3029
import com.baidu.hugegraph.computer.core.graph.value.ValueType;
3130
import com.baidu.hugegraph.config.ConfigOption;
3231
import com.baidu.hugegraph.config.HugeConfig;
3332
import com.baidu.hugegraph.config.TypedOption;
3433
import com.baidu.hugegraph.util.E;
35-
import com.baidu.hugegraph.util.Log;
3634

3735
public final class Config {
3836

39-
private static final Logger LOG = Log.logger(Config.class);
40-
4137
private final HugeConfig allConfig;
4238
private final HotConfig hotConfig;
4339

@@ -156,7 +152,7 @@ public String getString(String key, String defaultValue) {
156152
* to create object.
157153
*/
158154
public <T> T createObject(ConfigOption<Class<?>> clazzOption) {
159-
Class clazz = this.get(clazzOption);
155+
Class<?> clazz = this.get(clazzOption);
160156
if (clazz == Null.class) {
161157
return null;
162158
}

0 commit comments

Comments
 (0)