Ndb Class Reference

Represents the NDB kernel and is the main class of the NDB API. More...

#include <Ndb.hpp>

List of all members.

Classes

Public Member Functions

General
Meta Information
Event subscriptions
Error Handling

Starting and Closing Transactions


Detailed Description

Represents the NDB kernel and is the main class of the NDB API.

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.

Note:
It is not allowed to call methods in the NDB API on the same Ndb object in different threads simultaneously (without special handling of the Ndb object).

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.


Constructor & Destructor Documentation

Ndb::Ndb ( Ndb_cluster_connection ndb_cluster_connection,
const char *  aCatalogName = "",
const char *  aSchemaName = "def" 
)

The Ndb object represents a connection to a database.

Note:
The init() method must be called before the Ndb object may actually be used.
Parameters:
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.
Note:
The catalog name provides a namespace for the tables and indexes created in any connection from the Ndb object.
Parameters:
aSchemaName is the name of the schema you want to use.
Note:
The schema name provides an additional namespace for the tables and indexes created in a given catalog.


Member Function Documentation

void Ndb::closeTransaction ( NdbTransaction  ) 

Close a transaction.

Note:
should be called after the transaction has completed, irrespective of success or failure

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

Parameters:
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
Note:
if xfrmbuf is null (default) malloc/free will be made if xfrmbuf is not null but length is too short, method will fail
Returns:
0 - ok - hashvalueptr is set else - fail, return error code

NdbEventOperation* Ndb::createEventOperation ( const char *  eventName  ) 

Create a subcription to an event defined in the database

Parameters:
eventName unique identifier of the event
Returns:
Object representing an event, NULL on failure

int Ndb::dropEventOperation ( NdbEventOperation eventOp  ) 

Drop a subscription to an event

Parameters:
eventOp Event operation
Returns:
0 on success

const char* Ndb::getDatabaseName (  )  const

The current database name can be fetched by getDatabaseName.

Returns:
the current database name

const char* Ndb::getDatabaseSchemaName (  )  const

The current database schema name can be fetched by getDatabaseSchemaName.

Returns:
the current database schema name

class NdbDictionary::Dictionary* Ndb::getDictionary (  )  const

Get an object for retrieving or manipulating database schema information

Note:
this object operates outside any transaction
Returns:
Object containing meta information about all tables in NDB Cluster.

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  ) 

Get a NdbError object for a specific error code

The NdbError object is valid until you call a new NDB API method.

const NdbError& Ndb::getNdbError (  )  const

Get the NdbError object

Note:
The NdbError object is valid until a new NDB API method is called.

int Ndb::init ( int  maxNoOfTransactions = 4  ) 

Initializes the Ndb object

Parameters:
maxNoOfTransactions Maximum number of parallel NdbTransaction objects that can be handled by the Ndb object. Maximum value is 1024.
Note:
each scan or index scan operation uses one extra NdbTransaction object
Returns:
0 if successful, -1 otherwise.

NdbEventOperation* Ndb::nextEvent (  ) 

Returns an event operation that has data after a pollEvents

Returns:
an event operations that has data, NULL if no events left with data.

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.

Parameters:
aMillisecondNumber maximum time to wait
Returns:
> 0 if events available, 0 if no events available, < 0 on failure

int Ndb::setDatabaseName ( const char *  aDatabaseName  ) 

The current database name can be set by setDatabaseName.

Parameters:
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.

Parameters:
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

Note:
When the transaction is completed it must be closed using Ndb::closeTransaction or NdbTransaction::close. The transaction must be closed independent of its outcome, i.e. even if there is an error.
Parameters:
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
Returns:
NdbTransaction object, or NULL on failure.


Documentation generated Wed Apr 22 09:21:37 2009 from mysql source files.
© 2003-2004 MySQL AB