Search in sources :

Example 16 with Edges

use of com.baidu.hugegraph.computer.core.graph.edge.Edges in project hugegraph-computer by hugegraph.

the class ComputeManagerTest method addSingleFreqEdgeBuffer.

private static void addSingleFreqEdgeBuffer(Consumer<ManagedBuffer> consumer) throws IOException {
    for (long i = 0L; i < 200L; i++) {
        Vertex vertex = graphFactory().createVertex();
        vertex.id(BytesId.of(i));
        int count = RANDOM.nextInt(20);
        if (count == 0) {
            continue;
        }
        Edges edges = graphFactory().createEdges(count);
        for (long j = 0; j < count; j++) {
            Edge edge = graphFactory().createEdge();
            edge.targetId(BytesId.of(RANDOM.nextInt(200)));
            Properties properties = graphFactory().createProperties();
            properties.put("p1", new LongValue(i));
            edge.properties(properties);
            edges.add(edge);
        }
        vertex.edges(edges);
        ReceiverUtil.consumeBuffer(writeEdges(vertex, EdgeFrequency.SINGLE), consumer);
    }
}
Also used : Vertex(com.baidu.hugegraph.computer.core.graph.vertex.Vertex) LongValue(com.baidu.hugegraph.computer.core.graph.value.LongValue) Properties(com.baidu.hugegraph.computer.core.graph.properties.Properties) Edges(com.baidu.hugegraph.computer.core.graph.edge.Edges) Edge(com.baidu.hugegraph.computer.core.graph.edge.Edge)

Example 17 with Edges

use of com.baidu.hugegraph.computer.core.graph.edge.Edges in project hugegraph-computer by hugegraph.

the class EdgeMessageRecvPartitionTest method addTenEdgeBuffer.

public static void addTenEdgeBuffer(Consumer<ManagedBuffer> consumer) throws IOException {
    for (long i = 0L; i < 10L; i++) {
        Vertex vertex = graphFactory().createVertex();
        vertex.id(BytesId.of(i));
        Edges edges = graphFactory().createEdges(2);
        for (long j = i + 1; j < i + 3; j++) {
            Edge edge = graphFactory().createEdge();
            edge.targetId(BytesId.of(j));
            Properties properties = graphFactory().createProperties();
            properties.put("p1", new LongValue(i));
            edge.properties(properties);
            edges.add(edge);
        }
        vertex.edges(edges);
        ReceiverUtil.consumeBuffer(writeEdges(vertex), consumer);
    }
}
Also used : Vertex(com.baidu.hugegraph.computer.core.graph.vertex.Vertex) LongValue(com.baidu.hugegraph.computer.core.graph.value.LongValue) Properties(com.baidu.hugegraph.computer.core.graph.properties.Properties) Edges(com.baidu.hugegraph.computer.core.graph.edge.Edges) Edge(com.baidu.hugegraph.computer.core.graph.edge.Edge)

Example 18 with Edges

use of com.baidu.hugegraph.computer.core.graph.edge.Edges in project hugegraph-computer by hugegraph.

the class EdgeMessageRecvPartitionTest method addTenDuplicateEdgeBuffer.

private static void addTenDuplicateEdgeBuffer(Consumer<ManagedBuffer> consumer) throws IOException {
    for (long i = 0L; i < 10L; i++) {
        Vertex vertex = graphFactory().createVertex();
        vertex.id(BytesId.of(i));
        Edges edges = graphFactory().createEdges(2);
        for (long j = i + 1; j < i + 3; j++) {
            Edge edge = graphFactory().createEdge();
            edge.targetId(BytesId.of(j));
            Properties properties = graphFactory().createProperties();
            properties.put("p1", new LongValue(i));
            edge.properties(properties);
            edges.add(edge);
        }
        vertex.edges(edges);
        ReceiverUtil.consumeBuffer(writeEdges(vertex), consumer);
    }
    for (long i = 0L; i < 10L; i++) {
        Vertex vertex = graphFactory().createVertex();
        vertex.id(BytesId.of(i));
        Edges edges = graphFactory().createEdges(2);
        for (long j = i + 1; j < i + 3; j++) {
            Edge edge = graphFactory().createEdge();
            edge.targetId(BytesId.of(j));
            Properties properties = graphFactory().createProperties();
            properties.put("p2", new LongValue(2L * i));
            edge.properties(properties);
            edges.add(edge);
        }
        vertex.edges(edges);
        ReceiverUtil.consumeBuffer(writeEdges(vertex), consumer);
    }
}
Also used : Vertex(com.baidu.hugegraph.computer.core.graph.vertex.Vertex) LongValue(com.baidu.hugegraph.computer.core.graph.value.LongValue) Properties(com.baidu.hugegraph.computer.core.graph.properties.Properties) Edges(com.baidu.hugegraph.computer.core.graph.edge.Edges) Edge(com.baidu.hugegraph.computer.core.graph.edge.Edge)

Aggregations

Edges (com.baidu.hugegraph.computer.core.graph.edge.Edges)18 Vertex (com.baidu.hugegraph.computer.core.graph.vertex.Vertex)13 Edge (com.baidu.hugegraph.computer.core.graph.edge.Edge)11 ComputerException (com.baidu.hugegraph.computer.core.common.exception.ComputerException)10 Properties (com.baidu.hugegraph.computer.core.graph.properties.Properties)9 LongValue (com.baidu.hugegraph.computer.core.graph.value.LongValue)8 IOException (java.io.IOException)7 Value (com.baidu.hugegraph.computer.core.graph.value.Value)3 Id (com.baidu.hugegraph.computer.core.graph.id.Id)2 BytesId (com.baidu.hugegraph.computer.core.graph.id.BytesId)1 PartitionStat (com.baidu.hugegraph.computer.core.graph.partition.PartitionStat)1 IdListList (com.baidu.hugegraph.computer.core.graph.value.IdListList)1 ConnectionId (com.baidu.hugegraph.computer.core.network.ConnectionId)1 ComputerOutput (com.baidu.hugegraph.computer.core.output.ComputerOutput)1 HashSet (java.util.HashSet)1