Documentation Home
MySQL NDB Cluster API Developer Guide
Download this Manual

2.3.21 The NdbRecAttr Class

This section provides information about the NdbRecAttr class.

NdbRecAttr Class Overview

Parent class

None

Child classes

None

Description

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.

Methods

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().

Types

The NdbRecAttr class defines no public types.

~NdbRecAttr()

Description

The NdbRecAttr class destructor method.

You should delete only copies of NdbRecAttr objects that were created in your application using the clone() method.

Signature
~NdbRecAttr
    (
      void
    )
Parameters

None.

Return value

None.

NdbRecAttr::aRef()

Description

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.

Signature
char* aRef
    (
      void
    ) const
Parameters

A pointer to the attribute value. Because this pointer is constant, this method can be called anytime after NdbOperation::getValue() has been called.

Return value

None.

NdbRecAttr::char_value()

Description

This method gets a Char value stored in an NdbRecAttr object, and returns it as a char.

Signature
char char_value
    (
      void
    ) const
Parameters

None.

Return value

A char value.

NdbRecAttr::clone()

Description

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.

Signature
NdbRecAttr* clone
    (
      void
    ) const
Parameters

None.

Return value

An NdbRecAttr object. This is a complete copy of the original, including all data.

NdbRecAttr::double_value()

Description

This method gets a Double value stored in an NdbRecAttr object, and returns it as a double.

Signature
double double_value
    (
      void
    ) const
Parameters

None.

Return value

A double (8 bytes).

NdbRecAttr::float_value()

Description

This method gets a Float value stored in an NdbRecAttr object, and returns it as a float.

Signature
float float_value
    (
      void
    ) const
Parameters

None.

Return value

A float (4 bytes).

NdbRecAttr::get_size_in_bytes()

Description

You can use this method to obtain the size of an attribute (element).

Signature
Uint32 get_size_in_bytes
    (
      void
    ) const
Parameters

None.

Return value

The attribute size in bytes, as an unsigned 32-bit integer.

NdbRecAttr::getColumn()

Description

This method is used to obtain the column to which the attribute belongs.

Signature
const NdbDictionary::Column* getColumn
    (
      void
    ) const
Parameters

None.

Return value

A pointer to a Column object.

NdbRecAttr::getType()

Description

This method is used to obtain the column's data type.

Signature
NdbDictionary::Column::Type getType
    (
      void
    ) const
Parameters

None.

Return value

A Column::Type value.

NdbRecAttr::int8_value()

Description

This method gets a Small value stored in an NdbRecAttr object, and returns it as an 8-bit signed integer.

Signature
Int8 int8_value
    (
      void
    ) const
Parameters

None.

Return value

An 8-bit signed integer.

NdbRecAttr::int32_value()

Description

This method gets an Int value stored in an NdbRecAttr object, and returns it as a 32-bit signed integer.

Signature
Int32 int32_value
    (
      void
    ) const
Parameters

None.

Return value

A 32-bit signed integer.

NdbRecAttr::int64_value()

Description

This method gets a Bigint value stored in an NdbRecAttr object, and returns it as a 64-bit signed integer.

Signature
Int64 int64_value
    (
      void
    ) const
Parameters

None.

Return value

A 64-bit signed integer.

NdbRecAttr::isNULL()

Description

This method checks whether a given attribute value is NULL.

Signature
int isNULL
    (
      void
    ) const
Parameters

None.

Return value

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.

NdbRecAttr::medium_value()

Description

Gets the value of a Mediumint value stored in an NdbRecAttr object, and returns it as a 32-bit signed integer.

Signature
Int32 medium_value
    (
      void
    ) const
Parameters

None.

Return value

A 32-bit signed integer.

NdbRecAttr::short_value()

Description

This method gets a Smallint value stored in an NdbRecAttr object, and returns it as a 16-bit signed integer (short).

Signature
short short_value
    (
      void
    ) const
Parameters

None.

Return value

A 16-bit signed integer.

NdbRecAttr::u_8_value()

Description

This method gets a Smallunsigned value stored in an NdbRecAttr object, and returns it as an 8-bit unsigned integer.

Signature
Uint8 u_8_value
    (
      void
    ) const
Parameters

None.

Return value

An 8-bit unsigned integer.

NdbRecAttr::u_32_value()

Description

This method gets an Unsigned value stored in an NdbRecAttr object, and returns it as a 32-bit unsigned integer.

Signature
Uint32 u_32_value
    (
      void
    ) const
Parameters

None.

Return value

A 32-bit unsigned integer.

NdbRecAttr::u_64_value()

Description

This method gets a Bigunsigned value stored in an NdbRecAttr object, and returns it as a 64-bit unsigned integer.

Signature
Uint64 u_64_value
    (
      void
    ) const
Parameters

None.

Return value

A 64-bit unsigned integer.

NdbRecAttr::u_char_value()

Description

This method gets a Char value stored in an NdbRecAttr object, and returns it as an unsigned char.

Signature
Uint8 u_char_value
    (
      void
    ) const
Parameters

None.

Return value

An 8-bit unsigned char value.

NdbRecAttr::u_medium_value()

Description

This method gets an Mediumunsigned value stored in an NdbRecAttr object, and returns it as a 32-bit unsigned integer.

Signature
Uint32 u_medium_value
    (
      void
    ) const
Parameters

None.

Return value

A 32-bit unsigned integer.

NdbRecAttr::u_short_value()

Description

This method gets a Smallunsigned value stored in an NdbRecAttr object, and returns it as a 16-bit (short) unsigned integer.

Signature
Uint16 u_short_value
    (
      void
    ) const
Parameters

None.

Return value

A short (16-bit) unsigned integer.