Refactored code to consolidate functionality in Database* classes.
Renamed few methods and variables to align with local convention and also to match the description of functionality.

Change-Id: Ib17e73079534c76f76bcb01f14b6496e62275dbd
diff --git a/core/store/dist/src/main/java/org/onosproject/store/consistent/impl/PartitionedDatabase.java b/core/store/dist/src/main/java/org/onosproject/store/consistent/impl/PartitionedDatabase.java
index bc287f0..b0fa4fe 100644
--- a/core/store/dist/src/main/java/org/onosproject/store/consistent/impl/PartitionedDatabase.java
+++ b/core/store/dist/src/main/java/org/onosproject/store/consistent/impl/PartitionedDatabase.java
@@ -82,14 +82,14 @@
     }
 
     @Override
-    public CompletableFuture<Set<String>> tableNames() {
+    public CompletableFuture<Set<String>> maps() {
         checkState(isOpen.get(), DB_NOT_OPEN);
-        Set<String> tableNames = Sets.newConcurrentHashSet();
+        Set<String> mapNames = Sets.newConcurrentHashSet();
         return CompletableFuture.allOf(partitions
                 .stream()
-                .map(db -> db.tableNames().thenApply(tableNames::addAll))
+                .map(db -> db.maps().thenApply(mapNames::addAll))
                 .toArray(CompletableFuture[]::new))
-            .thenApply(v -> tableNames);
+            .thenApply(v -> mapNames);
     }
 
     @Override
@@ -108,158 +108,100 @@
     }
 
     @Override
-    public CompletableFuture<Integer> size(String tableName) {
+    public CompletableFuture<Integer> mapSize(String mapName) {
         checkState(isOpen.get(), DB_NOT_OPEN);
         AtomicInteger totalSize = new AtomicInteger(0);
         return CompletableFuture.allOf(partitions
                     .stream()
-                    .map(p -> p.size(tableName).thenApply(totalSize::addAndGet))
+                    .map(p -> p.mapSize(mapName).thenApply(totalSize::addAndGet))
                     .toArray(CompletableFuture[]::new))
                 .thenApply(v -> totalSize.get());
     }
 
     @Override
-    public CompletableFuture<Boolean> isEmpty(String tableName) {
+    public CompletableFuture<Boolean> mapIsEmpty(String mapName) {
         checkState(isOpen.get(), DB_NOT_OPEN);
-        return size(tableName).thenApply(size -> size == 0);
+        return mapSize(mapName).thenApply(size -> size == 0);
     }
 
     @Override
-    public CompletableFuture<Boolean> containsKey(String tableName, String key) {
+    public CompletableFuture<Boolean> mapContainsKey(String mapName, String key) {
         checkState(isOpen.get(), DB_NOT_OPEN);
-        return partitioner.getPartition(tableName, key).containsKey(tableName, key);
+        return partitioner.getPartition(mapName, key).mapContainsKey(mapName, key);
     }
 
     @Override
-    public CompletableFuture<Boolean> containsValue(String tableName, byte[] value) {
+    public CompletableFuture<Boolean> mapContainsValue(String mapName, byte[] value) {
         checkState(isOpen.get(), DB_NOT_OPEN);
         AtomicBoolean containsValue = new AtomicBoolean(false);
         return CompletableFuture.allOf(partitions
                     .stream()
-                    .map(p -> p.containsValue(tableName, value).thenApply(v -> containsValue.compareAndSet(false, v)))
+                    .map(p -> p.mapContainsValue(mapName, value)
+                               .thenApply(v -> containsValue.compareAndSet(false, v)))
                     .toArray(CompletableFuture[]::new))
                 .thenApply(v -> containsValue.get());
     }
 
     @Override
-    public CompletableFuture<Versioned<byte[]>> get(String tableName, String key) {
+    public CompletableFuture<Versioned<byte[]>> mapGet(String mapName, String key) {
         checkState(isOpen.get(), DB_NOT_OPEN);
-        return partitioner.getPartition(tableName, key).get(tableName, key);
+        return partitioner.getPartition(mapName, key).mapGet(mapName, key);
     }
 
     @Override
-    public CompletableFuture<Result<Versioned<byte[]>>> put(String tableName, String key, byte[] value) {
-        checkState(isOpen.get(), DB_NOT_OPEN);
-        return partitioner.getPartition(tableName, key).put(tableName, key, value);
+    public CompletableFuture<Result<UpdateResult<String, byte[]>>> mapUpdate(
+            String mapName, String key, Match<byte[]> valueMatch,
+            Match<Long> versionMatch, byte[] value) {
+        return partitioner.getPartition(mapName, key).mapUpdate(mapName, key, valueMatch, versionMatch, value);
+
     }
 
     @Override
-    public CompletableFuture<Result<UpdateResult<Versioned<byte[]>>>> putAndGet(String tableName,
-            String key,
-            byte[] value) {
-        checkState(isOpen.get(), DB_NOT_OPEN);
-        return partitioner.getPartition(tableName, key).putAndGet(tableName, key, value);
-    }
-
-    @Override
-    public CompletableFuture<Result<UpdateResult<Versioned<byte[]>>>> putIfAbsentAndGet(String tableName,
-            String key,
-            byte[] value) {
-        checkState(isOpen.get(), DB_NOT_OPEN);
-        return partitioner.getPartition(tableName, key).putIfAbsentAndGet(tableName, key, value);
-    }
-
-    @Override
-    public CompletableFuture<Result<Versioned<byte[]>>> remove(String tableName, String key) {
-        checkState(isOpen.get(), DB_NOT_OPEN);
-        return partitioner.getPartition(tableName, key).remove(tableName, key);
-    }
-
-    @Override
-    public CompletableFuture<Result<Void>> clear(String tableName) {
+    public CompletableFuture<Result<Void>> mapClear(String mapName) {
         AtomicBoolean isLocked = new AtomicBoolean(false);
         checkState(isOpen.get(), DB_NOT_OPEN);
         return CompletableFuture.allOf(partitions
                     .stream()
-                    .map(p -> p.clear(tableName)
+                    .map(p -> p.mapClear(mapName)
                             .thenApply(v -> isLocked.compareAndSet(false, Result.Status.LOCKED == v.status())))
                     .toArray(CompletableFuture[]::new))
                 .thenApply(v -> isLocked.get() ? Result.locked() : Result.ok(null));
     }
 
     @Override
-    public CompletableFuture<Set<String>> keySet(String tableName) {
+    public CompletableFuture<Set<String>> mapKeySet(String mapName) {
         checkState(isOpen.get(), DB_NOT_OPEN);
         Set<String> keySet = Sets.newConcurrentHashSet();
         return CompletableFuture.allOf(partitions
                     .stream()
-                    .map(p -> p.keySet(tableName).thenApply(keySet::addAll))
+                    .map(p -> p.mapKeySet(mapName).thenApply(keySet::addAll))
                     .toArray(CompletableFuture[]::new))
                 .thenApply(v -> keySet);
     }
 
     @Override
-    public CompletableFuture<Collection<Versioned<byte[]>>> values(String tableName) {
+    public CompletableFuture<Collection<Versioned<byte[]>>> mapValues(String mapName) {
         checkState(isOpen.get(), DB_NOT_OPEN);
         List<Versioned<byte[]>> values = new CopyOnWriteArrayList<>();
         return CompletableFuture.allOf(partitions
                     .stream()
-                    .map(p -> p.values(tableName).thenApply(values::addAll))
+                    .map(p -> p.mapValues(mapName).thenApply(values::addAll))
                     .toArray(CompletableFuture[]::new))
                 .thenApply(v -> values);
     }
 
     @Override
-    public CompletableFuture<Set<Entry<String, Versioned<byte[]>>>> entrySet(String tableName) {
+    public CompletableFuture<Set<Entry<String, Versioned<byte[]>>>> mapEntrySet(String mapName) {
         checkState(isOpen.get(), DB_NOT_OPEN);
         Set<Entry<String, Versioned<byte[]>>> entrySet = Sets.newConcurrentHashSet();
         return CompletableFuture.allOf(partitions
                     .stream()
-                    .map(p -> p.entrySet(tableName).thenApply(entrySet::addAll))
+                    .map(p -> p.mapEntrySet(mapName).thenApply(entrySet::addAll))
                     .toArray(CompletableFuture[]::new))
                 .thenApply(v -> entrySet);
     }
 
     @Override
-    public CompletableFuture<Result<Versioned<byte[]>>> putIfAbsent(String tableName, String key, byte[] value) {
-        checkState(isOpen.get(), DB_NOT_OPEN);
-        return partitioner.getPartition(tableName, key).putIfAbsent(tableName, key, value);
-    }
-
-    @Override
-    public CompletableFuture<Result<Boolean>> remove(String tableName, String key, byte[] value) {
-        checkState(isOpen.get(), DB_NOT_OPEN);
-        return partitioner.getPartition(tableName, key).remove(tableName, key, value);
-    }
-
-    @Override
-    public CompletableFuture<Result<Boolean>> remove(String tableName, String key, long version) {
-        checkState(isOpen.get(), DB_NOT_OPEN);
-        return partitioner.getPartition(tableName, key).remove(tableName, key, version);
-    }
-
-    @Override
-    public CompletableFuture<Result<Boolean>> replace(
-            String tableName, String key, byte[] oldValue, byte[] newValue) {
-        checkState(isOpen.get(), DB_NOT_OPEN);
-        return partitioner.getPartition(tableName, key).replace(tableName, key, oldValue, newValue);
-    }
-
-    @Override
-    public CompletableFuture<Result<Boolean>> replace(
-            String tableName, String key, long oldVersion, byte[] newValue) {
-        checkState(isOpen.get(), DB_NOT_OPEN);
-        return partitioner.getPartition(tableName, key).replace(tableName, key, oldVersion, newValue);
-    }
-
-    @Override
-    public CompletableFuture<Result<UpdateResult<Versioned<byte[]>>>> replaceAndGet(
-            String tableName, String key, long oldVersion, byte[] newValue) {
-        checkState(isOpen.get(), DB_NOT_OPEN);
-        return partitioner.getPartition(tableName, key).replaceAndGet(tableName, key, oldVersion, newValue);
-    }
-
-    @Override
     public CompletableFuture<Long> counterGet(String counterName) {
         checkState(isOpen.get(), DB_NOT_OPEN);
         return partitioner.getPartition(counterName, counterName).counterGet(counterName);
@@ -408,7 +350,7 @@
             Transaction transaction) {
         Map<Database, List<DatabaseUpdate>> perPartitionUpdates = Maps.newHashMap();
         for (DatabaseUpdate update : transaction.updates()) {
-            Database partition = partitioner.getPartition(update.tableName(), update.key());
+            Database partition = partitioner.getPartition(update.mapName(), update.key());
             List<DatabaseUpdate> partitionUpdates =
                     perPartitionUpdates.computeIfAbsent(partition, k -> Lists.newLinkedList());
             partitionUpdates.add(update);