edits
authorbdemsky <bdemsky@uci.edu>
Thu, 18 Jan 2018 22:17:42 +0000 (14:17 -0800)
committerbdemsky <bdemsky@uci.edu>
Thu, 18 Jan 2018 22:17:42 +0000 (14:17 -0800)
version2/src/C/ArbitrationRound.cc
version2/src/C/ArbitrationRound.h
version2/src/C/Commit.cc
version2/src/C/Commit.h
version2/src/C/TableStatus.cc
version2/src/C/TableStatus.h
version2/src/C/array.h
version2/src/C/common.h
version2/src/C/hashset.h
version2/src/C/hashtable.h
version2/src/C/vector.h

index 8b847855d3858f3eb59ef4503f13786cc8c2a7a9..f7886711cd4c819f11fd34c941535f6b0caabbe1 100644 (file)
@@ -1,25 +1,29 @@
-#include"ArbitrationRound.h"
+#include "ArbitrationRound.h"
+#include "Commit.h"
 
-ArbitrationRound::ArbitrationRound(Commit * _commit, Set<Abort *> * _abortsBefore) {
-  parts = new ArrayList<Entry>();
-  commit = _commit;
-  abortsBefore = _abortsBefore;
+ArbitrationRound::ArbitrationRound(Commit * _commit, Hashset<Abort *> * _abortsBefore) :
+       abortsBefore(_abortsBefore),
+  parts(new Vector<Entry *>()),
+  commit(_commit),
+       currentSize(0),
+       didSendPart(false),
+       didGenerateParts(false) {
   
   if (commit != NULL) {
-    commit.createCommitParts();
-    currentSize += commit.getNumberOfParts();
-    }
+    commit->createCommitParts();
+    currentSize += commit->getNumberOfParts();
+       }
   
-  currentSize += abortsBefore.size();
+  currentSize += abortsBefore->size();
 }
 
 void ArbitrationRound::generateParts() {
   if (didGenerateParts) {
     return;
   }
-  parts = new ArrayList<Entry>(abortsBefore);
+  parts = new Vector<Entry>(abortsBefore);
   if (commit != NULL) {
-    parts.addAll(commit.getParts().values());
+    parts->addAll(commit->getParts()->values());
   }
 }
 
@@ -28,16 +32,16 @@ List<Entry *> * ArbitrationRound::getParts() {
 }
 
 void ArbitrationRound::removeParts(List<Entry *> * removeParts) {
-  parts.removeAll(removeParts);
+  parts->removeAll(removeParts);
   didSendPart = true;
 }
 
 bool ArbitrationRound::isDoneSending() {
-  if ((commit == NULL) && abortsBefore.isEmpty()) {
+  if ((commit == NULL) && abortsBefore->isEmpty()) {
     return true;
   }
   
-  return parts.isEmpty();
+  return parts->isEmpty();
 }
 
 Commit * ArbitrationRound::getCommit() {
@@ -46,31 +50,31 @@ Commit * ArbitrationRound::getCommit() {
   
 void ArbitrationRound::setCommit(Commit * _commit) {
   if (commit != NULL) {
-    currentSize -= commit.getNumberOfParts();
+    currentSize -= commit->getNumberOfParts();
   }
   commit = _commit;
   
   if (commit != NULL) {
-    currentSize += commit.getNumberOfParts();
+    currentSize += commit->getNumberOfParts();
   }
 }
 
 void ArbitrationRound::addAbort(Abort * abort) {
-  abortsBefore.add(abort);
+  abortsBefore->add(abort);
   currentSize++;
 }
   
-void ArbitrationRound::addAborts(Set<Abort *> * aborts) {
-  abortsBefore.addAll(aborts);
-  currentSize += aborts.size();
+void ArbitrationRound::addAborts(Hashset<Abort *> * aborts) {
+  abortsBefore->addAll(aborts);
+  currentSize += aborts->size();
 }
   
-Set<Abort> ArbitrationRound::getAborts() {
+Hashset<Abort *> * ArbitrationRound::getAborts() {
   return abortsBefore;
 }
 
 int ArbitrationRound::getAbortsCount() {
-  return abortsBefore.size();
+  return abortsBefore->size();
 }
 
 int ArbitrationRound::getCurrentSize() {
@@ -81,7 +85,7 @@ bool ArbitrationRound::isFull() {
   return currentSize >= MAX_PARTS;
 }
   
-bool ArbitrationRound::didSendPart() {
+bool ArbitrationRound::getDidSendPart() {
   return didSendPart;
 }
 
index 7ef4a2eacf54ffc709171e13818baae9c04675bc..da1a2a8a2186e14e8b033401e9f250bee636bd3e 100644 (file)
@@ -2,30 +2,32 @@
 #define ARBITRATIONROUND_H
 
 #define MAX_PARTS 10
+#include "common.h"
 
 class ArbitrationRound {
  private:
-  Set<Abort *> * abortsBefore = NULL;
-  List<Entry *> * parts = NULL;
-  Commit commit = NULL;
-  int currentSize = 0;
-  bool didSendPart = false;
-  bool didGenerateParts = false;
+  Hashset<Abort *> * abortsBefore;
+  Vector<Entry *> * parts;
+  Commit * commit;
+  int currentSize;
+  bool didSendPart;
+  bool didGenerateParts;
 
  public:
-  ArbitrationRound(Commit * _commit, Set<Abort *> * _abortsBefore);
+  ArbitrationRound(Commit * _commit, Hashset<Abort *> * _abortsBefore);
+       ~ArbitrationRound();
   void generateParts();
-  List<Entry> * getParts();
-  void removeParts(List<Entry> * removeParts);
+  Vector<Entry *> * getParts();
+  void removeParts(Vector<Entry *> * removeParts);
   bool isDoneSending();
   void setCommit(Commit * _commit);
   void addAbort(Abort * abort);
-  void addAborts(Set<Abort *> * aborts);
-  Set<Abort *> * getAborts();
+  void addAborts(Hashset<Abort *> * aborts);
+  Hashset<Abort *> * getAborts();
   int getAbortsCount();
   int getCurrentSize();
   bool isFull();
-  bool didSendPart();
+  bool getDidSendPart();
 };
 
 #endif
index 4925d6f7e3b5428efec5aeab505d39a276b7c1ad..32e21756ce1846d5fa78f7f65f21548ab1c70b1c 100644 (file)
@@ -1,84 +1,77 @@
+#include "commit.h"
+
+Commit::Commit() :
+       parts(new HashMap<int32_t, CommitPart *>()),
+       missingParts(NULL),
+       fldisComplete(false),
+       hasLastPart(false),
+       keyValueUpdateSet(new HashSet<KeyValue *>()),
+       isDead(false),
+       sequenceNumber(-1),
+       machineId(-1),
+       transactionSequenceNumber(-1),
+       liveKeys(new Hashset<IoTString *>) {
+}
 
 
-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 HashMap<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 *>) {
+}
 
-                // Get the sequence number and arbitrator of this transaction
-                sequenceNumber = parts.get(0).getSequenceNumber();
-                machineId = parts.get(0).getMachineId();
-                transactionSequenceNumber = parts.get(0).getTransactionSequenceNumber();
-            }
-        }
-    }
+void Commit::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 (!fldisComplete && 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
+                       fldisComplete = true;
+                       
+                       // Decode all the parts and create the key value guard and update sets
+                       decodeCommitData();
+                       
+                       // Get the sequence number and arbitrator of this transaction
+                       sequenceNumber = parts.get(0).getSequenceNumber();
+                       machineId = parts.get(0).getMachineId();
+                       transactionSequenceNumber = parts.get(0).getTransactionSequenceNumber();
+               }
+       }
+}
 
     int64_t getSequenceNumber() {
         return sequenceNumber;
@@ -109,21 +102,9 @@ class Commit {
         return keyValueUpdateSet;
     }
 
-    int getNumberOfParts() {
-        return parts.size();
-    }
-
-    int64_t getMachineId() {
-        return machineId;
-    }
-
-    bool isComplete() {
-        return isComplete;
-    }
-
-    bool isLive() {
-        return !isDead;
-    }
+int32_t getNumberOfParts() {
+       return parts.size();
+}
 
     void setDead() {
         if (isDead) {
index c2354524ecfc80f1521d197da96d37c0b9ae187b..4dd5a9d810e06dbf380d12928e1b312ba7da2247 100644 (file)
-
+#ifndef COMMIT_H
+#define COMMIT_H
+#include "common.h"
 
 class Commit {
-
-    private Map<Integer, CommitPart> parts = NULL;
-    private Set<Integer> missingParts = NULL;
-    private bool isComplete = false;
-    private bool hasLastPart = false;
-    private Set<KeyValue> keyValueUpdateSet = NULL;
-    private bool isDead = false;
-    private int64_t sequenceNumber = -1;
-    private int64_t machineId = -1;
-    private int64_t transactionSequenceNumber = -1;
-
-    private Set<IoTString> liveKeys = NULL;
-
-    public Commit() {
-        parts = new HashMap<Integer, CommitPart>();
-        keyValueUpdateSet = new HashSet<KeyValue>();
-
-        liveKeys = new HashSet<IoTString>();
-    }
-
-    public 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;
-    }
-
-
-    public 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();
-
-                // Get the sequence number and arbitrator of this transaction
-                sequenceNumber = parts.get(0).getSequenceNumber();
-                machineId = parts.get(0).getMachineId();
-                transactionSequenceNumber = parts.get(0).getTransactionSequenceNumber();
-            }
-        }
-    }
-
-    public int64_t getSequenceNumber() {
-        return sequenceNumber;
-    }
-
-    public int64_t getTransactionSequenceNumber() {
-        return transactionSequenceNumber;
-    }
-
-    public Map<Integer, CommitPart> getParts() {
-        return parts;
-    }
-
-    public void addKV(KeyValue kv) {
-        keyValueUpdateSet.add(kv);
-        liveKeys.add(kv.getKey());
-    }
-
-    public void invalidateKey(IoTString key) {
-        liveKeys.remove(key);
-
-        if (liveKeys.size() == 0) {
-            setDead();
-        }
-    }
-
-    public Set<KeyValue> getKeyValueUpdateSet() {
-        return keyValueUpdateSet;
-    }
-
-    public int getNumberOfParts() {
-        return parts.size();
-    }
-
-    public int64_t getMachineId() {
-        return machineId;
-    }
-
-    public bool isComplete() {
-        return isComplete;
-    }
-
-    public bool isLive() {
-        return !isDead;
-    }
-
-    public void setDead() {
-        if (isDead) {
-            // Already dead
-            return;
-        }
-
-        // Set dead
-        isDead = true;
-
-        // Make all the parts of this transaction dead
-        for (Integer partNumber : parts.keySet()) {
-            CommitPart part = parts.get(partNumber);
-            part.setDead();
-        }
-    }
-
-    public CommitPart getPart(int index) {
-        return parts.get(index);
-    }
-
-    public void createCommitParts() {
-
-        parts.clear();
-
-        // Convert to chars
-        char[] charData = convertDataToBytes();
-
-
-        int commitPartCount = 0;
-        int currentPosition = 0;
-        int remaining = charData.length;
-
-        while (remaining > 0) {
-
-            Boolean isLastPart = false;
-            // determine how much to copy
-            int copySize = CommitPart.MAX_NON_HEADER_SIZE;
-            if (remaining <= CommitPart.MAX_NON_HEADER_SIZE) {
-                copySize = remaining;
-                isLastPart = true; // last bit of data so last part
-            }
-
-            // Copy to a smaller version
-            char[] partData = new char[copySize];
-            System.arraycopy(charData, currentPosition, partData, 0, copySize);
-
-            CommitPart part = new CommitPart(NULL, machineId, sequenceNumber, transactionSequenceNumber, commitPartCount, partData, isLastPart);
-            parts.put(part.getPartNumber(), part);
-
-            // Update position, count and remaining
-            currentPosition += copySize;
-            commitPartCount++;
-            remaining -= copySize;
-        }
-    }
-
-    private void decodeCommitData() {
-
-        // Calculate the size of the data section
-        int dataSize = 0;
-        for (int i = 0; i < parts.keySet().size(); i++) {
-            CommitPart tp = parts.get(i);
-            dataSize += tp.getDataSize();
-        }
-
-        char[] combinedData = new char[dataSize];
-        int currentPosition = 0;
-
-        // Stitch all the data sections together
-        for (int i = 0; i < parts.keySet().size(); i++) {
-            CommitPart tp = parts.get(i);
-            System.arraycopy(tp.getData(), 0, combinedData, currentPosition, tp.getDataSize());
-            currentPosition += tp.getDataSize();
-        }
-
-        // Decoder Object
-        ByteBuffer bbDecode = ByteBuffer.wrap(combinedData);
-
-        // Decode how many key value pairs need to be decoded
-        int numberOfKVUpdates = bbDecode.getInt();
-
-        // Decode all the updates key values
-        for (int i = 0; i < numberOfKVUpdates; i++) {
-            KeyValue kv = (KeyValue)KeyValue.decode(bbDecode);
-            keyValueUpdateSet.add(kv);
-            liveKeys.add(kv.getKey());
-        }
-    }
-
-    private char[] convertDataToBytes() {
-
-        // Calculate the size of the data
-        int sizeOfData = sizeof(int32_t); // Number of Update KV's
-        for (KeyValue kv : keyValueUpdateSet) {
-            sizeOfData += kv.getSize();
-        }
-
-        // Data handlers and storage
-        char[] dataArray = new char[sizeOfData];
-        ByteBuffer bbEncode = ByteBuffer.wrap(dataArray);
-
-        // Encode the size of the updates and guard sets
-        bbEncode.putInt(keyValueUpdateSet.size());
-
-        // Encode all the updates
-        for (KeyValue kv : keyValueUpdateSet) {
-            kv.encode(bbEncode);
-        }
-
-        return bbEncode.array();
-    }
-
-    private void setKVsMap(Map<IoTString, KeyValue> newKVs) {
-        keyValueUpdateSet.clear();
-        liveKeys.clear();
-
-        keyValueUpdateSet.addAll(newKVs.values());
-        liveKeys.addAll(newKVs.keySet());
-
-    }
-
-
-    public static Commit merge(Commit newer, Commit older, int64_t newSequenceNumber) {
-
-        if (older == NULL) {
-            return newer;
-        } else if (newer == NULL) {
-            return older;
-        }
-
-        Map<IoTString, KeyValue> kvSet = new HashMap<IoTString, KeyValue>();
-        for (KeyValue kv : older.getKeyValueUpdateSet()) {
-            kvSet.put(kv.getKey(), kv);
-        }
-
-        for (KeyValue kv : newer.getKeyValueUpdateSet()) {
-            kvSet.put(kv.getKey(), kv);
-        }
-
-        int64_t transactionSequenceNumber = newer.getTransactionSequenceNumber();
-
-        if (transactionSequenceNumber == -1) {
-            transactionSequenceNumber = older.getTransactionSequenceNumber();
-        }
-
-        Commit newCommit = new Commit(newSequenceNumber, newer.getMachineId(), transactionSequenceNumber);
-
-        newCommit.setKVsMap(kvSet);
-
-        return newCommit;
-    }
-}
+ private:
+       Hashtable<int32_t, CommitPart *> * parts;
+       Hashset<int32_t> *missingParts;
+  bool fldisComplete;
+       bool hasLastPart;
+  Hashset<KeyValue *> *keyValueUpdateSet;
+  bool isDead;
+  int64_t sequenceNumber;
+       int64_t machineId;
+  int64_t transactionSequenceNumber;
+  Hashset<IoTString*> * liveKeys;
+       Array<char> * convertDataToBytes();
+       void setKVsMap(Hashtable<IoTString *, KeyValue *> * newKVs);
+       
+ public:
+       Commit();
+       Commit(int64_t _sequenceNumber, int64_t _machineId, int64_t _transactionSequenceNumber);
+       
+       void addPartDecode(CommitPart * newPart);
+       int64_t getSequenceNumber();
+       int64_t getTransactionSequenceNumber();
+       Hashtable<int32_t, CommitPart *> *getParts();
+       void addKV(KeyValue * kv);
+       void invalidateKey(IoTString * key);
+       Hashset<KeyValue *> * getKeyValueUpdateSet();
+       int32_t getNumberOfParts();
+       int64_t getMachineId() { return machineId; }
+       bool isComplete() { return fldisComplete; }
+       bool isLive() { return !isDead; }
+       void setDead();
+       CommitPart * getPart(int32_t index);
+       void createCommitParts();
+       void decodeCommitData();
+};
+
+Commit * Commit_merge(Commit * newer, Commit * older, int64_t newSequenceNumber);
+#endif
index 10c259c3c3aee5c6aca6401b904c74ddc3753d85..49fcb0f201d1cc67b5caa9fba7e080757c2b6422 100644 (file)
@@ -1,43 +1,12 @@
+#include "TableStatus.h"
+#include "ByteBuffer.h"
 
-/**
- * TableStatus entries record the current size of the data structure
- * in slots.  Used to remember the size and to perform resizes.
- * @author Brian Demsky
- * @version 1.0
- */
-
-
-class TableStatus extends Entry {
-       int maxslots;
-
-       TableStatus(Slot slot, int _maxslots) {
-               super(slot);
-               maxslots=_maxslots;
-       }
-
-       int getMaxSlots() {
-               return maxslots;
-       }
-
-       static Entry decode(Slot slot, ByteBuffer bb) {
-               int maxslots=bb.getInt();
-               return new TableStatus(slot, maxslots);
-       }
-
-       void encode(ByteBuffer bb) {
-               bb.put(Entry.TypeTableStatus);
-               bb.putInt(maxslots);
-       }
-
-       int getSize() {
-               return sizeof(int32_t)+sizeof(char);
-       }
-
-       char getType() {
-               return Entry.TypeTableStatus;
-       }
+Entry * TableStatus_decode(Slot * slot, ByteBuffer * bb) {
+       int maxslots=bb.getInt();
+       return new TableStatus(slot, maxslots);
+}
 
-       Entry getCopy(Slot s) {
-               return new TableStatus(s, maxslots);
-       }
+void TableStatus::encode(ByteBuffer * bb) {
+       bb->put(TypeTableStatus);
+       bb->putInt(maxslots);
 }
index 9637f7a17efaa7086fe7aafa5aaeeaeb5b6f0a5c..ce2576e97702b42ba9a09c5237fe34b1b3706154 100644 (file)
@@ -1,3 +1,7 @@
+#ifndef TABLESTATUS_H
+#define TABLESTATUS_H
+#include "common.h"
+#include "Entry.h"
 
 /**
  * TableStatus entries record the current size of the data structure
  * @version 1.0
  */
 
-
-class TableStatus extends Entry {
-       private int maxslots;
-
-       TableStatus(Slot slot, int _maxslots) {
-               super(slot);
-               maxslots=_maxslots;
-       }
-
-       int getMaxSlots() {
-               return maxslots;
-       }
-
-       static Entry decode(Slot slot, ByteBuffer bb) {
-               int maxslots=bb.getInt();
-               return new TableStatus(slot, maxslots);
-       }
-
-       void encode(ByteBuffer bb) {
-               bb.put(Entry.TypeTableStatus);
-               bb.putInt(maxslots);
-       }
-
-       int getSize() {
-               return sizeof(int32_t)+sizeof(char);
-       }
-
-       char getType() {
-               return Entry.TypeTableStatus;
-       }
-
-       Entry getCopy(Slot s) {
-               return new TableStatus(s, maxslots);
-       }
-}
+class TableStatus : public Entry {
+ private:
+       int maxslots;
+
+ public:
+ TableStatus(Slot * slot, int _maxslots) : Entry(slot),
+               maxslots(_maxslots) {
+               }
+       int getMaxSlots() { return maxslots; }
+       void encode(ByteBuffer *bb);
+       int getSize() { return sizeof(int32_t)+sizeof(char); }
+       
+       char getType() { return TypeTableStatus; }
+       
+       Entry * getCopy(Slot * s) { return new TableStatus(s, maxslots); }
+};
+
+Entry * TableStatus_decode(Slot * slot, ByteBuffer * bb);
+#endif
index 274982212aac4190fe5fec2bb85a8833635a113b..3126238e2c9a811c369aa8df4505173ce21c40f3 100644 (file)
@@ -1,5 +1,8 @@
 #ifndef ARRAY_H
 #define ARRAY_H
+#include <inttypes.h>
+
+typedef uint32_t uint;
 
 template<typename type>
 class Array {
@@ -9,7 +12,7 @@ class Array {
     size(0) {
   }
   
- Array(uint _size) :
+ Array(uint32_t _size) :
   array((type *) ourcalloc(1, sizeof(type) * _size)),
                size(_size)
     {
index 63ba35f3cd963943825267998bd85e6ce8248c6c..0decddaaeed91b9dd777fb4d415f08c52881f3ab 100644 (file)
@@ -1,12 +1,25 @@
 #ifndef COMMON_H
 #define COMMON_H
 #include <inttypes.h>
+typedef uint32_t uint;
+#define CMEMALLOC ;
+#define model_print printf
+
+#include "hashset.h"
+#include "vector.h"
+#include "array.h"
+
+
 
 class Abort;
 class Entry;
 class Slot;
 class ByteBuffer;
 class Liveness;
-
+class Commit;
+class CommitPart;
+class ArbitrationRound;
+class KeyValue;
+class IoTString;
 
 #endif
index 009c047904ce91d34dd28af551027634cb4f0c72..2a94d9666f1842885f399dcb134eaf271441cc54 100644 (file)
@@ -76,7 +76,7 @@ private:
        Hashset <_Key, _KeyInt, _Shift, hash_function, equals> *set;
 };
 
-template<typename _Key, typename _KeyInt, int _Shift = 0, unsigned int (*hash_function) (_Key) = defaultHashFunction<_Key, _Shift, _KeyInt>, bool (*equals) (_Key, _Key) = defaultEquals<_Key> >
+template<typename _Key, typename _KeyInt = uintptr_t, int _Shift = 0, unsigned int (*hash_function) (_Key) = defaultHashFunction<_Key, _Shift, _KeyInt>, bool (*equals) (_Key, _Key) = defaultEquals<_Key> >
 class Hashset {
 public:
        Hashset(unsigned int initialcapacity = 16, double factor = 0.5) :
index 0a50bb9f39511aa4beba010c6a56f11ae73149b0..648377ef0d20de105dd3d2bfe63dafac3dc38be0 100644 (file)
@@ -17,8 +17,8 @@
 #include <stdlib.h>
 #include <stdio.h>
 #include <string.h>
-#include "mymemory.h"
 #include "common.h"
+#include "mymemory.h"
 
 /**
  * @brief Hashtable node
index 2d4cc1956df10579e362966c84371f4f34d5c63f..7b49d4e96f3a916618e62aaf00b1169c0c5ca35d 100644 (file)
@@ -1,7 +1,6 @@
 #ifndef CPPVECTOR_H
 #define CPPVECTOR_H
 #include <string.h>
-
 #define VECTOR_DEFCAP 8
 
 template<typename type>