use of com.baidu.hugegraph.backend.id.EdgeId in project incubator-hugegraph by apache.
the class EdgeIdTest method testEdgeIdEqual.
@Test
public void testEdgeIdEqual() {
EdgeId edgeId1 = new EdgeId(IdGenerator.of("1:marko"), Directions.OUT, IdGenerator.of(1), "", IdGenerator.of("1:josh"));
EdgeId edgeId2 = new EdgeId(IdGenerator.of("1:marko"), Directions.OUT, IdGenerator.of(1), "", IdGenerator.of("1:josh"));
EdgeId edgeId3 = new EdgeId(IdGenerator.of("1:josh"), Directions.IN, IdGenerator.of(1), "", IdGenerator.of("1:marko"));
Assert.assertTrue(edgeId1.equals(edgeId2));
Assert.assertTrue(edgeId2.equals(edgeId1));
Assert.assertTrue(edgeId1.equals(edgeId3));
Assert.assertTrue(edgeId3.equals(edgeId1));
}
use of com.baidu.hugegraph.backend.id.EdgeId in project incubator-hugegraph by apache.
the class TableSerializer method writeEdgeProperty.
@Override
public BackendEntry writeEdgeProperty(HugeEdgeProperty<?> prop) {
HugeEdge edge = prop.element();
EdgeId id = edge.idWithDirection();
TableBackendEntry.Row row = new TableBackendEntry.Row(edge.type(), id);
if (edge.hasTtl()) {
row.ttl(edge.ttl());
row.column(HugeKeys.EXPIRED_TIME, edge.expiredTime());
}
// Id: ownerVertex + direction + edge-label + sortValues + otherVertex
row.column(HugeKeys.OWNER_VERTEX, this.writeId(id.ownerVertexId()));
row.column(HugeKeys.DIRECTION, id.directionCode());
row.column(HugeKeys.LABEL, id.edgeLabelId().asLong());
row.column(HugeKeys.SORT_VALUES, id.sortValues());
row.column(HugeKeys.OTHER_VERTEX, this.writeId(id.otherVertexId()));
// Format edge property
this.formatProperty(prop, row);
TableBackendEntry entry = newBackendEntry(row);
entry.subId(IdGenerator.of(prop.key()));
return entry;
}
use of com.baidu.hugegraph.backend.id.EdgeId in project incubator-hugegraph by apache.
the class TableSerializer method formatEdge.
protected TableBackendEntry.Row formatEdge(HugeEdge edge) {
EdgeId id = edge.idWithDirection();
TableBackendEntry.Row row = new TableBackendEntry.Row(edge.type(), id);
if (edge.hasTtl()) {
row.ttl(edge.ttl());
row.column(HugeKeys.EXPIRED_TIME, edge.expiredTime());
}
// Id: ownerVertex + direction + edge-label + sortValues + otherVertex
row.column(HugeKeys.OWNER_VERTEX, this.writeId(id.ownerVertexId()));
row.column(HugeKeys.DIRECTION, id.directionCode());
row.column(HugeKeys.LABEL, id.edgeLabelId().asLong());
row.column(HugeKeys.SORT_VALUES, id.sortValues());
row.column(HugeKeys.OTHER_VERTEX, this.writeId(id.otherVertexId()));
this.formatProperties(edge, row);
return row;
}
use of com.baidu.hugegraph.backend.id.EdgeId in project incubator-hugegraph by apache.
the class TextSerializer method writeEdgeId.
private String writeEdgeId(Id id, boolean withOwnerVertex) {
EdgeId edgeId;
if (id instanceof EdgeId) {
edgeId = (EdgeId) id;
} else {
edgeId = EdgeId.parse(id.asString());
}
List<String> list = new ArrayList<>(5);
if (withOwnerVertex) {
list.add(writeEntryId(edgeId.ownerVertexId()));
}
// Edge name: type + edge-label-name + sortKeys + targetVertex
list.add(writeType(edgeId.direction().type()));
list.add(writeId(edgeId.edgeLabelId()));
list.add(writeEdgeName(edgeId.sortValues()));
list.add(writeEntryId(edgeId.otherVertexId()));
return EdgeId.concat(list.toArray(new String[0]));
}
use of com.baidu.hugegraph.backend.id.EdgeId in project incubator-hugegraph by apache.
the class BytesBuffer method writeEdgeId.
public BytesBuffer writeEdgeId(Id id) {
// owner-vertex + dir + edge-label + sort-values + other-vertex
EdgeId edge = (EdgeId) id;
this.writeId(edge.ownerVertexId());
this.write(edge.directionCode());
this.writeId(edge.edgeLabelId());
this.writeStringWithEnding(edge.sortValues());
this.writeId(edge.otherVertexId());
return this;
}
Aggregations