}
void Transaction::addPartEncode(TransactionPart *newPart) {
- TransactionPart * old=parts->setExpand(newPart->getPartNumber(), newPart);
+ TransactionPart *old = parts->setExpand(newPart->getPartNumber(), newPart);
if (old == NULL)
partCount++;
partsPendingSend->add(newPart->getPartNumber());
TransactionPart *previouslySeenPart = parts->setExpand(newPart->getPartNumber(), newPart);
if (previouslySeenPart == NULL)
partCount++;
-
+
if (previouslySeenPart != NULL) {
// Set dead the old one since the new one is a rescued version of this part
previouslySeenPart->setDead();
void Transaction::setSequenceNumber(int64_t _sequenceNumber) {
sequenceNumber = _sequenceNumber;
-
- for (int32_t i = 0; i < parts->size(); i++) {
- TransactionPart * tp = parts->get(i);
- if (tp !=NULL)
+
+ for (uint32_t i = 0; i < parts->size(); i++) {
+ TransactionPart *tp = parts->get(i);
+ if (tp != NULL)
tp->setSequenceNumber(sequenceNumber);
}
}
nextPartToSend = 0;
bool changed = false;
uint lastusedindex = 0;
- for(uint i=0; i < partsPendingSend->size(); i++) {
+ for (uint i = 0; i < partsPendingSend->size(); i++) {
int32_t parti = partsPendingSend->get(i);
- for(uint j=0; j < sentParts->size(); j++) {
+ for (uint j = 0; j < sentParts->size(); j++) {
int32_t partj = sentParts->get(j);
if (parti == partj) {
changed = true;
}
}
partsPendingSend->set(lastusedindex++, parti);
- NextElement:
+NextElement:
;
}
if (changed) {
return fldisComplete;
}
-Pair<int64_t, int64_t> Transaction::getId() {
- return transactionId;
+Pair<int64_t, int64_t> *Transaction::getId() {
+ return &transactionId;
}
void Transaction::setDead() {
- if (isDead) {
- // Already dead
- return;
- }
-
- // Set dead
- isDead = true;
-
- // Make all the parts of this transaction dead
- for (int32_t partNumber = 0; partNumber < parts->size(); partNumber ++) {
- TransactionPart *part = parts->get(partNumber);
- if (part != NULL)
- part->setDead();
+ if (!isDead) {
+ // Set dead
+ isDead = true;
+ // Make all the parts of this transaction dead
+ for (uint32_t partNumber = 0; partNumber < parts->size(); partNumber++) {
+ TransactionPart *part = parts->get(partNumber);
+ if (part != NULL)
+ part->setDead();
+ }
}
}
void Transaction::decodeTransactionData() {
// Calculate the size of the data section
int dataSize = 0;
- for (int i = 0; i < parts->size(); i++) {
+ for (uint i = 0; i < parts->size(); i++) {
TransactionPart *tp = parts->get(i);
dataSize += tp->getDataSize();
}
int currentPosition = 0;
// Stitch all the data sections together
- for (int i = 0; i < parts->size(); i++) {
+ for (uint i = 0; i < parts->size(); i++) {
TransactionPart *tp = parts->get(i);
System_arraycopy(tp->getData(), 0, combinedData, currentPosition, tp->getDataSize());
currentPosition += tp->getDataSize();
}
}
-bool Transaction::evaluateGuard(Hashtable<IoTString *, KeyValue *> *committedKeyValueTable, Hashtable<IoTString *, KeyValue *> *speculatedKeyValueTable, Hashtable<IoTString *, KeyValue *> *pendingTransactionSpeculatedKeyValueTable) {
- SetIterator<KeyValue *>* kvit=keyValueGuardSet->iterator();
- while(kvit->hasNext()) {
+bool Transaction::evaluateGuard(Hashtable<IoTString *, KeyValue *, uintptr_t, 0, hashString, StringEquals> *committedKeyValueTable, Hashtable<IoTString *, KeyValue *, uintptr_t, 0, hashString, StringEquals> *speculatedKeyValueTable, Hashtable<IoTString *, KeyValue *, uintptr_t, 0, hashString, StringEquals> *pendingTransactionSpeculatedKeyValueTable) {
+ SetIterator<KeyValue *, 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 = NULL;