public void restore(Map<String, Map<String, Map<String, Map<Long, Map<IncrementalSnapshotInfo, byte[]>>>>>
                                snapshot)
            throws CannotRestoreSiddhiAppStateException {
        try {
            threadBarrier.lock();
            waitForSystemStabilization();
            try {
                //cleaning old group by states
                cleanGroupByStates();
                //restore data
                for (Map.Entry<String, Map<String, Map<String, Map<Long, Map<IncrementalSnapshotInfo, byte[]>>>>>
                        partitionIdSnapshot : snapshot.entrySet()) {
                    PartitionIdStateHolder partitionStateHolder = partitionIdStates.get(partitionIdSnapshot.getKey());
                    if (partitionStateHolder == null) {
                        continue;
                    }
                    for (Iterator<Map.Entry<String, Map<String, Map<Long, Map<IncrementalSnapshotInfo, byte[]>>>>>
                         iterator = partitionIdSnapshot.getValue().entrySet().iterator(); iterator.hasNext(); ) {
                        Map.Entry<String, Map<String, Map<Long, Map<IncrementalSnapshotInfo, byte[]>>>>
                                partitionGroupByKeySnapshot = iterator.next();
                        restoreIncrementalSnapshot(partitionStateHolder, partitionGroupByKeySnapshot.getValue());
                        iterator.remove();
                    }

                }
            } catch (Throwable t) {
                throw new CannotRestoreSiddhiAppStateException("Restoring of Siddhi app " +
                        siddhiAppContext.getName() + " not completed properly because content of Siddhi " +
                        "app has changed since last state persistence. Clean persistence store for a " +
                        "fresh deployment.", t);
            }
        } finally {
            threadBarrier.unlock();
        }
    }
Service level implementation to take/restore snapshots of processing elements.
Memory   : PartitionId + QueryName + ElementId + PartitionGroupByKey + Item
Snapshot : PartitionId + PartitionGroupByKey + QueryName + ElementId + Item
modules/siddhi-core/src/main/java/io/siddhi/core/util/snapshot/SnapshotService.java