MySQL NDB Cluster API Developer Guide
This section provides information about the Index
class.
None
This class represents an index on an NDB
Cluster
table column. It is a descendant of the
NdbDictionary
class, using
the Object
class.
If you create or change indexes using the NDB API, these
modifications cannot be seen by MySQL. The only exception to
this is using
Index::setName()
to rename
the index.
The following table lists the public methods of
Index
and the purpose or use of each
method:
Table 2.22 Index class methods and descriptions
Name | Description |
---|---|
Index() |
Class constructor |
~Index() |
Destructor |
addColumn() |
Adds a Column 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 |
Index
defines one public type, the
Type
type.
This is used to create an new instance of
Index
.
Indexes created using the NDB API cannot be seen by the MySQL Server.
Index
(
const char* name
= ""
)
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
Index::setName().
A new instance of Index
.
The destructor (~Index()
) is supplied as
a virtual method.
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.
void addColumn
(
const Column& c
)
A reference c
to the column which
is to be added to the index.
None.
This method works in the same way as
addColumn()
, except that it takes the
name of the column as a parameter. See
Index::getColumn().
void addColumnName
(
const char* name
)
The name
of the column to be
added to the index, as a constant character pointer.
None.
This method is used to add several column names to an index definition at one time.
As with the
addColumn()
and
addColumnName()
methods, the indexes are numbered in the order in which they
were added. This normally matters only for ordered indexes.
void addColumnNames ( unsignednoOfNames
, const char**names
)
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).
None.
This method retrieves the column at the specified position within the index.
const Column* getColumn
(
unsigned no
) const
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
Index::getNoOfColumns(), for details.
The column having position no
in
the index, as a pointer to an instance of
Column
. See
Section 2.3.1, “The Column Class”.
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.)
bool getLogging ( void ) const
None.
A Boolean value:
true
: The index is being logged to
disk.
false
: The index is not being logged.
This method is used to obtain the name of an index.
const char* getName ( void ) const
None.
The name of the index, as a constant character pointer.
This method is used to obtain the number of columns making up the index.
unsigned getNoOfColumns ( void ) const
None.
An unsigned integer representing the number of columns in the index.
This method gets the object status of the index.
virtual Object::Status getObjectStatus ( void ) const
None.
A Status
value; see
Object::Status, for more information.
This method gets the object version of the index (see NDB Schema Object Versions).
virtual int getObjectVersion ( void ) const
None.
The object version for the index, as an integer.
This method is used to obtain the object ID of the index.
virtual int getObjectId ( void ) const
None.
The object ID, as an integer.
This method can be used to obtain the name of the table to which the index belongs.
const char* getTable ( void ) const
None.
The name of the table, as a constant character pointer.
This method can be used to find the type of index.
Type getType ( void ) const
None.
An index type. See Index::Type, for possible values.
This method is used to enable or disable logging of the index to disk.
void setLogging
(
bool enable
)
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.
None.
This method sets the name of the index.
This is the only
Index::set
method whose result is visible to a MySQL Server.
*
()
void setName
(
const char* name
)
The desired name
for the index,
as a constant character pointer.
None.
This method sets the table that is to be indexed. The table is referenced by name.
void setTable
(
const char* name
)
The name
of the table to be
indexed, as a constant character pointer.
None.
This method is used to set the index type.
void setType
(
Type type
)
The type
of index. For possible
values, see Index::Type.
None.
This section provides information about the
Index
type.
This is an enumerated type which describes the sort of
column index represented by a given instance of
Index
.
Do not confuse this enumerated type with
Object::Type
, or with
Column::Type
.
Possible values are shown, along with descriptions, in the following table:
Table 2.23 Index::Type data type values and descriptions
Name | Description |
---|---|
Undefined |
Undefined object type (initial/default value) |
UniqueHashIndex |
Unique unordered hash index (only index type currently supported) |
OrderedIndex |
Nonunique, ordered index |