IBM WebSphereTM eXtreme Scale, Release 8.6
API Specification

com.ibm.websphere.objectgrid.plugins.io
Interface DataSerializer.DataAttributeInflatable

All Superinterfaces:
DataSerializer
All Known Subinterfaces:
KeyDataSerializer, KeyDataSerializer.Partitionable, KeySerializerPlugin, ValueDataSerializer, ValueDataSerializer.Mergeable, ValueDataSerializer.Versionable, ValueSerializerPlugin
Enclosing interface:
DataSerializer

public static interface DataSerializer.DataAttributeInflatable
extends DataSerializer

DataSerializers implement this interface to allow inflating attributes from the serialized form of a data object. Attribute path strings are passed to the getAttributeContexts(String...) method, returning a user defined context object. The context object is cached and passed to the inflateDataObjectAttributes(DataObjectContext, XsDataInputStream, Object) method to inflate the specified attributes.

For each call to getAttributeContexts(String...) for a set of attribute paths, there will typically be more than one call to inflateDataObjectAttributes(DataObjectContext, XsDataInputStream, Object). The getAttributeContexts(String...) can, therefore, be used to optimize calculation, allocation or other processing that might normally be done during the call to {#link inflateDataObjectAttributes(DataObjectContext, XsDataInputStream, Object). This mix-in interface is required when using ObjectQuery or the HashIndex plug-in.

Since:
7.1.1

Nested Class Summary
 
Nested classes/interfaces inherited from interface com.ibm.websphere.objectgrid.plugins.io.DataSerializer
DataSerializer.DataAttributeInflatable, DataSerializer.Identifiable, DataSerializer.SpecialValue, DataSerializer.UserReadable
 
Method Summary
 Object getAttributeContexts(String... attributePaths)
          Retrieve a context from the specified attribute paths.
 Object[] inflateDataObjectAttributes(DataObjectContext dataObjectContext, XsDataInputStream dataObjectInput, Object attributeContexts)
          From the specified data input stream, inflate the specified attributes.
 
Methods inherited from interface com.ibm.websphere.objectgrid.plugins.io.DataSerializer
inflateDataObject, serializeDataObject
 

Method Detail

getAttributeContexts

Object getAttributeContexts(String... attributePaths)
Retrieve a context from the specified attribute paths. This method is invoked prior to the call to inflateDataObjectAttributes(DataObjectContext, XsDataInputStream, Object) and is used to identify the paths that will be inflated. The resulting attribute context object is passed to the inflateDataObjectAttributes method as-is.

This is useful for returning optimized data structures for the implementation. For example, returning int[] instead of String[] to identify each attribute to extract.

Parameters:
attributePaths - the non-null strings that identify attributes that this DataSerializer can inflate.
Returns:
an attribute context. This object will be passed to the inflateDataObjectAttributes(DataObjectContext, XsDataInputStream, Object) method of the same DataSerializer instance. The resulting object must not be null.

inflateDataObjectAttributes

Object[] inflateDataObjectAttributes(DataObjectContext dataObjectContext,
                                     XsDataInputStream dataObjectInput,
                                     Object attributeContexts)
                                     throws IOException
From the specified data input stream, inflate the specified attributes.

If the attribute doesn't exist, DataSerializer.SpecialValue.NOT_FOUND must be returned.

Attributes with isCollection() set to true, must return Collections. Collections of primitive objects must return primitive type wrapper collections. For example: Collection

Embedded attributes are returned as the native data type, such that it can be used directly with the DataSerializer.serializeDataObject(DataObjectContext, Object, XsDataOutputStream) method..

For example:

 Person {
   Name: String,
   Address : {
     Street: String,
     City: String,
     State: String
   }
 }
 
Object attrCtx = getAttributeContext("Address"); inflateDataObjectAttributes(..., attrCtx) would return:
 {
   Street: String,
   City: String,
   State: String
 }
 
Object attrCtx = getAttributeContext("Name"); inflateDataObjectAttributes(..., attrCtx) would return: "John Doe"

Do not store or use the data stream beyond the confines of this method call. The data stream is owned by the WebSphere eXtreme Scale framework and my be closed, pooled or reused as required.

Parameters:
dataObjectContext - the context of the method call.
dataObjectInput - the data input stream to read the object, produced from DataSerializer.serializeDataObject(DataObjectContext, Object, XsDataOutputStream). Must not be null.
attributeContexts - the context of the attributes to retrieve from the input stream. Must not be null.
Returns:
an array of attribute values, one value for each attribute included in the specified context, or DataSerializer.SpecialValue.NOT_FOUND for any values not found.
Throws:
IOException - thrown if there is a problem reading the data.

IBM WebSphereTM eXtreme Scale, Release 8.6
API Specification

© Copyright International Business Machines Corp 2005,2012. All rights reserved.