NdbBlob Class Reference

Blob handle. More...

#include <NdbBlob.hpp>

List of all members.

Classes

struct  Buf

Public Types

enum  State {
  Idle = 0, Prepared = 1, Active = 2, Closed = 3,
  Invalid = 9
}
typedef int ActiveHook (NdbBlob *me, void *arg)

Public Member Functions

State getState ()
void getVersion (int &version)
int getValue (void *data, Uint32 bytes)
int setValue (const void *data, Uint32 bytes)
int setActiveHook (ActiveHook *activeHook, void *arg)
int getDefined (int &isNull)
int getNull (bool &isNull)
int getNull (int &isNull)
int setNull ()
int getLength (Uint64 &length)
int truncate (Uint64 length=0)
int getPos (Uint64 &pos)
int setPos (Uint64 pos)
int readData (void *data, Uint32 &bytes)
int writeData (const void *data, Uint32 bytes)
const NdbDictionary::ColumngetColumn ()
const NdbErrorgetNdbError () const
const NdbOperationgetNdbOperation () const
NdbBlobblobsFirstBlob ()
NdbBlobblobsNextBlob ()

Static Public Member Functions

static int getBlobTableName (char *btname, Ndb *anNdb, const char *tableName, const char *columnName)
static int getBlobEventName (char *bename, Ndb *anNdb, const char *eventName, const char *columnName)

Private Types

enum  {
  BtColumnPk = 0, BtColumnDist = 1, BtColumnPart = 2, BtColumnPkid = 3,
  BtColumnData = 4
}

Private Member Functions

void setState (State newState)
Uint32 noPartitionId ()
 NdbBlob (Ndb *)
void init ()
void release ()
bool isTableOp ()
bool isIndexOp ()
bool isKeyOp ()
bool isReadOp ()
bool isInsertOp ()
bool isUpdateOp ()
bool isWriteOp ()
bool isDeleteOp ()
bool isScanOp ()
bool isReadOnlyOp ()
bool isTakeOverOp ()
Uint32 getPartNumber (Uint64 pos)
Uint32 getPartOffset (Uint64 pos)
Uint32 getPartCount ()
Uint32 getDistKey (Uint32 part)
int packKeyValue (const NdbTableImpl *aTable, const Buf &srcBuf)
int unpackKeyValue (const NdbTableImpl *aTable, Buf &dstBuf)
int copyKeyFromRow (const NdbRecord *record, const char *row, Buf &packedBuf, Buf &unpackedBuf)
Uint32 getHeadInlineSize ()
void prepareSetHeadInlineValue ()
void getNullOrEmptyBlobHeadDataPtr (const char *&data, Uint32 &byteSize)
void packBlobHead ()
void unpackBlobHead ()
int getTableKeyValue (NdbOperation *anOp)
int setTableKeyValue (NdbOperation *anOp)
int setAccessKeyValue (NdbOperation *anOp)
int setDistKeyValue (NdbOperation *anOp, Uint32 part)
int setPartKeyValue (NdbOperation *anOp, Uint32 part)
int setPartPkidValue (NdbOperation *anOp, Uint32 pkid)
int getPartDataValue (NdbOperation *anOp, char *buf, Uint16 *aLenLoc)
int setPartDataValue (NdbOperation *anOp, const char *buf, const Uint16 &aLen)
int getHeadInlineValue (NdbOperation *anOp)
void getHeadFromRecAttr ()
int setHeadInlineValue (NdbOperation *anOp)
void setHeadPartitionId (NdbOperation *anOp)
void setPartPartitionId (NdbOperation *anOp)
int readDataPrivate (char *buf, Uint32 &bytes)
int writeDataPrivate (const char *buf, Uint32 bytes)
int readParts (char *buf, Uint32 part, Uint32 count)
int readPart (char *buf, Uint32 part, Uint16 &len)
int readTableParts (char *buf, Uint32 part, Uint32 count)
int readTablePart (char *buf, Uint32 part, Uint16 &len)
int readEventParts (char *buf, Uint32 part, Uint32 count)
int readEventPart (char *buf, Uint32 part, Uint16 &len)
int insertParts (const char *buf, Uint32 part, Uint32 count)
int insertPart (const char *buf, Uint32 part, const Uint16 &len)
int updateParts (const char *buf, Uint32 part, Uint32 count)
int updatePart (const char *buf, Uint32 part, const Uint16 &len)
int deleteParts (Uint32 part, Uint32 count)
int deletePartsUnknown (Uint32 part)
int executePendingBlobReads ()
int executePendingBlobWrites ()
int invokeActiveHook ()
int atPrepare (NdbTransaction *aCon, NdbOperation *anOp, const NdbColumnImpl *aColumn)
int atPrepareNdbRecord (NdbTransaction *aCon, NdbOperation *anOp, const NdbColumnImpl *aColumn, const NdbRecord *key_record, const char *key_row)
int atPrepareNdbRecordTakeover (NdbTransaction *aCon, NdbOperation *anOp, const NdbColumnImpl *aColumn, const char *keyinfo, Uint32 keyinfo_bytes)
int atPrepareNdbRecordScan (NdbTransaction *aCon, NdbOperation *anOp, const NdbColumnImpl *aColumn)
int atPrepareCommon (NdbTransaction *aCon, NdbOperation *anOp, const NdbColumnImpl *aColumn)
int atPrepare (NdbEventOperationImpl *anOp, NdbEventOperationImpl *aBlobOp, const NdbColumnImpl *aColumn, int version)
int prepareColumn ()
int preExecute (NdbTransaction::ExecType anExecType, bool &batch)
int postExecute (NdbTransaction::ExecType anExecType)
int preCommit ()
int atNextResult ()
int atNextResultNdbRecord (const char *keyinfo, Uint32 keyinfo_bytes)
int atNextResultCommon ()
int atNextEvent ()
void setErrorCode (int anErrorCode, bool invalidFlag=false)
void setErrorCode (NdbOperation *anOp, bool invalidFlag=false)
void setErrorCode (NdbEventOperationImpl *anOp, bool invalidFlag=false)
void next (NdbBlob *obj)
NdbBlobnext ()
 NdbBlob (const NdbBlob &)
NdbBloboperator= (const NdbBlob &)

Static Private Member Functions

static void getBlobTableName (char *btname, const NdbTableImpl *t, const NdbColumnImpl *c)
static int getBlobTable (NdbTableImpl &bt, const NdbTableImpl *t, const NdbColumnImpl *c, struct NdbError &error)
static void getBlobEventName (char *bename, const NdbEventImpl *e, const NdbColumnImpl *c)
static void getBlobEvent (NdbEventImpl &be, const NdbEventImpl *e, const NdbColumnImpl *c)

Private Attributes

int theBlobVersion
bool theFixedDataFlag
Uint32 theHeadSize
Uint32 theVarsizeBytes
State theState
bool theNdbRecordFlag
int theEventBlobVersion
int theBtColumnNo [5]
NdbtheNdb
NdbTransactiontheNdbCon
NdbOperationtheNdbOp
NdbEventOperationImpl * theEventOp
NdbEventOperationImpl * theBlobEventOp
NdbRecAttrtheBlobEventPkRecAttr
NdbRecAttrtheBlobEventDistRecAttr
NdbRecAttrtheBlobEventPartRecAttr
NdbRecAttrtheBlobEventPkidRecAttr
NdbRecAttrtheBlobEventDataRecAttr
const NdbTableImpl * theTable
const NdbTableImpl * theAccessTable
const NdbTableImpl * theBlobTable
const NdbColumnImpl * theColumn
unsigned char theFillChar
Uint32 theInlineSize
Uint32 thePartSize
Uint32 theStripeSize
bool theGetFlag
char * theGetBuf
bool theSetFlag
const char * theSetBuf
Uint32 theGetSetBytes
Uint8 thePendingBlobOps
ActiveHooktheActiveHook
void * theActiveHookArg
Buf theKeyBuf
Buf theAccessKeyBuf
Buf thePackKeyBuf
Buf theHeadInlineBuf
Buf theHeadInlineCopyBuf
Buf thePartBuf
Uint16 thePartLen
Buf theBlobEventDataBuf
Uint32 theBlobEventDistValue
Uint32 theBlobEventPartValue
Uint32 theBlobEventPkidValue
Head theHead
char * theInlineData
NdbRecAttrtheHeadInlineRecAttr
NdbOperationtheHeadInlineReadOp
bool theHeadInlineUpdateFlag
bool userDefinedPartitioning
Uint32 thePartitionId
NdbRecAttrthePartitionIdRecAttr
int theNullFlag
Uint64 theLength
Uint64 thePos
NdbError theError
NdbBlobtheNext

Friends

struct Ndb_free_list_t< NdbBlob >


Detailed Description

Blob handle.

Blob data is stored in 2 places:

Inline and part sizes can be set via NdbDictionary::Column methods when the table is created.

NdbBlob is a blob handle. To access blob data, the handle must be created using NdbOperation::getBlobHandle in operation prepare phase. The handle has following states:

NdbBlob supports 3 styles of data access:

The styles can be applied in combination (in above order).

Blob operations take effect at next transaction execute. In some cases NdbBlob is forced to do implicit executes. To avoid this, operate on complete blob parts.

Use NdbTransaction::executePendingBlobOps to flush your reads and writes. It avoids execute penalty if nothing is pending. It is not needed after execute (obviously) or after next scan result.

NdbBlob also supports reading post or pre blob data from events. The handle can be read after next event on main table has been retrieved. The data is available immediately. See NdbEventOperation.

Non-void NdbBlob methods return -1 on error and 0 on success. Output parameters are used when necessary.

Usage notes for different operation types:

Bugs / limitations:


Member Typedef Documentation

typedef int NdbBlob::ActiveHook(NdbBlob *me, void *arg)

Callback for setActiveHook(). Invoked immediately when the prepared operation has been executed (but not committed). Any getValue() or setValue() is done first. The blob handle is active so readData or writeData() etc can be used to manipulate blob value. A user-defined argument is passed along. Returns non-zero on error.


Member Enumeration Documentation

anonymous enum [private]

Enumerator:
BtColumnPk 
BtColumnDist 
BtColumnPart 
BtColumnPkid 
BtColumnData 

State.

Enumerator:
Idle 
Prepared 
Active 
Closed 
Invalid 


Constructor & Destructor Documentation

NdbBlob::NdbBlob ( Ndb  )  [private]

NdbBlob::NdbBlob ( const NdbBlob  )  [private]


Member Function Documentation

int NdbBlob::atNextEvent (  )  [private]

int NdbBlob::atNextResult (  )  [private]

int NdbBlob::atNextResultCommon (  )  [private]

int NdbBlob::atNextResultNdbRecord ( const char *  keyinfo,
Uint32  keyinfo_bytes 
) [private]

int NdbBlob::atPrepare ( NdbEventOperationImpl *  anOp,
NdbEventOperationImpl *  aBlobOp,
const NdbColumnImpl *  aColumn,
int  version 
) [private]

int NdbBlob::atPrepare ( NdbTransaction aCon,
NdbOperation anOp,
const NdbColumnImpl *  aColumn 
) [private]

int NdbBlob::atPrepareCommon ( NdbTransaction aCon,
NdbOperation anOp,
const NdbColumnImpl *  aColumn 
) [private]

int NdbBlob::atPrepareNdbRecord ( NdbTransaction aCon,
NdbOperation anOp,
const NdbColumnImpl *  aColumn,
const NdbRecord *  key_record,
const char *  key_row 
) [private]

int NdbBlob::atPrepareNdbRecordScan ( NdbTransaction aCon,
NdbOperation anOp,
const NdbColumnImpl *  aColumn 
) [private]

int NdbBlob::atPrepareNdbRecordTakeover ( NdbTransaction aCon,
NdbOperation anOp,
const NdbColumnImpl *  aColumn,
const char *  keyinfo,
Uint32  keyinfo_bytes 
) [private]

NdbBlob* NdbBlob::blobsFirstBlob (  ) 

Return info about all blobs in this operation.

Get first blob in list.

NdbBlob* NdbBlob::blobsNextBlob (  ) 

Return info about all blobs in this operation.

Get next blob in list. Initialize with blobsFirstBlob().

int NdbBlob::copyKeyFromRow ( const NdbRecord *  record,
const char *  row,
Buf packedBuf,
Buf unpackedBuf 
) [private]

int NdbBlob::deleteParts ( Uint32  part,
Uint32  count 
) [private]

int NdbBlob::deletePartsUnknown ( Uint32  part  )  [private]

int NdbBlob::executePendingBlobReads (  )  [private]

int NdbBlob::executePendingBlobWrites (  )  [private]

static void NdbBlob::getBlobEvent ( NdbEventImpl &  be,
const NdbEventImpl *  e,
const NdbColumnImpl *  c 
) [static, private]

static void NdbBlob::getBlobEventName ( char *  bename,
const NdbEventImpl *  e,
const NdbColumnImpl *  c 
) [static, private]

static int NdbBlob::getBlobEventName ( char *  bename,
Ndb anNdb,
const char *  eventName,
const char *  columnName 
) [static]

Get blob event name. The blob event is created if the main event monitors the blob column. The name includes main event name.

static int NdbBlob::getBlobTable ( NdbTableImpl &  bt,
const NdbTableImpl *  t,
const NdbColumnImpl *  c,
struct NdbError error 
) [static, private]

static void NdbBlob::getBlobTableName ( char *  btname,
const NdbTableImpl *  t,
const NdbColumnImpl *  c 
) [static, private]

static int NdbBlob::getBlobTableName ( char *  btname,
Ndb anNdb,
const char *  tableName,
const char *  columnName 
) [static]

Get blob parts table name. Useful only to test programs.

const NdbDictionary::Column* NdbBlob::getColumn (  ) 

Return the blob column.

int NdbBlob::getDefined ( int &  isNull  ) 

Uint32 NdbBlob::getDistKey ( Uint32  part  )  [private]

void NdbBlob::getHeadFromRecAttr (  )  [private]

Uint32 NdbBlob::getHeadInlineSize (  )  [inline, private]

int NdbBlob::getHeadInlineValue ( NdbOperation anOp  )  [private]

int NdbBlob::getLength ( Uint64 &  length  ) 

Get current length in bytes. Use getNull to distinguish between length 0 blob and NULL blob.

const NdbError& NdbBlob::getNdbError (  )  const

Return error object. The error may be blob specific or may be copied from a failed implicit operation.

The error code is copied back to the operation unless the operation already has a non-zero error code.

const NdbOperation* NdbBlob::getNdbOperation (  )  const

Get a pointer to the operation which this Blob Handle was initially created as part of. Note that this could be a scan operation. Note that the pointer returned is a const pointer.

int NdbBlob::getNull ( int &  isNull  ) 

Return -1, 0, 1 if blob is undefined, non-null, or null. For non-event blob, undefined causes a state error.

int NdbBlob::getNull ( bool &  isNull  ) 

void NdbBlob::getNullOrEmptyBlobHeadDataPtr ( const char *&  data,
Uint32 &  byteSize 
) [private]

Uint32 NdbBlob::getPartCount (  )  [private]

int NdbBlob::getPartDataValue ( NdbOperation anOp,
char *  buf,
Uint16 *  aLenLoc 
) [private]

Uint32 NdbBlob::getPartNumber ( Uint64  pos  )  [private]

Uint32 NdbBlob::getPartOffset ( Uint64  pos  )  [private]

int NdbBlob::getPos ( Uint64 &  pos  ) 

Get current read/write position.

State NdbBlob::getState (  ) 

Get the state of a NdbBlob object.

int NdbBlob::getTableKeyValue ( NdbOperation anOp  )  [private]

int NdbBlob::getValue ( void *  data,
Uint32  bytes 
)

Prepare to read blob value. The value is available after execute. Use getNull() to check for NULL and getLength() to get the real length and to check for truncation. Sets current read/write position to after the data read.

void NdbBlob::getVersion ( int &  version  ) 

Returns -1 for normal statement based blob and 0/1 for event operation post/pre data blob. Always succeeds.

void NdbBlob::init (  )  [private]

int NdbBlob::insertPart ( const char *  buf,
Uint32  part,
const Uint16 &  len 
) [private]

int NdbBlob::insertParts ( const char *  buf,
Uint32  part,
Uint32  count 
) [private]

int NdbBlob::invokeActiveHook (  )  [private]

bool NdbBlob::isDeleteOp (  )  [private]

bool NdbBlob::isIndexOp (  )  [private]

bool NdbBlob::isInsertOp (  )  [private]

bool NdbBlob::isKeyOp (  )  [private]

bool NdbBlob::isReadOnlyOp (  )  [private]

bool NdbBlob::isReadOp (  )  [private]

bool NdbBlob::isScanOp (  )  [private]

bool NdbBlob::isTableOp (  )  [private]

bool NdbBlob::isTakeOverOp (  )  [private]

bool NdbBlob::isUpdateOp (  )  [private]

bool NdbBlob::isWriteOp (  )  [private]

NdbBlob* NdbBlob::next (  )  [inline, private]

void NdbBlob::next ( NdbBlob obj  )  [inline, private]

Uint32 NdbBlob::noPartitionId (  )  [inline, private]

NdbBlob& NdbBlob::operator= ( const NdbBlob  )  [private]

void NdbBlob::packBlobHead (  )  [private]

int NdbBlob::packKeyValue ( const NdbTableImpl *  aTable,
const Buf srcBuf 
) [private]

int NdbBlob::postExecute ( NdbTransaction::ExecType  anExecType  )  [private]

int NdbBlob::preCommit (  )  [private]

int NdbBlob::preExecute ( NdbTransaction::ExecType  anExecType,
bool &  batch 
) [private]

int NdbBlob::prepareColumn (  )  [private]

void NdbBlob::prepareSetHeadInlineValue (  )  [private]

int NdbBlob::readData ( void *  data,
Uint32 &  bytes 
)

Read at current position and set new position to first byte after the data read. A read past blob end returns actual number of bytes read in the in/out bytes parameter.

int NdbBlob::readDataPrivate ( char *  buf,
Uint32 &  bytes 
) [private]

int NdbBlob::readEventPart ( char *  buf,
Uint32  part,
Uint16 &  len 
) [private]

int NdbBlob::readEventParts ( char *  buf,
Uint32  part,
Uint32  count 
) [private]

int NdbBlob::readPart ( char *  buf,
Uint32  part,
Uint16 &  len 
) [private]

int NdbBlob::readParts ( char *  buf,
Uint32  part,
Uint32  count 
) [private]

int NdbBlob::readTablePart ( char *  buf,
Uint32  part,
Uint16 &  len 
) [private]

int NdbBlob::readTableParts ( char *  buf,
Uint32  part,
Uint32  count 
) [private]

void NdbBlob::release (  )  [private]

int NdbBlob::setAccessKeyValue ( NdbOperation anOp  )  [private]

int NdbBlob::setActiveHook ( ActiveHook activeHook,
void *  arg 
)

Define callback for blob handle activation. The queue of prepared operations will be executed in no commit mode up to this point and then the callback is invoked.

int NdbBlob::setDistKeyValue ( NdbOperation anOp,
Uint32  part 
) [private]

void NdbBlob::setErrorCode ( NdbEventOperationImpl *  anOp,
bool  invalidFlag = false 
) [private]

void NdbBlob::setErrorCode ( NdbOperation anOp,
bool  invalidFlag = false 
) [private]

void NdbBlob::setErrorCode ( int  anErrorCode,
bool  invalidFlag = false 
) [private]

int NdbBlob::setHeadInlineValue ( NdbOperation anOp  )  [private]

void NdbBlob::setHeadPartitionId ( NdbOperation anOp  )  [private]

int NdbBlob::setNull (  ) 

Set blob to NULL.

int NdbBlob::setPartDataValue ( NdbOperation anOp,
const char *  buf,
const Uint16 &  aLen 
) [private]

int NdbBlob::setPartKeyValue ( NdbOperation anOp,
Uint32  part 
) [private]

void NdbBlob::setPartPartitionId ( NdbOperation anOp  )  [private]

int NdbBlob::setPartPkidValue ( NdbOperation anOp,
Uint32  pkid 
) [private]

int NdbBlob::setPos ( Uint64  pos  ) 

Set read/write position. Must be between 0 and current length. "Sparse blobs" are not supported.

void NdbBlob::setState ( State  newState  )  [private]

int NdbBlob::setTableKeyValue ( NdbOperation anOp  )  [private]

int NdbBlob::setValue ( const void *  data,
Uint32  bytes 
)

Prepare to insert or update blob value. An existing longer blob value will be truncated. The data buffer must remain valid until execute. Sets current read/write position to after the data. Set data to null pointer (0) to create a NULL value.

int NdbBlob::truncate ( Uint64  length = 0  ) 

Truncate blob to given length. Has no effect if the length is larger than current length.

void NdbBlob::unpackBlobHead (  )  [private]

int NdbBlob::unpackKeyValue ( const NdbTableImpl *  aTable,
Buf dstBuf 
) [private]

int NdbBlob::updatePart ( const char *  buf,
Uint32  part,
const Uint16 &  len 
) [private]

int NdbBlob::updateParts ( const char *  buf,
Uint32  part,
Uint32  count 
) [private]

int NdbBlob::writeData ( const void *  data,
Uint32  bytes 
)

Write at current position and set new position to first byte after the data written. A write past blob end extends the blob value.

int NdbBlob::writeDataPrivate ( const char *  buf,
Uint32  bytes 
) [private]


Friends And Related Function Documentation

friend struct Ndb_free_list_t< NdbBlob > [friend]


Member Data Documentation

const NdbTableImpl* NdbBlob::theAccessTable [private]

void* NdbBlob::theActiveHookArg [private]

NdbEventOperationImpl* NdbBlob::theBlobEventOp [private]

const NdbTableImpl* NdbBlob::theBlobTable [private]

int NdbBlob::theBlobVersion [private]

int NdbBlob::theBtColumnNo[5] [private]

const NdbColumnImpl* NdbBlob::theColumn [private]

NdbEventOperationImpl* NdbBlob::theEventOp [private]

unsigned char NdbBlob::theFillChar [private]

bool NdbBlob::theFixedDataFlag [private]

char* NdbBlob::theGetBuf [private]

bool NdbBlob::theGetFlag [private]

Uint32 NdbBlob::theGetSetBytes [private]

Head NdbBlob::theHead [private]

Uint32 NdbBlob::theHeadSize [private]

char* NdbBlob::theInlineData [private]

Uint32 NdbBlob::theInlineSize [private]

Uint64 NdbBlob::theLength [private]

Ndb* NdbBlob::theNdb [private]

bool NdbBlob::theNdbRecordFlag [private]

int NdbBlob::theNullFlag [private]

Uint32 NdbBlob::thePartitionId [private]

Uint16 NdbBlob::thePartLen [private]

Uint32 NdbBlob::thePartSize [private]

Uint8 NdbBlob::thePendingBlobOps [private]

Uint64 NdbBlob::thePos [private]

const char* NdbBlob::theSetBuf [private]

bool NdbBlob::theSetFlag [private]

Uint32 NdbBlob::theStripeSize [private]

const NdbTableImpl* NdbBlob::theTable [private]

Uint32 NdbBlob::theVarsizeBytes [private]


The documentation for this class was generated from the following file:

MySQL Cluster Database Blog

Based on MySQL Cluster 7.0.10.

This page is for information only and is not maintained by MySQL or Sun Microsystems - use at your own risk. For an upto date view of the API refer to the header files included with your MySQL Cluster distribution or check the MySQL Cluster API Developer Guide.