2.3.10.2 Index Methods

2.3.10.2.1 Index Class Constructor
2.3.10.2.2 Index::addColumn()
2.3.10.2.3 Index::addColumnName()
2.3.10.2.4 Index::addColumnNames()
2.3.10.2.5 Index::getColumn()
2.3.10.2.6 Index::getLogging()
2.3.10.2.7 Index::getName()
2.3.10.2.8 Index::getNoOfColumns()
2.3.10.2.9 Index::getObjectStatus()
2.3.10.2.10 Index::getObjectVersion()
2.3.10.2.11 Index::getObjectId()
2.3.10.2.12 Index::getTable()
2.3.10.2.13 Index::getType()
2.3.10.2.14 Index::setLogging
2.3.10.2.15 Index::setName()
2.3.10.2.16 Index::setTable()
2.3.10.2.17 Index::setType()

Abstract

This section contain descriptions of all public methods of the Index class. This class has relatively few methods (compared to, say, Table), which are fairly straightforward to use.

Important

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

2.3.10.2.1 Index Class Constructor

Description.  This is used to create an new instance of Index.

Important

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 using setName(). See Section 2.3.10.2.15, “Index::setName()”.

Return value.  A new instance of Index.

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

2.3.10.2.2 Index::addColumn()

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

Note

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 reference c to the column which is to be added to the index.

Return value.  None.

2.3.10.2.3 Index::addColumnName()

Description.  This method works in the same way as addColumn(), except that it takes the name of the column as a parameter. See Section 2.3.10.2.5, “Index::getColumn()”.

Signature. 

void addColumnName
    (
      const char* name
    )

Parameters.  The name of the column to be added to the index, as a constant character pointer.

Return value.  None.

2.3.10.2.4 Index::addColumnNames()

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

Note

As with the addColumn() and addColumnName() methods, the indexes are numbered in the order in which they were added. (However, this matters only for ordered indexes.)

Signature. 

void addColumnNames
    (
      unsigned     noOfNames,
      const char** names
    )

Parameters.  This method takes two parameters, listed here:

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

  • The names to be added (as a pointer to a pointer).

Return value.  None.

2.3.10.2.5 Index::getColumn()

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

Signature. 

const Column* getColumn
    (
      unsigned no
    ) const

Parameters.  The ordinal position number no of the column, as an unsigned integer. Use the getNoOfColumns() method to determine how many columns make up the index—see Section 2.3.10.2.8, “Index::getNoOfColumns()”, for details.

Return value.  The column having position no in the index, as a pointer to an instance of Column. See Section 2.3.2, “The Column Class”.

2.3.10.2.6 Index::getLogging()

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

Note

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.

2.3.10.2.7 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.

2.3.10.2.8 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.

2.3.10.2.9 Index::getObjectStatus()

Description.  This method gets the object status of the index.

Signature. 

virtual Object::Status getObjectStatus
    (
      void
    ) const

Parameters.  None.

Return value.  A Status value—see Section 2.3.30.1.3, “The Object::Status Type”, for more information.

2.3.10.2.10 Index::getObjectVersion()

Description.  This method gets the object version of the index (see Section 8.6, “NDB Schema Object Versions”).

Signature. 

virtual int getObjectVersion
    (
      void
    ) const

Parameters.  None.

Return value.  The object version for the index, as an integer.

2.3.10.2.11 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.

2.3.10.2.12 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.

2.3.10.2.13 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. See Section 2.3.10.1, “The Index::Type Type”, for possible values.

2.3.10.2.14 Index::setLogging

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

Signature. 

void setLogging
    (
      bool enable
    )

Parameters.  setLogging() takes a single Boolean parameter enable. If enable is true, then logging is enabled for the index; if false, then logging of this index is disabled.

Return value.  None.

2.3.10.2.15 Index::setName()

Description.  This method sets the name of the index.

Note

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

Signature. 

void setName
    (
      const char* name
    )

Parameters.  The desired name for the index, as a constant character pointer.

Return value.  None.

2.3.10.2.16 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.  The name of the table to be indexed, as a constant character pointer.

Return value.  None.

2.3.10.2.17 Index::setType()

Description.  This method is used to set the index type.

Signature. 

void setType
    (
      Type type
    )

Parameters.  The type of index. For possible values, see Section 2.3.10.1, “The Index::Type Type”.

Return value.  None.