From ac348386de09337c108f8c3294cd019581c661fc Mon Sep 17 00:00:00 2001 From: zyxxoo <1318247699@qq.com> Date: Thu, 29 Apr 2021 14:14:59 +0800 Subject: [PATCH] chore use utils tools to convert to double type --- .../traversal/algorithm/NeighborRankTraverser.java | 4 ++-- .../algorithm/SingleSourceShortestPathTraverser.java | 12 +++--------- 2 files changed, 5 insertions(+), 11 deletions(-) diff --git a/hugegraph-core/src/main/java/com/baidu/hugegraph/traversal/algorithm/NeighborRankTraverser.java b/hugegraph-core/src/main/java/com/baidu/hugegraph/traversal/algorithm/NeighborRankTraverser.java index 68fd791863..6433786717 100644 --- a/hugegraph-core/src/main/java/com/baidu/hugegraph/traversal/algorithm/NeighborRankTraverser.java +++ b/hugegraph-core/src/main/java/com/baidu/hugegraph/traversal/algorithm/NeighborRankTraverser.java @@ -244,8 +244,8 @@ public static class Step { public Step(HugeGraph g, Directions direction, List 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); diff --git a/hugegraph-core/src/main/java/com/baidu/hugegraph/traversal/algorithm/SingleSourceShortestPathTraverser.java b/hugegraph-core/src/main/java/com/baidu/hugegraph/traversal/algorithm/SingleSourceShortestPathTraverser.java index e85f995bcd..217c687ff7 100644 --- a/hugegraph-core/src/main/java/com/baidu/hugegraph/traversal/algorithm/SingleSourceShortestPathTraverser.java +++ b/hugegraph-core/src/main/java/com/baidu/hugegraph/traversal/algorithm/SingleSourceShortestPathTraverser.java @@ -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; @@ -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 skipSuperNodeIfNeeded(Iterator edges) { if (this.skipDegree <= 0L) { return edges;