use of com.baidu.hugegraph.schema.PropertyKey in project incubator-hugegraph by apache.
the class StandardHugeGraph method serverStarted.
@Override
public void serverStarted(Id serverId, NodeRole serverRole) {
LOG.info("Init server info [{}-{}] for graph '{}'...", serverId, serverRole, this.name);
this.serverInfoManager().initServerInfo(serverId, serverRole);
// TODO: check necessary?
LOG.info("Check olap property-key tables for graph '{}'", this.name);
for (PropertyKey pk : this.schemaTransaction().getPropertyKeys()) {
if (pk.olap()) {
this.graphTransaction().initAndRegisterOlapTable(pk.id());
}
}
LOG.info("Restoring incomplete tasks for graph '{}'...", this.name);
this.taskScheduler().restoreTasks();
this.started = true;
}
use of com.baidu.hugegraph.schema.PropertyKey in project incubator-hugegraph by apache.
the class HugeGraph method mapPkName2Id.
default List<Id> mapPkName2Id(Collection<String> pkeys) {
List<Id> ids = new ArrayList<>(pkeys.size());
for (String pkey : pkeys) {
PropertyKey propertyKey = this.propertyKey(pkey);
ids.add(propertyKey.id());
}
return ids;
}
use of com.baidu.hugegraph.schema.PropertyKey in project incubator-hugegraph by apache.
the class EntityManager method queryEntity.
private Iterator<Vertex> queryEntity(String label, Map<String, Object> conditions, long limit) {
ConditionQuery query = new ConditionQuery(HugeType.VERTEX);
VertexLabel vl = this.graph().vertexLabel(label);
query.eq(HugeKeys.LABEL, vl.id());
for (Map.Entry<String, Object> entry : conditions.entrySet()) {
PropertyKey pkey = this.graph().propertyKey(entry.getKey());
query.query(Condition.eq(pkey.id(), entry.getValue()));
}
query.showHidden(true);
if (limit != NO_LIMIT) {
query.limit(limit);
}
return this.tx().queryVertices(query);
}
use of com.baidu.hugegraph.schema.PropertyKey in project incubator-hugegraph by apache.
the class RelationshipManager method queryRelationship.
private Iterator<Edge> queryRelationship(Id source, Directions direction, String label, Map<String, Object> conditions, long limit) {
ConditionQuery query = new ConditionQuery(HugeType.EDGE);
EdgeLabel el = this.graph().edgeLabel(label);
if (direction == null) {
direction = Directions.OUT;
}
if (source != null) {
query.eq(HugeKeys.OWNER_VERTEX, source);
query.eq(HugeKeys.DIRECTION, direction);
}
if (label != null) {
query.eq(HugeKeys.LABEL, el.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<Edge> edges = this.tx().queryEdges(query);
if (limit == NO_LIMIT) {
return edges;
}
long[] size = new long[1];
return new MapperIterator<>(edges, edge -> {
if (++size[0] > limit) {
return null;
}
return edge;
});
}
use of com.baidu.hugegraph.schema.PropertyKey in project incubator-hugegraph by apache.
the class TableSerializer method parseProperty.
protected void parseProperty(Id key, Object colValue, HugeElement owner) {
// Get PropertyKey by PropertyKey id
PropertyKey pkey = owner.graph().propertyKey(key);
// Parse value
Object value = this.readProperty(pkey, colValue);
// Set properties of vertex/edge
if (pkey.cardinality() == Cardinality.SINGLE) {
owner.addProperty(pkey, value);
} else {
if (!(value instanceof Collection)) {
throw new BackendException("Invalid value of non-single property: %s", value);
}
owner.addProperty(pkey, value);
}
}
Aggregations