Documentation Home
MySQL NDB Cluster API Developer Guide
Related Documentation Download this Manual
PDF (US Ltr) - 3.7Mb
PDF (A4) - 3.7Mb


2.3.8 The Index Class

This section provides information about theIndex class.

Index Class Overview

Parent class

NdbDictionary

Child classes

None

Description

This class represents an index on anNDB Cluster table column. It is a descendant of theNdbDictionary class, using theObject class.

If you create or change indexes using the NDB API, these modifications cannot be seen by MySQL. The only exception to this is usingIndex::setName() to rename the index.

Methods

The following table lists the public methods ofIndex and the purpose or use of each method:

Table 2.23 Index class methods and descriptions

NameDescription
Index()Class constructor
~Index()Destructor
addColumn()Adds aColumn object to the index
addColumnName()Adds a column by name to the index
addColumnNames()Adds multiple columns by name to the index
getColumn()Gets a column making up (part of) the index
getLogging()Checks whether the index is logged to disk
getName()Gets the name of the index
getNoOfColumns()Gets the number of columns belonging to the index
getObjectStatus()Gets the index object status
getObjectVersion()Gets the index object status
getObjectId()Gets the index object ID
getTable()Gets the name of the table being indexed
getType()Gets the index type
setLogging()Enable/disable logging of the index to disk
setName()Sets the name of the index
setTable()Sets the name of the table to be indexed
setType()Set the index type

Types

Index defines one public type, theType type.

Index Class Constructor

Description

This is used to create an new instance ofIndex.

Indexes created using the NDB API cannot be seen by the MySQL Server.

Signature
Index    (      const char*name = ""    )
Parameters

The name of the new index. It is possible to create an index without a name, and then assign a name to it later usingsetName(). SeeIndex::setName().

Return value

A new instance ofIndex.

Destructor

The destructor (~Index()) is supplied as a virtual method.

Index::addColumn()

Description

This method may be used to add a column to an index.

The order of the columns matches the order in which they are added to the index. However, this matters only with ordered indexes.

Signature
void addColumn    (      const Column&c    )
Parameters

A referencec to the column which is to be added to the index.

Return value

None.

Index::addColumnName()

Description

This method works in the same way asaddColumn(), except that it takes the name of the column as a parameter. SeeIndex::getColumn().

Signature
void addColumnName    (      const char*name    )
Parameters

Thename of the column to be added to the index, as a constant character pointer.

Return value

None.

Index::addColumnNames()

Description

This method is used to add several column names to an index definition at one time.

As with theaddColumn() andaddColumnName() methods, the indexes are numbered in the order in which they were added. This normally matters only for ordered indexes.

Signature
void addColumnNames    (      unsignednoOfNames,      const char**names    )
Parameters

This method takes two parameters, listed here:

  • The number of columns and namesnoOfNames to be added to the index.

  • Thenames to be added (as a pointer to a pointer).

Return value

None.

Index::getColumn()

Description

This method retrieves the column at the specified position within the index.

Signature
const Column* getColumn    (      unsignedno    ) const
Parameters

The ordinal position numberno of the column, as an unsigned integer. Use thegetNoOfColumns() method to determine how many columns make up the index—seeIndex::getNoOfColumns(), for details.

Return value

The column having positionno in the index, as a pointer to an instance ofColumn. SeeSection 2.3.1, “The Column Class”.

Index::getLogging()

Description

Use this method to determine whether logging to disk has been enabled for the index.

Indexes which are not logged are rebuilt when the cluster is started or restarted.

Ordered indexes currently do not support logging to disk; they are rebuilt each time the cluster is started. (This includes restarts.)

Signature
bool getLogging    (      void    ) const
Parameters

None.

Return value

A Boolean value:

  • true: The index is being logged to disk.

  • false: The index is not being logged.

Index::getName()

Description

This method is used to obtain the name of an index.

Signature
const char* getName    (      void    ) const
Parameters

None.

Return value

The name of the index, as a constant character pointer.

Index::getNoOfColumns()

Description

This method is used to obtain the number of columns making up the index.

Signature
unsigned getNoOfColumns    (      void    ) const
Parameters

None.

Return value

An unsigned integer representing the number of columns in the index.

Index::getObjectStatus()

Description

This method gets the object status of the index.

Signature
virtual Object::Status getObjectStatus    (      void    ) const
Parameters

None.

Return value

AStatus value; seeObject::Status, for more information.

Index::getObjectVersion()

Description

This method gets the object version of the index (seeNDB Schema Object Versions).

Signature
virtual int getObjectVersion    (      void    ) const
Parameters

None.

Return value

The object version for the index, as an integer.

Index::getObjectId()

Description

This method is used to obtain the object ID of the index.

Signature
virtual int getObjectId    (      void    ) const
Parameters

None.

Return value

The object ID, as an integer.

Index::getTable()

Description

This method can be used to obtain the name of the table to which the index belongs.

Signature
const char* getTable    (      void    ) const
Parameters

None.

Return value

The name of the table, as a constant character pointer.

Index::getType()

Description

This method can be used to find the type of index.

Signature
Type getType    (      void    ) const
Parameters

None.

Return value

An index type. SeeIndex::Type, for possible values.

Index::setLogging

Description

This method is used to enable or disable logging of the index to disk.

Signature
void setLogging    (      boolenable    )
Parameters

setLogging() takes a single Boolean parameterenable. Ifenable istrue, then logging is enabled for the index; if false, then logging of this index is disabled.

Return value

None.

Index::setName()

Description

This method sets the name of the index.

This is the onlyIndex::set*() method whose result is visible to a MySQL Server.

Signature
void setName    (      const char*name    )
Parameters

The desiredname for the index, as a constant character pointer.

Return value

None.

Index::setTable()

Description

This method sets the table that is to be indexed. The table is referenced by name.

Signature
void setTable    (      const char*name    )
Parameters

Thename of the table to be indexed, as a constant character pointer.

Return value

None.

Index::setType()

Description

This method is used to set the index type.

Signature
void setType    (      Typetype    )
Parameters

Thetype of index. For possible values, seeIndex::Type.

Return value

None.

Index::Type

This section provides information about theIndex type.

Description

This is an enumerated type which describes the sort of column index represented by a given instance ofIndex.

Do not confuse this enumerated type withObject::Type, or withColumn::Type.

Enumeration values

Possible values are shown, along with descriptions, in the following table:

Table 2.24 Index::Type data type values and descriptions

NameDescription
UndefinedUndefined object type (initial/default value)
UniqueHashIndexUnique unordered hash index (only index type currently supported)
OrderedIndexNonunique, ordered index