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