use of com.baidu.hugegraph.schema.SchemaElement in project incubator-hugegraph by apache.
the class CachedSchemaTransaction method getSchema.
@Override
@SuppressWarnings("unchecked")
protected <T extends SchemaElement> T getSchema(HugeType type, String name) {
Id prefixedName = generateId(type, name);
Object value = this.nameCache.get(prefixedName);
if (value == null) {
value = super.getSchema(type, name);
if (value != null) {
SchemaElement schema = (SchemaElement) value;
this.updateCache(schema);
}
}
return (T) value;
}
use of com.baidu.hugegraph.schema.SchemaElement in project incubator-hugegraph by apache.
the class CachedSchemaTransaction method getSchema.
@Override
@SuppressWarnings("unchecked")
protected <T extends SchemaElement> T getSchema(HugeType type, Id id) {
// try get from optimized array cache
if (id.number() && id.asLong() > 0L) {
SchemaElement value = this.arrayCaches.get(type, id);
if (value != null) {
return (T) value;
}
}
Id prefixedId = generateId(type, id);
Object value = this.idCache.get(prefixedId);
if (value == null) {
value = super.getSchema(type, id);
if (value != null) {
SchemaElement schema = (SchemaElement) value;
// update id cache, name cache and optimized array cache
this.updateCache(schema);
}
} else {
// update optimized array cache for the result from id cache
this.arrayCaches.updateIfNeeded((SchemaElement) value);
}
return (T) value;
}
use of com.baidu.hugegraph.schema.SchemaElement in project incubator-hugegraph by apache.
the class HugeGraph method mapPkId2Name.
default List<String> mapPkId2Name(Collection<Id> ids) {
List<String> names = new ArrayList<>(ids.size());
for (Id id : ids) {
SchemaElement schema = this.propertyKey(id);
names.add(schema.name());
}
return names;
}
use of com.baidu.hugegraph.schema.SchemaElement in project incubator-hugegraph by apache.
the class HugeGraph method mapVlId2Name.
default List<String> mapVlId2Name(Collection<Id> ids) {
List<String> names = new ArrayList<>(ids.size());
for (Id id : ids) {
SchemaElement schema = this.vertexLabel(id);
names.add(schema.name());
}
return names;
}
Aggregations