Search in sources :

Example 31 with BackendMutation

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

the class StoreSerializerTest method testSerializeStoreCommand.

@Test
public void testSerializeStoreCommand() {
    BinaryBackendEntry entry = new BinaryBackendEntry(HugeType.VERTEX, new byte[] { 1, 2 });
    entry.column(new byte[] { 1 }, new byte[] { 1 });
    entry.column(new byte[] { 2 }, new byte[] { 2 });
    entry.column(new byte[] { 127 }, new byte[] { 127 });
    BackendMutation origin = new BackendMutation();
    origin.add(entry, Action.INSERT);
    byte[] mutationBytes = StoreSerializer.writeMutation(origin);
    StoreCommand command = new StoreCommand(StoreType.GRAPH, StoreAction.MUTATE, mutationBytes);
    Assert.assertEquals(StoreAction.MUTATE, command.action());
    Assert.assertArrayEquals(mutationBytes, command.data());
    byte[] commandBytes = command.data();
    StoreCommand actual = StoreCommand.fromBytes(commandBytes);
    Assert.assertEquals(StoreType.GRAPH, command.type());
    Assert.assertEquals(command.action(), actual.action());
    Assert.assertArrayEquals(command.data(), actual.data());
}
Also used : BackendMutation(com.baidu.hugegraph.backend.store.BackendMutation) BinaryBackendEntry(com.baidu.hugegraph.backend.serializer.BinaryBackendEntry) StoreCommand(com.baidu.hugegraph.backend.store.raft.StoreCommand) Test(org.junit.Test)

Aggregations

BackendMutation (com.baidu.hugegraph.backend.store.BackendMutation)31 Test (org.junit.Test)22 BackendEntry (com.baidu.hugegraph.backend.store.BackendEntry)21 TextBackendEntry (com.baidu.hugegraph.backend.serializer.TextBackendEntry)20 BaseUnitTest (com.baidu.hugegraph.unit.BaseUnitTest)20 BinaryBackendEntry (com.baidu.hugegraph.backend.serializer.BinaryBackendEntry)3 BytesBuffer (com.baidu.hugegraph.backend.serializer.BytesBuffer)3 BackendAction (com.baidu.hugegraph.backend.store.BackendAction)2 BackendException (com.baidu.hugegraph.backend.BackendException)1 Id (com.baidu.hugegraph.backend.id.Id)1 BackendStore (com.baidu.hugegraph.backend.store.BackendStore)1 IncrCounter (com.baidu.hugegraph.backend.store.raft.RaftBackendStore.IncrCounter)1 StoreCommand (com.baidu.hugegraph.backend.store.raft.StoreCommand)1 Watched (com.baidu.hugegraph.perf.PerfUtil.Watched)1 HugeType (com.baidu.hugegraph.type.HugeType)1 Action (com.baidu.hugegraph.type.define.Action)1 ArrayList (java.util.ArrayList)1