use of com.baidu.hugegraph.schema.IndexLabel in project incubator-hugegraph by apache.
the class IndexLabelCoreTest method testAddIndexLabelWithUserdata.
@Test
public void testAddIndexLabelWithUserdata() {
super.initPropertyKeys();
SchemaManager schema = graph().schema();
schema.vertexLabel("person").properties("id", "name", "age", "city").primaryKeys("id").create();
IndexLabel personByName = schema.indexLabel("personByName").onV("person").secondary().by("name").userdata("min", 0).userdata("max", 100).create();
Assert.assertEquals(3, personByName.userdata().size());
Assert.assertEquals(0, personByName.userdata().get("min"));
Assert.assertEquals(100, personByName.userdata().get("max"));
IndexLabel personByAge = schema.indexLabel("personByAge").onV("person").range().by("age").userdata("length", 15).userdata("length", 18).create();
// The same key user data will be overwritten
Assert.assertEquals(2, personByAge.userdata().size());
Assert.assertEquals(18, personByAge.userdata().get("length"));
List<Object> datas = ImmutableList.of("Beijing", "Shanghai");
IndexLabel personByCity = schema.indexLabel("personByCity").onV("person").secondary().by("city").userdata("range", datas).create();
Assert.assertEquals(2, personByCity.userdata().size());
Assert.assertEquals(datas, personByCity.userdata().get("range"));
}
use of com.baidu.hugegraph.schema.IndexLabel in project incubator-hugegraph by apache.
the class IndexLabelCoreTest method testCreateTime.
@Test
public void testCreateTime() {
super.initPropertyKeys();
SchemaManager schema = graph().schema();
schema.vertexLabel("person").properties("id", "name", "age", "city").primaryKeys("id").create();
IndexLabel personByName = schema.indexLabel("personByName").onV("person").secondary().by("name").create();
Date createTime = (Date) personByName.userdata().get(Userdata.CREATE_TIME);
Date now = DateUtil.now();
Assert.assertFalse(createTime.after(now));
personByName = schema.getIndexLabel("personByName");
createTime = (Date) personByName.userdata().get(Userdata.CREATE_TIME);
Assert.assertFalse(createTime.after(now));
}
use of com.baidu.hugegraph.schema.IndexLabel in project incubator-hugegraph by apache.
the class FakeObjects method newIndexLabel.
public IndexLabel newIndexLabel(Id id, String name, HugeType baseType, Id baseValue, IndexType indexType, Id... fields) {
IndexLabel schema = new IndexLabel(this.graph, id, name);
schema.baseType(baseType);
schema.baseValue(baseValue);
schema.indexType(indexType);
schema.indexFields(fields);
Mockito.when(this.graph.indexLabel(id)).thenReturn(schema);
return schema;
}
Aggregations