Search in sources :

Example 6 with Value

use of com.baidu.hugegraph.computer.core.graph.value.Value in project hugegraph-computer by hugegraph.

the class DefaultProperties method write.

@Override
public void write(RandomAccessOutput out) throws IOException {
    out.writeInt(this.keyValues.size());
    for (Map.Entry<String, Value> entry : this.keyValues.entrySet()) {
        out.writeUTF(entry.getKey());
        Value value = entry.getValue();
        out.writeByte(value.valueType().code());
        value.write(out);
    }
}
Also used : Value(com.baidu.hugegraph.computer.core.graph.value.Value) Map(java.util.Map)

Example 7 with Value

use of com.baidu.hugegraph.computer.core.graph.value.Value in project hugegraph-computer by hugegraph.

the class StructGraphOutput method writeListValue.

private void writeListValue(ListValue<?> values) throws IOException {
    this.writeArrayStart();
    int size = values.size();
    int i = 0;
    for (Value value : values.values()) {
        this.writeValue(value);
        if (++i < size) {
            this.writeSplitter();
        }
    }
    this.writeArrayEnd();
}
Also used : ListValue(com.baidu.hugegraph.computer.core.graph.value.ListValue) Value(com.baidu.hugegraph.computer.core.graph.value.Value)

Example 8 with Value

use of com.baidu.hugegraph.computer.core.graph.value.Value in project hugegraph-computer by hugegraph.

the class StreamGraphInput method readValue.

@Override
public Value readValue(RandomAccessInput in) throws IOException {
    byte code = in.readByte();
    Value value = this.graphFactory.createValue(code);
    value.read(in);
    return value;
}
Also used : Value(com.baidu.hugegraph.computer.core.graph.value.Value)

Example 9 with Value

use of com.baidu.hugegraph.computer.core.graph.value.Value in project hugegraph-computer by hugegraph.

the class StreamGraphInput method readMessage.

private Value readMessage(RandomAccessInput in) throws IOException {
    Value value = this.config.createObject(ComputerOptions.ALGORITHM_MESSAGE_CLASS);
    value.read(in);
    return value;
}
Also used : Value(com.baidu.hugegraph.computer.core.graph.value.Value)

Example 10 with Value

use of com.baidu.hugegraph.computer.core.graph.value.Value in project hugegraph-computer by hugegraph.

the class DefaultPropertiesTest method testConstructor.

@Test
public void testConstructor() {
    DefaultProperties properties = new DefaultProperties(graphFactory());
    Assert.assertEquals(0, properties.get().size());
    properties.put("p1", new LongValue(1L));
    properties.put("p2", new DoubleValue(2.0D));
    Map<String, Value> props = properties.get();
    Assert.assertEquals(2, props.size());
    Assert.assertEquals(new LongValue(1L), props.get("p1"));
    Assert.assertEquals(new DoubleValue(2.0D), props.get("p2"));
}
Also used : DefaultProperties(com.baidu.hugegraph.computer.core.graph.properties.DefaultProperties) DoubleValue(com.baidu.hugegraph.computer.core.graph.value.DoubleValue) LongValue(com.baidu.hugegraph.computer.core.graph.value.LongValue) DoubleValue(com.baidu.hugegraph.computer.core.graph.value.DoubleValue) LongValue(com.baidu.hugegraph.computer.core.graph.value.LongValue) Value(com.baidu.hugegraph.computer.core.graph.value.Value) Test(org.junit.Test)

Aggregations

Value (com.baidu.hugegraph.computer.core.graph.value.Value)19 DoubleValue (com.baidu.hugegraph.computer.core.graph.value.DoubleValue)7 LongValue (com.baidu.hugegraph.computer.core.graph.value.LongValue)7 Test (org.junit.Test)6 Vertex (com.baidu.hugegraph.computer.core.graph.vertex.Vertex)5 ComputerException (com.baidu.hugegraph.computer.core.common.exception.ComputerException)3 GraphFactory (com.baidu.hugegraph.computer.core.graph.GraphFactory)3 Edges (com.baidu.hugegraph.computer.core.graph.edge.Edges)3 BytesId (com.baidu.hugegraph.computer.core.graph.id.BytesId)3 Id (com.baidu.hugegraph.computer.core.graph.id.Id)3 Properties (com.baidu.hugegraph.computer.core.graph.properties.Properties)3 BooleanValue (com.baidu.hugegraph.computer.core.graph.value.BooleanValue)3 FloatValue (com.baidu.hugegraph.computer.core.graph.value.FloatValue)3 IntValue (com.baidu.hugegraph.computer.core.graph.value.IntValue)3 IOException (java.io.IOException)3 ComputerContext (com.baidu.hugegraph.computer.core.common.ComputerContext)2 Config (com.baidu.hugegraph.computer.core.config.Config)2 DefaultProperties (com.baidu.hugegraph.computer.core.graph.properties.DefaultProperties)2 ListValue (com.baidu.hugegraph.computer.core.graph.value.ListValue)2 BytesInput (com.baidu.hugegraph.computer.core.io.BytesInput)2