gemfire::PdxInstance Class Reference

Inherited by gemfire::WritablePdxInstance.


Detailed Description

PdxInstance provides run time access to the fields of a PDX without deserializing the PDX.

Preventing deserialization saves time and memory. The PdxInstance implementation is a light weight wrapper that simply refers to the raw bytes of the PDX that are kept in the cache. Applications can choose to access PdxInstances instead of C++ objects by configuring the Cache to prefer PDX instances during deserialization. This can be done in cache.xml by setting the attribute read-serialized to true on the pdx element. Or it can be done programmatically using setPdxReadSerialized method. Once this preference is configured, then any time deserialization of a PDX is done it will deserialize into a PdxInstance. PdxInstance are immutable. If you want to change one call createWriter.

Public Member Functions

virtual
WritablePdxInstancePtr 
createWriter ()=0
 Creates and returns a WritablePdxInstance whose initial values are those of this PdxInstance.
virtual void fromData (PdxReaderPtr input)=0
virtual SerializablefromData (DataInput &input)
virtual const char * getClassName () const =0
 Return the full name of the class that this pdx instance represents.
virtual void getField (const char *fieldname, CacheableObjectArrayPtr &value) const =0
 Reads the named field and set its value in CacheableObjectArrayPtr type out param.
virtual void getField (const char *fieldName, int8_t ***value, int32_t &arrayLength, int32_t *&elementLength) const =0
 Reads the named field and set its value in array of byte arrays type out param.
virtual void getField (const char *fieldname, CacheableDatePtr &value) const =0
 Reads the named field and set its value in CacheableDatePtr type out param.
virtual void getField (const char *fieldname, char ***value, int32_t &length) const =0
 Reads the named field and set its value in char* array type out param.
virtual void getField (const char *fieldname, wchar_t ***value, int32_t &length) const =0
 Reads the named field and set its value in wchar_t* array type out param.
virtual void getField (const char *fieldname, char **value) const =0
 Reads the named field and set its value in char* type out param.
virtual void getField (const char *fieldname, wchar_t **value) const =0
 Reads the named field and set its value in wchar_t* type out param.
virtual void getField (const char *fieldName, char **value, int32_t &length) const =0
 Reads the named field and set its value in char array type out param.
virtual void getField (const char *fieldName, wchar_t **value, int32_t &length) const =0
 Reads the named field and set its value in wchar_t array type out param.
virtual void getField (const char *fieldname, double **value, int32_t &length) const =0
 Reads the named field and set its value in double array type out param.
virtual void getField (const char *fieldname, float **value, int32_t &length) const =0
 Reads the named field and set its value in float array type out param.
virtual void getField (const char *fieldname, int64_t **value, int32_t &length) const =0
 Reads the named field and set its value in int64_t array type out param.
virtual void getField (const char *fieldname, int32_t **value, int32_t &length) const =0
 Reads the named field and set its value in int32_t array type out param.
virtual void getField (const char *fieldname, int16_t **value, int32_t &length) const =0
 Reads the named field and set its value in int16_t array type out param.
virtual void getField (const char *fieldname, unsigned char **value, int32_t &length) const =0
 Reads the named field and set its value in unsigned char array type out param.
virtual void getField (const char *fieldname, signed char **value, int32_t &length) const =0
 Reads the named field and set its value in signed char array type out param.
virtual void getField (const char *fieldname, bool **value, int32_t &length) const =0
 Reads the named field and set its value in bool array type out param.
virtual void getField (const char *fieldName, char &value) const =0
 Reads the named field and set its value in char type out param.
virtual void getField (const char *fieldName, wchar_t &value) const =0
 Reads the named field and set its value in wchar_t type out param.
virtual void getField (const char *fieldname, double &value) const =0
 Reads the named field and set its value in double type out param.
virtual void getField (const char *fieldname, float &value) const =0
 Reads the named field and set its value in float type out param.
virtual void getField (const char *fieldname, int64_t &value) const =0
 Reads the named field and set its value in int64_t type out param.
virtual void getField (const char *fieldname, int32_t &value) const =0
 Reads the named field and set its value in int32_t type out param.
virtual void getField (const char *fieldname, int16_t &value) const =0
 Reads the named field and set its value in int16_t type out param.
virtual void getField (const char *fieldname, unsigned char &value) const =0
 Reads the named field and set its value in unsigned char type out param.
virtual void getField (const char *fieldname, signed char &value) const =0
 Reads the named field and set its value in signed char type out param.
virtual void getField (const char *fieldname, bool &value) const =0
 Reads the named field and set its value in bool type out param.
virtual void getField (const char *fieldname, CacheablePtr &value) const =0
 Reads the named field and set its value in CacheablePtr type out param.
virtual
CacheableStringArrayPtr 
getFieldNames ()=0
 Return an unmodifiable list of the field names on this PdxInstance.
virtual
PdxSerializablePtr 
getObject ()=0
 Deserializes and returns the domain object that this instance represents.
virtual bool hasField (const char *fieldname)=0
 Checks if the named field exists and returns the result.
virtual uint32_t hashcode () const =0
 Generates a hashcode based on the identity fields of this PdxInstance.
virtual bool isIdentityField (const char *fieldname)=0
 Checks if the named field was PdxWriter#markIdentityFieldmarked as an identity field.
virtual uint32_t objectSize () const =0
 
Returns:
the size of the object in bytes This is an internal method.

virtual bool operator== (const CacheableKey &other) const =0
 Returns true if the given CacheableKey derived object is equals to this instance.
virtual void toData (PdxWriterPtr output)=0
virtual void toData (DataOutput &output) const
virtual
CacheableStringPtr 
toString () const =0
 Prints out all of the identity fields of this PdxInstance.
virtual ~PdxInstance ()

Protected Member Functions

 PdxInstance ()


Constructor & Destructor Documentation

virtual gemfire::PdxInstance::~PdxInstance (  )  [inline, virtual]

destructor

gemfire::PdxInstance::PdxInstance (  )  [inline, protected]

constructors


Member Function Documentation

virtual WritablePdxInstancePtr gemfire::PdxInstance::createWriter (  )  [pure virtual]

Creates and returns a WritablePdxInstance whose initial values are those of this PdxInstance.

This call returns a copy of the current field values so modifications made to the returned value will not modify this PdxInstance.

Returns:
a WritablePdxInstance

virtual void gemfire::PdxInstance::fromData ( PdxReaderPtr  input  )  [pure virtual]

Deserialize this object. This is an internal method.

Parameters:
PdxReader to Deserialize the PDX object

virtual Serializable* gemfire::PdxInstance::fromData ( DataInput input  )  [inline, virtual]

deserialize this object, typical implementation should return the 'this' pointer. This is an internal method.

virtual const char* gemfire::PdxInstance::getClassName (  )  const [pure virtual]

Return the full name of the class that this pdx instance represents.

Returns:
the name of the class that this pdx instance represents.
Exceptions:
IllegalStateException if the PdxInstance typeid is not defined yet, to get classname or if PdxType is not defined for PdxInstance.

virtual void gemfire::PdxInstance::getField ( const char *  fieldname,
CacheableObjectArrayPtr value 
) const [pure virtual]

Reads the named field and set its value in CacheableObjectArrayPtr type out param.

For deserialization C++ Native Client requires the domain class to be registered. CacheableObjectArrayPtr type is corresponding to java Object[] type.

Parameters:
fieldname name of the field to read.
value value of the field to be set with CacheableObjectArrayPtr type.
Exceptions:
IllegalStateException if PdxInstance doesn't has the named field.
See also:
Serializable::registerPdxType

PdxInstance::hasField

virtual void gemfire::PdxInstance::getField ( const char *  fieldName,
int8_t ***  value,
int32_t &  arrayLength,
int32_t *&  elementLength 
) const [pure virtual]

Reads the named field and set its value in array of byte arrays type out param.

int8_t** type is corresponding to java byte[][] type.

Parameters:
fieldname name of the field to read.
value value of the field to be set with array of byte arrays type.
arrayLength arrayLength is set to the number of byte arrays.
elementLength elementLength is set to individual byte array lengths.
Exceptions:
IllegalStateException if PdxInstance doesn't has the named field.
See also:
PdxInstance::hasField

virtual void gemfire::PdxInstance::getField ( const char *  fieldname,
CacheableDatePtr value 
) const [pure virtual]

Reads the named field and set its value in CacheableDatePtr type out param.

CacheableDatePtr type is corresponding to java Java.util.date type.

Parameters:
fieldname name of the field to read
value value of the field to be set with CacheableDatePtr type.
Exceptions:
IllegalStateException if PdxInstance doesn't has the named field.
See also:
PdxInstance::hasField

virtual void gemfire::PdxInstance::getField ( const char *  fieldname,
char ***  value,
int32_t &  length 
) const [pure virtual]

Reads the named field and set its value in char* array type out param.

char** type is corresponding to java String[] type.

Parameters:
fieldname name of the field to read
value value of the field to be set with char* array type.
length length is set with number of char** elements.
Exceptions:
IllegalStateException if PdxInstance doesn't has the named field.
See also:
PdxInstance::hasField

virtual void gemfire::PdxInstance::getField ( const char *  fieldname,
wchar_t ***  value,
int32_t &  length 
) const [pure virtual]

Reads the named field and set its value in wchar_t* array type out param.

wchar_t** type is corresponding to java String[] type.

Parameters:
fieldname name of the field to read
value value of the field to be set with wchar_t* array type.
length length is set with number of wchar_t** elements.
Exceptions:
IllegalStateException if PdxInstance doesn't has the named field.
See also:
PdxInstance::hasField

virtual void gemfire::PdxInstance::getField ( const char *  fieldname,
char **  value 
) const [pure virtual]

Reads the named field and set its value in char* type out param.

char* type is corresponding to java String type.

Parameters:
fieldname name of the field to read
value value of the field to be set with char* type.
Exceptions:
IllegalStateException if PdxInstance doesn't has the named field.
See also:
PdxInstance::hasField

virtual void gemfire::PdxInstance::getField ( const char *  fieldname,
wchar_t **  value 
) const [pure virtual]

Reads the named field and set its value in wchar_t* type out param.

wchar_t* type is corresponding to java String type.

Parameters:
fieldname name of the field to read
value value of the field to be set with wchar_t type.
Exceptions:
IllegalStateException if PdxInstance doesn't has the named field.
See also:
PdxInstance::hasField

virtual void gemfire::PdxInstance::getField ( const char *  fieldName,
char **  value,
int32_t &  length 
) const [pure virtual]

Reads the named field and set its value in char array type out param.

char* type is corresponding to java String type.

Parameters:
fieldname name of the field to read
value value of the field to be set with char array type.
length length is set with number of char* elements.
Exceptions:
IllegalStateException if PdxInstance doesn't has the named field.
See also:
PdxInstance::hasField

virtual void gemfire::PdxInstance::getField ( const char *  fieldName,
wchar_t **  value,
int32_t &  length 
) const [pure virtual]

Reads the named field and set its value in wchar_t array type out param.

wchar_t* type is corresponding to java String type.

Parameters:
fieldname name of the field to read
value value of the field to be set with wchar_t array type.
length length is set with number of wchar_t* elements.
Exceptions:
IllegalStateException if PdxInstance doesn't has the named field.
See also:
PdxInstance::hasField

virtual void gemfire::PdxInstance::getField ( const char *  fieldname,
double **  value,
int32_t &  length 
) const [pure virtual]

Reads the named field and set its value in double array type out param.

double* type is corresponding to java double[] type.

Parameters:
fieldname name of the field to read
value value of the field to be set with double array type.
length length is set with number of double elements.
Exceptions:
IllegalStateException if PdxInstance doesn't has the named field.
See also:
PdxInstance::hasField

virtual void gemfire::PdxInstance::getField ( const char *  fieldname,
float **  value,
int32_t &  length 
) const [pure virtual]

Reads the named field and set its value in float array type out param.

float* type is corresponding to java float[] type.

Parameters:
fieldname name of the field to read
value value of the field to be set with float array type.
length length is set with number of float elements.
Exceptions:
IllegalStateException if PdxInstance doesn't has the named field.
See also:
PdxInstance::hasField

virtual void gemfire::PdxInstance::getField ( const char *  fieldname,
int64_t **  value,
int32_t &  length 
) const [pure virtual]

Reads the named field and set its value in int64_t array type out param.

int64_t* type is corresponding to java long[] type.

Parameters:
fieldname name of the field to read
value value of the field to be set with int64_t array type.
length length is set with number of int64_t elements.
Exceptions:
IllegalStateException if PdxInstance doesn't has the named field.
See also:
PdxInstance::hasField

virtual void gemfire::PdxInstance::getField ( const char *  fieldname,
int32_t **  value,
int32_t &  length 
) const [pure virtual]

Reads the named field and set its value in int32_t array type out param.

int32_t* type is corresponding to java int[] type.

Parameters:
fieldname name of the field to read
value value of the field to be set with int32_t array type.
length length is set with number of int32_t elements.
Exceptions:
IllegalStateException if PdxInstance doesn't has the named field.
See also:
PdxInstance::hasField

virtual void gemfire::PdxInstance::getField ( const char *  fieldname,
int16_t **  value,
int32_t &  length 
) const [pure virtual]

Reads the named field and set its value in int16_t array type out param.

int16_t* type is corresponding to java short[] type.

Parameters:
fieldname name of the field to read
value value of the field to be set with int16_t array type.
length length is set with number of int16_t elements.
Exceptions:
IllegalStateException if PdxInstance doesn't has the named field.
See also:
PdxInstance::hasField

virtual void gemfire::PdxInstance::getField ( const char *  fieldname,
unsigned char **  value,
int32_t &  length 
) const [pure virtual]

Reads the named field and set its value in unsigned char array type out param.

unsigned char* type is corresponding to java byte[] type. For C++ on Windows and Linux, unsigned char* type is corresponding to int8_t* type. However C++ users on Solaris should always use this api after casting int8_t* to unsigned char*.

Parameters:
fieldname name of the field to read
value value of the field to be set with unsigned char array type.
length length is set with number of unsigned char elements.
Exceptions:
IllegalStateException if PdxInstance doesn't has the named field.
See also:
PdxInstance::hasField

virtual void gemfire::PdxInstance::getField ( const char *  fieldname,
signed char **  value,
int32_t &  length 
) const [pure virtual]

Reads the named field and set its value in signed char array type out param.

signed char* type is corresponding to java byte[] type. For C++ on Windows and Linux, signed char* type is corresponding to int8_t* type. However C++ users on Solaris should always use this api after casting int8_t* to signed char*.

Parameters:
fieldname name of the field to read
value value of the field to be set with signed char array type.
length length is set with number of signed char elements.
Exceptions:
IllegalStateException if PdxInstance doesn't has the named field.
See also:
PdxInstance::hasField

virtual void gemfire::PdxInstance::getField ( const char *  fieldname,
bool **  value,
int32_t &  length 
) const [pure virtual]

Reads the named field and set its value in bool array type out param.

bool* type is corresponding to java boolean[] type.

Parameters:
fieldname name of the field to read
value value of the field to be set with bool array type.
length length is set with number of bool elements.
Exceptions:
IllegalStateException if PdxInstance doesn't has the named field.
See also:
PdxInstance::hasField

virtual void gemfire::PdxInstance::getField ( const char *  fieldName,
char &  value 
) const [pure virtual]

Reads the named field and set its value in char type out param.

char type is corresponding to java char type.

Parameters:
fieldname name of the field to read
value value of the field to be set with char type.
Exceptions:
IllegalStateException if PdxInstance doesn't has the named field.
See also:
PdxInstance::hasField

virtual void gemfire::PdxInstance::getField ( const char *  fieldName,
wchar_t &  value 
) const [pure virtual]

Reads the named field and set its value in wchar_t type out param.

wchar_t type is corresponding to java char type.

Parameters:
fieldname name of the field to read
value value of the field to be set with wchar_t type.
Exceptions:
IllegalStateException if PdxInstance doesn't has the named field.
See also:
PdxInstance::hasField

virtual void gemfire::PdxInstance::getField ( const char *  fieldname,
double &  value 
) const [pure virtual]

Reads the named field and set its value in double type out param.

double type is corresponding to java double type.

Parameters:
fieldname name of the field to read
value value of the field to be set with double type.
Exceptions:
IllegalStateException if PdxInstance doesn't has the named field.
See also:
PdxInstance::hasField

virtual void gemfire::PdxInstance::getField ( const char *  fieldname,
float &  value 
) const [pure virtual]

Reads the named field and set its value in float type out param.

float type is corresponding to java float type.

Parameters:
fieldname name of the field to read
value value of the field to be set with float type.
Exceptions:
IllegalStateException if PdxInstance doesn't has the named field.
See also:
PdxInstance::hasField

virtual void gemfire::PdxInstance::getField ( const char *  fieldname,
int64_t &  value 
) const [pure virtual]

Reads the named field and set its value in int64_t type out param.

int64_t type is corresponding to java long type.

Parameters:
fieldname name of the field to read
value value of the field to be set with int64_t type.
Exceptions:
IllegalStateException if PdxInstance doesn't has the named field.
See also:
PdxInstance::hasField

virtual void gemfire::PdxInstance::getField ( const char *  fieldname,
int32_t &  value 
) const [pure virtual]

Reads the named field and set its value in int32_t type out param.

int32_t type is corresponding to java int type.

Parameters:
fieldname name of the field to read
value value of the field to be set with int32_t type.
Exceptions:
IllegalStateException if PdxInstance doesn't has the named field.

virtual void gemfire::PdxInstance::getField ( const char *  fieldname,
int16_t &  value 
) const [pure virtual]

Reads the named field and set its value in int16_t type out param.

int16_t type is corresponding to java short type.

Parameters:
fieldname name of the field to read
value value of the field to be set with int16_t type.
Exceptions:
IllegalStateException if PdxInstance doesn't has the named field.
See also:
PdxInstance::hasField

virtual void gemfire::PdxInstance::getField ( const char *  fieldname,
unsigned char &  value 
) const [pure virtual]

Reads the named field and set its value in unsigned char type out param.

unsigned char type is corresponding to java byte type. For C++ on Windows and Linux, unsigned char type is corresponding to int8_t type. However C++ users on Solaris should always use this api after casting int8_t to unsigned char.

Parameters:
fieldname name of the field to read
value value of the field to be set with unsigned char type.
Exceptions:
IllegalStateException if PdxInstance doesn't has the named field.
See also:
PdxInstance::hasField

virtual void gemfire::PdxInstance::getField ( const char *  fieldname,
signed char &  value 
) const [pure virtual]

Reads the named field and set its value in signed char type out param.

signed char type is corresponding to java byte type. For C++ on Windows and Linux, signed char type is corresponding to int8_t type. However C++ users on Solaris should always use this api after casting int8_t to signed char.

Parameters:
fieldname name of the field to read
value value of the field to be set with signed char type.
Exceptions:
IllegalStateException if PdxInstance doesn't has the named field.
See also:
PdxInstance::hasField

virtual void gemfire::PdxInstance::getField ( const char *  fieldname,
bool &  value 
) const [pure virtual]

Reads the named field and set its value in bool type out param.

bool type is corresponding to java boolean type.

Parameters:
fieldname name of the field to read
value value of the field to be set with bool type.
Exceptions:
IllegalStateException if PdxInstance doesn't has the named field.
See also:
PdxInstance::hasField

virtual void gemfire::PdxInstance::getField ( const char *  fieldname,
CacheablePtr value 
) const [pure virtual]

Reads the named field and set its value in CacheablePtr type out param.

CacheablePtr type is corresponding to java object type.

Parameters:
fieldname name of the field to read
value value of the field to be set with CacheablePtr type.
Exceptions:
IllegalStateException if PdxInstance doesn't has the named field. For deserialization C++ Native Client requires the domain class to be registered.
See also:
Serializable::registerPdxType

PdxInstance::hasField

virtual CacheableStringArrayPtr gemfire::PdxInstance::getFieldNames (  )  [pure virtual]

Return an unmodifiable list of the field names on this PdxInstance.

Returns:
an unmodifiable list of the field names on this PdxInstance

virtual PdxSerializablePtr gemfire::PdxInstance::getObject (  )  [pure virtual]

Deserializes and returns the domain object that this instance represents.

For deserialization C++ Native Client requires the domain class to be registered.

Returns:
the deserialized domain object.
See also:
Serializable::registerPdxType

virtual bool gemfire::PdxInstance::hasField ( const char *  fieldname  )  [pure virtual]

Checks if the named field exists and returns the result.

This can be useful when writing code that handles more than one version of a PDX class.

Parameters:
fieldname the name of the field to check
Returns:
true if the named field exists; otherwise false

virtual uint32_t gemfire::PdxInstance::hashcode (  )  const [pure virtual]

Generates a hashcode based on the identity fields of this PdxInstance.

If a PdxInstance has marked identity fields using PdxWriter#markIdentityField then only the marked identity fields are its identity fields. Otherwise all its fields are identity fields. For deserialization C++ Native Client requires the domain class to be registered. If the field is an array then all array elements are used for hashcode computation. Otherwise the raw bytes of its value are used to compute the hash code.

Exceptions:
IllegalStateException if the field contains an element that is not of CacheableKey derived type.
See also:
Serializable::registerPdxType

virtual bool gemfire::PdxInstance::isIdentityField ( const char *  fieldname  )  [pure virtual]

Checks if the named field was PdxWriter#markIdentityFieldmarked as an identity field.

Note that if no fields have been marked then all the fields are used as identity fields even though this method will return false since none of them have been marked.

Parameters:
fieldname the name of the field to check
Returns:
true if the named field exists and was marked as an identify field; otherwise false

virtual uint32_t gemfire::PdxInstance::objectSize (  )  const [pure virtual]

Returns:
the size of the object in bytes This is an internal method.

It is used in case of heap LRU property is set.

virtual bool gemfire::PdxInstance::operator== ( const CacheableKey other  )  const [pure virtual]

Returns true if the given CacheableKey derived object is equals to this instance.

If other is not a PdxInstance then it is not equal to this instance. NOTE: Even if other is the result of calling getObject() it will not be equal to this instance.

Otherwise equality of two PdxInstances is determined as follows:

  1. The domain class name must be equal for both PdxInstances
  2. Each identity field must be equal.
If one of the instances does not have a field that the other one does then equals will assume it has the field with a default value. If a PdxInstance has marked identity fields using markIdentityField then only the marked identity fields are its identity fields. Otherwise all its fields are identity fields.

An identity field is equal if all the following are true:

  1. The field name is equal.
  2. The field type is equal.
  3. The field value is equal.
If an identity field is of type derived from Cacheable then it is deserialized. For deserialization C++ Native Client requires the domain class to be registered. If the deserialized object is an array then all array elements are used to determine equality. If an identity field is of type CacheableObjectArray then it is deserialized and all array elements are used to determine equality. For all other field types the value does not need to be deserialized. Instead the serialized raw bytes are compared and used to determine equality.
Parameters:
other the other instance to compare to this.
Returns:
true if this instance is equal to other.
Exceptions:
IllegalStateException if the field contains an element that is not of CacheableKey derived type.
See also:
Serializable::registerPdxType

virtual void gemfire::PdxInstance::toData ( PdxWriterPtr  output  )  [pure virtual]

serialize this object in gemfire PDX format. This is an internal method.

Parameters:
PdxWriter to serialize the PDX object

virtual void gemfire::PdxInstance::toData ( DataOutput output  )  const [inline, virtual]

serialize this object. This is an internal method.

virtual CacheableStringPtr gemfire::PdxInstance::toString (  )  const [pure virtual]

Prints out all of the identity fields of this PdxInstance.

If a PdxInstance has marked identity fields using PdxWriter#markIdentityField then only the marked identity fields are its identity fields. Otherwise all its fields are identity fields. For deserialization C++ Native Client requires the domain class to be registered.

See also:
Serializable::registerPdxType


GemFire C++ Cache API Documentation