use of com.baidu.hugegraph.schema.PropertyKey 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.PropertyKey in project incubator-hugegraph by apache.
the class VertexLabelBuilder method hasSameProperties.
/**
* Check whether this has same properties with existedVertexLabel.
* Only properties, primaryKeys, nullableKeys, enableLabelIndex are checked.
* The id, idStrategy, checkExist, userdata are not checked.
* @param existedVertexLabel to be compared with
* @return true if this has same properties with existedVertexLabel
*/
private boolean hasSameProperties(VertexLabel existedVertexLabel) {
HugeGraph graph = this.graph();
Set<Id> existedProperties = existedVertexLabel.properties();
if (this.properties.size() != existedProperties.size()) {
return false;
}
for (String propertyName : this.properties) {
PropertyKey propertyKey = graph.propertyKey(propertyName);
if (!existedProperties.contains(propertyKey.id())) {
return false;
}
}
List<Id> existedPrimaryKeys = existedVertexLabel.primaryKeys();
if (this.primaryKeys.size() != existedPrimaryKeys.size()) {
return false;
}
for (String primaryKeyName : this.primaryKeys) {
PropertyKey primaryKey = graph.propertyKey(primaryKeyName);
if (!existedPrimaryKeys.contains(primaryKey.id())) {
return false;
}
}
Set<Id> existedNullableKeys = existedVertexLabel.nullableKeys();
if (this.nullableKeys.size() != existedNullableKeys.size()) {
return false;
}
for (String nullableKeyName : this.nullableKeys) {
PropertyKey nullableKey = graph.propertyKey(nullableKeyName);
if (!existedNullableKeys.contains(nullableKey.id())) {
return false;
}
}
// this.enableLabelIndex == null, it means true.
if (this.enableLabelIndex == null || this.enableLabelIndex) {
return existedVertexLabel.enableLabelIndex();
} else {
// this.enableLabelIndex is false
return !existedVertexLabel.enableLabelIndex();
}
}
use of com.baidu.hugegraph.schema.PropertyKey in project incubator-hugegraph by apache.
the class OlapPropertyKeyRemoveJob method execute.
@Override
public Object execute() {
Id olap = this.schemaId();
// Remove olap data table
this.params().graphTransaction().removeOlapPk(olap);
// Remove corresponding index label and index data
Id indexLabel = findOlapIndexLabel(this.params(), olap);
if (indexLabel != null) {
removeIndexLabel(this.params(), indexLabel);
}
// Remove olap property key
SchemaTransaction schemaTx = this.params().schemaTransaction();
PropertyKey propertyKey = schemaTx.getPropertyKey(olap);
removeSchema(schemaTx, propertyKey);
return null;
}
use of com.baidu.hugegraph.schema.PropertyKey in project incubator-hugegraph by apache.
the class TraversalUtil method transProperties.
public static Map<Id, Object> transProperties(HugeGraph graph, Map<String, Object> props) {
Map<Id, Object> pks = new HashMap<>(props.size());
for (Map.Entry<String, Object> e : props.entrySet()) {
PropertyKey pk = graph.propertyKey(e.getKey());
pks.put(pk.id(), e.getValue());
}
return pks;
}
use of com.baidu.hugegraph.schema.PropertyKey in project incubator-hugegraph by apache.
the class TraversalUtil method convCompare2UserpropRelation.
private static Relation convCompare2UserpropRelation(HugeGraph graph, HugeType type, HasContainer has) {
BiPredicate<?, ?> bp = has.getPredicate().getBiPredicate();
assert bp instanceof Compare;
String key = has.getKey();
PropertyKey pkey = graph.propertyKey(key);
Id pkeyId = pkey.id();
Object value = validPropertyValue(has.getValue(), pkey);
switch((Compare) bp) {
case eq:
return Condition.eq(pkeyId, value);
case gt:
return Condition.gt(pkeyId, value);
case gte:
return Condition.gte(pkeyId, value);
case lt:
return Condition.lt(pkeyId, value);
case lte:
return Condition.lte(pkeyId, value);
case neq:
return Condition.neq(pkeyId, value);
default:
throw newUnsupportedPredicate(has.getPredicate());
}
}
Aggregations