use of com.baidu.hugegraph.exception.NotFoundException in project incubator-hugegraph by apache.
the class EdgeLabelBuilder method eliminate.
@Override
public EdgeLabel eliminate() {
EdgeLabel edgeLabel = this.edgeLabelOrNull(this.name);
if (edgeLabel == null) {
throw new NotFoundException("Can't update edge label '%s' " + "since it doesn't exist", this.name);
}
// Only allowed to eliminate user data
this.checkStableVars();
this.checkProperties(Action.ELIMINATE);
this.checkNullableKeys(Action.ELIMINATE);
Userdata.check(this.userdata, Action.ELIMINATE);
edgeLabel.removeUserdata(this.userdata);
this.graph().addEdgeLabel(edgeLabel);
return edgeLabel;
}
use of com.baidu.hugegraph.exception.NotFoundException in project incubator-hugegraph by apache.
the class PropertyKeyBuilder method append.
@Override
public PropertyKey append() {
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.APPEND);
propertyKey.userdata(this.userdata);
this.graph().addPropertyKey(propertyKey);
return propertyKey;
}
use of com.baidu.hugegraph.exception.NotFoundException 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.exception.NotFoundException in project incubator-hugegraph by apache.
the class VertexLabelBuilder method eliminate.
@Override
public VertexLabel eliminate() {
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);
}
// Only allowed to eliminate user data
this.checkStableVars();
this.checkProperties(Action.ELIMINATE);
this.checkNullableKeys(Action.ELIMINATE);
Userdata.check(this.userdata, Action.ELIMINATE);
vertexLabel.removeUserdata(this.userdata);
this.graph().addVertexLabel(vertexLabel);
return vertexLabel;
}
use of com.baidu.hugegraph.exception.NotFoundException in project incubator-hugegraph by apache.
the class MysqlTable method queryId2Select.
protected List<StringBuilder> queryId2Select(Query query, StringBuilder select) {
// Query by id(s)
if (query.idsSize() == 0) {
return ImmutableList.of(select);
}
List<HugeKeys> nameParts = this.idColumnName();
List<List<Object>> ids = new ArrayList<>(query.idsSize());
for (Id id : query.ids()) {
List<Object> idParts = this.idColumnValue(id);
if (nameParts.size() != idParts.size()) {
throw new NotFoundException("Unsupported ID format: '%s' (should contain %s)", id, nameParts);
}
ids.add(idParts);
}
// Query only by partition-key
if (nameParts.size() == 1) {
List<Object> values = new ArrayList<>(ids.size());
for (List<Object> objects : ids) {
assert objects.size() == 1;
values.add(objects.get(0));
}
WhereBuilder where = this.newWhereBuilder();
where.in(formatKey(nameParts.get(0)), values);
select.append(where.build());
return ImmutableList.of(select);
}
/*
* Query by partition-key + clustering-key
* NOTE: Error if multi-column IN clause include partition key:
* error: multi-column relations can only be applied to clustering
* columns when using: select.where(QueryBuilder.in(names, idList));
* So we use multi-query instead of IN
*/
List<StringBuilder> selections = new ArrayList<>(ids.size());
for (List<Object> objects : ids) {
assert nameParts.size() == objects.size();
StringBuilder idSelection = new StringBuilder(select);
/*
* NOTE: concat with AND relation, like:
* "pk = id and ck1 = v1 and ck2 = v2"
*/
WhereBuilder where = this.newWhereBuilder();
where.and(formatKeys(nameParts), objects);
idSelection.append(where.build());
selections.add(idSelection);
}
return selections;
}
Aggregations