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:
}
void Entry::setDead() {
-
- if (!islive ) {
- return; // already dead
- }
-
- islive = false;
-
- if (parentslot != NULL) {
- parentslot->decrementLiveCount();
+ if (islive) {
+ islive = false;
+ if (parentslot != NULL) {
+ parentslot->decrementLiveCount();
+ }
}
}
*/
virtual void encode(ByteBuffer *bb) = 0;
-
/**
* Returns the size in chars the entry object will take in the char
* array.
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;
}
* @version 1.0
*/
+KeyValue::~KeyValue() {
+ delete key;
+ delete value;
+}
+
KeyValue *KeyValue_decode(ByteBuffer *bb) {
int keylength = bb->getInt();
int valuelength = bb->getInt();
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));
}
key(_key),
value(_value) {
}
+ ~KeyValue();
IoTString *getKey() { return key; }
IoTString *getValue() { return value; }
* 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) {
}
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;