Search in sources :

Example 1 with DefaultProperties

use of com.baidu.hugegraph.computer.core.graph.properties.DefaultProperties 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)

Example 2 with DefaultProperties

use of com.baidu.hugegraph.computer.core.graph.properties.DefaultProperties in project hugegraph-computer by hugegraph.

the class DefaultPropertiesTest method testHashCode.

@Test
public void testHashCode() {
    DefaultProperties props = new DefaultProperties(graphFactory());
    props.put("p1", new LongValue(1L));
    props.put("p2", new DoubleValue(2.0D));
    Assert.assertEquals(1073748897, props.hashCode());
}
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) Test(org.junit.Test)

Example 3 with DefaultProperties

use of com.baidu.hugegraph.computer.core.graph.properties.DefaultProperties in project hugegraph-computer by hugegraph.

the class DefaultPropertiesTest method testOverwrite.

@Test
public void testOverwrite() {
    DefaultProperties properties = new DefaultProperties(graphFactory());
    Assert.assertEquals(0, properties.get().size());
    properties.put("p1", new LongValue(1L));
    properties.put("p2", new DoubleValue(2.0D));
    Assert.assertEquals(new LongValue(1L), properties.get("p1"));
    properties.put("p1", new LongValue(2L));
    Assert.assertEquals(new LongValue(2L), properties.get("p1"));
    Map<String, Value> props = properties.get();
    Assert.assertEquals(2, props.size());
    Assert.assertEquals(new LongValue(2L), 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)

Example 4 with DefaultProperties

use of com.baidu.hugegraph.computer.core.graph.properties.DefaultProperties in project hugegraph-computer by hugegraph.

the class DefaultEdgeTest method testEquals.

@Test
public void testEquals() {
    DefaultEdge edge1 = new DefaultEdge(graphFactory());
    edge1.label("knows");
    edge1.name("2021-06-01");
    edge1.targetId(BytesId.of(1L));
    Properties properties = new DefaultProperties(graphFactory());
    properties.put("p1", new LongValue(1L));
    properties.put("p2", new DoubleValue(2.0D));
    edge1.properties(properties);
    DefaultEdge edge2 = new DefaultEdge(graphFactory(), "knows", "2021-06-01", BytesId.of(1L));
    edge2.properties().put("p1", new LongValue(1L));
    edge2.properties().put("p2", new DoubleValue(2.0D));
    Assert.assertEquals(edge1, edge2);
    Assert.assertNotEquals(edge1, properties);
}
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) DefaultEdge(com.baidu.hugegraph.computer.core.graph.edge.DefaultEdge) Properties(com.baidu.hugegraph.computer.core.graph.properties.Properties) DefaultProperties(com.baidu.hugegraph.computer.core.graph.properties.DefaultProperties) Test(org.junit.Test)

Example 5 with DefaultProperties

use of com.baidu.hugegraph.computer.core.graph.properties.DefaultProperties in project hugegraph-computer by hugegraph.

the class DefaultEdgeTest method testOverwrite.

@Test
public void testOverwrite() {
    DefaultEdge edge = new DefaultEdge(graphFactory());
    edge.label("knows");
    edge.name("2021-06-01");
    edge.targetId(BytesId.of(1L));
    Properties properties = new DefaultProperties(graphFactory());
    properties.put("p1", new LongValue(1L));
    properties.put("p2", new DoubleValue(2.0D));
    edge.properties(properties);
    Assert.assertEquals("knows", edge.label());
    Assert.assertEquals("2021-06-01", edge.name());
    Assert.assertEquals(BytesId.of(1L), edge.targetId());
    Assert.assertEquals(properties, edge.properties());
}
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) DefaultEdge(com.baidu.hugegraph.computer.core.graph.edge.DefaultEdge) Properties(com.baidu.hugegraph.computer.core.graph.properties.Properties) DefaultProperties(com.baidu.hugegraph.computer.core.graph.properties.DefaultProperties) Test(org.junit.Test)

Aggregations

DefaultProperties (com.baidu.hugegraph.computer.core.graph.properties.DefaultProperties)8 Test (org.junit.Test)8 DoubleValue (com.baidu.hugegraph.computer.core.graph.value.DoubleValue)7 LongValue (com.baidu.hugegraph.computer.core.graph.value.LongValue)7 DefaultEdge (com.baidu.hugegraph.computer.core.graph.edge.DefaultEdge)3 Properties (com.baidu.hugegraph.computer.core.graph.properties.Properties)2 Value (com.baidu.hugegraph.computer.core.graph.value.Value)2