Search in sources :

Example 16 with Value

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

the class CsvStructGraphOutputTest method testWriteReadVertexOnlyIdAndValue.

@Test
public void testWriteReadVertexOnlyIdAndValue() throws IOException {
    UnitTestBase.updateOptions(ComputerOptions.OUTPUT_WITH_ADJACENT_EDGES, "false", ComputerOptions.OUTPUT_WITH_VERTEX_PROPERTIES, "false", ComputerOptions.OUTPUT_WITH_EDGE_PROPERTIES, "false");
    ComputerContext context = context();
    GraphFactory factory = context.graphFactory();
    Id longId = BytesId.of(100L);
    Value value = BytesId.of(999L);
    Vertex vertex = factory.createVertex(longId, value);
    String fileName = "output.csv";
    File file = new File(fileName);
    try {
        BufferedFileOutput dos = new BufferedFileOutput(file);
        StructGraphOutput output = (StructGraphOutput) IOFactory.createGraphOutput(context, OutputFormat.CSV, dos);
        output.writeVertex(vertex);
        dos.close();
        @SuppressWarnings("deprecation") String text = FileUtils.readFileToString(file);
        Assert.assertEquals("100,999" + System.lineSeparator(), text);
    } finally {
        FileUtils.deleteQuietly(file);
    }
}
Also used : Vertex(com.baidu.hugegraph.computer.core.graph.vertex.Vertex) GraphFactory(com.baidu.hugegraph.computer.core.graph.GraphFactory) DoubleValue(com.baidu.hugegraph.computer.core.graph.value.DoubleValue) FloatValue(com.baidu.hugegraph.computer.core.graph.value.FloatValue) Value(com.baidu.hugegraph.computer.core.graph.value.Value) IntValue(com.baidu.hugegraph.computer.core.graph.value.IntValue) LongValue(com.baidu.hugegraph.computer.core.graph.value.LongValue) BooleanValue(com.baidu.hugegraph.computer.core.graph.value.BooleanValue) Id(com.baidu.hugegraph.computer.core.graph.id.Id) BytesId(com.baidu.hugegraph.computer.core.graph.id.BytesId) File(java.io.File) ComputerContext(com.baidu.hugegraph.computer.core.common.ComputerContext) Test(org.junit.Test)

Example 17 with Value

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

the class StreamGraphInput method readProperties.

private Properties readProperties(RandomAccessInput in) throws IOException {
    Properties properties = this.graphFactory.createProperties();
    int size = in.readInt();
    for (int i = 0; i < size; i++) {
        String key = in.readUTF();
        Value value = this.readValue(in);
        properties.put(key, value);
    }
    return properties;
}
Also used : Value(com.baidu.hugegraph.computer.core.graph.value.Value) Properties(com.baidu.hugegraph.computer.core.graph.properties.Properties)

Example 18 with Value

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

the class HugeConverter method convertProperties.

public static Properties convertProperties(Map<String, Object> rawProperties) {
    Properties properties = GRAPH_FACTORY.createProperties();
    for (Map.Entry<String, Object> entry : rawProperties.entrySet()) {
        String key = entry.getKey();
        Value value = convertValue(entry.getValue());
        properties.put(key, value);
    }
    return properties;
}
Also used : DoubleValue(com.baidu.hugegraph.computer.core.graph.value.DoubleValue) FloatValue(com.baidu.hugegraph.computer.core.graph.value.FloatValue) Value(com.baidu.hugegraph.computer.core.graph.value.Value) NullValue(com.baidu.hugegraph.computer.core.graph.value.NullValue) IntValue(com.baidu.hugegraph.computer.core.graph.value.IntValue) LongValue(com.baidu.hugegraph.computer.core.graph.value.LongValue) StringValue(com.baidu.hugegraph.computer.core.graph.value.StringValue) BooleanValue(com.baidu.hugegraph.computer.core.graph.value.BooleanValue) ListValue(com.baidu.hugegraph.computer.core.graph.value.ListValue) Properties(com.baidu.hugegraph.computer.core.graph.properties.Properties) Map(java.util.Map)

Example 19 with Value

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

the class SortManager method createMessageCombiner.

private PointerCombiner createMessageCombiner() {
    Config config = this.context.config();
    Combiner<Value> valueCombiner = config.createObject(ComputerOptions.WORKER_COMBINER_CLASS, false);
    if (valueCombiner == null) {
        return null;
    }
    return new MessageValueCombiner(this.context);
}
Also used : Config(com.baidu.hugegraph.computer.core.config.Config) Value(com.baidu.hugegraph.computer.core.graph.value.Value) MessageValueCombiner(com.baidu.hugegraph.computer.core.combiner.MessageValueCombiner)

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