edits
authorbdemsky <bdemsky@uci.edu>
Sun, 21 Jan 2018 08:41:45 +0000 (00:41 -0800)
committerbdemsky <bdemsky@uci.edu>
Sun, 21 Jan 2018 08:41:45 +0000 (00:41 -0800)
version2/src/C/Table.cc
version2/src/C/hashset.h

index dcdc99b..5f93fe8 100644 (file)
@@ -321,9 +321,12 @@ bool Table::update()  {
                updateLiveTransactionsAndStatus();
                return true;
        } catch (Exception *e) {
-               for (int64_t m : localCommunicationTable->keySet()) {
+               SetIterator<int64_t> * 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<Transaction *> * 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<Entry *> * 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<ArbitrationRound *> *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<bool, bool, Array<Slot *> *> 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<bool, int32_t, bool> 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; i<size; i++)
+               ArbitrartionRound *round = pendingSendArbitrationRounds->get(i);
                bool isFull = false;
                round->generateParts();
                Vector<Entry *> *parts = round->getParts();
 
                // Insert pending arbitration data
-               for (Entry *arbitrationData : parts) {
-
+               uint vsize = parts->size();
+               for (uint vi=0; vi<vsize; vi++) {
+                       Entry *arbitrationData = parts->get(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<Pair<int64_t int32_t>, TransactionPart *> *parts = newTransactionParts->get(machineId);
+               Hashtable<Pair<int64_t, int32_t>, TransactionPart *, uintptr_t, 0, pairHashFunction, pairEquals> *parts = newTransactionParts->get(machineId);
 
                // Iterate through all the parts for that machine Id
                for (Pair<int64_t, int32_t> partId : parts->keySet()) {
index a9af155..d0b01f6 100644 (file)
@@ -173,8 +173,8 @@ private:
        Hashtable<_Key, _Key, _KeyInt, _Shift, hash_function, equals> *table;
 };
 
-template<typename _Key, typename _KeyInt, int _Shift, unsigned int (*hash_function)(_Key), bool (*equals)(_Key, _Key)>
-       SetIterator<_Key, _KeyInt, _Shift, hash_function, equals> * getKeyIterator(Hashtable<_Key,_Key,_KeyInt,_Shift,hash_function,equals> *table) {
+template<typename _Key, typename _Val, typename _KeyInt, int _Shift, unsigned int (*hash_function)(_Key), bool (*equals)(_Key, _Key)>
+       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