[+/-]
Table ConstructorTable::addColumn()Table::aggregate()Table::equal()Table::getDefaultNoPartitionsFlag()Table::getFragmentData()Table::getFragmentDataLen()Table::getFrmData()Table::getFrmLength()Table::getColumn()Table::getFragmentCount()Table::getFragmentNodes()Table::getFragmentType()Table::getKValue()Table::getLinearFlag()Table::getLogging()Table::getMaxLoadFactor()Table::getMaxRows()Table::getMinLoadFactor()Table:getName()Table::getNoOfCOlumns()Table::getNoOfPrimaryKeys()Table::getObjectId()Table::getObjectStatus()Table::getObjectType()Table::getObjectVersion()Table::getPartitionId()Table::getPrimaryKey()Table::getRangeListData()Table::getRangeListDataLen()Table::getRowChecksumIndicator()Table::getRowGCIIndicator()Table::getTableId()Table::getTablespace()Table::getTablespaceData()Table::getTablespaceDataLen()Table::getTablespaceNames()Table::getTablespaceNamesLen()Table::hasDefaultValues()Table::setDefaultNoPartitionsFlag()Table::setFragmentCount()Table::setFragmentData()Table::setFragmentType()Table::setFrm()Table::setKValue()Table::setLinearFlag()Table::setLogging()Table::setMaxLoadFactor()Table::setMaxRows()Table::setMinLoadFactor()Table::setName()Table::setObjectType()Table::setRangeListData()Table::setRowChecksumIndicator()Table::setRowGCIIndicator()Table::setStatusInvalid()Table::setTablespace()Table::setTablespaceData()Table::setTablespaceNames()Table::validate()Abstract
This section discusses the public methods of the
Table class.
The assignment (=) operator is overloaded for
this class, so that it always performs a deep copy.
As with other database objects,
Table object creation and
attribute changes to existing tables done using the NDB API are
not visible from MySQL. For example, if you add a new column to
a table using
Table::addColumn(), MySQL will
not see the new column. The only exception to this rule with
regard to tables is that you can change the name of an existing
table using Table::setName().
Description.
Creates a Table instance.
There are two version of the
Table constructor, one for
creating a new instance, and a copy constructor.
Tables created in the NDB API using this method are not accessible from MySQL.
Signature. New instance:
Table
(
const char* name = ""
)
Copy constructor:
Table
(
const Table& table
)
Parameters. For a new instance, the name of the table to be created. For a copy, a reference to the table to be copied.
Return value.
A Table object.
Destructor.
virtual ~Table()
Description. Adds a column to a table.
Signature.
void addColumn
(
const Column& column
)
Parameters. A reference to the column which is to be added to the table.
Return value.
None; however, it does create a copy of
the original Column object.
Description.
This method computes aggregate data for the table. It is
required in order for aggregate methods such as
getNoOfPrimaryKeys() to
work properly before the table has been created and retrieved
via getTableId().
This method was added in MySQL 5.1.12 (see Bug #21690).
Signature.
int aggregate
(
struct NdbError& error
)
Parameters.
A reference to an NdbError
object.
Return value.
An integer, whose value is 0 on success,
and -1 if the table is in an inconsistent
state. In the latter case, the
error is also set.
Description.
This method is used to compare one instance of
Table with another.
Signature.
bool equal
(
const Table& table
) const
Parameters.
A reference to the Table
object with which the current instance is to be compared.
Return value.
true if the two tables are the same,
otherwise false.
Description. This method is used to find out whether the default number of partitions is used for the table.
Signature.
Uint32 getDefaultNoPartitionsFlag
(
void
) const
Parameters. None.
Return value. A 32-bit unsigned integer.
Description. This method gets the table's fragment data (ID, state, and node group).
Signature.
const void* getFragmentData
(
void
) const
Parameters. None.
Return value. A pointer to the data to be read.
Description. Gets the length of the table fragment data to be read, in bytes.
Signature.
Uint32 getFragmentDataLen
(
void
) const
Parameters. None.
Return value. The number of bytes to be read, as an unsigned 32-bit integer.
Description.
The the data from the .FRM file
associated with the table.
Signature.
const void* getFrmData
(
void
) const
Parameters. None.
Return value.
A pointer to the .FRM data.
Description.
Gets the length of the table's .FRM file
data, in bytes.
Signature.
Uint32 getFrmLength
(
void
) const
Parameters. None.
Return value.
The length of the .FRM file data (an
unsigned 32-bit integer).
Description. This method is used to obtain a column definition, given either the index or the name of the column.
Signature. This method can be invoked using either the column ID or column name, as shown here:
Column* getColumn
(
const int AttributeId
)
Column* getColumn
(
const char* name
)
Parameters.
Either of: the column's index in the table (as it would be
returned by the column's getColumnNo()
method), or the name of the column.
Return value.
A pointer to the column with the specified index or name. If
there is no such column, then this method returns
NULL.
Description. This method gets the number of fragments in the table.
Signature.
Uint32 getFragmentCount
(
void
) const
Parameters. None.
Return value. The number of table fragments, as a 32-bit unsigned integer.
Description. This method retrieves a list of nodes storing a given fragment.
Signature.
Uint32 getFragmentNodes
(
Uint32 fragmentId,
Uint32* nodeIdArrayPtr,
Uint32 arraySize
) const
Parameters. This method takes the following three parameters:
fragmentId: The ID of the desired
fragment.
nodeIdArrayPtr: Pointer to an
array of node IDs of the nodes containing this fragment.
Normally, the primary fragment is entry 0 in this array.
arraySize: The size of the array
containing the node IDs. If this is less than the number of
fragments, then only the first
arraySize entries are written to
this array.
Return value.
A return value of 0 indicates an error;
otherwise, this is the number of table fragments, as a 32-bit
unsigned integer.
This method was added in MySQL Cluster NDB 6.2.19, MySQL Cluster NDB 6.3.33, MySQL Cluster NDB 7.0.14, and MySQL Cluster NDB 7.1.2.
Description. This method gets the table's fragmentation type.
Signature.
FragmentType getFragmentType
(
void
) const
Parameters. None.
Return value.
A FragmentType value, as defined in
Section 2.3.28.1.1, “The Object::FragmentType Type”.
Description.
This method gets the KValue, a hashing parameter which is
currently restricted to the value 6. In a
future release, it may become feasible to set this parameter
to other values.
Signature.
int getKValue
(
void
) const
Parameters. None.
Return value.
An integer (currently always 6).
Description. This method retrieves the value of the table's linear hashing flag.
Signature.
bool getLinearFlag
(
void
) const
Parameters. None.
Return value.
true if the flag is set, and
false if it is not.
Description. This class is used to check whether a table is logged to disk—that is, whether it is permanent or temporary.
Signature.
bool getLogging
(
void
) const
Parameters. None.
Return value.
Returns a Boolean value. If this method returns
true, then full checkpointing and logging
are done on the table. If false, then the
table is a temporary table and is not logged to disk; in the
event of a system restart the table still exists and retains
its definition, but it will be empty. The default logging
value is true.
Description. This method returns the load factor (a hashing parameter) when splitting of the containers in the local hash tables begins.
Signature.
int getMaxLoadFactor
(
void
) const
Parameters. None.
Return value. An integer whose maximum value is 100. When the maximum value is returned, this means that memory usage is optimised. Smaller values indicate that less data is stored in each container, which means that keys are found more quickly; however, this also consumes more memory.
Description. This method gets the maximum number of rows that the table can hold. This is used for calculating the number of partitions.
Signature.
Uint64 getMaxRows
(
void
) const
Parameters. None.
Return value. The maximum number of table rows, as a 64-bit unsigned integer.
Description.
This method gets the value of the load factor when reduction
of the hash table begins. This should always be less than the
value returned by getMaxLoadFactor().
Signature.
int getMinLoadFactor
(
void
) const
Parameters. None.
Return value.
An integer (actually, a percentage expressed as an integer;
see Section 2.3.34.2.17, “Table::getMaxLoadFactor()”).
Description. Gets the name of a table.
Signature.
const char* getName
(
void
) const
Parameters. None.
Return value. The name of the table (a string).
Description. This method is used to obtain the number of columns in a table.
Signature.
int getNoOfColumns
(
void
) const
Parameters. None.
Return value. An integer representing the number of columns in the table.
Description. This method finds the number of primary key columns in the table.
Signature.
int getNoOfPrimaryKeys
(
void
) const
Parameters. None.
Return value. An integer representing the number of primary key columns in the table.
Description. This method gets the table's object ID.
Signature.
virtual int getObjectId
(
void
) const
Parameters. None.
Return value. The object ID is returned as an integer.
Description.
This method gets the table's status—that is, its
Object::Status.
Signature.
virtual Object::Status getObjectStatus
(
void
) const
Parameters. None.
Return value.
A Status value. For possible values, see
Section 2.3.28.1.3, “The Object::Status Type”.
Description.
This method is used to obtain the table's type—that is,
its Object::Type value
Signature.
Object::Type getObjectType
(
void
) const
Parameters. None.
Return value.
Returns a Type value. For possible values,
see Section 2.3.28.1.5, “The Object::Type Type”.
Description. This method gets the table's object version.
Signature.
virtual int getObjectVersion
(
void
) const
Parameters. None.
Return value. The table's object version, as an integer.
Description. Gets a table partition ID given its hash value.
Signature.
Uint32 getPartitionId
(
Uint32 hashvalue
) const
Parameters.
A hashvalue. Note that if the table
has not actually been retrieved (using, for example,
getTableId()), then the
result is likely not to be accurate or useful.
Return value.
The identifier of the partition corresponding to the
hashvalue.
Description. This method is used to obtain the name of the table's primary key.
Signature.
const char* getPrimaryKey
(
int no
) const
Parameters. None.
Return value. The name of the primary key, a string (character pointer).
Description. This method gets the range or list data associated with the table.
Signature.
const void* getRangeListData
(
void
) const
Parameters. None.
Return value. A pointer to the data.
Description. This method gets the size of the table's range or list array.
Signature.
Uint32 getRangeListDataLen
(
void
) const
Parameters. None.
Return value. The length of the list or range array, as an integer.
Description. Check whether the row checksum indicator has been set.
Signature.
bool getRowChecksumIndicator
(
void
) const
Parameters. None.
Return value.
A true or false value.
Description. Checks whether the row GCI indicator has been set.
Signature.
bool getRowGCIIndicator
(
void
) const
Parameters. None.
Return value.
A true or false value.
Description. This method gets a table's ID.
Signature.
int getTableId
(
void
) const
Parameters. None.
Return value. An integer.
Description. This method is used in two ways: to obtain the name of the tablespace to which this table is assigned; to verify that a given tablespace is the one being used by this table.
Signatures. To obtain the name of the tablespace, invoke without any arguments:
const char* getTablespace
(
void
) const
To determine whether the tablespace is the one indicated by the given ID and version, supply these as arguments, as shown here:
bool getTablespace
(
Uint32* id = 0,
Uint32* version = 0
) const
Parameters. The number and types of parameters depend on how this method is being used:
When used to obtain the name of the tablespace in use by the table, it is called without any arguments.
When used to determine whether the given tablespace is the one being used by this table, then getTablespace() takes two parameters:
The tablespace id, given as a
pointer to a 32-bit unsigned integer
The tablespace version, also
given as a pointer to a 32-bit unsigned integer
The default value for both id and
version is 0.
Return value. The return type depends on how the method is called.
When getTablespace() is called without
any arguments, it returns a
Tablespace object instance.
When called with two arguments, it returns
true if the tablespace is the same as the
one having the ID and version indicated; otherwise, it
returns false.
Description. This method gets the table's tablespace data (ID and version).
Signature.
const void* getTablespaceData
(
void
) const
Parameters. None.
Return value. A pointer to the data.
Description. This method is used to get the length of the table's tablespace data.
Signature.
Uint32 getTablespaceDataLen
(
void
) const
Parameters. None.
Return value. The length of the data, as a 32-bit unsigned integer.
Description. This method gets a pointer to the names of the tablespaces used in the table fragments.
Signature.
const void* getTablespaceNames
(
void
)
Parameters. None.
Return value. Returns a pointer to the tablespace name data.
Description.
This method gets the length of the tablespace name data
returned by getTablespaceNames(). (See
Section 2.3.34.2.37, “Table::getTablespaceNames()”.)
Signature.
Uint32 getTablespaceNamesLen
(
void
) const
Parameters. None.
Return value. Returns the length of the name data, in bytes, as a 32-but unsigned integer.
Description.
Used to determine whether the table has any columns that are
defined with non-NULL default values.
This method was added in MySQL Cluster NDB 7.0.15 and MySQL Cluster NDB 7.1.4.
To read and write default column values, use
Column::getDefaultValue()
and
Column::setDefaultValue().
Signature.
bool hasDefaultValues
(
void
) const
Parameters. None.
Return value.
Returns true if the table has any
non-NULL columns with default values,
otherwise false.
Description. This method sets an indicator that determines whether the default number of partitions is used for the table.
Signature.
void setDefaultNoPartitionsFlag
(
Uint32 indicator
) const
Parameters.
This method takes a single argument
indicator, a 32-bit unsigned
integer.
Return value. None.
Description. Sets the number of table fragments.
Signature.
void setFragmentCount
(
Uint32 count
)
Parameters.
count is the number of fragments to
be used for the table.
Return value. None.
Description. This method writes an array containing the following fragment information:
Fragment ID
Node group ID
Fragment State
Signature.
void setFragmentData
(
const void* data,
Uint32 len
)
Parameters. This method takes the following two parameters:
A pointer to the fragment data to
be written
The length (len) of this data, in
bytes, as a 32-bit unsigned integer
Return value. None.
Description. This method sets the table's fragmentation type.
Signature.
void setFragmentType
(
FragmentType fragmentType
)
Parameters.
This method takes one argument, a
FragmentType value. See
Section 2.3.28.1.1, “The Object::FragmentType Type”, for more
information.
Return value. None.
Description.
This method is used to write data to this table's
.FRM file.
Signature.
void setFrm
(
const void* data,
Uint32 len
)
Parameters. This method takes the following two arguments:
A pointer to the data to be
written.
The length (len) of the data.
Return value. None.
Description.
This sets the KValue, a hashing parameter.
Signature.
void setKValue
(
int kValue
)
Parameters.
kValue is an integer. Currently the
only permitted value is 6. In a future
version this may become a variable parameter.
Return value. None.
Description.
Signature.
void setLinearFlag
(
Uint32 flag
)
Parameters.
The flag is a 32-bit unsigned
integer.
Return value. None.
Description.
Toggles the table's logging state. See
Section 2.3.34.2.16, “Table::getLogging()”.
Signature.
void setLogging
(
bool enable
)
Parameters.
If enable is
true, then logging for this table is
enabled; if it is false, then logging is
disabled.
Return value. None.
Description. This method sets the maximum load factor when splitting the containers in the local hash tables.
Signature.
void setMaxLoadFactor
(
int max
)
Parameters.
This method takes a single parameter
max, an integer representation of a
percentage (for example, 45 represents 45
percent). For more information, see
Section 2.3.34.2.17, “Table::getMaxLoadFactor()”.
This should never be greater than the minimum load factor.
Return value. None.
Description. This method sets the maximum number of rows that can be held by the table.
Signature.
void setMaxRows
(
Uint64 maxRows
)
Parameters.
maxRows is a 64-bit unsigned
integer that represents the maximum number of rows to be held
in the table.
Return value. None.
Description. This method sets the minimum load factor when reduction of the hash table begins.
Signature.
void setMinLoadFactor
(
int min
)
Parameters.
This method takes a single parameter
min, an integer representation of a
percentage (for example, 45 represents 45
percent). For more information, see
Section 2.3.34.2.19, “Table::getMinLoadFactor()”.
Return value. None.
Description. This method sets the name of the table.
This is the only
set method of
*()Table whose effects are
visible to MySQL.
Signature.
void setName
(
const char* name
)
Parameters.
name is the (new) name of the
table.
Return value. None.
Description. This method sets the table's object type.
Signature.
void setObjectType
(
Object::Type type
)
Parameters.
The desired object type. This must
be one of the Type values listed in
Section 2.3.28.1.5, “The Object::Type Type”.
Return value. None.
Description. This method sets an array containing information that maps range values and list values to fragments. This is essentially a sorted map consisting of fragment-ID/value pairs. For range partitions there is one pair per fragment. For list partitions it could be any number of pairs, but at least as many pairs as there are fragments.
Signature.
void setRangeListData
(
const void* data,
Uint32 len
)
Parameters. This method requires the following two parameters:
A pointer to the range or list
data containing the ID/value
pairs
The length (len) of this data, as
a 32-bit unsigned integer.
Return value. None.
Description. Set the row checksum indicator.
Signature.
void setRowChecksumIndicator
(
bool value
) const
Parameters.
A true/false
value.
Return value. None.
Description. Sets the row GCI indicator.
Signature.
void setRowGCIIndicator
(
bool value
) const
Parameters.
A true/false
value.
Return value. None.
Description. Forces the table's status to be invalidated.
Signature.
void setStatusInvalid
(
void
) const
Parameters. None.
Return value. None.
Description. This method sets the tablespace for the table.
Signatures. Using the name of the tablespace:
void setTablespace
(
const char* name
)
Using a Tablespace object:
void setTablespace
(
const class Tablespace& tablespace
)
Parameters. This method can be called with a single argument, which can be of either one of these two types:
The name of the tablespace (a
string).
A reference to an existing
Tablespace instance.
See Section 2.3.35, “The Tablespace Class”.
Return value. None.
Description. This method sets the tablespace information for each fragment, and includes a tablespace ID and a tablespace version.
Signature.
void setTablespaceData
(
const void* data,
Uint32 len
)
Parameters. This method requires the following two parameters:
A pointer to the data containing
the tablespace ID and version
The length (len) of this data, as
a 32-bit unsigned integer.
Return value. None.
Description. Sets the names of the tablespaces used by the table fragments.
Signature.
void setTablespaceNames
(
const void* data
Uint32 len
)
Parameters. This method takes the following two parameters:
A pointer to the tablespace names
data
The length (len) of the names
data, as a 32-bit unsigned integer.
Return value. None.
Description.
This method validates the definition for a new table prior to
its being created, and executes the
Table::aggregate() method, as
well as performing additional checks.
validate() is called automatically when a
table is created or retrieved. For this reason, it is usually
not necessary to call
aggregate() or
validate() directly.
Even after the validate() method is called,
there may still exist errors which can be detected only by the
NDB kernel when the table is actually
created.
This method was added in MySQL 5.1.12 (see Bug #21690).
Signature.
int validate
(
struct NdbError& error
)
Parameters.
A reference to an NdbError
object.
Return value.
An integer, whose value is 0 on success,
and -1 if the table is in an inconsistent
state. In the latter case, the
error is also set.
