[ATL] Global map for caching elements [message #799770] |
Thu, 16 February 2012 09:39 |
Stefan Wülfrath Messages: 18 Registered: February 2012 |
Junior Member |
|
|
Hi,
I have created an ATL transformation for transforming MOF (Managed Object Format) models to CIM (Common Information Model) models.
It works for now but I have a big transformation performance issue.
My target metamodel (CIM) contains following metaclasses: "Class", "Qualifier" and "QualifierType"
My source metamodel (MOF) has some related metaclasses: "ClassDeclaration", "Qualifier", "QualifierDeclaration".
Each cim!Class can contain zero to many qualifiers (cim!Qualifier). Each qualifier is related to a cim!QualifierType.
My parser which parses the MOF files into my intermediate MOF model cannot resolve this relation. So my MOF model doesn't contain this reference.
Now the transformation should solve this problem by taking a mof!Qualifier and searching for a mof!QualifierType that has same name.
My ATL code:
rule ClassDecl2Class {
from
classDecl : mof!ClassDeclaration
to
class : cim!Class (
Name <- classDecl.name,
SuperClass <- classDecl.superClass,
OwnedQualifier <- classDecl.classQualifiers
}
rule QualifierDecl2QualifierType {
from
decl : mof!QualifierDeclaration (
not decl.name.oclIsUndefined()
)
to
qualifierType : cim!QualifierType (
Name <- decl.name,
OwnedType <- decl.qualifierDataType,
OwnedDefaultValue <- decl.qualifierDefaultValue
)
}
rule Qualifier2Qualifier {
from
mofQualifier : mof!Qualifier
to
cimQualifier : cim!Qualifier (
Name <- mofQualifier.name,
-- The next line causes the performance impact
QualifierTypeRef <- cim!QualifierType->allInstances()->select(qt | qt.Name.toLower() = mofQualifier.name.toLower())->first(),
QualifierValue <- mofQualifier.qualifierParamValue
)
}
As you can see I iterate over all cim!QualifierTypes and looking for that one having the same name. This works as expected but causes a performance impact. I have measured that one cim!Qualifier generation needs 1 second with this line included. When this line is omitted the generation is very fast.
Unfortunately I have to transform 1000 classes and their members (the so called Common Schema). They own all together more than 32,000 qualifiers! So it would take 32,000 seconds to transform...
I think the problem is the iteration over all existing Qualifier Types. So my idea is to create a global hash map which contains all qualifier types and to use this map when resolving the "QualifierTypeRef" reference. This should improve performance significantly.
So my question is: How do I declare such a global map and how do I have to use it?
Thank you very much for your help in advance!
Stefan
|
|
|
Powered by
FUDForum. Page generated in 0.03587 seconds