}
int keyPartsSize = keyParts.size();
NdbTransaction ndbTransaction = null;
TableConst table = ndbDictionary.getTable(tableName);
handleError(table, ndb);
Key_part_ptrArray key_part_ptrArray = null;
if (keyPartsSize == 1) {
// extract the ByteBuffer and length from the keyPart
ByteBuffer buffer = keyParts.get(0).buffer;
int length = keyParts.get(0).length;
ndbTransaction = ndb.startTransaction(table, buffer, length);
if (ndbTransaction == null) {
logger.warn(local.message("ERR_Transaction_Start_Failed",
tableName, buffer.position(), buffer.limit(), buffer.capacity(), length));
}
handleError (ndbTransaction, ndb);
return ndbTransaction;
}
key_part_ptrArray = Key_part_ptrArray.create(keyPartsSize + 1);
try {
// the key part pointer array has one entry for each key part
// plus one extra for "null-terminated array concept"
Key_part_ptr key_part_ptr;
for (int i = 0; i < keyPartsSize; ++i) {
// each key part ptr consists of a ByteBuffer (char *) and length
key_part_ptr = key_part_ptrArray.at(i);
key_part_ptr.ptr(keyParts.get(i).buffer);
key_part_ptr.len(keyParts.get(i).length);
}
// the last key part needs to be initialized to (char *)null
key_part_ptr = key_part_ptrArray.at(keyPartsSize);
key_part_ptr.ptr(null);
key_part_ptr.len(0);
ndbTransaction = ndb.startTransaction(
table, key_part_ptrArray,
partitionKeyScratchBuffer, partitionKeyScratchBuffer.capacity());