-class Commit {
-
- Map<Integer, CommitPart> parts = NULL;
- Set<Integer> missingParts = NULL;
- bool isComplete = false;
- bool hasLastPart = false;
- Set<KeyValue> keyValueUpdateSet = NULL;
- bool isDead = false;
- int64_t sequenceNumber = -1;
- int64_t machineId = -1;
- int64_t transactionSequenceNumber = -1;
-
- Set<IoTString> liveKeys = NULL;
-
- Commit() {
- parts = new HashMap<Integer, CommitPart>();
- keyValueUpdateSet = new HashSet<KeyValue>();
-
- liveKeys = new HashSet<IoTString>();
- }
-
- Commit(int64_t _sequenceNumber, int64_t _machineId, int64_t _transactionSequenceNumber) {
- parts = new HashMap<Integer, CommitPart>();
- keyValueUpdateSet = new HashSet<KeyValue>();
-
- liveKeys = new HashSet<IoTString>();
-
- sequenceNumber = _sequenceNumber;
- machineId = _machineId;
- transactionSequenceNumber = _transactionSequenceNumber;
- isComplete = true;
- }
-
-
- void addPartDecode(CommitPart newPart) {
-
- if (isDead) {
- // If dead then just kill this part and move on
- newPart.setDead();
- return;
- }
-
- CommitPart previoslySeenPart = parts.put(newPart.getPartNumber(), newPart);
-
- if (previoslySeenPart != NULL) {
- // Set dead the old one since the new one is a rescued version of this part
- previoslySeenPart.setDead();
- } else if (newPart.isLastPart()) {
- missingParts = new HashSet<Integer>();
- hasLastPart = true;
-
- for (int i = 0; i < newPart.getPartNumber(); i++) {
- if (parts.get(i) == NULL) {
- missingParts.add(i);
- }
- }
- }
-
- if (!isComplete && hasLastPart) {
-
- // We have seen this part so remove it from the set of missing parts
- missingParts.remove(newPart.getPartNumber());
-
- // Check if all the parts have been seen
- if (missingParts.size() == 0) {
-
- // We have all the parts
- isComplete = true;
-
- // Decode all the parts and create the key value guard and update sets
- decodeCommitData();
+Commit::Commit(int64_t _sequenceNumber, int64_t _machineId, int64_t _transactionSequenceNumber) :
+ parts(new Hashtable<int32_t, CommitPart *>()),
+ missingParts(NULL),
+ fldisComplete(true),
+ hasLastPart(false),
+ keyValueUpdateSet(new HashSet<KeyValue *>()),
+ isDead(false),
+ sequenceNumber(_sequenceNumber),
+ machineId(_machineId),
+ transactionSequenceNumber(_transactionSequenceNumber),
+ liveKeys(new Hashset<IoTString *>) {
+}