Search in sources :

Example 1 with PropertyKey

use of com.baidu.hugegraph.structure.schema.PropertyKey in project incubator-hugegraph-toolchain by apache.

the class PropertyKeyApiTest method testClearOlapPropertyKey.

@Test
public void testClearOlapPropertyKey() {
    PropertyKey pagerank = schema().propertyKey("pagerank").asDouble().writeType(WriteType.OLAP_RANGE).build();
    PropertyKey.PropertyKeyWithTask propertyKeyWithTask;
    propertyKeyWithTask = propertyKeyAPI.create(pagerank);
    long taskId = propertyKeyWithTask.taskId();
    Assert.assertNotEquals(0L, taskId);
    waitUntilTaskCompleted(taskId);
    pagerank = propertyKeyWithTask.propertyKey();
    Assert.assertEquals("pagerank", pagerank.name());
    Assert.assertEquals(WriteType.OLAP_RANGE, pagerank.writeType());
    Assert.assertEquals(DataType.DOUBLE, pagerank.dataType());
    propertyKeyWithTask = propertyKeyAPI.clear(pagerank);
    taskId = propertyKeyWithTask.taskId();
    Assert.assertNotEquals(0L, taskId);
    waitUntilTaskCompleted(taskId);
    pagerank = propertyKeyWithTask.propertyKey();
    Assert.assertEquals("pagerank", pagerank.name());
    Assert.assertEquals(WriteType.OLAP_RANGE, pagerank.writeType());
    Assert.assertEquals(DataType.DOUBLE, pagerank.dataType());
    pagerank = propertyKeyAPI.get("pagerank");
    Assert.assertEquals("pagerank", pagerank.name());
    Assert.assertEquals(WriteType.OLAP_RANGE, pagerank.writeType());
    Assert.assertEquals(DataType.DOUBLE, pagerank.dataType());
}
Also used : PropertyKey(com.baidu.hugegraph.structure.schema.PropertyKey) Test(org.junit.Test)

Example 2 with PropertyKey

use of com.baidu.hugegraph.structure.schema.PropertyKey in project incubator-hugegraph-toolchain by apache.

the class PropertyKeyApiTest method testCreateWithAggregateType.

@Test
public void testCreateWithAggregateType() {
    PropertyKey propertyKey = schema().propertyKey("name").asText().valueSingle().build();
    PropertyKey.PropertyKeyWithTask propertyKeyWithTask;
    propertyKeyWithTask = propertyKeyAPI.create(propertyKey);
    Assert.assertEquals(0L, propertyKeyWithTask.taskId());
    propertyKey = propertyKeyWithTask.propertyKey();
    Assert.assertEquals("name", propertyKey.name());
    Assert.assertEquals(DataType.TEXT, propertyKey.dataType());
    Assert.assertEquals(Cardinality.SINGLE, propertyKey.cardinality());
    Assert.assertEquals(AggregateType.NONE, propertyKey.aggregateType());
    Assert.assertTrue(propertyKey.aggregateType().isNone());
    Assert.assertFalse(propertyKey.aggregateType().isNumber());
    Assert.assertTrue(propertyKey.aggregateType().isIndexable());
    propertyKey = schema().propertyKey("no").asText().valueSingle().calcOld().build();
    propertyKeyWithTask = propertyKeyAPI.create(propertyKey);
    Assert.assertEquals(0L, propertyKeyWithTask.taskId());
    propertyKey = propertyKeyWithTask.propertyKey();
    Assert.assertEquals("no", propertyKey.name());
    Assert.assertEquals(DataType.TEXT, propertyKey.dataType());
    Assert.assertEquals(Cardinality.SINGLE, propertyKey.cardinality());
    Assert.assertEquals(AggregateType.OLD, propertyKey.aggregateType());
    Assert.assertTrue(propertyKey.aggregateType().isOld());
    Assert.assertTrue(propertyKey.aggregateType().isIndexable());
    Assert.assertFalse(propertyKey.aggregateType().isNumber());
    propertyKey = schema().propertyKey("max").asInt().valueSingle().calcMax().build();
    propertyKeyWithTask = propertyKeyAPI.create(propertyKey);
    Assert.assertEquals(0L, propertyKeyWithTask.taskId());
    propertyKey = propertyKeyWithTask.propertyKey();
    Assert.assertEquals("max", propertyKey.name());
    Assert.assertEquals(DataType.INT, propertyKey.dataType());
    Assert.assertEquals(Cardinality.SINGLE, propertyKey.cardinality());
    Assert.assertEquals(AggregateType.MAX, propertyKey.aggregateType());
    Assert.assertTrue(propertyKey.aggregateType().isMax());
    Assert.assertTrue(propertyKey.aggregateType().isIndexable());
    Assert.assertTrue(propertyKey.aggregateType().isNumber());
    propertyKey = schema().propertyKey("min").asInt().valueSingle().calcMin().build();
    propertyKeyWithTask = propertyKeyAPI.create(propertyKey);
    Assert.assertEquals(0L, propertyKeyWithTask.taskId());
    propertyKey = propertyKeyWithTask.propertyKey();
    Assert.assertEquals("min", propertyKey.name());
    Assert.assertEquals(DataType.INT, propertyKey.dataType());
    Assert.assertEquals(Cardinality.SINGLE, propertyKey.cardinality());
    Assert.assertEquals(AggregateType.MIN, propertyKey.aggregateType());
    Assert.assertTrue(propertyKey.aggregateType().isMin());
    Assert.assertTrue(propertyKey.aggregateType().isIndexable());
    Assert.assertTrue(propertyKey.aggregateType().isNumber());
    propertyKey = schema().propertyKey("sum").asInt().valueSingle().calcSum().build();
    propertyKeyWithTask = propertyKeyAPI.create(propertyKey);
    Assert.assertEquals(0L, propertyKeyWithTask.taskId());
    propertyKey = propertyKeyWithTask.propertyKey();
    Assert.assertEquals("sum", propertyKey.name());
    Assert.assertEquals(DataType.INT, propertyKey.dataType());
    Assert.assertEquals(Cardinality.SINGLE, propertyKey.cardinality());
    Assert.assertEquals(AggregateType.SUM, propertyKey.aggregateType());
    Assert.assertTrue(propertyKey.aggregateType().isSum());
    Assert.assertFalse(propertyKey.aggregateType().isIndexable());
    Assert.assertTrue(propertyKey.aggregateType().isNumber());
    propertyKey = schema().propertyKey("total").asInt().valueSingle().aggregateType(AggregateType.SUM).build();
    propertyKeyWithTask = propertyKeyAPI.create(propertyKey);
    Assert.assertEquals(0L, propertyKeyWithTask.taskId());
    propertyKey = propertyKeyWithTask.propertyKey();
    Assert.assertEquals("total", propertyKey.name());
    Assert.assertEquals(DataType.INT, propertyKey.dataType());
    Assert.assertEquals(Cardinality.SINGLE, propertyKey.cardinality());
    Assert.assertEquals(AggregateType.SUM, propertyKey.aggregateType());
    Assert.assertTrue(propertyKey.aggregateType().isSum());
    Assert.assertFalse(propertyKey.aggregateType().isIndexable());
    Assert.assertTrue(propertyKey.aggregateType().isNumber());
    propertyKey = schema().propertyKey("nameV46").asText().valueSingle().build();
    PropertyKey.PropertyKeyV46 pk = propertyKey.switchV46();
    Assert.assertEquals("nameV46", pk.name());
    Assert.assertEquals(DataType.TEXT, pk.dataType());
    Assert.assertEquals(Cardinality.SINGLE, pk.cardinality());
    propertyKey = schema().propertyKey("nameV58").asText().valueSingle().calcOld().build();
    PropertyKey.PropertyKeyV58 pk1 = propertyKey.switchV58();
    Assert.assertEquals("nameV58", pk1.name());
    Assert.assertEquals(DataType.TEXT, pk1.dataType());
    Assert.assertEquals(Cardinality.SINGLE, pk1.cardinality());
    Assert.assertEquals(AggregateType.OLD, pk1.aggregateType());
}
Also used : PropertyKey(com.baidu.hugegraph.structure.schema.PropertyKey) Test(org.junit.Test)

Example 3 with PropertyKey

use of com.baidu.hugegraph.structure.schema.PropertyKey in project incubator-hugegraph-toolchain by apache.

the class PropertyKeyApiTest method testListByNames.

@Test
public void testListByNames() {
    PropertyKey name = schema().propertyKey("name").asText().build();
    PropertyKey.PropertyKeyWithTask propertyKeyWithTask;
    propertyKeyWithTask = propertyKeyAPI.create(name);
    Assert.assertEquals(0L, propertyKeyWithTask.taskId());
    name = propertyKeyWithTask.propertyKey();
    PropertyKey age = schema().propertyKey("age").asInt().build();
    propertyKeyWithTask = propertyKeyAPI.create(age);
    Assert.assertEquals(0L, propertyKeyWithTask.taskId());
    age = propertyKeyWithTask.propertyKey();
    List<PropertyKey> propertyKeys;
    propertyKeys = propertyKeyAPI.list(ImmutableList.of("name"));
    Assert.assertEquals(1, propertyKeys.size());
    assertContains(propertyKeys, name);
    propertyKeys = propertyKeyAPI.list(ImmutableList.of("age"));
    Assert.assertEquals(1, propertyKeys.size());
    assertContains(propertyKeys, age);
    propertyKeys = propertyKeyAPI.list(ImmutableList.of("name", "age"));
    Assert.assertEquals(2, propertyKeys.size());
    assertContains(propertyKeys, name);
    assertContains(propertyKeys, age);
}
Also used : PropertyKey(com.baidu.hugegraph.structure.schema.PropertyKey) Test(org.junit.Test)

Example 4 with PropertyKey

use of com.baidu.hugegraph.structure.schema.PropertyKey in project incubator-hugegraph-toolchain by apache.

the class PropertyKeyApiTest method testCreate.

@Test
public void testCreate() {
    PropertyKey propertyKey = schema().propertyKey("name").asText().valueSingle().build();
    PropertyKey.PropertyKeyWithTask propertyKeyWithTask;
    propertyKeyWithTask = propertyKeyAPI.create(propertyKey);
    Assert.assertEquals(0L, propertyKeyWithTask.taskId());
    propertyKey = propertyKeyWithTask.propertyKey();
    Assert.assertEquals("name", propertyKey.name());
    Assert.assertEquals(DataType.TEXT, propertyKey.dataType());
    Assert.assertEquals(Cardinality.SINGLE, propertyKey.cardinality());
}
Also used : PropertyKey(com.baidu.hugegraph.structure.schema.PropertyKey) Test(org.junit.Test)

Example 5 with PropertyKey

use of com.baidu.hugegraph.structure.schema.PropertyKey in project incubator-hugegraph-toolchain by apache.

the class PropertyKeyApiTest method testCreateWithCardinality.

@Test
public void testCreateWithCardinality() {
    PropertyKey propertyKey = schema().propertyKey("name").asText().cardinality(Cardinality.SET).build();
    PropertyKey.PropertyKeyWithTask propertyKeyWithTask;
    propertyKeyWithTask = propertyKeyAPI.create(propertyKey);
    Assert.assertEquals(0L, propertyKeyWithTask.taskId());
    propertyKey = propertyKeyWithTask.propertyKey();
    Assert.assertEquals("name", propertyKey.name());
    Assert.assertEquals(DataType.TEXT, propertyKey.dataType());
    Assert.assertEquals(Cardinality.SET, propertyKey.cardinality());
}
Also used : PropertyKey(com.baidu.hugegraph.structure.schema.PropertyKey) Test(org.junit.Test)

Aggregations

PropertyKey (com.baidu.hugegraph.structure.schema.PropertyKey)40 Test (org.junit.Test)27 SchemaManager (com.baidu.hugegraph.driver.SchemaManager)7 HugeClient (com.baidu.hugegraph.driver.HugeClient)6 RestResult (com.baidu.hugegraph.rest.RestResult)6 ExternalException (com.baidu.hugegraph.exception.ExternalException)4 Date (java.util.Date)4 ServerException (com.baidu.hugegraph.exception.ServerException)3 PropertyKeyEntity (com.baidu.hugegraph.entity.schema.PropertyKeyEntity)2 Vertex (com.baidu.hugegraph.structure.graph.Vertex)2 IndexLabel (com.baidu.hugegraph.structure.schema.IndexLabel)2 VertexLabel (com.baidu.hugegraph.structure.schema.VertexLabel)2 GremlinRequest (com.baidu.hugegraph.api.gremlin.GremlinRequest)1 NotSupportException (com.baidu.hugegraph.exception.NotSupportException)1 InputSource (com.baidu.hugegraph.loader.source.InputSource)1 FileSource (com.baidu.hugegraph.loader.source.file.FileSource)1 ListFormat (com.baidu.hugegraph.loader.source.file.ListFormat)1 Edge (com.baidu.hugegraph.structure.graph.Edge)1 ResultSet (com.baidu.hugegraph.structure.gremlin.ResultSet)1 EdgeLabel (com.baidu.hugegraph.structure.schema.EdgeLabel)1