Search in sources :

Example 41 with IndexLabel

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

the class SchemaTransaction method removeIndexLabel.

@Watched(prefix = "schema")
public Id removeIndexLabel(Id id) {
    LOG.debug("SchemaTransaction remove index label '{}'", id);
    SchemaJob callable = new IndexLabelRemoveJob();
    IndexLabel schema = this.getIndexLabel(id);
    return asyncRun(this.graph(), schema, callable);
}
Also used : IndexLabel(com.baidu.hugegraph.schema.IndexLabel) IndexLabelRemoveJob(com.baidu.hugegraph.job.schema.IndexLabelRemoveJob) SchemaJob(com.baidu.hugegraph.job.schema.SchemaJob) Watched(com.baidu.hugegraph.perf.PerfUtil.Watched)

Example 42 with IndexLabel

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

the class IndexLabelBuilder method checkRepeatIndex.

private void checkRepeatIndex(SchemaLabel schemaLabel, BiPredicate<List<String>, List<String>> check, IndexType... checkedTypes) {
    for (Id id : schemaLabel.indexLabels()) {
        IndexLabel old = this.graph().indexLabel(id);
        if (!Arrays.asList(checkedTypes).contains(old.indexType())) {
            continue;
        }
        List<String> newFields = this.indexFields;
        List<String> oldFields = this.graph().mapPkId2Name(old.indexFields());
        E.checkArgument(!check.test(newFields, oldFields), "Repeated new index label %s(%s) with fields %s " + "due to existed index label %s(%s) with fields %s", this.name, this.indexType, newFields, old.name(), old.indexType(), old.indexFields());
    }
}
Also used : IndexLabel(com.baidu.hugegraph.schema.IndexLabel) Id(com.baidu.hugegraph.backend.id.Id)

Example 43 with IndexLabel

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

the class IndexLabelBuilder method build.

@Override
public IndexLabel build() {
    Id id = this.validOrGenerateId(HugeType.INDEX_LABEL, this.id, this.name);
    this.checkBaseType();
    this.checkIndexType();
    HugeGraph graph = this.graph();
    this.checkFields4Range();
    IndexLabel indexLabel = new IndexLabel(graph, id, this.name);
    indexLabel.baseType(this.baseType);
    SchemaLabel schemaLabel = this.loadBaseLabel();
    indexLabel.baseValue(schemaLabel.id());
    indexLabel.indexType(this.indexType);
    for (String field : this.indexFields) {
        PropertyKey propertyKey = graph.propertyKey(field);
        indexLabel.indexField(propertyKey.id());
    }
    indexLabel.userdata(this.userdata);
    return indexLabel;
}
Also used : HugeGraph(com.baidu.hugegraph.HugeGraph) IndexLabel(com.baidu.hugegraph.schema.IndexLabel) SchemaLabel(com.baidu.hugegraph.schema.SchemaLabel) Id(com.baidu.hugegraph.backend.id.Id) PropertyKey(com.baidu.hugegraph.schema.PropertyKey)

Example 44 with IndexLabel

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

the class IndexLabelBuilder method eliminate.

@Override
public IndexLabel eliminate() {
    IndexLabel indexLabel = this.indexLabelOrNull(this.name);
    if (indexLabel == null) {
        throw new NotFoundException("Can't update index label '%s' " + "since it doesn't exist", this.name);
    }
    this.checkStableVars();
    Userdata.check(this.userdata, Action.ELIMINATE);
    indexLabel.removeUserdata(this.userdata);
    SchemaLabel schemaLabel = indexLabel.baseLabel();
    this.graph().addIndexLabel(schemaLabel, indexLabel);
    return indexLabel;
}
Also used : IndexLabel(com.baidu.hugegraph.schema.IndexLabel) NotFoundException(com.baidu.hugegraph.exception.NotFoundException) SchemaLabel(com.baidu.hugegraph.schema.SchemaLabel)

Example 45 with IndexLabel

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

the class IndexLabelBuilder method append.

@Override
public IndexLabel append() {
    IndexLabel indexLabel = this.indexLabelOrNull(this.name);
    if (indexLabel == null) {
        throw new NotFoundException("Can't update index label '%s' " + "since it doesn't exist", this.name);
    }
    this.checkStableVars();
    Userdata.check(this.userdata, Action.APPEND);
    indexLabel.userdata(this.userdata);
    SchemaLabel schemaLabel = indexLabel.baseLabel();
    this.graph().addIndexLabel(schemaLabel, indexLabel);
    return indexLabel;
}
Also used : IndexLabel(com.baidu.hugegraph.schema.IndexLabel) NotFoundException(com.baidu.hugegraph.exception.NotFoundException) SchemaLabel(com.baidu.hugegraph.schema.SchemaLabel)

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