Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore use utils tools to convert to double type #1438

Merged
merged 1 commit into from
Apr 29, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -244,8 +244,8 @@ public static class Step {
public Step(HugeGraph g, Directions direction, List<String> labels,
long degree, long skipDegree, int top, int capacity) {
E.checkArgument(top > 0 && top <= MAX_TOP,
"The top of each layer must be in (0, %s]",
MAX_TOP);
"The top of each layer must be in (0, %s], but " +
"got %s", MAX_TOP, top);
E.checkArgument(capacity > 0,
"The capacity of each layer must be > 0, " +
"but got %s", capacity);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@
import com.baidu.hugegraph.util.CollectionUtil;
import com.baidu.hugegraph.util.E;
import com.baidu.hugegraph.util.InsertionOrderUtil;
import com.baidu.hugegraph.util.NumericUtil;
import com.google.common.collect.ImmutableMap;
import com.google.common.collect.ImmutableSet;

Expand Down Expand Up @@ -212,19 +213,12 @@ private double edgeWeight(HugeEdge edge) {
!edge.property(this.weight).isPresent()) {
edgeWeight = 1.0;
} else {
edgeWeight = this.toDouble(edge.value(this.weight));
edgeWeight = NumericUtil.convertToNumber(
edge.value(this.weight)).doubleValue();
}
return edgeWeight;
}

private double toDouble(Object obj) {
if (obj instanceof Number) {
return ((Number) obj).doubleValue();
}

return (double) obj;
}

private Iterator<Edge> skipSuperNodeIfNeeded(Iterator<Edge> edges) {
if (this.skipDegree <= 0L) {
return edges;
Expand Down