use of com.baidu.hugegraph.backend.store.BackendEntry.BackendColumn 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.store.BackendEntry.BackendColumn 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());
}
use of com.baidu.hugegraph.backend.store.BackendEntry.BackendColumn in project incubator-hugegraph by apache.
the class BinaryScatterSerializer method readVertex.
@Override
public HugeVertex readVertex(HugeGraph graph, BackendEntry bytesEntry) {
if (bytesEntry == null) {
return null;
}
BinaryBackendEntry entry = this.convertEntry(bytesEntry);
// Parse label
final byte[] VL = this.formatSyspropName(entry.id(), HugeKeys.LABEL);
BackendColumn vl = entry.column(VL);
VertexLabel vertexLabel = VertexLabel.NONE;
if (vl != null) {
Id labelId = BytesBuffer.wrap(vl.value).readId();
vertexLabel = graph.vertexLabelOrNone(labelId);
}
// Parse id
Id id = entry.id().origin();
HugeVertex vertex = new HugeVertex(graph, id, vertexLabel);
// Parse all properties and edges of a Vertex
for (BackendColumn col : entry.columns()) {
this.parseColumn(col, vertex);
}
return vertex;
}
use of com.baidu.hugegraph.backend.store.BackendEntry.BackendColumn in project incubator-hugegraph by apache.
the class StoreSerializer method writeMutation.
public static byte[] writeMutation(BackendMutation mutation) {
BytesBuffer buffer = BytesBuffer.allocate(MUTATION_SIZE);
// write mutation size
buffer.writeVInt(mutation.size());
for (Iterator<BackendAction> items = mutation.mutation(); items.hasNext(); ) {
BackendAction item = items.next();
// write Action
buffer.write(item.action().code());
BackendEntry entry = item.entry();
// write HugeType
buffer.write(entry.type().code());
// write id
buffer.writeBytes(entry.id().asBytes());
// write subId
if (entry.subId() != null) {
buffer.writeId(entry.subId());
} else {
buffer.writeId(IdGenerator.ZERO);
}
// write ttl
buffer.writeVLong(entry.ttl());
// write columns
buffer.writeVInt(entry.columns().size());
for (BackendColumn column : entry.columns()) {
buffer.writeBytes(column.name);
buffer.writeBytes(column.value);
}
}
return buffer.bytes();
}
use of com.baidu.hugegraph.backend.store.BackendEntry.BackendColumn in project incubator-hugegraph by apache.
the class TextBackendEntryTest method testColumns.
@Test
public void testColumns() {
TextBackendEntry entry = new TextBackendEntry(HugeType.VERTEX, IdGenerator.of(1));
entry.column(HugeKeys.ID, "1");
entry.column(HugeKeys.NAME, "tom");
BackendColumn col1 = BackendColumn.of(new byte[] { 'i', 'd' }, new byte[] { '1' });
BackendColumn col2 = BackendColumn.of(new byte[] { 'n', 'a', 'm', 'e' }, new byte[] { 't', 'o', 'm' });
Assert.assertEquals(2, entry.columnsSize());
Assert.assertEquals(ImmutableList.of(col1, col2), entry.columns());
}
Aggregations