use of com.baidu.hugegraph.structure.schema.PropertyKey in project incubator-hugegraph-toolchain by apache.
the class ElementBuilder method convertPropertyValue.
private Object convertPropertyValue(String key, Object rawValue) {
PropertyKey propertyKey = this.getPropertyKey(key);
InputSource inputSource = this.struct.input();
return DataTypeUtil.convert(rawValue, propertyKey, inputSource);
}
use of com.baidu.hugegraph.structure.schema.PropertyKey in project incubator-hugegraph-toolchain by apache.
the class PropertyKeyAPI method append.
public PropertyKey.PropertyKeyWithTask append(PropertyKey propertyKey) {
String id = propertyKey.name();
Map<String, Object> params = ImmutableMap.of("action", "append");
Object pkey = this.checkCreateOrUpdate(propertyKey);
RestResult result = this.client.put(this.path(), id, pkey, params);
return result.readObject(PropertyKey.PropertyKeyWithTask.class);
}
use of com.baidu.hugegraph.structure.schema.PropertyKey in project incubator-hugegraph-toolchain by apache.
the class PropertyKeyAPI method eliminate.
public PropertyKey.PropertyKeyWithTask eliminate(PropertyKey propertyKey) {
String id = propertyKey.name();
Map<String, Object> params = ImmutableMap.of("action", "eliminate");
Object pkey = this.checkCreateOrUpdate(propertyKey);
RestResult result = this.client.put(this.path(), id, pkey, params);
return result.readObject(PropertyKey.PropertyKeyWithTask.class);
}
use of com.baidu.hugegraph.structure.schema.PropertyKey in project incubator-hugegraph-toolchain by apache.
the class PropertyKeyAPI method clear.
public PropertyKey.PropertyKeyWithTask clear(PropertyKey propertyKey) {
if (this.client.apiVersionLt("0.65")) {
throw new NotSupportException("action clear on property key");
}
String id = propertyKey.name();
Map<String, Object> params = ImmutableMap.of("action", "clear");
Object pkey = this.checkCreateOrUpdate(propertyKey);
RestResult result = this.client.put(this.path(), id, pkey, params);
return result.readObject(PropertyKey.PropertyKeyWithTask.class);
}
use of com.baidu.hugegraph.structure.schema.PropertyKey in project incubator-hugegraph-toolchain by apache.
the class FileLoadTest method testAutoCreateSchema.
/**
* NOTE: Unsupport auto create schema
*/
// @Test
public void testAutoCreateSchema() {
String[] args = new String[] { "-f", "example/struct.json", "-g", GRAPH, "-h", SERVER, "--batch-insert-threads", "2" };
HugeGraphLoader.main(args);
List<PropertyKey> propertyKeys = CLIENT.schema().getPropertyKeys();
propertyKeys.forEach(pkey -> {
Assert.assertEquals(DataType.TEXT, pkey.dataType());
});
List<Vertex> vertices = CLIENT.graph().listVertices();
List<Edge> edges = CLIENT.graph().listEdges();
Assert.assertEquals(7, vertices.size());
Assert.assertEquals(6, edges.size());
boolean interestedVertex = false;
for (Vertex vertex : vertices) {
Assert.assertEquals(String.class, vertex.id().getClass());
if (((String) vertex.id()).contains("li,nary")) {
interestedVertex = true;
Assert.assertEquals("26", vertex.property("age"));
Assert.assertEquals("Wu,han", vertex.property("city"));
}
}
Assert.assertTrue(interestedVertex);
boolean interestedEdge = false;
for (Edge edge : edges) {
Assert.assertEquals(String.class, edge.sourceId().getClass());
Assert.assertEquals(String.class, edge.targetId().getClass());
if (((String) edge.sourceId()).contains("marko") && ((String) edge.targetId()).contains("vadas")) {
interestedEdge = true;
Assert.assertEquals("20160110", edge.property("date"));
Assert.assertEquals("0.5", edge.property("weight"));
}
}
Assert.assertTrue(interestedEdge);
}
Aggregations