edits
[iotcloud.git] / version2 / src / C / Commit.cc
index 6c46fed..a24e014 100644 (file)
@@ -34,7 +34,7 @@ Commit::Commit(int64_t _sequenceNumber, int64_t _machineId, int64_t _transaction
 Commit::~Commit() {
        delete parts;
        delete keyValueUpdateSet;
-       delete liveKeys;
+       delete liveKeys;
        if (missingParts != NULL)
                delete missingParts;
 }
@@ -231,13 +231,14 @@ Array<char> *Commit::convertDataToBytes() {
        return bbEncode->array();
 }
 
-void Commit::setKVsMap(Hashset<KeyValue *, uintptr_t, 0> *newKVs) {
+void Commit::setKVsMap(Hashset<KeyValue *, uintptr_t, 0, hashKeyValue, KeyValueEquals> *newKVs) {
        keyValueUpdateSet->clear();
-       keyValueUpdateSet->addAll(newKVs);
        liveKeys->clear();
-       SetIterator<KeyValue *, KeyValue *, uintptr_t, 0> *kvit = newKVs->iterator();
+       SetIterator<KeyValue *, KeyValue *, uintptr_t, 0, hashKeyValue, KeyValueEquals> *kvit = newKVs->iterator();
        while (kvit->hasNext()) {
-               liveKeys->add(kvit->next()->getKey());
+               KeyValue *kv = kvit->next();
+               liveKeys->add(kv->getKey());
+               keyValueUpdateSet->add(kv);
        }
        delete kvit;
 }
@@ -248,7 +249,7 @@ Commit *Commit_merge(Commit *newer, Commit *older, int64_t newSequenceNumber) {
        } else if (newer == NULL) {
                return older;
        }
-       Hashset<KeyValue *, uintptr_t, 0> *kvSet = new Hashset<KeyValue *, uintptr_t, 0>();
+       Hashset<KeyValue *, uintptr_t, 0, hashKeyValue, KeyValueEquals> *kvSet = new Hashset<KeyValue *, uintptr_t, 0, hashKeyValue, KeyValueEquals>();
        SetIterator<KeyValue *, KeyValue *, uintptr_t, 0> *kvit = older->getKeyValueUpdateSet()->iterator();
        while (kvit->hasNext()) {
                KeyValue *kv = kvit->next();