1 #ifndef PENDINGTRANSACTION_H
2 #define PENDINGTRANSACTION_H
6 class PendingTransaction {
8 Hashset<KeyValue *> *keyValueUpdateSet;
9 Hashset<KeyValue *> *keyValueGuardSet;
11 int64_t clientLocalSequenceNumber;
13 int32_t currentDataSize;
16 PendingTransaction(int64_t _machineId);
18 * Add a new key value to the updates
21 void addKV(KeyValue *newKV);
23 * Add a new key value to the guard set
26 void addKVGuard(KeyValue *newKV);
28 * Checks if the arbitrator is the same
30 bool checkArbitrator(int64_t arb);
32 * Get the transaction arbitrator
34 int64_t getArbitrator();
36 * Get the key value update set
38 Hashset<KeyValue *> *getKVUpdates() { return keyValueUpdateSet; }
41 * Get the key value update set
43 Hashset<KeyValue *> *getKVGuard() { return keyValueGuardSet; }
45 void setClientLocalSequenceNumber(int64_t _clientLocalSequenceNumber) { clientLocalSequenceNumber = _clientLocalSequenceNumber; }
47 int64_t getClientLocalSequenceNumber() { return clientLocalSequenceNumber; }
49 int64_t getMachineId() { return machineId; }
51 bool evaluateGuard(Hashtable<IoTString *, KeyValue *> *keyValTableCommitted, Hashtable<IoTString *, KeyValue *> *keyValTableSpeculative, Hashtable<IoTString *, KeyValue *> *keyValTablePendingTransSpeculative);
53 Transaction *createTransaction();
55 Array<char> *convertDataToBytes();