Search in sources :

Example 1 with BinaryBackendEntry

use of com.baidu.hugegraph.backend.serializer.BinaryBackendEntry in project incubator-hugegraph by apache.

the class HbaseTable method newEntryIterator.

protected BackendEntryIterator newEntryIterator(Query query, RowIterator rows) {
    return new BinaryEntryIterator<>(rows, query, (entry, row) -> {
        E.checkState(!row.isEmpty(), "Can't parse empty HBase result");
        byte[] id = row.getRow();
        if (entry == null || !Bytes.prefixWith(id, entry.id().asBytes())) {
            HugeType type = query.resultType();
            // NOTE: only support BinaryBackendEntry currently
            entry = new BinaryBackendEntry(type, id, this.enablePartition);
        }
        try {
            this.parseRowColumns(row, entry, query, this.enablePartition);
        } catch (IOException e) {
            throw new BackendException("Failed to read HBase columns", e);
        }
        return entry;
    });
}
Also used : BinaryEntryIterator(com.baidu.hugegraph.backend.serializer.BinaryEntryIterator) BinaryBackendEntry(com.baidu.hugegraph.backend.serializer.BinaryBackendEntry) IOException(java.io.IOException) HugeType(com.baidu.hugegraph.type.HugeType) BackendException(com.baidu.hugegraph.backend.BackendException)

Example 2 with BinaryBackendEntry

use of com.baidu.hugegraph.backend.serializer.BinaryBackendEntry in project incubator-hugegraph by apache.

the class BinaryScatterSerializerTest method parse.

private static BackendEntry parse(BackendEntry originEntry) {
    byte[] bytes = originEntry.id().asBytes();
    BackendEntry parsedEntry = new BinaryBackendEntry(originEntry.type(), bytes);
    parsedEntry.columns(originEntry.columns());
    return parsedEntry;
}
Also used : BackendEntry(com.baidu.hugegraph.backend.store.BackendEntry) BinaryBackendEntry(com.baidu.hugegraph.backend.serializer.BinaryBackendEntry) BinaryBackendEntry(com.baidu.hugegraph.backend.serializer.BinaryBackendEntry)

Example 3 with BinaryBackendEntry

use of com.baidu.hugegraph.backend.serializer.BinaryBackendEntry in project incubator-hugegraph by apache.

the class BinaryBackendEntryTest method testColumns.

@Test
public void testColumns() {
    BinaryBackendEntry entry = new BinaryBackendEntry(HugeType.VERTEX, new byte[] { 1, 2 });
    BackendColumn col = BackendColumn.of(new byte[] { 1, 2 }, new byte[] { 3, 4 });
    entry.columns(ImmutableList.of(col));
    Assert.assertEquals(1, entry.columnsSize());
    Assert.assertEquals(ImmutableList.of(col), entry.columns());
    entry.columns(ImmutableList.of(col, col));
    Assert.assertEquals(3, entry.columnsSize());
    Assert.assertEquals(ImmutableList.of(col, col, col), entry.columns());
}
Also used : BackendColumn(com.baidu.hugegraph.backend.store.BackendEntry.BackendColumn) BinaryBackendEntry(com.baidu.hugegraph.backend.serializer.BinaryBackendEntry) BaseUnitTest(com.baidu.hugegraph.unit.BaseUnitTest) Test(org.junit.Test)

Example 4 with BinaryBackendEntry

use of com.baidu.hugegraph.backend.serializer.BinaryBackendEntry in project incubator-hugegraph by apache.

the class BinaryBackendEntryTest method testEquals.

@Test
public void testEquals() {
    BinaryBackendEntry entry = new BinaryBackendEntry(HugeType.VERTEX, new byte[] { 1, 2 });
    BinaryBackendEntry entry2 = new BinaryBackendEntry(HugeType.VERTEX, new byte[] { 2, 2 });
    BinaryBackendEntry entry3 = new BinaryBackendEntry(HugeType.VERTEX, new byte[] { 1, 2 });
    BinaryBackendEntry entry4 = new BinaryBackendEntry(HugeType.VERTEX, new byte[] { 1, 2 });
    BinaryBackendEntry entry5 = new BinaryBackendEntry(HugeType.VERTEX, new byte[] { 1, 2 });
    BackendColumn col = BackendColumn.of(new byte[] { 1, 2 }, new byte[] { 3, 4 });
    BackendColumn col2 = BackendColumn.of(new byte[] { 5, 6 }, new byte[] { 7, 8 });
    entry.column(col);
    entry2.column(col2);
    entry3.column(col2);
    entry4.column(col);
    entry4.column(col2);
    entry5.column(col);
    Assert.assertNotEquals(entry, entry2);
    Assert.assertNotEquals(entry, entry3);
    Assert.assertNotEquals(entry, entry4);
    Assert.assertEquals(entry, entry5);
}
Also used : BackendColumn(com.baidu.hugegraph.backend.store.BackendEntry.BackendColumn) BinaryBackendEntry(com.baidu.hugegraph.backend.serializer.BinaryBackendEntry) BaseUnitTest(com.baidu.hugegraph.unit.BaseUnitTest) Test(org.junit.Test)

Example 5 with BinaryBackendEntry

use of com.baidu.hugegraph.backend.serializer.BinaryBackendEntry in project incubator-hugegraph by apache.

the class BinaryBackendEntryTest method testMerge.

@Test
public void testMerge() {
    BinaryBackendEntry entry = new BinaryBackendEntry(HugeType.VERTEX, new byte[] { 1, 2 });
    BinaryBackendEntry entry2 = new BinaryBackendEntry(HugeType.VERTEX, new byte[] { 2, 2 });
    BackendColumn col = BackendColumn.of(new byte[] { 1, 2 }, new byte[] { 3, 4 });
    BackendColumn col2 = BackendColumn.of(new byte[] { 5, 6 }, new byte[] { 7, 8 });
    entry.column(col);
    entry2.column(col2);
    Assert.assertEquals(1, entry.columnsSize());
    Assert.assertEquals(ImmutableList.of(col), entry.columns());
    entry.merge(entry2);
    Assert.assertEquals(2, entry.columnsSize());
    Assert.assertEquals(ImmutableList.of(col, col2), entry.columns());
}
Also used : BackendColumn(com.baidu.hugegraph.backend.store.BackendEntry.BackendColumn) BinaryBackendEntry(com.baidu.hugegraph.backend.serializer.BinaryBackendEntry) BaseUnitTest(com.baidu.hugegraph.unit.BaseUnitTest) Test(org.junit.Test)

Aggregations

BinaryBackendEntry (com.baidu.hugegraph.backend.serializer.BinaryBackendEntry)10 Test (org.junit.Test)6 BackendColumn (com.baidu.hugegraph.backend.store.BackendEntry.BackendColumn)4 BaseUnitTest (com.baidu.hugegraph.unit.BaseUnitTest)4 BackendMutation (com.baidu.hugegraph.backend.store.BackendMutation)3 HugeType (com.baidu.hugegraph.type.HugeType)3 BinaryEntryIterator (com.baidu.hugegraph.backend.serializer.BinaryEntryIterator)2 BackendAction (com.baidu.hugegraph.backend.store.BackendAction)2 BackendEntry (com.baidu.hugegraph.backend.store.BackendEntry)2 BackendException (com.baidu.hugegraph.backend.BackendException)1 Id (com.baidu.hugegraph.backend.id.Id)1 BytesBuffer (com.baidu.hugegraph.backend.serializer.BytesBuffer)1 StoreCommand (com.baidu.hugegraph.backend.store.raft.StoreCommand)1 Action (com.baidu.hugegraph.type.define.Action)1 IOException (java.io.IOException)1