Search in sources :

Example 1 with TransientTypeSystem

use of org.apache.atlas.typesystem.types.TypeSystem.TransientTypeSystem in project incubator-atlas by apache.

the class StoreBackedTypeCache method onTypeFault.

/**
     * Check the type store for the requested type. 
     * If found in the type store, the type and any required super and attribute types
     * are loaded from the type store, and added to the cache.
     */
@Override
public IDataType onTypeFault(String typeName) throws AtlasException {
    // Type is not cached - check the type store.
    // Any super and attribute types needed by the requested type
    // which are not cached will also be loaded from the store.
    Context context = new Context();
    TypesDef typesDef = getTypeFromStore(typeName, context);
    if (typesDef.isEmpty()) {
        // Type not found in the type store.
        return null;
    }
    // Add all types that were loaded from the store to the cache.
    TransientTypeSystem transientTypeSystem = typeSystem.createTransientTypeSystem(context.getTypesDef(), false);
    Map<String, IDataType> typesAdded = transientTypeSystem.getTypesAdded();
    putAll(typesAdded.values());
    return typesAdded.get(typeName);
}
Also used : TypesDef(org.apache.atlas.typesystem.TypesDef) TransientTypeSystem(org.apache.atlas.typesystem.types.TypeSystem.TransientTypeSystem) IDataType(org.apache.atlas.typesystem.types.IDataType)

Aggregations

TypesDef (org.apache.atlas.typesystem.TypesDef)1 IDataType (org.apache.atlas.typesystem.types.IDataType)1 TransientTypeSystem (org.apache.atlas.typesystem.types.TypeSystem.TransientTypeSystem)1