use of com.baidu.hugegraph.schema.PropertyKey in project incubator-hugegraph by apache.
the class PropertyKeyBuilder method eliminate.
@Override
public PropertyKey eliminate() {
PropertyKey propertyKey = this.propertyKeyOrNull(this.name);
if (propertyKey == null) {
throw new NotFoundException("Can't update property key '%s' " + "since it doesn't exist", this.name);
}
this.checkStableVars();
Userdata.check(this.userdata, Action.ELIMINATE);
propertyKey.removeUserdata(this.userdata);
this.graph().addPropertyKey(propertyKey);
return propertyKey;
}
use of com.baidu.hugegraph.schema.PropertyKey in project incubator-hugegraph by apache.
the class VertexLabelBuilder method checkTtl.
private void checkTtl() {
E.checkArgument(this.ttl >= 0, "The ttl must be >= 0, but got: %s", this.ttl);
if (this.ttl == 0L) {
E.checkArgument(this.ttlStartTime == null, "Can't set ttl start time if ttl is not set");
return;
}
if (this.ttlStartTime == null) {
return;
}
// Check whether the properties contains the specified keys
E.checkArgument(!this.properties.isEmpty(), "The properties can't be empty when exist " + "ttl start time for edge label '%s'", this.name);
E.checkArgument(this.properties.contains(this.ttlStartTime), "The ttl start time '%s' must be contained in " + "properties '%s' for vertex label '%s'", this.ttlStartTime, this.name, this.properties);
PropertyKey pkey = this.graph().propertyKey(this.ttlStartTime);
E.checkArgument(pkey.dataType().isDate(), "The ttl start time property must be date type," + "but got '%s(%s)'", this.ttlStartTime, pkey.dataType());
}
use of com.baidu.hugegraph.schema.PropertyKey in project incubator-hugegraph by apache.
the class VertexLabelBuilder method build.
@Override
public VertexLabel build() {
Id id = this.validOrGenerateId(HugeType.VERTEX_LABEL, this.id, this.name);
VertexLabel vertexLabel = new VertexLabel(this.graph(), id, this.name);
vertexLabel.idStrategy(this.idStrategy);
vertexLabel.enableLabelIndex(this.enableLabelIndex == null || this.enableLabelIndex);
vertexLabel.ttl(this.ttl);
if (this.ttlStartTime != null) {
vertexLabel.ttlStartTime(this.graph().propertyKey(this.ttlStartTime).id());
}
// Assign properties
for (String key : this.properties) {
PropertyKey propertyKey = this.graph().propertyKey(key);
vertexLabel.property(propertyKey.id());
}
for (String key : this.primaryKeys) {
PropertyKey propertyKey = this.graph().propertyKey(key);
vertexLabel.primaryKey(propertyKey.id());
}
for (String key : this.nullableKeys) {
PropertyKey propertyKey = this.graph().propertyKey(key);
vertexLabel.nullableKey(propertyKey.id());
}
vertexLabel.userdata(this.userdata);
return vertexLabel;
}
use of com.baidu.hugegraph.schema.PropertyKey in project incubator-hugegraph by apache.
the class HugeElement method setProperty.
@Watched(prefix = "element")
public <V> HugeProperty<?> setProperty(HugeProperty<V> prop) {
if (this.properties == EMPTY_MAP) {
this.properties = CollectionFactory.newIntObjectMap();
}
PropertyKey pkey = prop.propertyKey();
E.checkArgument(this.properties.containsKey(intFromId(pkey.id())) || this.properties.size() < MAX_PROPERTIES, "Exceeded the maximum number of properties");
return this.properties.put(intFromId(pkey.id()), prop);
}
use of com.baidu.hugegraph.schema.PropertyKey in project incubator-hugegraph by apache.
the class HugeElement method updateToDefaultValueIfNone.
protected void updateToDefaultValueIfNone() {
if (this.fresh() || this.defaultValueUpdated) {
return;
}
this.defaultValueUpdated = true;
// Set default value if needed
for (Id pkeyId : this.schemaLabel().properties()) {
if (this.properties.containsKey(intFromId(pkeyId))) {
continue;
}
PropertyKey pkey = this.graph().propertyKey(pkeyId);
Object value = pkey.defaultValue();
if (value != null) {
this.setProperty(this.newProperty(pkey, value));
}
}
this.defaultValueUpdated = true;
}
Aggregations