Search in sources :

Example 51 with BackendEntry

use of com.baidu.hugegraph.backend.store.BackendEntry in project incubator-hugegraph by apache.

the class BinarySerializerTest method testEdge.

@Test
public void testEdge() {
    HugeConfig config = FakeObjects.newConfig();
    BinarySerializer ser = new BinarySerializer(config);
    FakeObjects objects = new FakeObjects();
    HugeEdge edge1 = objects.newEdge(123, 456);
    HugeEdge edge2 = objects.newEdge(147, 789);
    BackendEntry entry1 = ser.writeEdge(edge1);
    HugeVertex vertex1 = ser.readVertex(edge1.graph(), entry1);
    Assert.assertEquals(1, vertex1.getEdges().size());
    HugeEdge edge = vertex1.getEdges().iterator().next();
    Assert.assertEquals(edge1, edge);
    assertCollectionEquals(edge1.getProperties(), edge.getProperties());
    BackendEntry entry2 = ser.writeEdge(edge2);
    HugeVertex vertex2 = ser.readVertex(edge1.graph(), entry2);
    Assert.assertEquals(1, vertex2.getEdges().size());
    edge = vertex2.getEdges().iterator().next();
    Assert.assertEquals(edge2, edge);
    assertCollectionEquals(edge2.getProperties(), edge.getProperties());
}
Also used : BackendEntry(com.baidu.hugegraph.backend.store.BackendEntry) FakeObjects(com.baidu.hugegraph.unit.FakeObjects) HugeEdge(com.baidu.hugegraph.structure.HugeEdge) HugeConfig(com.baidu.hugegraph.config.HugeConfig) HugeVertex(com.baidu.hugegraph.structure.HugeVertex) BinarySerializer(com.baidu.hugegraph.backend.serializer.BinarySerializer) BaseUnitTest(com.baidu.hugegraph.unit.BaseUnitTest) Test(org.junit.Test)

Example 52 with BackendEntry

use of com.baidu.hugegraph.backend.store.BackendEntry in project incubator-hugegraph by apache.

the class BinarySerializerTest method testVertex.

@Test
public void testVertex() {
    HugeConfig config = FakeObjects.newConfig();
    BinarySerializer ser = new BinarySerializer(config);
    HugeEdge edge = new FakeObjects().newEdge(123, 456);
    BackendEntry entry1 = ser.writeVertex(edge.sourceVertex());
    HugeVertex vertex1 = ser.readVertex(edge.graph(), entry1);
    Assert.assertEquals(edge.sourceVertex(), vertex1);
    assertCollectionEquals(edge.sourceVertex().getProperties(), vertex1.getProperties());
    BackendEntry entry2 = ser.writeVertex(edge.targetVertex());
    HugeVertex vertex2 = ser.readVertex(edge.graph(), entry2);
    Assert.assertEquals(edge.targetVertex(), vertex2);
    assertCollectionEquals(edge.targetVertex().getProperties(), vertex2.getProperties());
    Whitebox.setInternalState(vertex2, "removed", true);
    Assert.assertTrue(vertex2.removed());
    BackendEntry entry3 = ser.writeVertex(vertex2);
    Assert.assertEquals(0, entry3.columnsSize());
    Assert.assertNull(ser.readVertex(edge.graph(), null));
}
Also used : BackendEntry(com.baidu.hugegraph.backend.store.BackendEntry) FakeObjects(com.baidu.hugegraph.unit.FakeObjects) HugeEdge(com.baidu.hugegraph.structure.HugeEdge) HugeConfig(com.baidu.hugegraph.config.HugeConfig) HugeVertex(com.baidu.hugegraph.structure.HugeVertex) BinarySerializer(com.baidu.hugegraph.backend.serializer.BinarySerializer) BaseUnitTest(com.baidu.hugegraph.unit.BaseUnitTest) Test(org.junit.Test)

Example 53 with BackendEntry

use of com.baidu.hugegraph.backend.store.BackendEntry in project incubator-hugegraph by apache.

the class BinarySerializerTest method testEdgeForPartition.

@Test
public void testEdgeForPartition() {
    BinarySerializer ser = new BinarySerializer(true, true, true);
    FakeObjects objects = new FakeObjects();
    HugeEdge edge1 = objects.newEdge("123", "456");
    HugeEdge edge2 = objects.newEdge("147", "789");
    BackendEntry entry1 = ser.writeEdge(edge1);
    HugeVertex vertex1 = ser.readVertex(edge1.graph(), ser.parse(entry1));
    Assert.assertEquals(1, vertex1.getEdges().size());
    HugeEdge edge = vertex1.getEdges().iterator().next();
    Assert.assertEquals(edge1, edge);
    assertCollectionEquals(edge1.getProperties(), edge.getProperties());
    BackendEntry entry2 = ser.writeEdge(edge2);
    HugeVertex vertex2 = ser.readVertex(edge1.graph(), ser.parse(entry2));
    Assert.assertEquals(1, vertex2.getEdges().size());
    edge = vertex2.getEdges().iterator().next();
    Assert.assertEquals(edge2, edge);
    assertCollectionEquals(edge2.getProperties(), edge.getProperties());
}
Also used : BackendEntry(com.baidu.hugegraph.backend.store.BackendEntry) FakeObjects(com.baidu.hugegraph.unit.FakeObjects) HugeEdge(com.baidu.hugegraph.structure.HugeEdge) HugeVertex(com.baidu.hugegraph.structure.HugeVertex) BinarySerializer(com.baidu.hugegraph.backend.serializer.BinarySerializer) BaseUnitTest(com.baidu.hugegraph.unit.BaseUnitTest) Test(org.junit.Test)

Example 54 with BackendEntry

use of com.baidu.hugegraph.backend.store.BackendEntry in project incubator-hugegraph by apache.

the class BinaryScatterSerializerTest method testEdge.

@Test
public void testEdge() {
    HugeConfig config = FakeObjects.newConfig();
    BinaryScatterSerializer ser = new BinaryScatterSerializer(config);
    FakeObjects objects = new FakeObjects();
    HugeEdge edge1 = objects.newEdge(123, 456);
    HugeEdge edge2 = objects.newEdge(147, 789);
    BackendEntry entry1 = ser.writeEdge(edge1);
    HugeVertex vertex1 = ser.readVertex(edge1.graph(), parse(entry1));
    Assert.assertEquals(1, vertex1.getEdges().size());
    HugeEdge edge = vertex1.getEdges().iterator().next();
    Assert.assertEquals(edge1, edge);
    assertCollectionEquals(edge1.getProperties(), edge.getProperties());
    BackendEntry entry2 = ser.writeEdge(edge2);
    HugeVertex vertex2 = ser.readVertex(edge1.graph(), parse(entry2));
    Assert.assertEquals(1, vertex2.getEdges().size());
    edge = vertex2.getEdges().iterator().next();
    Assert.assertEquals(edge2, edge);
    assertCollectionEquals(edge2.getProperties(), edge.getProperties());
}
Also used : BackendEntry(com.baidu.hugegraph.backend.store.BackendEntry) BinaryBackendEntry(com.baidu.hugegraph.backend.serializer.BinaryBackendEntry) BinaryScatterSerializer(com.baidu.hugegraph.backend.serializer.BinaryScatterSerializer) FakeObjects(com.baidu.hugegraph.unit.FakeObjects) HugeEdge(com.baidu.hugegraph.structure.HugeEdge) HugeConfig(com.baidu.hugegraph.config.HugeConfig) HugeVertex(com.baidu.hugegraph.structure.HugeVertex) BaseUnitTest(com.baidu.hugegraph.unit.BaseUnitTest) Test(org.junit.Test)

Aggregations

BackendEntry (com.baidu.hugegraph.backend.store.BackendEntry)54 Test (org.junit.Test)27 TextBackendEntry (com.baidu.hugegraph.backend.serializer.TextBackendEntry)26 BaseUnitTest (com.baidu.hugegraph.unit.BaseUnitTest)26 BackendMutation (com.baidu.hugegraph.backend.store.BackendMutation)21 HugeEdge (com.baidu.hugegraph.structure.HugeEdge)7 HugeVertex (com.baidu.hugegraph.structure.HugeVertex)7 Id (com.baidu.hugegraph.backend.id.Id)6 FakeObjects (com.baidu.hugegraph.unit.FakeObjects)6 ConditionQuery (com.baidu.hugegraph.backend.query.ConditionQuery)5 BinaryBackendEntry (com.baidu.hugegraph.backend.serializer.BinaryBackendEntry)5 HugeIndex (com.baidu.hugegraph.structure.HugeIndex)5 Query (com.baidu.hugegraph.backend.query.Query)4 BinarySerializer (com.baidu.hugegraph.backend.serializer.BinarySerializer)4 HugeConfig (com.baidu.hugegraph.config.HugeConfig)4 ArrayList (java.util.ArrayList)4 Watched (com.baidu.hugegraph.perf.PerfUtil.Watched)3 LockUtil (com.baidu.hugegraph.util.LockUtil)3 BackendException (com.baidu.hugegraph.backend.BackendException)2 Condition (com.baidu.hugegraph.backend.query.Condition)2