#include <Ndb.hpp>
Always start your application program by creating an Ndb object. By using several Ndb objects it is possible to design a multi-threaded application, but note that Ndb objects cannot be shared by several threads. Different threads should use different Ndb objects. A thread might however use multiple Ndb objects. Currently there is a limit of maximum 128 Ndb objects per application process.
The Ndb object is multi-thread safe in the following manner. Each Ndb object can ONLY be handled in one thread. If an Ndb object is handed over to another thread then the application must ensure that a memory barrier is used to ensure that the new thread see all updates performed by the previous thread. Semaphores, mutexes and so forth are easy ways of issuing memory barriers without having to bother about the memory barrier concept.
Ndb::Ndb | ( | Ndb_cluster_connection * | ndb_cluster_connection, | |
const char * | aCatalogName = "" , |
|||
const char * | aSchemaName = "def" | |||
) |
The Ndb object represents a connection to a database.
ndb_cluster_connection | is a connection to the cluster containing the database to be used | |
aCatalogName | is the name of the catalog to be used. |
aSchemaName | is the name of the schema you want to use. |
void Ndb::closeTransaction | ( | NdbTransaction * | ) |
Close a transaction.
static int Ndb::computeHash | ( | Uint32 * | hashvalueptr, | |
const NdbDictionary::Table * | , | |||
const struct Key_part_ptr * | keyData, | |||
void * | xfrmbuf = 0 , |
|||
Uint32 | xfrmbuflen = 0 | |||
) | [static] |
Compute hash value given table/keys
hashvalueptr | - OUT, is set to hashvalue if return value is 0 | |
table | Pointer to table object | |
keyData | Null-terminated array of pointers to keyParts that is part of distribution key. Length of resp. keyPart will be read from metadata and checked against passed value | |
xfrmbuf | Pointer to temporary buffer that will be used to calculate hashvalue | |
xfrmbuflen | Lengh of buffer |
NdbEventOperation* Ndb::createEventOperation | ( | const char * | eventName | ) |
Create a subcription to an event defined in the database
eventName | unique identifier of the event |
int Ndb::dropEventOperation | ( | NdbEventOperation * | eventOp | ) |
Drop a subscription to an event
eventOp | Event operation |
const char* Ndb::getDatabaseName | ( | ) | const |
The current database name can be fetched by getDatabaseName.
const char* Ndb::getDatabaseSchemaName | ( | ) | const |
The current database schema name can be fetched by getDatabaseSchemaName.
class NdbDictionary::Dictionary* Ndb::getDictionary | ( | ) | const |
Get an object for retrieving or manipulating database schema information
const NdbEventOperation* Ndb::getGCIEventOperations | ( | Uint32 * | iter, | |
Uint32 * | event_types | |||
) |
Iterate over distinct event operations which are part of current GCI. Valid after nextEvent. Used to get summary information for the epoch (e.g. list of all tables) before processing event data.
Set *iter=0 to start. Returns NULL when no more. If event_types is not NULL, it returns bitmask of received event types.
const NdbError& Ndb::getNdbError | ( | int | errorCode | ) |
const NdbError& Ndb::getNdbError | ( | ) | const |
int Ndb::init | ( | int | maxNoOfTransactions = 4 |
) |
Initializes the Ndb object
maxNoOfTransactions | Maximum number of parallel NdbTransaction objects that can be handled by the Ndb object. Maximum value is 1024. |
NdbEventOperation* Ndb::nextEvent | ( | ) |
Returns an event operation that has data after a pollEvents
int Ndb::pollEvents | ( | int | aMillisecondNumber, | |
Uint64 * | latestGCI = 0 | |||
) |
Wait for an event to occur. Will return as soon as an event is detected on any of the created events.
aMillisecondNumber | maximum time to wait |
int Ndb::setDatabaseName | ( | const char * | aDatabaseName | ) |
The current database name can be set by setDatabaseName.
aDatabaseName | is the new name of the current database |
int Ndb::setDatabaseSchemaName | ( | const char * | aDatabaseSchemaName | ) |
The current database schema name can be set by setDatabaseSchemaName.
aDatabaseSchemaName | is the new name of the current database schema |
NdbTransaction* Ndb::startTransaction | ( | const NdbDictionary::Table * | table = 0 , |
|
const char * | keyData = 0 , |
|||
Uint32 | keyLen = 0 | |||
) |
Start a transaction
table | Pointer to table object used for deciding which node to run the Transaction Coordinator on | |
keyData | Pointer to partition key corresponding to table | |
keyLen | Length of partition key expressed in bytes |