Search in sources :

Example 6 with EdgeId

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));
}
Also used : EdgeId(com.baidu.hugegraph.backend.id.EdgeId) BaseUnitTest(com.baidu.hugegraph.unit.BaseUnitTest) Test(org.junit.Test)

Example 7 with EdgeId

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;
}
Also used : EdgeId(com.baidu.hugegraph.backend.id.EdgeId) HugeEdge(com.baidu.hugegraph.structure.HugeEdge)

Example 8 with EdgeId

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;
}
Also used : EdgeId(com.baidu.hugegraph.backend.id.EdgeId)

Example 9 with EdgeId

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]));
}
Also used : EdgeId(com.baidu.hugegraph.backend.id.EdgeId) ArrayList(java.util.ArrayList)

Example 10 with EdgeId

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;
}
Also used : EdgeId(com.baidu.hugegraph.backend.id.EdgeId)

Aggregations

EdgeId (com.baidu.hugegraph.backend.id.EdgeId)14 Id (com.baidu.hugegraph.backend.id.Id)6 BaseUnitTest (com.baidu.hugegraph.unit.BaseUnitTest)5 Test (org.junit.Test)5 BinaryId (com.baidu.hugegraph.backend.serializer.BinaryBackendEntry.BinaryId)2 HugeEdge (com.baidu.hugegraph.structure.HugeEdge)2 ArrayList (java.util.ArrayList)2 IdQuery (com.baidu.hugegraph.backend.query.IdQuery)1 BackendColumn (com.baidu.hugegraph.backend.store.BackendEntry.BackendColumn)1 BatchMapperIterator (com.baidu.hugegraph.iterator.BatchMapperIterator)1 ExtendableIterator (com.baidu.hugegraph.iterator.ExtendableIterator)1 FilterIterator (com.baidu.hugegraph.iterator.FilterIterator)1 FlatMapperIterator (com.baidu.hugegraph.iterator.FlatMapperIterator)1 LimitIterator (com.baidu.hugegraph.iterator.LimitIterator)1 ListIterator (com.baidu.hugegraph.iterator.ListIterator)1 MapperIterator (com.baidu.hugegraph.iterator.MapperIterator)1 Watched (com.baidu.hugegraph.perf.PerfUtil.Watched)1 PropertyKey (com.baidu.hugegraph.schema.PropertyKey)1 HugeVertex (com.baidu.hugegraph.structure.HugeVertex)1 HashMap (java.util.HashMap)1