Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » EMF » Fast retrieval of an EClassifier by qualified name and root EPackage
Fast retrieval of an EClassifier by qualified name and root EPackage [message #924202] Wed, 26 September 2012 15:55 Go to next message
Tassilo Horn is currently offline Tassilo HornFriend
Messages: 93
Registered: July 2009
Member
Hi all,

say you have some root EPackage of an ecore model and the fully
qualified name of an EClassifier, e.g., the EPackage foo and the qname
"foo.bar.Baz". Is there a faster way to retrieve the EClassifier Baz
except for checking foo.getESubpackages() for an EPackage with name
"baz", and then getEClassifier("Baz") (possibliy recursively if there's
a deeper package nesting)? Basically, why is there no constant-time
lookup method

EPackage getESubpackage(String)

when there's

EClassifier getEClassifier(String)

in EPackage.

With some metamodels with lots of sub-EPackages (JaMoPP for example),
that's pretty slow if you do such lookups often.

Maybe another way was to use the nsURIs and the package registry
instead. If the package foo has the nsURI "http://foo", is it
guaranteed that the package foo.bar has the nsURI "http://foo/bar"?
That's the case for all Ecore models I've ever seen, but you never
know...

Bye,
Tassilo
--
Dipl.-Inform. Tassilo Horn | Room: B015
University of Koblenz-Landau, Campus Koblenz | Phone: +49 (261) 287-2745
Institute for Software Technology | Mail: horn@xxxxxxxx
Universitätsstr. 1, 56070 Koblenz, Germany |
Re: Fast retrieval of an EClassifier by qualified name and root EPackage [message #924747 is a reply to message #924202] Thu, 27 September 2012 05:09 Go to previous messageGo to next message
Ed Merks is currently offline Ed MerksFriend
Messages: 26285
Registered: July 2009
Senior Member
Tassilo,

Comments below.

On 26/09/2012 5:55 PM, Tassilo Horn wrote:
> Hi all,
>
> say you have some root EPackage of an ecore model and the fully
> qualified name of an EClassifier, e.g., the EPackage foo and the qname
> "foo.bar.Baz". Is there a faster way to retrieve the EClassifier Baz
> except for checking foo.getESubpackages() for an EPackage with name
> "baz", and then getEClassifier("Baz") (possibliy recursively if there's
> a deeper package nesting)? Basically, why is there no constant-time
> lookup method
>
> EPackage getESubpackage(String)
No. Generally nsURIs are used to locate packages.
>
> when there's
>
> EClassifier getEClassifier(String)
>
> in EPackage.
>
> With some metamodels with lots of sub-EPackages (JaMoPP for example),
> that's pretty slow if you do such lookups often.
You can always build a map once. It's not so common to have a qualified
name you need to look up. Whereas looking up features and classifiers
by name is common because deserializers often need to do that.
>
> Maybe another way was to use the nsURIs and the package registry
> instead.
Yes, the registry is how the package is normally looked up quickly.
> If the package foo has the nsURI "http://foo", is it
> guaranteed that the package foo.bar has the nsURI "http://foo/bar"?
No.
> That's the case for all Ecore models I've ever seen, but you never
> know...
If you're looking for base lookup in generated models, the nsURI and the
classifier name are the best way.
>
> Bye,
> Tassilo
Re: Fast retrieval of an EClassifier by qualified name and root EPackage [message #924865 is a reply to message #924747] Thu, 27 September 2012 07:33 Go to previous message
Tassilo Horn is currently offline Tassilo HornFriend
Messages: 93
Registered: July 2009
Member
Ed Merks <ed.merks@xxxxxxxx> writes:

Hi Ed,

>> when there's
>>
>> EClassifier getEClassifier(String)
>>
>> in EPackage.
>>
>> With some metamodels with lots of sub-EPackages (JaMoPP for example),
>> that's pretty slow if you do such lookups often.
>
> You can always build a map once. It's not so common to have a
> qualified name you need to look up. Whereas looking up features and
> classifiers by name is common because deserializers often need to do
> that.

I do model querying on EMF models, and at least there it seems to me
that qualified names are rather common. I mean, it's much easier for a
user to write something along the lines of

forall (class : model.allInstancesOf("java.classifiers.Class")) ...

than

forall (class : model.allInstancesOf(
"http://www.emftext.org/java/classifiers/Class")) ...

I know all the nsURIs of packages, so I guess I'll use a map like

{ baseNsURI -> { qname -> package }}

Thanks,
Tassilo
--
Dipl.-Inform. Tassilo Horn | Room: B015
University of Koblenz-Landau, Campus Koblenz | Phone: +49 (261) 287-2745
Institute for Software Technology | Mail: horn@xxxxxxxx
Universitätsstr. 1, 56070 Koblenz, Germany |
Previous Topic:Cross-domain references
Next Topic:Expired certificate with org.eclipse.emf.ecore 2.7.0
Goto Forum:
  


Current Time: Sat Dec 20 23:54:31 GMT 2014

Powered by FUDForum. Page generated in 0.01493 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software