use of com.baidu.hugegraph.schema.EdgeLabel in project incubator-hugegraph by apache.
the class TextSerializer method readEdgeLabel.
@Override
public EdgeLabel readEdgeLabel(HugeGraph graph, BackendEntry backendEntry) {
if (backendEntry == null) {
return null;
}
TextBackendEntry entry = this.convertEntry(backendEntry);
Id id = readId(entry.id());
String name = JsonUtil.fromJson(entry.column(HugeKeys.NAME), String.class);
String sourceLabel = entry.column(HugeKeys.SOURCE_LABEL);
String targetLabel = entry.column(HugeKeys.TARGET_LABEL);
String frequency = entry.column(HugeKeys.FREQUENCY);
String sortKeys = entry.column(HugeKeys.SORT_KEYS);
String nullablekeys = entry.column(HugeKeys.NULLABLE_KEYS);
String properties = entry.column(HugeKeys.PROPERTIES);
String indexLabels = entry.column(HugeKeys.INDEX_LABELS);
String enableLabelIndex = entry.column(HugeKeys.ENABLE_LABEL_INDEX);
String status = entry.column(HugeKeys.STATUS);
String ttl = entry.column(HugeKeys.TTL);
String ttlStartTime = entry.column(HugeKeys.TTL_START_TIME);
EdgeLabel edgeLabel = new EdgeLabel(graph, id, name);
edgeLabel.sourceLabel(readId(sourceLabel));
edgeLabel.targetLabel(readId(targetLabel));
edgeLabel.frequency(JsonUtil.fromJson(frequency, Frequency.class));
edgeLabel.properties(readIds(properties));
edgeLabel.sortKeys(readIds(sortKeys));
edgeLabel.nullableKeys(readIds(nullablekeys));
edgeLabel.addIndexLabels(readIds(indexLabels));
edgeLabel.enableLabelIndex(JsonUtil.fromJson(enableLabelIndex, Boolean.class));
readUserdata(edgeLabel, entry);
edgeLabel.status(JsonUtil.fromJson(status, SchemaStatus.class));
edgeLabel.ttl(JsonUtil.fromJson(ttl, Long.class));
edgeLabel.ttlStartTime(readId(ttlStartTime));
return edgeLabel;
}
use of com.baidu.hugegraph.schema.EdgeLabel 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.schema.EdgeLabel in project incubator-hugegraph by apache.
the class EdgeLabelBuilder method create.
@Override
public EdgeLabel create() {
HugeType type = HugeType.EDGE_LABEL;
this.checkSchemaName(this.name);
return this.lockCheckAndCreateSchema(type, this.name, name -> {
EdgeLabel edgeLabel = this.edgeLabelOrNull(this.name);
if (edgeLabel != null) {
if (this.checkExist || !hasSameProperties(edgeLabel)) {
throw new ExistedException(type, this.name);
}
return edgeLabel;
}
this.checkSchemaIdIfRestoringMode(type, this.id);
// These methods will check params and fill to member variables
this.checkRelation();
this.checkProperties(Action.INSERT);
this.checkSortKeys();
this.checkNullableKeys(Action.INSERT);
Userdata.check(this.userdata, Action.INSERT);
this.checkTtl();
this.checkUserdata(Action.INSERT);
edgeLabel = this.build();
assert edgeLabel.name().equals(name);
this.graph().addEdgeLabel(edgeLabel);
return edgeLabel;
});
}
use of com.baidu.hugegraph.schema.EdgeLabel in project incubator-hugegraph by apache.
the class EdgeLabelBuilder method eliminate.
@Override
public EdgeLabel eliminate() {
EdgeLabel edgeLabel = this.edgeLabelOrNull(this.name);
if (edgeLabel == null) {
throw new NotFoundException("Can't update edge 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);
edgeLabel.removeUserdata(this.userdata);
this.graph().addEdgeLabel(edgeLabel);
return edgeLabel;
}
use of com.baidu.hugegraph.schema.EdgeLabel in project incubator-hugegraph by apache.
the class EdgeLabelBuilder method build.
@Override
public EdgeLabel build() {
Id id = this.validOrGenerateId(HugeType.EDGE_LABEL, this.id, this.name);
HugeGraph graph = this.graph();
EdgeLabel edgeLabel = new EdgeLabel(graph, id, this.name);
edgeLabel.sourceLabel(graph.vertexLabel(this.sourceLabel).id());
edgeLabel.targetLabel(graph.vertexLabel(this.targetLabel).id());
edgeLabel.frequency(this.frequency == Frequency.DEFAULT ? Frequency.SINGLE : this.frequency);
edgeLabel.ttl(this.ttl);
if (this.ttlStartTime != null) {
edgeLabel.ttlStartTime(this.graph().propertyKey(this.ttlStartTime).id());
}
edgeLabel.enableLabelIndex(this.enableLabelIndex == null || this.enableLabelIndex);
for (String key : this.properties) {
PropertyKey propertyKey = graph.propertyKey(key);
edgeLabel.property(propertyKey.id());
}
for (String key : this.sortKeys) {
PropertyKey propertyKey = graph.propertyKey(key);
edgeLabel.sortKey(propertyKey.id());
}
for (String key : this.nullableKeys) {
PropertyKey propertyKey = graph.propertyKey(key);
edgeLabel.nullableKey(propertyKey.id());
}
edgeLabel.userdata(this.userdata);
return edgeLabel;
}
Aggregations