From 178126b9fba2afc8f66e1c920f4991fd643d615b Mon Sep 17 00:00:00 2001 From: bdemsky Date: Sun, 21 Jan 2018 00:41:45 -0800 Subject: [PATCH] edits --- version2/src/C/Table.cc | 46 +++++++++++++++++++++++++++------------- version2/src/C/hashset.h | 4 ++-- 2 files changed, 33 insertions(+), 17 deletions(-) diff --git a/version2/src/C/Table.cc b/version2/src/C/Table.cc index dcdc99b..5f93fe8 100644 --- a/version2/src/C/Table.cc +++ b/version2/src/C/Table.cc @@ -321,9 +321,12 @@ bool Table::update() { updateLiveTransactionsAndStatus(); return true; } catch (Exception *e) { - for (int64_t m : localCommunicationTable->keySet()) { + SetIterator * kit = getKeyIterator(localCommunicationTable); + while(kit->hasNext()) { + int64_t m = kit->next(); updateFromLocal(m); } + delete kit; } return false; @@ -425,8 +428,8 @@ TransactionStatus *Table::commitTransaction() { } } } + pendingTransactionQueue->setSize(oldindex); } - pendingTransactionQueue->setSize(oldindex); updateLiveStateFromLocal(); @@ -461,7 +464,9 @@ bool Table::sendToServer(NewKey *newKey) { } } - for (Transaction *transaction : lastTransactionPartsSent->keySet()) { + SetIterator * trit = getKeyIterator(lastTransactionPartsSent); + while(trit->hasNext()) { + Transaction *transaction = trit->next(); transaction->resetServerFailure(); // Update which transactions parts still need to be sent transaction->removeSentParts(lastTransactionPartsSent->get(transaction)); @@ -478,6 +483,7 @@ bool Table::sendToServer(NewKey *newKey) { pendingTransactionQueue->remove(transaction); } } + delete trit; } else { newSlots = sendSlotsReturn.getThird(); bool isInserted = false; @@ -496,7 +502,10 @@ bool Table::sendToServer(NewKey *newKey) { } // Process each entry in the slot - for (Entry *entry : s->getEntries()) { + Vector * ventries=s->getEntries(); + uint vesize = ventries->size(); + for(uint vei = 0; vei < vesize; vei++) { + Entry *entry = ventries->get(vei); if (entry->getType() == TypeLastMessage) { LastMessage *lastMessage = (LastMessage *)entry; if ((lastMessage->getMachineID() == localMachineId) && (lastMessage->getSequenceNumber() == lastSlotAttemptedToSend->getSequenceNumber())) { @@ -703,15 +712,19 @@ bool Table::sendToServer(NewKey *newKey) { } // Remove the aborts and commit parts that were sent from the pending to send queue - for (Iterator *iter = pendingSendArbitrationRounds->iterator(); iter->hasNext(); ) { - ArbitrationRound *round = iter->next(); + uint size = pendingSendArbitrationRounds->size(); + uint oldcount = 0; + for (uint i=0; i < size; i++) + ArbitrationRound *round = pendingSendArbitrartionRounds->get(i); round->removeParts(pendingSendArbitrationEntriesToDelete); - if (round->isDoneSending()) { + if (!round->isDoneSending()) { // Sent all the parts - iter->remove(); + pendingSendArbitrartionRounds->set(oldcount++, + pendingSendArbitrartionRounds->get(i)); } } + pendingSendArbitrationRounds->setSize(oldcount); for (Transaction *transaction : transactionPartsSent->keySet()) { transaction->resetServerFailure(); @@ -1052,7 +1065,7 @@ ThreeTuple *> Table::sendSlotsToServer(Slot *slot, int if (hadPartialSendToServer) { bool isInserted = false; - uint size = s->size(); + uint size = array->size(); for(uint i=0; i < size; i++) { Slot *s = array->get(i); if ((s->getSequenceNumber() == slot->getSequenceNumber()) && (s->getMachineID() == localMachineId)) { @@ -1139,17 +1152,20 @@ ThreeTuple Table::fillSlot(Slot *slot, bool resize, NewKey // Clear the transactions, aborts and commits that were sent previously transactionPartsSent->clear(); pendingSendArbitrationEntriesToDelete->clear(); - - for (ArbitrationRound *round : pendingSendArbitrationRounds) { + uint size = pendingSendArbitrationRounds->size(); + for (uint i=0; iget(i); bool isFull = false; round->generateParts(); Vector *parts = round->getParts(); // Insert pending arbitration data - for (Entry *arbitrationData : parts) { - + uint vsize = parts->size(); + for (uint vi=0; viget(vi); + // If it is an abort then we need to set some information - if (arbitrationData instanceof Abort) { + if (arbitrationData->getType() == TypeAbort) { ((Abort *)arbitrationData)->setSequenceNumber(slot->getSequenceNumber()); } @@ -1496,7 +1512,7 @@ void Table::processNewTransactionParts() { // Iterate through all the machine Ids that we received new parts // for for (int64_t machineId : newTransactionParts->keySet()) { - Hashtable, TransactionPart *> *parts = newTransactionParts->get(machineId); + Hashtable, TransactionPart *, uintptr_t, 0, pairHashFunction, pairEquals> *parts = newTransactionParts->get(machineId); // Iterate through all the parts for that machine Id for (Pair partId : parts->keySet()) { diff --git a/version2/src/C/hashset.h b/version2/src/C/hashset.h index a9af155..d0b01f6 100644 --- a/version2/src/C/hashset.h +++ b/version2/src/C/hashset.h @@ -173,8 +173,8 @@ private: Hashtable<_Key, _Key, _KeyInt, _Shift, hash_function, equals> *table; }; -template - SetIterator<_Key, _KeyInt, _Shift, hash_function, equals> * getKeyIterator(Hashtable<_Key,_Key,_KeyInt,_Shift,hash_function,equals> *table) { +template + SetIterator<_Key, _KeyInt, _Shift, hash_function, equals> * getKeyIterator(Hashtable<_Key,_Val,_KeyInt,_Shift,hash_function,equals> *table) { return new SetIterator<_Key, _KeyInt, _Shift, hash_function, equals>(table->list, table); } #endif -- 2.34.1