use of com.baidu.hugegraph.schema.VertexLabel in project incubator-hugegraph by apache.
the class HugeGraph method mapVlName2Id.
default Id[] mapVlName2Id(String[] vertexLabels) {
Id[] ids = new Id[vertexLabels.length];
for (int i = 0; i < vertexLabels.length; i++) {
VertexLabel vertexLabel = this.vertexLabel(vertexLabels[i]);
ids[i] = vertexLabel.id();
}
return ids;
}
use of com.baidu.hugegraph.schema.VertexLabel in project incubator-hugegraph by apache.
the class RelationshipManager method newVertex.
private HugeVertex newVertex(Object id, String label) {
VertexLabel vl = this.graph().vertexLabel(label);
Id idValue = HugeVertex.getIdValue(id);
return HugeVertex.create(this.tx(), idValue, vl);
}
use of com.baidu.hugegraph.schema.VertexLabel 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.VertexLabel 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);
});
}
use of com.baidu.hugegraph.schema.VertexLabel in project incubator-hugegraph by apache.
the class IndexLabelBuilder method checkPrimaryKeyIndex.
private void checkPrimaryKeyIndex(SchemaLabel schemaLabel) {
if (schemaLabel instanceof VertexLabel) {
VertexLabel vl = (VertexLabel) schemaLabel;
if (vl.idStrategy().isPrimaryKey()) {
if (this.indexType.isSecondary() || this.indexType.isUnique() || this.indexType.isShard() && this.allStringIndex(this.indexFields)) {
List<String> pks = this.graph().mapPkId2Name(vl.primaryKeys());
E.checkArgument(!this.indexFields.containsAll(pks), "No need to build index on properties " + "%s, because they contains all primary " + "keys %s for vertex label '%s'", this.indexFields, pks, vl.name());
}
}
}
}
Aggregations