use of com.baidu.hugegraph.schema.SchemaManager in project incubator-hugegraph by apache.
the class VertexCoreTest method testUpdatePropertyToValueOfRemovedVertexWithUniqueIndex.
@Test
public void testUpdatePropertyToValueOfRemovedVertexWithUniqueIndex() {
SchemaManager schema = graph().schema();
schema.vertexLabel("user").properties("name").create();
schema.indexLabel("userByName").onV("user").by("name").unique().create();
Vertex tom = graph().addVertex(T.label, "user", "name", "Tom");
Vertex jack = graph().addVertex(T.label, "user", "name", "Jack");
Vertex james = graph().addVertex(T.label, "user", "name", "James");
this.commitTx();
tom.remove();
this.commitTx();
jack.property("name", "Tom");
this.commitTx();
james.remove();
jack.property("name", "James");
this.commitTx();
}
use of com.baidu.hugegraph.schema.SchemaManager in project incubator-hugegraph by apache.
the class VertexCoreTest method initComputerIndex.
protected void initComputerIndex() {
SchemaManager schema = graph().schema();
LOG.debug("=============== computer index ================");
schema.indexLabel("pcByBand").onV("computer").secondary().by("band").ifNotExist().create();
schema.indexLabel("pcByCpuAndRamAndBand").onV("computer").secondary().by("cpu", "ram", "band").ifNotExist().create();
}
use of com.baidu.hugegraph.schema.SchemaManager in project incubator-hugegraph by apache.
the class VertexCoreTest method testAddVertexWithAutomaticIdStrategyButPassedId.
@Test
public void testAddVertexWithAutomaticIdStrategyButPassedId() {
HugeGraph graph = graph();
SchemaManager schema = graph.schema();
schema.vertexLabel("programmer").useAutomaticId().properties("name", "age", "city").create();
Assert.assertThrows(IllegalArgumentException.class, () -> {
graph.addVertex(T.label, "programmer", T.id, "123456", "name", "marko", "age", 18, "city", "Beijing");
});
}
use of com.baidu.hugegraph.schema.SchemaManager in project incubator-hugegraph by apache.
the class VertexCoreTest method testAddVertexWithCustomizeStringIdStrategyWithoutValidId.
@Test
public void testAddVertexWithCustomizeStringIdStrategyWithoutValidId() {
HugeGraph graph = graph();
SchemaManager schema = graph.schema();
schema.vertexLabel("programmer").useCustomizeStringId().properties("name", "age", "city").create();
// Expect id, but no id
Assert.assertThrows(IllegalArgumentException.class, () -> {
graph.addVertex(T.label, "programmer", "name", "marko", "age", 18, "city", "Beijing");
});
// Expect string id, but got number id
Assert.assertThrows(IllegalArgumentException.class, () -> {
graph.addVertex(T.label, "programmer", T.id, 123456, "name", "marko", "age", 18, "city", "Beijing");
});
// Expect id length <= 128
Assert.assertThrows(IllegalArgumentException.class, () -> {
String largeId = new String(new byte[128]) + ".";
assert largeId.length() == 129;
graph.addVertex(T.label, "programmer", T.id, largeId, "name", "marko", "age", 18, "city", "Beijing");
});
}
use of com.baidu.hugegraph.schema.SchemaManager in project incubator-hugegraph by apache.
the class VertexCoreTest method testQueryByJointIndexesOnlyWithCompositeIndex.
@Test
public void testQueryByJointIndexesOnlyWithCompositeIndex() {
SchemaManager schema = graph().schema();
schema.vertexLabel("dog").properties("name", "age", "city").nullableKeys("age").create();
schema.indexLabel("dogByNameAndCity").onV("dog").secondary().by("name", "city").create();
schema.indexLabel("dogByCityAndAge").onV("dog").secondary().by("city", "age").create();
graph().addVertex(T.label, "dog", "name", "Tom", "city", "Hongkong", "age", 3);
this.mayCommitTx();
List<Vertex> vertices = graph().traversal().V().has("age", 3).has("city", "Hongkong").has("name", "Tom").toList();
Assert.assertEquals(1, vertices.size());
}
Aggregations