use of com.baidu.hugegraph.rest.RestResult in project incubator-hugegraph-toolchain by apache.
the class VertexAPI method list.
public Vertices list(String label, Map<String, Object> properties, boolean keepP, int offset, String page, int limit) {
checkOffset(offset);
checkLimit(limit, "Limit");
String props = GraphAPI.formatProperties(properties);
Map<String, Object> params = new LinkedHashMap<>();
params.put("label", label);
params.put("properties", props);
params.put("keep_start_p", keepP);
params.put("offset", offset);
params.put("limit", limit);
params.put("page", page);
RestResult result = this.client.get(this.path(), params);
return result.readObject(Vertices.class);
}
use of com.baidu.hugegraph.rest.RestResult in project incubator-hugegraph-toolchain by apache.
the class VertexAPI method update.
public List<Vertex> update(BatchVertexRequest request) {
this.client.checkApiVersion("0.45", "batch property update");
MultivaluedHashMap<String, Object> headers = new MultivaluedHashMap<>();
headers.putSingle("Content-Encoding", BATCH_ENCODING);
RestResult result = this.client.put(this.batchPath(), null, request, headers);
return result.readList(this.type(), Vertex.class);
}
use of com.baidu.hugegraph.rest.RestResult in project incubator-hugegraph-toolchain by apache.
the class VertexAPI method eliminate.
public Vertex eliminate(Vertex vertex) {
String id = GraphAPI.formatVertexId(vertex.id());
Map<String, Object> params = ImmutableMap.of("action", "eliminate");
RestResult result = this.client.put(this.path(), id, vertex, params);
return result.readObject(Vertex.class);
}
use of com.baidu.hugegraph.rest.RestResult in project incubator-hugegraph-toolchain by apache.
the class VertexAPI method create.
public List<Object> create(List<Vertex> vertices) {
MultivaluedHashMap<String, Object> headers = new MultivaluedHashMap<>();
headers.putSingle("Content-Encoding", BATCH_ENCODING);
RestResult result = this.client.post(this.batchPath(), vertices, headers);
List<Object> ids = result.readList(Object.class);
if (vertices.size() != ids.size()) {
throw new NotAllCreatedException("Not all vertices are successfully created, " + "expect '%s', the actual is '%s'", ids, vertices.size(), ids.size());
}
return ids;
}
use of com.baidu.hugegraph.rest.RestResult in project incubator-hugegraph-toolchain by apache.
the class VertexAPI method update.
public int update(BatchOlapPropertyRequest request) {
this.client.checkApiVersion("0.59", "olap property batch update");
MultivaluedHashMap<String, Object> headers = new MultivaluedHashMap<>();
headers.putSingle("Content-Encoding", BATCH_ENCODING);
String path = String.join("/", this.path(), "olap/batch");
RestResult result = this.client.put(path, null, request, headers);
Object size = result.readObject(Map.class).get("size");
if (!(size instanceof Integer)) {
throw new InvalidResponseException("The 'size' in response must be int, but got: %s(%s)", size, size.getClass());
}
return (int) size;
}
Aggregations