Search in sources :

Example 1 with BytesId

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

the class StoreTestUtil method idFromPointer.

public static Id idFromPointer(Pointer pointer) throws IOException {
    BytesInput input = IOFactory.createBytesInput(pointer.bytes());
    Id id = new BytesId();
    id.read(input);
    return id;
}
Also used : BytesId(com.baidu.hugegraph.computer.core.graph.id.BytesId) BytesInput(com.baidu.hugegraph.computer.core.io.BytesInput) Id(com.baidu.hugegraph.computer.core.graph.id.Id) BytesId(com.baidu.hugegraph.computer.core.graph.id.BytesId)

Example 2 with BytesId

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

the class SerializeUtilTest method testConvertBytesAndListObject.

@Test
public void testConvertBytesAndListObject() {
    Id id1 = BytesId.of(1L);
    Id id2 = BytesId.of(2L);
    List<Id> list1 = new ArrayList<>(2);
    list1.add(id1);
    list1.add(id2);
    byte[] bytes = SerializeUtil.toBytes(list1);
    List<Id> list2 = SerializeUtil.fromBytes(bytes, () -> new BytesId());
    Assert.assertEquals(list1, list2);
}
Also used : BytesId(com.baidu.hugegraph.computer.core.graph.id.BytesId) ArrayList(java.util.ArrayList) Id(com.baidu.hugegraph.computer.core.graph.id.Id) BytesId(com.baidu.hugegraph.computer.core.graph.id.BytesId) Test(org.junit.Test)

Example 3 with BytesId

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

the class IdValueTest method testEquals.

@Test
public void testEquals() {
    Value value1 = new BytesId();
    Assert.assertEquals(value1, value1);
    Assert.assertEquals(value1, new BytesId());
    Assert.assertNotEquals(value1, new BytesId(IdType.LONG, new byte[] { 1 }));
    Assert.assertNotEquals(value1, new IntValue(1));
    Assert.assertNotEquals(null, value1);
}
Also used : BytesId(com.baidu.hugegraph.computer.core.graph.id.BytesId) Test(org.junit.Test)

Example 4 with BytesId

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

the class StreamGraphInput method readId.

public static Id readId(RandomAccessInput in) throws IOException {
    Id id = new BytesId();
    id.read(in);
    return id;
}
Also used : BytesId(com.baidu.hugegraph.computer.core.graph.id.BytesId) Id(com.baidu.hugegraph.computer.core.graph.id.Id) BytesId(com.baidu.hugegraph.computer.core.graph.id.BytesId)

Aggregations

BytesId (com.baidu.hugegraph.computer.core.graph.id.BytesId)4 Id (com.baidu.hugegraph.computer.core.graph.id.Id)3 Test (org.junit.Test)2 BytesInput (com.baidu.hugegraph.computer.core.io.BytesInput)1 ArrayList (java.util.ArrayList)1