use of com.baidu.hugegraph.schema.PropertyKey in project incubator-hugegraph by apache.
the class SchemaDefine method createPropertyKey.
protected String createPropertyKey(String name, DataType dataType, Cardinality cardinality) {
SchemaManager schema = this.schema();
PropertyKey propertyKey = schema.propertyKey(name).dataType(dataType).cardinality(cardinality).build();
this.graph.schemaTransaction().addPropertyKey(propertyKey);
return name;
}
use of com.baidu.hugegraph.schema.PropertyKey in project incubator-hugegraph by apache.
the class StandardHugeGraph method propertyKey.
@Override
public PropertyKey propertyKey(Id id) {
PropertyKey pk = this.schemaTransaction().getPropertyKey(id);
E.checkArgument(pk != null, "Undefined property key with id: '%s'", id);
return pk;
}
use of com.baidu.hugegraph.schema.PropertyKey in project incubator-hugegraph by apache.
the class StandardHugeGraph method propertyKey.
@Override
public PropertyKey propertyKey(String name) {
PropertyKey pk = this.schemaTransaction().getPropertyKey(name);
E.checkArgument(pk != null, "Undefined property key: '%s'", name);
return pk;
}
use of com.baidu.hugegraph.schema.PropertyKey in project incubator-hugegraph by apache.
the class ServerInfoManager method serverInfos.
private Iterator<HugeServerInfo> serverInfos(Map<String, Object> conditions, long limit, String page) {
return this.call(() -> {
ConditionQuery query = new ConditionQuery(HugeType.VERTEX);
if (page != null) {
query.page(page);
}
HugeGraph graph = this.graph.graph();
VertexLabel vl = graph.vertexLabel(HugeServerInfo.P.SERVER);
query.eq(HugeKeys.LABEL, vl.id());
for (Map.Entry<String, Object> entry : conditions.entrySet()) {
PropertyKey pk = graph.propertyKey(entry.getKey());
query.query(Condition.eq(pk.id(), entry.getValue()));
}
query.showHidden(true);
if (limit != NO_LIMIT) {
query.limit(limit);
}
Iterator<Vertex> vertices = this.tx().queryVertices(query);
Iterator<HugeServerInfo> servers = new MapperIterator<>(vertices, HugeServerInfo::fromVertex);
// Convert iterator to list to avoid across thread tx accessed
return QueryResults.toList(servers);
});
}
use of com.baidu.hugegraph.schema.PropertyKey in project incubator-hugegraph by apache.
the class StandardTaskScheduler method queryTask.
private <V> Iterator<HugeTask<V>> queryTask(Map<String, Object> conditions, long limit, String page) {
return this.call(() -> {
ConditionQuery query = new ConditionQuery(HugeType.VERTEX);
if (page != null) {
query.page(page);
}
VertexLabel vl = this.graph().vertexLabel(P.TASK);
query.eq(HugeKeys.LABEL, vl.id());
for (Map.Entry<String, Object> entry : conditions.entrySet()) {
PropertyKey pk = this.graph().propertyKey(entry.getKey());
query.query(Condition.eq(pk.id(), entry.getValue()));
}
query.showHidden(true);
if (limit != NO_LIMIT) {
query.limit(limit);
}
Iterator<Vertex> vertices = this.tx().queryVertices(query);
Iterator<HugeTask<V>> tasks = new MapperIterator<>(vertices, HugeTask::fromVertex);
// Convert iterator to list to avoid across thread tx accessed
return QueryResults.toList(tasks);
});
}
Aggregations