use of com.baidu.hugegraph.schema.SchemaElement in project incubator-hugegraph by apache.
the class HugeGraph method mapElId2Name.
default List<String> mapElId2Name(Collection<Id> ids) {
List<String> names = new ArrayList<>(ids.size());
for (Id id : ids) {
SchemaElement schema = this.edgeLabel(id);
names.add(schema.name());
}
return names;
}
use of com.baidu.hugegraph.schema.SchemaElement in project incubator-hugegraph by apache.
the class HugeGraph method mapIlId2Name.
default List<String> mapIlId2Name(Collection<Id> ids) {
List<String> names = new ArrayList<>(ids.size());
for (Id id : ids) {
SchemaElement schema = this.indexLabel(id);
names.add(schema.name());
}
return names;
}
use of com.baidu.hugegraph.schema.SchemaElement in project incubator-hugegraph by apache.
the class HugeGraphAuthProxy method verifySchemaPermission.
private <V extends SchemaElement> V verifySchemaPermission(HugePermission actionPerm, boolean throwIfNoPerm, Supplier<V> schemaFetcher) {
return verifyResPermission(actionPerm, throwIfNoPerm, () -> {
String graph = this.hugegraph.name();
SchemaElement elem = schemaFetcher.get();
@SuppressWarnings("unchecked") ResourceObject<V> r = (ResourceObject<V>) ResourceObject.of(graph, elem);
return r;
});
}
use of com.baidu.hugegraph.schema.SchemaElement 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.SchemaElement in project incubator-hugegraph by apache.
the class CachedSchemaTransaction method invalidateCache.
private final void invalidateCache(HugeType type, Id id) {
// remove from id cache and name cache
Id prefixedId = generateId(type, id);
Object value = this.idCache.get(prefixedId);
if (value != null) {
this.idCache.invalidate(prefixedId);
SchemaElement schema = (SchemaElement) value;
Id prefixedName = generateId(schema.type(), schema.name());
this.nameCache.invalidate(prefixedName);
}
// remove from optimized array cache
this.arrayCaches.remove(type, id);
}
Aggregations