use of com.baidu.hugegraph.schema.VertexLabel in project incubator-hugegraph by apache.
the class HugeVertexProperty method remove.
@Override
public void remove() {
assert this.owner instanceof HugeVertex;
VertexLabel vertexLabel = ((HugeVertex) this.owner).schemaLabel();
E.checkArgument(vertexLabel.nullableKeys().contains(this.propertyKey().id()), "Can't remove non-null vertex property '%s'", this);
this.owner.graph().removeVertexProperty(this);
}
use of com.baidu.hugegraph.schema.VertexLabel in project incubator-hugegraph by apache.
the class HugeEdge method constructEdge.
@Watched
public static HugeEdge constructEdge(HugeVertex ownerVertex, boolean isOutEdge, EdgeLabel edgeLabel, String sortValues, Id otherVertexId) {
HugeGraph graph = ownerVertex.graph();
VertexLabel srcLabel = graph.vertexLabelOrNone(edgeLabel.sourceLabel());
VertexLabel tgtLabel = graph.vertexLabelOrNone(edgeLabel.targetLabel());
VertexLabel otherVertexLabel;
if (isOutEdge) {
ownerVertex.correctVertexLabel(srcLabel);
otherVertexLabel = tgtLabel;
} else {
ownerVertex.correctVertexLabel(tgtLabel);
otherVertexLabel = srcLabel;
}
HugeVertex otherVertex = new HugeVertex(graph, otherVertexId, otherVertexLabel);
ownerVertex.propNotLoaded();
otherVertex.propNotLoaded();
HugeEdge edge = new HugeEdge(graph, null, edgeLabel);
edge.name(sortValues);
edge.vertices(isOutEdge, ownerVertex, otherVertex);
edge.assignId();
if (isOutEdge) {
ownerVertex.addOutEdge(edge);
otherVertex.addInEdge(edge.switchOwner());
} else {
ownerVertex.addInEdge(edge);
otherVertex.addOutEdge(edge.switchOwner());
}
return edge;
}
use of com.baidu.hugegraph.schema.VertexLabel in project incubator-hugegraph by apache.
the class VertexLabelBuilder method append.
@Override
public VertexLabel append() {
VertexLabel vertexLabel = this.vertexLabelOrNull(this.name);
if (vertexLabel == null) {
throw new NotFoundException("Can't update vertex label '%s' " + "since it doesn't exist", this.name);
}
this.checkStableVars();
this.checkProperties(Action.APPEND);
this.checkNullableKeys(Action.APPEND);
Userdata.check(this.userdata, Action.APPEND);
for (String key : this.properties) {
PropertyKey propertyKey = this.graph().propertyKey(key);
vertexLabel.property(propertyKey.id());
}
for (String key : this.nullableKeys) {
PropertyKey propertyKey = this.graph().propertyKey(key);
vertexLabel.nullableKey(propertyKey.id());
}
vertexLabel.userdata(this.userdata);
this.graph().addVertexLabel(vertexLabel);
return vertexLabel;
}
use of com.baidu.hugegraph.schema.VertexLabel in project incubator-hugegraph by apache.
the class VertexLabelBuilder method create.
@Override
public VertexLabel create() {
HugeType type = HugeType.VERTEX_LABEL;
this.checkSchemaName(this.name);
return this.lockCheckAndCreateSchema(type, this.name, name -> {
VertexLabel vertexLabel = this.vertexLabelOrNull(name);
if (vertexLabel != null) {
if (this.checkExist || !hasSameProperties(vertexLabel)) {
throw new ExistedException(type, name);
}
return vertexLabel;
}
this.checkSchemaIdIfRestoringMode(type, this.id);
this.checkProperties(Action.INSERT);
this.checkIdStrategy();
this.checkNullableKeys(Action.INSERT);
Userdata.check(this.userdata, Action.INSERT);
this.checkTtl();
this.checkUserdata(Action.INSERT);
vertexLabel = this.build();
assert vertexLabel.name().equals(name);
this.graph().addVertexLabel(vertexLabel);
return vertexLabel;
});
}
use of com.baidu.hugegraph.schema.VertexLabel in project incubator-hugegraph by apache.
the class VertexLabelBuilder method eliminate.
@Override
public VertexLabel eliminate() {
VertexLabel vertexLabel = this.vertexLabelOrNull(this.name);
if (vertexLabel == null) {
throw new NotFoundException("Can't update vertex label '%s' " + "since it doesn't exist", this.name);
}
// Only allowed to eliminate user data
this.checkStableVars();
this.checkProperties(Action.ELIMINATE);
this.checkNullableKeys(Action.ELIMINATE);
Userdata.check(this.userdata, Action.ELIMINATE);
vertexLabel.removeUserdata(this.userdata);
this.graph().addVertexLabel(vertexLabel);
return vertexLabel;
}
Aggregations