edits
authorbdemsky <bdemsky@uci.edu>
Sat, 20 Jan 2018 07:09:51 +0000 (23:09 -0800)
committerbdemsky <bdemsky@uci.edu>
Sat, 20 Jan 2018 07:09:51 +0000 (23:09 -0800)
version2/src/C/Entry.cc
version2/src/C/Entry.h
version2/src/C/IoTString.h
version2/src/C/KeyValue.cc
version2/src/C/KeyValue.h
version2/src/C/Table.cc

index 538a68631caaf0e1a1aa2a66dc2655c6fe1e504a..097967bdae7d7af455e59283c93e49185e923cdd 100644 (file)
 Entry *Entry_decode(Slot *slot, ByteBuffer *bb) {
        char type = bb->get();
        switch (type) {
-
        case TypeCommitPart:
                return CommitPart_decode(slot, bb);
-
        case TypeAbort:
                return Abort_decode(slot, bb);
-
        case TypeTransactionPart:
                return TransactionPart_decode(slot, bb);
-
        case TypeNewKey:
                return NewKey_decode(slot, bb);
-
        case TypeLastMessage:
                return LastMessage_decode(slot, bb);
-
        case TypeRejectedMessage:
                return RejectedMessage_decode(slot, bb);
        case TypeTableStatus:
@@ -45,14 +39,10 @@ Entry *Entry_decode(Slot *slot, ByteBuffer *bb) {
 }
 
 void Entry::setDead() {
-
-       if (!islive ) {
-               return; // already dead
-       }
-
-       islive = false;
-
-       if (parentslot != NULL) {
-               parentslot->decrementLiveCount();
+       if (islive) {
+               islive = false;
+               if (parentslot != NULL) {
+                       parentslot->decrementLiveCount();
+               }
        }
 }
index 363b771d9e25dfb25b7b9990f238846879107e85..1a8c4b516457bc8555c37e141cc693f69a161e7e 100644 (file)
@@ -46,7 +46,6 @@ public:
         */
        virtual void encode(ByteBuffer *bb) = 0;
 
-
        /**
         * Returns the size in chars the entry object will take in the char
         * array.
index a7343db5bf0b564d5c1124642f5fa6aef3bd7092..4500a661bad0958e9f134c26cc620232f68e792d 100644 (file)
@@ -21,12 +21,16 @@ private:
 
 public:
        IoTString(Array<char> *_array) : array(new Array<char>(_array)) {}
+
        IoTString(const char *_array) {
                int32_t len = strlen(_array);
                array = new Array<char>(len);
                strcpy(array->internalArray(), _array);
        }
 
+       IoTString(IoTString *string) : array(new Array<char>(string->array)) {
+       }
+
        ~IoTString() {
                delete array;
        }
index 96d740d9bfeb3cffc217eb215999ed4e2d11e7a7..8aea6f2900550a2b33e0712ea60b06842ed82ab4 100644 (file)
@@ -7,6 +7,11 @@
  * @version 1.0
  */
 
+KeyValue::~KeyValue() {
+       delete key;
+       delete value;
+}
+
 KeyValue *KeyValue_decode(ByteBuffer *bb) {
        int keylength = bb->getInt();
        int valuelength = bb->getInt();
@@ -24,28 +29,23 @@ KeyValue *KeyValue_decode(ByteBuffer *bb) {
 
 void KeyValue::encode(ByteBuffer *bb) {
        bb->putInt(key->length());
-
        if (value != NULL) {
                bb->putInt(value->length());
        } else {
                bb->putInt(0);
        }
-
        bb->put(key->internalBytes());
-
        if (value != NULL) {
                bb->put(value->internalBytes());
        }
 }
 
 int KeyValue::getSize() {
-       if (value != NULL) {
+       if (value != NULL)
                return 2 * sizeof(int32_t) + key->length() + value->length();
-       }
-
        return 2 * sizeof(int32_t) + key->length();
 }
 
 KeyValue *KeyValue::getCopy() {
-       return new KeyValue(key, value);
+       return new KeyValue(new IoTString(key), new IoTString(value));
 }
index bd384bef9944185369414af9ea7ca33164e25de3..06f514b577e096bc59692b9b406a20c3159419d4 100644 (file)
@@ -18,6 +18,7 @@ public:
                key(_key),
                value(_value) {
        }
+       ~KeyValue();
 
        IoTString *getKey() { return key; }
        IoTString *getValue() { return value; }
index d598f15cfda3939f9d65c9f6fbf6876530c18622..59c049a6c4ceb0dd8d741bd3889d91a2df488259 100644 (file)
@@ -1103,12 +1103,9 @@ ThreeTuple<bool, bool, Array<Slot *> *> Table::sendSlotsToServer(Slot *slot, int
  * Returns false if a resize was needed
  */
 ThreeTuple<bool, int32_t, bool> Table::fillSlot(Slot *slot, bool resize, NewKey *newKeyEntry) {
-
-
        int newSize = 0;
        if (liveSlotCount > bufferResizeThreshold) {
                resize = true;  //Resize is forced
-
        }
 
        if (resize) {
@@ -1177,22 +1174,14 @@ ThreeTuple<bool, int32_t, bool> Table::fillSlot(Slot *slot, bool resize, NewKey
        }
 
        if (pendingTransactionQueue->size() > 0) {
-
                Transaction *transaction = pendingTransactionQueue->get(0);
-
                // Set the transaction sequence number if it has yet to be inserted into the block chain
-               // if ((!transaction->didSendAPartToServer() && !transaction->getServerFailure()) || (transaction->getSequenceNumber() == -1)) {
-               //  transaction->setSequenceNumber(slot->getSequenceNumber());
-               // }
-
                if ((!transaction->didSendAPartToServer()) || (transaction->getSequenceNumber() == -1)) {
                        transaction->setSequenceNumber(slot->getSequenceNumber());
                }
 
-
                while (true) {
                        TransactionPart *part = transaction->getNextPartToSend();
-
                        if (part == NULL) {
                                // Ran out of parts to send for this transaction so move on
                                break;