MySQL NDB Cluster API Developer Guide
This section provides information about the
NdbRecAttr
class.
None
None
NdbRecAttr
contains the value of an
attribute. An NdbRecAttr
object is used
to store an attribute value after it has been retrieved
using the
NdbOperation::getValue()
method. This object is allocated by the NDB API. A brief
example is shown here:
MyRecAttr = MyOperation->getValue("ATTR2", NULL); if(MyRecAttr == NULL) goto error; if(MyTransaction->execute(Commit) == -1) goto error; ndbout << MyRecAttr->u_32_value();
For additional examples, see Section 2.5.1, “NDB API Example Using Synchronous Transactions”.
An NdbRecAttr
object is instantiated with
its value only when
NdbTransaction::execute()
is invoked. Prior to this, the value is undefined. (Use
NdbRecAttr::isNULL()
to
check whether the value is defined.) This means that an
NdbRecAttr
object has valid information
only between the times that
NdbTransaction::execute()
and Ndb::closeTransaction()
are called. The value of the NULL
indicator is -1
until the
NdbTransaction::execute()
method is invoked.
NdbRecAttr
has a number of methods for
retrieving values of various simple types directly from an
instance of this class.
It is also possible to obtain a reference to the value
regardless of its actual type, by using
NdbRecAttr::aRef()
;
however, you should be aware that this is not type-safe, and
requires a cast from the user.
The following table lists all of the public methods of this class and the purpose or use of each method:
Table 2.56 NdbRecAttr class methods and descriptions
Name | Description |
---|---|
~NdbRecAttr() |
Destructor method |
aRef() |
Gets a pointer to the attribute value |
char_value() |
Retrieves a Char attribute value |
clone() |
Makes a deep copy of the RecAttr object |
double_value() |
Retrieves a Double attribute value, as a double (8
bytes) |
float_value() |
Retrieves a Float attribute value, as a float (4
bytes) |
get_size_in_bytes() |
Gets the size of the attribute, in bytes |
getColumn() |
Gets the column to which the attribute belongs |
getType() |
Gets the attribute's type
(Column::Type ) |
isNULL() |
Tests whether the attribute is NULL |
int8_value() |
Retrieves a Tinyint attribute value, as an 8-bit
integer |
int32_value() |
Retrieves an Int attribute value, as a 32-bit integer |
int64_value() |
Retrieves a Bigint attribute value, as a 64-bit
integer |
medium_value() |
Retrieves a Mediumint attribute value, as a 32-bit
integer |
short_value() |
Retrieves a Smallint attribute value, as a 16-bit
integer |
u_8_value() |
Retrieves a Tinyunsigned attribute value, as an
unsigned 8-bit integer |
u_32_value() |
Retrieves an Unsigned attribute value, as an unsigned
32-bit integer |
u_64_value() |
Retrieves a Bigunsigned attribute value, as an
unsigned 64-bit integer |
u_char_value() |
Retrieves a Char attribute value, as an unsigned
char |
u_medium_value() |
Retrieves a Mediumunsigned attribute value, as an
unsigned 32-bit integer |
u_short_value() |
Retrieves a Smallunsigned attribute value, as an
unsigned 16-bit integer |
The NdbRecAttr
class has no
public constructor; an instance of this object is created
using
NdbTransaction::execute()
.
For information about the destructor, which is public, see
~NdbRecAttr().
The NdbRecAttr
class defines no public
types.
The NdbRecAttr
class
destructor method.
You should delete only copies of
NdbRecAttr
objects that
were created in your application using the
clone()
method.
~NdbRecAttr ( void )
None.
None.
This method is used to obtain a reference to an attribute
value, as a char
pointer. This pointer is
aligned appropriately for the data type. The memory is
released by the NDB API when
NdbTransaction::close()
is
executed on the transaction which read the value.
char* aRef ( void ) const
A pointer to the attribute value. Because this pointer is
constant, this method can be called anytime after
NdbOperation::getValue()
has been called.
None.
This method gets a Char
value stored in
an NdbRecAttr
object, and
returns it as a char
.
char char_value ( void ) const
None.
A char
value.
This method creates a deep copy of an
NdbRecAttr
object.
The copy created by this method should be deleted by the application when no longer needed.
NdbRecAttr* clone ( void ) const
None.
An NdbRecAttr
object. This
is a complete copy of the original, including all data.
This method gets a Double
value stored in
an NdbRecAttr
object, and
returns it as a double.
double double_value ( void ) const
None.
A double (8 bytes).
This method gets a Float
value stored in
an NdbRecAttr
object, and
returns it as a float.
float float_value ( void ) const
None.
A float (4 bytes).
You can use this method to obtain the size of an attribute (element).
Uint32 get_size_in_bytes ( void ) const
None.
The attribute size in bytes, as an unsigned 32-bit integer.
This method is used to obtain the column to which the attribute belongs.
const NdbDictionary::Column* getColumn ( void ) const
None.
A pointer to a Column
object.
This method is used to obtain the column's data type.
NdbDictionary::Column::Type getType ( void ) const
None.
A Column::Type
value.
This method gets a Small
value stored in
an NdbRecAttr
object, and
returns it as an 8-bit signed integer.
Int8 int8_value ( void ) const
None.
An 8-bit signed integer.
This method gets an Int
value stored in
an NdbRecAttr
object, and
returns it as a 32-bit signed integer.
Int32 int32_value ( void ) const
None.
A 32-bit signed integer.
This method gets a Bigint
value stored in
an NdbRecAttr
object, and
returns it as a 64-bit signed integer.
Int64 int64_value ( void ) const
None.
A 64-bit signed integer.
This method checks whether a given attribute value is
NULL
.
int isNULL ( void ) const
None.
One of the following three values:
-1
: The attribute value is not
defined due to an error.
0
: The attribute value is defined,
but is not NULL
.
1
: The attribute value is defined and
is NULL
.
In the event that
NdbTransaction::execute()
has not
yet been called, the value returned by isNULL()
is not determined.
Gets the value of a Mediumint
value
stored in an NdbRecAttr
object, and returns it as a 32-bit signed integer.
Int32 medium_value ( void ) const
None.
A 32-bit signed integer.
This method gets a Smallint
value stored
in an NdbRecAttr
object,
and returns it as a 16-bit signed integer (short).
short short_value ( void ) const
None.
A 16-bit signed integer.
This method gets a Smallunsigned
value
stored in an NdbRecAttr
object, and returns it as an 8-bit unsigned integer.
Uint8 u_8_value ( void ) const
None.
An 8-bit unsigned integer.
This method gets an Unsigned
value stored
in an NdbRecAttr
object,
and returns it as a 32-bit unsigned integer.
Uint32 u_32_value ( void ) const
None.
A 32-bit unsigned integer.
This method gets a Bigunsigned
value
stored in an NdbRecAttr
object, and returns it as a 64-bit unsigned integer.
Uint64 u_64_value ( void ) const
None.
A 64-bit unsigned integer.
This method gets a Char
value stored in
an NdbRecAttr
object, and
returns it as an unsigned char
.
Uint8 u_char_value ( void ) const
None.
An 8-bit unsigned char
value.
This method gets an Mediumunsigned
value
stored in an NdbRecAttr
object, and returns it as a 32-bit unsigned integer.
Uint32 u_medium_value ( void ) const
None.
A 32-bit unsigned integer.
This method gets a Smallunsigned
value
stored in an NdbRecAttr
object, and returns it as a 16-bit (short) unsigned integer.
Uint16 u_short_value ( void ) const
None.
A short (16-bit) unsigned integer.