See the WebSphere eXtreme Scale Wiki for links to eXtreme Scale Version 7.0 documentation.
If you log in
with your developerWorks ID, you can leave comments and feedback for the development team.
The EntityManager interface offers a much easier programming model than the Map-based models of ObjectGrid before the Version 6.1 release and any competitive products. The interface decouples applications from the state that is held in the grid, which is a major factor if you do not want to couple the grid with applications. For example, imagine a company that forces every application to use the same data access objects for a database. This implementation is not practical.
This ease of use comes with a performance cost. This cost is actually not high and depends on the type of work that is being performed. Always use the EntityManager and optimize the crucial business logic after the application is complete. Any code that uses EntityManager interfaces can be reworked to use Maps and Tuples. This code rework might be necessary for 10% of the code, given the usual 90/10 rule for how much of the code critically affects performance.
If you use relationships between objects, then the performance impact is lower because an application that is using Maps needs to manage those relationships similarly to the EntityManager.
Applications that use the EntityManager do not need to provide an ObjectTransformer because it is optimized automatically.
Reworking EntityManager code to work with Maps
A sample entity follows:
@Entity
public class Person
{
@Id
String ssn;
String firstName;
@Index
String middleName;
String surname;
}
Some code to find the entity and update the entity follows:
Person p = null;
s.begin();
p = (Person)em.find(Person.class, "1234567890");
p.middleName = String.valueOf(inner);
s.commit();
The same code using Maps follows:
Tuple key = null;
key = map.getEntityMetadata().getKeyMetadata().createTuple();
key.setAttribute(0, "1234567890");
map.setCopyMode(CopyMode.COPY_ON_READ);
s.begin();
Tuple value = (Tuple)map.get(key);
value.setAttribute(1, String.valueOf(inner));
map.update(key, value);
value = null;
s.commit();
Both of these code snippets have the same result, and an application can use either code snippet at the same time. The second code snippet shows how to use Maps directly and how to work with the Tuples. The key and values pairs are Tuples. The value Tuple has three attributes: firstName, middlename and surname, indexed at 0, 1 and 2. The key tuple has a single attribute the ID number is indexed at zero. You can see how Tuples are created by using the EntityMetadata#getKeyMetaData or EntityMetadata#getValueMetaData methods. You must use these methods to create Tuples for an Entity. You cannot implement the Tuple interface and pass an instance of your Tuple implementation.
Additional Information
© Copyright IBM Corporation 2007,2009. All Rights Reserved.