The ObjectTransformer interface uses callbacks to the application to provide custom implementations of common and expensive operations such as object serialization and deep copies on objects.
For details about the ObjectTransformer interface, see ObjectTransformer plug-in. From a performance viewpoint, and from the CopyMode method information that is in the CopyMode method best practices topic, eXtreme Scale clearly copies the values for all cases except when NO_COPY mode is used. The default copying mechanism that is employed in eXtreme Scale is serialization, which is known as an expensive operation. The ObjectTransformer interface is used in this situation. The ObjectTransformer interface uses callbacks to the application to provide a custom implementation of common and expensive operations, such as object serialization and deep copies on objects.
public interface ObjectTransformer { void serializeKey(Object key, ObjectOutputStream stream) throws IOException; void serializeValue(Object value, ObjectOutputStream stream) throws IOException; Object inflateKey(ObjectInputStream stream) throws IOException, ClassNotFoundException; Object inflateValue(ObjectInputStream stream) throws IOException, ClassNotFoundException; Object copyValue(Object value); Object copyKey(Object key); }
ObjectGrid g = ...; BackingMap bm = g.defineMap("PERSON"); MyObjectTransformer ot = new MyObjectTransformer(); bm.setObjectTransformer(ot);
Object serialization is typically the most important performance consideration with eXtreme Scale, which uses the default serializable mechanism if an ObjectTransformer plug-in is not supplied by the application. An application can provide implementations of either the Serializable readObject and writeObject, or it can have the objects implement the Externalizable interface, which is approximately ten times faster. If the objects in the map cannot be modified, then an application can associate an ObjectTransformer interface with the ObjectMap. The serialize and inflate methods are provided to allow the application to provide custom code to optimize these operations, given their large performance impact on the system. The serialize method serializes the object to the provided stream. The inflate method provides the input stream and expects the application to create the object, inflate it using data in the stream and return the object. Implementations of the serialize and inflate methods must mirror each other.