*/
void PendingTransaction::addKV(KeyValue *newKV) {
- KeyValue * rmKV = NULL;
+ KeyValue *rmKV = NULL;
// Make sure there are no duplicates
- SetIterator<KeyValue *> * kvit = keyValueUpdateSet->iterator();
- while(kvit->hasNext()) {
+ SetIterator<KeyValue *> *kvit = keyValueUpdateSet->iterator();
+ while (kvit->hasNext()) {
KeyValue *kv = kvit->next();
if (kv->getKey()->equals(newKV->getKey())) {
}
}
delete kvit;
-
+
// Remove key if we are adding a newer version of the same key
if (rmKV != NULL) {
keyValueUpdateSet->remove(rmKV);
return arb == arbitrator;
}
-bool PendingTransaction::evaluateGuard(Hashtable<IoTString *, KeyValue *> * keyValTableCommitted, Hashtable<IoTString *, KeyValue *> * keyValTableSpeculative, Hashtable<IoTString *, KeyValue *> * keyValTablePendingTransSpeculative) {
- SetIterator<KeyValue *> * kvit = keyValueGuardSet->iterator();
- while(kvit->hasNext()) {
+bool PendingTransaction::evaluateGuard(Hashtable<IoTString *, KeyValue *> *keyValTableCommitted, Hashtable<IoTString *, KeyValue *> *keyValTableSpeculative, Hashtable<IoTString *, KeyValue *> *keyValTablePendingTransSpeculative) {
+ SetIterator<KeyValue *> *kvit = keyValueGuardSet->iterator();
+ while (kvit->hasNext()) {
KeyValue *kvGuard = kvit->next();
// First check if the key is in the speculative table, this is the value of the latest assumption
- KeyValue * kv = keyValTablePendingTransSpeculative->get(kvGuard->getKey());
+ KeyValue *kv = keyValTablePendingTransSpeculative->get(kvGuard->getKey());
if (kv == NULL) {
Array<char> *partData = new Array<char>(copySize);
System_arraycopy(charData, currentPosition, partData, 0, copySize);
- TransactionPart * part = new TransactionPart(NULL, machineId, arbitrator, clientLocalSequenceNumber, transactionPartCount, partData, isLastPart);
+ TransactionPart *part = new TransactionPart(NULL, machineId, arbitrator, clientLocalSequenceNumber, transactionPartCount, partData, isLastPart);
newTransaction->addPartEncode(part);
// Update position, count and remaining
}
// Add the Guard Conditions
- SetIterator<KeyValue *> * kvit = keyValueGuardSet->iterator();
- while(kvit->hasNext()) {
+ SetIterator<KeyValue *> *kvit = keyValueGuardSet->iterator();
+ while (kvit->hasNext()) {
KeyValue *kv = kvit->next();
newTransaction->addGuardKV(kv);
}
delete kvit;
-
+
// Add the updates
kvit = keyValueUpdateSet->iterator();
- while(kvit->hasNext()) {
+ while (kvit->hasNext()) {
KeyValue *kv = kvit->next();
newTransaction->addUpdateKV(kv);
}
bbEncode->putInt(keyValueUpdateSet->size());
// Encode all the guard conditions
- SetIterator<KeyValue *> * kvit = keyValueGuardSet->iterator();
- while(kvit->hasNext()) {
+ SetIterator<KeyValue *> *kvit = keyValueGuardSet->iterator();
+ while (kvit->hasNext()) {
KeyValue *kv = kvit->next();
kv->encode(bbEncode);
}
delete kvit;
-
+
// Encode all the updates
kvit = keyValueUpdateSet->iterator();
- while(kvit->hasNext()) {
+ while (kvit->hasNext()) {
KeyValue *kv = kvit->next();
kv->encode(bbEncode);
}
delete kvit;
-
+
return bbEncode->array();
}