Search in sources :

Example 51 with Watched

use of com.baidu.hugegraph.perf.PerfUtil.Watched in project incubator-hugegraph by apache.

the class SchemaTransaction method removeEdgeLabel.

@Watched(prefix = "schema")
public Id removeEdgeLabel(Id id) {
    LOG.debug("SchemaTransaction remove edge label '{}'", id);
    SchemaJob callable = new EdgeLabelRemoveJob();
    EdgeLabel schema = this.getEdgeLabel(id);
    return asyncRun(this.graph(), schema, callable);
}
Also used : EdgeLabelRemoveJob(com.baidu.hugegraph.job.schema.EdgeLabelRemoveJob) EdgeLabel(com.baidu.hugegraph.schema.EdgeLabel) SchemaJob(com.baidu.hugegraph.job.schema.SchemaJob) Watched(com.baidu.hugegraph.perf.PerfUtil.Watched)

Example 52 with Watched

use of com.baidu.hugegraph.perf.PerfUtil.Watched in project incubator-hugegraph by apache.

the class HugeEdge method remove.

@Watched(prefix = "edge")
@Override
public void remove() {
    this.removed(true);
    this.sourceVertex.removeEdge(this);
    this.targetVertex.removeEdge(this);
    GraphTransaction tx = this.tx();
    if (tx != null) {
        assert this.fresh();
        tx.removeEdge(this);
    } else {
        this.graph().removeEdge(this);
    }
}
Also used : GraphTransaction(com.baidu.hugegraph.backend.tx.GraphTransaction) Watched(com.baidu.hugegraph.perf.PerfUtil.Watched)

Example 53 with Watched

use of com.baidu.hugegraph.perf.PerfUtil.Watched in project incubator-hugegraph by apache.

the class HugeEdge method assignId.

@Watched(prefix = "edge")
public void assignId() {
    // Generate an id and assign
    this.id = new EdgeId(this.ownerVertex(), this.direction(), this.schemaLabel().id(), this.name(), this.otherVertex());
    if (this.fresh()) {
        int len = this.id.length();
        E.checkArgument(len <= BytesBuffer.BIG_ID_LEN_MAX, "The max length of edge id is %s, but got %s {%s}", BytesBuffer.BIG_ID_LEN_MAX, len, this.id);
    }
}
Also used : EdgeId(com.baidu.hugegraph.backend.id.EdgeId) Watched(com.baidu.hugegraph.perf.PerfUtil.Watched)

Example 54 with Watched

use of com.baidu.hugegraph.perf.PerfUtil.Watched in project incubator-hugegraph by apache.

the class HugeVertex method assignId.

@Watched(prefix = "vertex")
public void assignId(Id id, boolean force) {
    IdStrategy strategy = this.label.idStrategy();
    // Generate an id and assign
    switch(strategy) {
        case CUSTOMIZE_STRING:
            assert !id.number();
            this.id = id;
            break;
        case CUSTOMIZE_NUMBER:
            assert id.number();
            this.id = id;
            break;
        case CUSTOMIZE_UUID:
            this.id = id.uuid() ? id : IdGenerator.of(id.asString(), true);
            break;
        case PRIMARY_KEY:
            this.id = SplicingIdGenerator.instance().generate(this);
            break;
        case AUTOMATIC:
            if (force) {
                // Resume id for AUTOMATIC id strategy in restoring mode
                assert id.number();
                this.id = id;
            } else {
                this.id = SnowflakeIdGenerator.instance(this.graph()).generate(this);
            }
            break;
        default:
            throw new AssertionError(String.format("Unknown id strategy '%s'", strategy));
    }
    this.checkIdLength();
}
Also used : IdStrategy(com.baidu.hugegraph.type.define.IdStrategy) Watched(com.baidu.hugegraph.perf.PerfUtil.Watched)

Example 55 with Watched

use of com.baidu.hugegraph.perf.PerfUtil.Watched in project incubator-hugegraph by apache.

the class HugeVertex method property.

@Watched(prefix = "vertex")
@Override
public <V> VertexProperty<V> property(VertexProperty.Cardinality cardinality, String key, V value, Object... objects) {
    if (objects.length != 0 && objects[0].equals(T.id)) {
        throw VertexProperty.Exceptions.userSuppliedIdsNotSupported();
    }
    // TODO: extra props: objects
    if (objects.length != 0) {
        throw VertexProperty.Exceptions.metaPropertiesNotSupported();
    }
    PropertyKey propertyKey = this.graph().propertyKey(key);
    /*
         * g.AddV("xxx").property("key1", val1).property("key2", val2)
         * g.AddV("xxx").property(single, "key1", val1)
         *              .property(list, "key2", val2)
         *
         * The cardinality single may be user supplied single, it may also be
         * that user doesn't supplied cardinality, when it is latter situation,
         * we shouldn't check it. Because of this reason, we are forced to
         * give up the check of user supplied cardinality single.
         * The cardinality not single must be user supplied, so should check it
         */
    if (cardinality != VertexProperty.Cardinality.single) {
        E.checkArgument(propertyKey.cardinality() == Cardinality.convert(cardinality), "Invalid cardinality '%s' for property key '%s', " + "expect '%s'", cardinality, key, propertyKey.cardinality().string());
    }
    // Check key in vertex label
    E.checkArgument(VertexLabel.OLAP_VL.equals(this.label) || this.label.properties().contains(propertyKey.id()), "Invalid property '%s' for vertex label '%s'", key, this.label);
    // Primary-Keys can only be set once
    if (this.schemaLabel().primaryKeys().contains(propertyKey.id())) {
        E.checkArgument(!this.hasProperty(propertyKey.id()), "Can't update primary key: '%s'", key);
    }
    @SuppressWarnings("unchecked") VertexProperty<V> prop = (VertexProperty<V>) this.addProperty(propertyKey, value, !this.fresh());
    return prop;
}
Also used : VertexProperty(org.apache.tinkerpop.gremlin.structure.VertexProperty) PropertyKey(com.baidu.hugegraph.schema.PropertyKey) Watched(com.baidu.hugegraph.perf.PerfUtil.Watched)

Aggregations

Watched (com.baidu.hugegraph.perf.PerfUtil.Watched)65 Id (com.baidu.hugegraph.backend.id.Id)30 ConditionQuery (com.baidu.hugegraph.backend.query.ConditionQuery)9 EdgeId (com.baidu.hugegraph.backend.id.EdgeId)8 IndexLabel (com.baidu.hugegraph.schema.IndexLabel)8 SchemaManager (com.baidu.hugegraph.schema.SchemaManager)7 ArrayList (java.util.ArrayList)7 PropertyKey (com.baidu.hugegraph.schema.PropertyKey)6 HugeVertex (com.baidu.hugegraph.structure.HugeVertex)6 BatchIdHolder (com.baidu.hugegraph.backend.page.IdHolder.BatchIdHolder)5 HugeIndex (com.baidu.hugegraph.structure.HugeIndex)5 IdHolder (com.baidu.hugegraph.backend.page.IdHolder)4 FixedIdHolder (com.baidu.hugegraph.backend.page.IdHolder.FixedIdHolder)4 PagingIdHolder (com.baidu.hugegraph.backend.page.IdHolder.PagingIdHolder)4 IdQuery (com.baidu.hugegraph.backend.query.IdQuery)4 Query (com.baidu.hugegraph.backend.query.Query)4 SchemaJob (com.baidu.hugegraph.job.schema.SchemaJob)4 SchemaLabel (com.baidu.hugegraph.schema.SchemaLabel)4 VertexLabel (com.baidu.hugegraph.schema.VertexLabel)4 HugeEdge (com.baidu.hugegraph.structure.HugeEdge)4