Search in sources :

Example 51 with VertexLabel

use of com.baidu.hugegraph.schema.VertexLabel in project incubator-hugegraph by apache.

the class StandardHugeGraph method removeVertex.

@Override
public void removeVertex(String label, Object id) {
    if (label != null) {
        VertexLabel vl = this.vertexLabel(label);
        // It's OK even if exist adjacent edges `vl.existsLinkLabel()`
        if (!vl.existsIndexLabel()) {
            // Improve perf by removeVertex(id)
            Id idValue = HugeVertex.getIdValue(id);
            HugeVertex vertex = new HugeVertex(this, idValue, vl);
            this.removeVertex(vertex);
            return;
        }
    }
    this.vertex(id).remove();
}
Also used : VertexLabel(com.baidu.hugegraph.schema.VertexLabel) Id(com.baidu.hugegraph.backend.id.Id) HugeVertex(com.baidu.hugegraph.structure.HugeVertex)

Example 52 with VertexLabel

use of com.baidu.hugegraph.schema.VertexLabel in project incubator-hugegraph by apache.

the class StandardHugeGraph method vertexLabel.

@Override
public VertexLabel vertexLabel(String name) {
    VertexLabel vl = this.schemaTransaction().getVertexLabel(name);
    E.checkArgument(vl != null, "Undefined vertex label: '%s'", name);
    return vl;
}
Also used : VertexLabel(com.baidu.hugegraph.schema.VertexLabel)

Example 53 with VertexLabel

use of com.baidu.hugegraph.schema.VertexLabel in project incubator-hugegraph by apache.

the class EntityManager method queryEntity.

private Iterator<Vertex> queryEntity(String label, Map<String, Object> conditions, long limit) {
    ConditionQuery query = new ConditionQuery(HugeType.VERTEX);
    VertexLabel vl = this.graph().vertexLabel(label);
    query.eq(HugeKeys.LABEL, vl.id());
    for (Map.Entry<String, Object> entry : conditions.entrySet()) {
        PropertyKey pkey = this.graph().propertyKey(entry.getKey());
        query.query(Condition.eq(pkey.id(), entry.getValue()));
    }
    query.showHidden(true);
    if (limit != NO_LIMIT) {
        query.limit(limit);
    }
    return this.tx().queryVertices(query);
}
Also used : ConditionQuery(com.baidu.hugegraph.backend.query.ConditionQuery) VertexLabel(com.baidu.hugegraph.schema.VertexLabel) ImmutableMap(com.google.common.collect.ImmutableMap) Map(java.util.Map) PropertyKey(com.baidu.hugegraph.schema.PropertyKey)

Example 54 with VertexLabel

use of com.baidu.hugegraph.schema.VertexLabel 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;
}
Also used : BackendColumn(com.baidu.hugegraph.backend.store.BackendEntry.BackendColumn) VertexLabel(com.baidu.hugegraph.schema.VertexLabel) Id(com.baidu.hugegraph.backend.id.Id) HugeVertex(com.baidu.hugegraph.structure.HugeVertex)

Example 55 with VertexLabel

use of com.baidu.hugegraph.schema.VertexLabel in project incubator-hugegraph by apache.

the class BinarySerializer method parseVertex.

protected void parseVertex(byte[] value, HugeVertex vertex) {
    BytesBuffer buffer = BytesBuffer.wrap(value);
    // Parse vertex label
    VertexLabel label = vertex.graph().vertexLabelOrNone(buffer.readId());
    vertex.correctVertexLabel(label);
    // Parse properties
    this.parseProperties(buffer, vertex);
    // Parse vertex expired time if needed
    if (vertex.hasTtl()) {
        this.parseExpiredTime(buffer, vertex);
    }
}
Also used : VertexLabel(com.baidu.hugegraph.schema.VertexLabel)

Aggregations

VertexLabel (com.baidu.hugegraph.schema.VertexLabel)86 Test (org.junit.Test)35 SchemaManager (com.baidu.hugegraph.schema.SchemaManager)27 Id (com.baidu.hugegraph.backend.id.Id)23 PropertyKey (com.baidu.hugegraph.schema.PropertyKey)20 HugeGraph (com.baidu.hugegraph.HugeGraph)19 HugeVertex (com.baidu.hugegraph.structure.HugeVertex)19 EdgeId (com.baidu.hugegraph.backend.id.EdgeId)12 EdgeLabel (com.baidu.hugegraph.schema.EdgeLabel)12 Vertex (org.apache.tinkerpop.gremlin.structure.Vertex)11 FakeObjects (com.baidu.hugegraph.unit.FakeObjects)7 ConditionQuery (com.baidu.hugegraph.backend.query.ConditionQuery)6 BaseUnitTest (com.baidu.hugegraph.unit.BaseUnitTest)5 Timed (com.codahale.metrics.annotation.Timed)5 RolesAllowed (jakarta.annotation.security.RolesAllowed)5 Produces (jakarta.ws.rs.Produces)5 Watched (com.baidu.hugegraph.perf.PerfUtil.Watched)4 IndexLabel (com.baidu.hugegraph.schema.IndexLabel)4 HugeEdge (com.baidu.hugegraph.structure.HugeEdge)4 Date (java.util.Date)4