CDO

Aus SDQ-Wiki

Using CDO enabled models

As soon as one CDO enabled model, such as de.ipd.sdq.identifier, is used, all other referenced models as well as the referencing model need to be CDO enabled as well. The process of migrating a model to CDO is also described at Managing_PCM_Instances_with_CDO

Otherwise the generated code does not implement the Methods of CDOObject, resulting in errors.

Increasing CDO query performance

Looking up all cross-references

This can be done using CDO's View.queryXRefs. Essentially, CDO allows users to look up all reference instances of a specific EReference that point to a specific object.

private final static EReference PU_MEASUREMENT_REF = PhysicalPackageImpl.eINSTANCE.getPuMeasurement_ObservedPu();
private static PuMeasurement getPuLoad(CDOTransaction transaction, PhysicalLoadModel load, 
 ProcessingUnitSpecification pu, Amount<Dimensionless> utilisationNew) {
	 List<CDOObjectReference> refs = transaction.queryXRefs(pu, PU_MEASUREMENT_REF);
	 return (PuMeasurement) refs.get(0).getSourceObject();
}

Here we query the load measurement for a specific ProcessingUnitSpecification pu. We fetch the reference type PU_MEASUREMENT_REF only once using a lookup from the PackageImpl instance of our load model. The main advantage of this way of querying is that CDO uses indexes for cross-reference lookups which is significantly faster.

Querying CDO using OCL

private static ProcessingUnitSpecification getProcessingUnitByID(CDOView view, PhysicalDCModel cdoPhysicalDCModel, String id) {
	CDOQuery query = view.createQuery("ocl", "self.rack.nodes->select(p | p.id = selId)", cdoPhysicalDCModel);
	query.setParameter("selId", id);
	query.setMaxResults(1);
	return (ProcessingUnitSpecification) query.getResult().get(0);
}

This query fetches a processing unit by its ID using an OCL query. While it is difficult to provide specifics on the expected performance benefit of this type of query, it will definitely also increase the performance as it is already evaluated at server side. This means it is not necessary to transfer all data on racks, nodes, ... to the client for the query evaluation.

For additional information on the OCL syntax you can refer to: http://cs.ulb.ac.be/public/_media/teaching/infoh302/oclnotes.pdf . OCL is very similar to SQL and the query style of other declarative languages (e.g. map/reduce frameworks).