Search in sources :

Example 71 with Id

use of com.baidu.hugegraph.computer.core.graph.id.Id in project hugegraph-computer by hugegraph.

the class IdSet method read.

@Override
public void read(RandomAccessInput in) throws IOException {
    int size = in.readInt();
    if (size > this.values.size() || size < this.values.size() / 2) {
        this.values = this.graphFactory.createSet(size);
    } else {
        this.values.clear();
    }
    for (int i = 0; i < size; i++) {
        Id id = this.graphFactory.createId();
        id.read(in);
        this.values.add(id);
    }
}
Also used : Id(com.baidu.hugegraph.computer.core.graph.id.Id)

Example 72 with Id

use of com.baidu.hugegraph.computer.core.graph.id.Id in project hugegraph-computer by hugegraph.

the class ComputeMessageRecvPartitionTest method addTwentyDuplicateIdValueListMessageBuffer.

private static void addTwentyDuplicateIdValueListMessageBuffer(Consumer<ManagedBuffer> consumer) throws IOException {
    for (long i = 0L; i < 10L; i++) {
        for (int j = 0; j < 2; j++) {
            Id id = BytesId.of(i);
            IdList message = new IdList();
            message.add(id);
            ReceiverUtil.consumeBuffer(ReceiverUtil.writeMessage(id, message), consumer);
        }
    }
}
Also used : Id(com.baidu.hugegraph.computer.core.graph.id.Id) BytesId(com.baidu.hugegraph.computer.core.graph.id.BytesId) IdList(com.baidu.hugegraph.computer.core.graph.value.IdList)

Example 73 with Id

use of com.baidu.hugegraph.computer.core.graph.id.Id in project hugegraph-computer by hugegraph.

the class MessageInputTest method addMessages.

private static void addMessages(Consumer<ManagedBuffer> consumer) throws IOException {
    Random random = new Random(1);
    for (long i = 0L; i < 200L; i++) {
        int count = random.nextInt(5);
        for (int j = 0; j < count; j++) {
            Id id = BytesId.of(random.nextInt(200));
            IdList message = new IdList();
            message.add(id);
            ReceiverUtil.consumeBuffer(ReceiverUtil.writeMessage(id, message), consumer);
        }
    }
}
Also used : Random(java.util.Random) Id(com.baidu.hugegraph.computer.core.graph.id.Id) BytesId(com.baidu.hugegraph.computer.core.graph.id.BytesId) ConnectionId(com.baidu.hugegraph.computer.core.network.ConnectionId) IdList(com.baidu.hugegraph.computer.core.graph.value.IdList)

Example 74 with Id

use of com.baidu.hugegraph.computer.core.graph.id.Id in project hugegraph-computer by hugegraph.

the class ComputeMessageRecvPartitionTest method addTwentyCombineMessageBuffer.

public static void addTwentyCombineMessageBuffer(Consumer<ManagedBuffer> consumer) throws IOException {
    for (long i = 0L; i < 10L; i++) {
        for (int j = 0; j < 2; j++) {
            Id id = BytesId.of(i);
            DoubleValue message = new DoubleValue(i);
            ReceiverUtil.consumeBuffer(ReceiverUtil.writeMessage(id, message), consumer);
        }
    }
}
Also used : DoubleValue(com.baidu.hugegraph.computer.core.graph.value.DoubleValue) Id(com.baidu.hugegraph.computer.core.graph.id.Id) BytesId(com.baidu.hugegraph.computer.core.graph.id.BytesId)

Aggregations

Id (com.baidu.hugegraph.computer.core.graph.id.Id)74 BytesId (com.baidu.hugegraph.computer.core.graph.id.BytesId)51 Test (org.junit.Test)29 IdList (com.baidu.hugegraph.computer.core.graph.value.IdList)18 Edge (com.baidu.hugegraph.computer.core.graph.edge.Edge)12 DoubleValue (com.baidu.hugegraph.computer.core.graph.value.DoubleValue)12 LongValue (com.baidu.hugegraph.computer.core.graph.value.LongValue)12 Vertex (com.baidu.hugegraph.computer.core.graph.vertex.Vertex)12 ComputerContext (com.baidu.hugegraph.computer.core.common.ComputerContext)11 GraphFactory (com.baidu.hugegraph.computer.core.graph.GraphFactory)10 KvEntry (com.baidu.hugegraph.computer.core.store.entry.KvEntry)9 ConnectionId (com.baidu.hugegraph.computer.core.network.ConnectionId)8 IdListList (com.baidu.hugegraph.computer.core.graph.value.IdListList)7 Properties (com.baidu.hugegraph.computer.core.graph.properties.Properties)6 File (java.io.File)6 Value (com.baidu.hugegraph.computer.core.graph.value.Value)5 BytesInput (com.baidu.hugegraph.computer.core.io.BytesInput)5 Config (com.baidu.hugegraph.computer.core.config.Config)4 BooleanValue (com.baidu.hugegraph.computer.core.graph.value.BooleanValue)4 FloatValue (com.baidu.hugegraph.computer.core.graph.value.FloatValue)4