javeme commented on code in PR #280:
URL: 
https://github.com/apache/incubator-hugegraph-computer/pull/280#discussion_r1398110782


##########
computer-algorithm/src/main/java/org/apache/hugegraph/computer/algorithm/sampling/RandomWalkOutput.java:
##########
@@ -17,28 +17,30 @@
 
 package org.apache.hugegraph.computer.algorithm.sampling;
 
+import java.util.ArrayList;
+import java.util.List;
+
 import org.apache.hugegraph.computer.core.graph.value.IdListList;
 import org.apache.hugegraph.computer.core.graph.vertex.Vertex;
 import org.apache.hugegraph.computer.core.output.hg.HugeGraphOutput;
 
-import java.util.ArrayList;
-import java.util.List;
-
 public class RandomWalkOutput extends HugeGraphOutput<List<String>> {
 
     @Override
     protected void prepareSchema() {
         this.client().schema().propertyKey(this.name())
-                .asText()
-                .writeType(this.writeType())
-                .valueList()
-                .ifNotExist()
-                .create();
+            .asText()
+            .writeType(this.writeType())
+            .valueList()
+            .ifNotExist()
+            .create();
     }
 
     @Override
     protected List<String> value(Vertex vertex) {
         IdListList value = vertex.value();
+        // TODO: use primitive array instead, like DoubleArray,
+        //  in order to reduce memory fragmentation generated during 
calculations

Review Comment:
   `List<String>` doesn't require replacement(because there is no `string[]` 
type), and the propValues doesn't look like very large.



##########
computer-algorithm/src/main/java/org/apache/hugegraph/computer/algorithm/sampling/RandomWalk.java:
##########
@@ -146,29 +237,129 @@ public void compute(ComputationContext context, Vertex 
vertex,
                 continue;
             }
 
+            vertex.edges().forEach(edge -> 
message.addToPreVertexAdjacence(edge.targetId()));
+
             // random select one edge and walk
-            Edge selectedEdge = this.randomSelectEdge(vertex.edges());
+            Edge selectedEdge = this.randomSelectEdge(preVertexId, 
message.preVertexAdjacence(),
+                                                      vertex.edges());
             context.sendMessage(selectedEdge.targetId(), message);
         }
     }
 
     /**
      * random select one edge
      */
-    private Edge randomSelectEdge(Edges edges) {
-        Edge selectedEdge = null;
-        int randomNum = random.nextInt(edges.size());
+    private Edge randomSelectEdge(Id preVertexId, IdList 
preVertexAdjacenceIdList, Edges edges) {
+        List<Double> weightList = new ArrayList<>();

Review Comment:
   yes, but we can use third-party libraries such as eclipse collections: 
https://eclipse.dev/collections/javadoc/11.1.0/org/eclipse/collections/api/list/primitive/DoubleList.html
   
   some libs of primitive collections:
   - eclipse-collections: https://github.com/eclipse/eclipse-collections
   - hppc: https://github.com/carrotsearch/hppc
   - fastutil: https://github.com/vigna/fastutil
   
   we also used them in 
https://github.com/apache/incubator-hugegraph/blob/25301f62288293e53c852f9c4eeb116a3a201594/hugegraph-server/hugegraph-core/src/main/java/org/apache/hugegraph/util/collection/CollectionFactory.java#L43



##########
computer-algorithm/src/main/java/org/apache/hugegraph/computer/algorithm/path/rings/filter/SpreadFilter.java:
##########
@@ -128,6 +128,8 @@ private static List<Serializable> expressions(
         if (filter.size() == 0) {
             return PASS;
         }
+        // TODO: use primitive array instead, like DoubleArray,

Review Comment:
   we only need to mark lists about algorithms.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to