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);
}
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());
}
}
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;
}
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;
}
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;
}
Aggregations