Adding a feature to read all keys and their respective values (Java side).
authorrtrimana <rtrimana@uci.edu>
Tue, 17 Apr 2018 16:26:01 +0000 (09:26 -0700)
committerrtrimana <rtrimana@uci.edu>
Tue, 17 Apr 2018 16:26:01 +0000 (09:26 -0700)
version2/src/java/iotcloud/Table.java
version2/src/java/simple_test/Read.java [new file with mode: 0644]
version2/src/java/simple_test/runRead.bash [new file with mode: 0755]

index e446152..6a05197 100644 (file)
@@ -299,6 +299,11 @@ final public class Table {
        public synchronized void close() {
                cloud.close();
        }
+       
+       // Return all keys in the table
+       public synchronized Set<IoTString> getKeys() {
+               return committedKeyValueTable.keySet();
+       }
 
        public synchronized IoTString getCommitted(IoTString key)  {
                KeyValue kv = committedKeyValueTable.get(key);
@@ -2745,4 +2750,4 @@ final public class Table {
                                throw new Error("Server Error: Invalid HMAC Chain" + currSlot + " " + prevSlot);
                }
        }
-}
\ No newline at end of file
+}
diff --git a/version2/src/java/simple_test/Read.java b/version2/src/java/simple_test/Read.java
new file mode 100644 (file)
index 0000000..71140b8
--- /dev/null
@@ -0,0 +1,20 @@
+import iotcloud.*;
+import java.util.Set;
+import java.util.HashSet;
+
+class Read {
+    public static void main(String[] args) throws Exception {
+
+
+        Table t1 = new Table("http://dc-6.calit2.uci.edu/test.iotcloud/", "reallysecret", 41567, -1);
+        // t1.initTable();
+        t1.rebuild();
+
+               Set<IoTString> keySet = t1.getKeys();
+               for(IoTString key : keySet) {
+                       System.out.print("Key: " + key.toString() + " -> ");
+               IoTString val = t1.getCommitted(key);
+                       System.out.println("Value: " + val.toString());         
+               }
+    }
+}
diff --git a/version2/src/java/simple_test/runRead.bash b/version2/src/java/simple_test/runRead.bash
new file mode 100755 (executable)
index 0000000..a44d55f
--- /dev/null
@@ -0,0 +1 @@
+java -cp .:../iotcloud/bin Read