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;
});
}
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;
}
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());
}
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);
}
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());
}
Aggregations