Search in sources :

Example 26 with IndexLabel

use of com.baidu.hugegraph.schema.IndexLabel in project incubator-hugegraph by apache.

the class GraphIndexTransaction method doSingleOrCompositeIndex.

@Watched(prefix = "index")
private IdHolder doSingleOrCompositeIndex(IndexQueries queries) {
    assert queries.size() == 1;
    Map.Entry<IndexLabel, ConditionQuery> entry = queries.one();
    IndexLabel indexLabel = entry.getKey();
    ConditionQuery query = entry.getValue();
    return this.doIndexQuery(indexLabel, query);
}
Also used : ConditionQuery(com.baidu.hugegraph.backend.query.ConditionQuery) IndexLabel(com.baidu.hugegraph.schema.IndexLabel) Map(java.util.Map) HashMap(java.util.HashMap) Watched(com.baidu.hugegraph.perf.PerfUtil.Watched)

Example 27 with IndexLabel

use of com.baidu.hugegraph.schema.IndexLabel in project incubator-hugegraph by apache.

the class SchemaTransaction method createIndexLabelForOlapPk.

public void createIndexLabelForOlapPk(PropertyKey propertyKey) {
    WriteType writeType = propertyKey.writeType();
    if (writeType == WriteType.OLTP || writeType == WriteType.OLAP_COMMON) {
        return;
    }
    String indexName = VertexLabel.OLAP_VL.name() + "_by_" + propertyKey.name();
    IndexLabel.Builder builder = this.graph().schema().indexLabel(indexName).onV(VertexLabel.OLAP_VL.name()).by(propertyKey.name());
    if (propertyKey.writeType() == WriteType.OLAP_SECONDARY) {
        builder.secondary();
    } else {
        assert propertyKey.writeType() == WriteType.OLAP_RANGE;
        builder.range();
    }
    this.graph().addIndexLabel(VertexLabel.OLAP_VL, builder.build());
}
Also used : WriteType(com.baidu.hugegraph.type.define.WriteType) IndexLabel(com.baidu.hugegraph.schema.IndexLabel)

Example 28 with IndexLabel

use of com.baidu.hugegraph.schema.IndexLabel in project incubator-hugegraph by apache.

the class HugeGraphAuthProxy method removeIndexLabel.

@Override
public Id removeIndexLabel(Id id) {
    IndexLabel label = this.hugegraph.indexLabel(id);
    verifySchemaPermission(HugePermission.DELETE, label);
    return this.hugegraph.removeIndexLabel(id);
}
Also used : IndexLabel(com.baidu.hugegraph.schema.IndexLabel)

Example 29 with IndexLabel

use of com.baidu.hugegraph.schema.IndexLabel in project incubator-hugegraph by apache.

the class JsonSerializer method writeTaskWithSchema.

@Override
public String writeTaskWithSchema(SchemaElement.TaskWithSchema taskWithSchema) {
    StringBuilder builder = new StringBuilder();
    long id = taskWithSchema.task() == null ? 0L : taskWithSchema.task().asLong();
    SchemaElement schemaElement = taskWithSchema.schemaElement();
    String type;
    String schema;
    if (schemaElement instanceof PropertyKey) {
        type = "property_key";
        schema = this.writePropertyKey((PropertyKey) schemaElement);
    } else if (schemaElement instanceof IndexLabel) {
        type = "index_label";
        schema = this.writeIndexlabel((IndexLabel) schemaElement);
    } else {
        throw new HugeException("Invalid schema element '%s' in " + "TaskWithSchema, only support " + "[PropertyKey, IndexLabel]", schemaElement);
    }
    return builder.append("{\"").append(type).append("\": ").append(schema).append(", \"task_id\": ").append(id).append("}").toString();
}
Also used : IndexLabel(com.baidu.hugegraph.schema.IndexLabel) SchemaElement(com.baidu.hugegraph.schema.SchemaElement) HugeException(com.baidu.hugegraph.HugeException) PropertyKey(com.baidu.hugegraph.schema.PropertyKey)

Example 30 with IndexLabel

use of com.baidu.hugegraph.schema.IndexLabel in project incubator-hugegraph by apache.

the class StandardHugeGraph method indexLabel.

@Override
public IndexLabel indexLabel(String name) {
    IndexLabel il = this.schemaTransaction().getIndexLabel(name);
    E.checkArgument(il != null, "Undefined index label: '%s'", name);
    return il;
}
Also used : IndexLabel(com.baidu.hugegraph.schema.IndexLabel)

Aggregations

IndexLabel (com.baidu.hugegraph.schema.IndexLabel)53 Id (com.baidu.hugegraph.backend.id.Id)24 Watched (com.baidu.hugegraph.perf.PerfUtil.Watched)8 SchemaLabel (com.baidu.hugegraph.schema.SchemaLabel)8 SchemaManager (com.baidu.hugegraph.schema.SchemaManager)8 Test (org.junit.Test)8 ConditionQuery (com.baidu.hugegraph.backend.query.ConditionQuery)7 HugeGraph (com.baidu.hugegraph.HugeGraph)5 PropertyKey (com.baidu.hugegraph.schema.PropertyKey)5 HugeType (com.baidu.hugegraph.type.HugeType)5 GraphTransaction (com.baidu.hugegraph.backend.tx.GraphTransaction)4 SchemaTransaction (com.baidu.hugegraph.backend.tx.SchemaTransaction)4 VertexLabel (com.baidu.hugegraph.schema.VertexLabel)4 HugeIndex (com.baidu.hugegraph.structure.HugeIndex)4 LockUtil (com.baidu.hugegraph.util.LockUtil)4 IdHolder (com.baidu.hugegraph.backend.page.IdHolder)3 BatchIdHolder (com.baidu.hugegraph.backend.page.IdHolder.BatchIdHolder)3 FixedIdHolder (com.baidu.hugegraph.backend.page.IdHolder.FixedIdHolder)3 PagingIdHolder (com.baidu.hugegraph.backend.page.IdHolder.PagingIdHolder)3 Condition (com.baidu.hugegraph.backend.query.Condition)3