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);
}
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);
}
}
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);
}
}
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();
}
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;
}
Aggregations