|
|
|
Re: emf model query [message #652518 is a reply to message #652513] |
Fri, 04 February 2011 11:23 |
saurav sarkar Messages: 428 Registered: July 2009 |
Senior Member |
|
|
Hi Chuck,
Model Query actually loads all the resource in the memory and then performs the query operations hence suffers in terms of scalability.
Whereas Model Query2 uses an index mechanism behind the scenes which allows user to query model data loading resources minimally.It also comes with a XText based SQL like query language and an convinient UI which will help you to query your resources.
Let us know if you need any further information
cheers,
Saurav
My Blog http://codifyit.blogspot.com/
Follow me: http://twitter.com/sauravs
[Updated on: Fri, 04 February 2011 11:24] Report message to a moderator
|
|
|
|
|
|
Re: emf model query [message #652570 is a reply to message #652513] |
Fri, 04 February 2011 15:13 |
saurav sarkar Messages: 428 Registered: July 2009 |
Senior Member |
|
|
Chuck,
1. Have the model plug-in your target platform.
2. Index the data i.e. the XMI files.
You can use the project builder as indexer if your data is in the workspace or you can manually index the data by loading from your specific file location.
Once data indexed, you can unload your data.Then your queries will be executed against the index.
You may wish to not to use Indexed data rather going directly to loaded resources.Then you need to pass the loaded resource set and URIs of the resources in the resource scope.
3. Execute your queries.
Since you are using Object based format.A Query can be executed like this.
//Form entries
// from clause
FromType employees = new FromType("em", employeeUri, true); //$NON-NLS-1$
FromEntry[] fromEntries = new FromEntry[] { employees };
// select clause
SelectAttrs selectEmployeeName = new SelectAttrs("em", new String[] { "name" }); //$NON-NLS-1$ //$NON-NLS-2$
SelectAlias selectEm = new SelectAlias("em"); //$NON-NLS-1$
SelectEntry[] selectEntries = new SelectEntry[] { selectEm, selectEmployeeName };
// where entries
WhereInt whereYoung = new WhereInt("age", Operation.SMALLER, 40); //$NON-NLS-1$
WhereEntry whereEmYoung = new LocalWhereEntry("em", whereYoung); //$NON-NLS-1$
WhereEntry[] whereEntries = new WhereEntry[] { whereEmYoung };
// the actual query
Query query = new Query(selectEntries, fromEntries, whereEntries);
QueryProcessorFactory.getDefault().createQueryProcessor(inde x).execute(Query, context);
4. You will get an instance of ResultSet which you can use to display your data.
You may want to have a look at the test cases for example
For loaded data example org.eclipse.emf.query2.test.SuiteCompanyQueryTest
For Indexes
BaseSyntheticQueryTests.
Let us know if you are stuck.
cheers,
Saurav
My Blog http://codifyit.blogspot.com/
Follow me: http://twitter.com/sauravs
[Updated on: Fri, 04 February 2011 15:14] Report message to a moderator
|
|
|
|
|
|
|
|
|
|
|
Powered by
FUDForum. Page generated in 0.04733 seconds