Abstract
This section describes the Table
class, which
models a database table in the NDB API.
Parent class. NdbDictionary
Child classes. None
Description.
The Table
class represents a table in a MySQL
Cluster database. This class extends the Object
class, which in turn is an inner class of the
NdbDictionary
class.
It is possible using the NDB API to create tables independently of
the MySQL server. However, it is usually not advisable to do so,
since tables created in this fashion cannot be seen by the MySQL
server. Similarly, it is possible using Table
methods to modify existing tables, but these changes (except for
renaming tables) are not visible to MySQL.
Calculating Table Sizes. When calculating the data storage one should add the size of all attributes (each attribute consuming a minimum of 4 bytes) and well as 12 bytes overhead. Variable size attributes have a size of 12 bytes plus the actual data storage parts, with an additional overhead based on the size of the variable part. For example, consider a table with 5 attributes: one 64-bit attribute, one 32-bit attribute, two 16-bit attributes, and one array of 64 8-bit attributes. The amount of memory consumed per record by this table is the sum of the following:
8 bytes for the 64-bit attribute
4 bytes for the 32-bit attribute
8 bytes for the two 16-bit attributes, each of these taking up 4 bytes due to right-alignment
64 bytes for the array (64 * 1 byte per array element)
12 bytes overhead
This totals 96 bytes per record. In addition, you should assume an overhead of about 2% for the allocation of page headers and wasted space. Thus, 1 million records should consume 96 MB, and the additional page header and other overhead comes to approximately 2 MB. Rounding up yields 100 MB.
Methods. The following table lists the public methods of this class and the purpose or use of each method:
Method | Purpose / Use |
---|---|
Table() |
Class constructor |
~Table() |
Destructor |
getName() |
Gets the table's name |
getTableId() |
Gets the table's ID |
getColumn() |
Gets a column (by name) from the table |
getLogging() |
Checks whether logging to disk is enabled for this table |
getFragmentType() |
Gets the table's FragmentType
|
getKValue() |
Gets the table's KValue
|
getMinLoadFactor() |
Gets the table's minimum load factor |
getMaxLoadFactor() |
Gets the table's maximum load factor |
getNoOfColumns() |
Gets the number of columns in the table |
getNoOfPrimaryKeys() |
Gets the number of columns in the table's primary key. |
getPrimaryKey() |
Gets the name of the table's primary key |
equal() |
Compares the table with another table |
getFrmData() |
Gets the data from the table .FRM file |
getFrmLength() |
Gets the length of the table's .FRM file |
getFragmentData() |
Gets table fragment data (ID, state, and node group) |
getFragmentDataLen() |
Gets the length of the table fragment data |
getRangeListData() |
Gets a RANGE or LIST array |
getRangeListDataLen() |
Gets the length of the table RANGE or
LIST array |
getTablespaceData() |
Gets the ID and version of the tablespace containing the table |
getTablespaceDataLen() |
Gets the length of the table's tablespace data |
getLinearFlag() |
Gets the current setting for the table's linear hashing flag |
getFragmentCount() |
Gets the number of fragments for this table |
getFragmentNodes() |
Gets IDs of data nodes on which fragments are located |
getTablespace() |
Gets the tablespace containing this table |
getTablespaceNames() |
|
getObjectType() |
Gets the table's object type (Object::Type as opposed
to Table::Type ) |
getObjectStatus() |
Gets the table's object status |
getObjectVersion() |
Gets the table's object version |
getObjectId() |
Gets the table's object ID |
getMaxRows() |
Gets the maximum number of rows that this table may contain |
getDefaultNoPartitionsFlag() |
Checks whether the default number of partitions is being used |
getRowGCIIndicator() |
|
getRowChecksumIndicator() |
|
setName() |
Sets the table's name |
addColumn() |
Adds a column to the table |
setLogging() |
Toggle logging of the table to disk |
setLinearFlag() |
Sets the table's linear hashing flag |
setFragmentCount() |
Sets the number of fragments for this table |
setFragmentType() |
Sets the table's FragmentType
|
setKValue() |
Set the KValue
|
setMinLoadFactor() |
Set the table's minimum load factor (MinLoadFactor ) |
setMaxLoadFactor() |
Set the table's maximum load factor (MaxLoadFactor ) |
setTablespace() |
Set the tablespace to use for this table |
setStatusInvalid() |
|
setMaxRows() |
Sets the maximum number of rows in the table |
setDefaultNoPartitionsFlag() |
Toggles whether the default number of partitions should be used for the table |
setFrm() |
Sets the .FRM file to be used for this table |
setFragmentData() |
Sets the fragment ID, node group ID, and fragment state |
setTablespaceNames() |
Sets the tablespace names for fragments |
setTablespaceData() |
Sets the tablespace ID and version |
setRangeListData() |
Sets LIST and RANGE partition data |
setObjectType() |
Sets the table's object type |
setRowGCIIndicator() |
Documentation not yet available. |
setRowChecksumIndicator() |
Documentation not yet available. |
aggregate() |
Computes aggregate data for the table |
validate() |
Validates the definition for a new table prior to creating it |
hasDefaultValues() |
Determine whether table has any columns using default values |
For detailed descriptions, signatures, and examples of use for each
of these methods, see Section 2.3.21.2, “Table
Methods”.
Types.
The Table
class defines a single public type
SingleUserMode
. For more information, see
Section 2.3.21.1, “The Table::SingleUserMode
Type”.
Class diagram.
This diagram shows all the available methods of the
Table
class: