private void addToSnapshotIncrements(Map<String, Map<String, byte[]>> incrementalSnapshotMap,
                                         Map.Entry<String, PartitionIdStateHolder> partitionIdState,
                                         Map.Entry<String, ElementStateHolder> queryState,
                                         Map.Entry<String, StateHolder> elementState,
                                         Map.Entry<String, Map<String, State>> partitionKeyState,
                                         Map.Entry<String, State> groupByKeyState,
                                         Map<String, Object> itemSnapshotsIncremental) {
        String id = partitionKeyState.getKey() + "--" + groupByKeyState.getKey() +
                PersistenceConstants.REVISION_SEPARATOR + queryState.getKey() +
                PersistenceConstants.REVISION_SEPARATOR + elementState.getKey();
        Map<String, byte[]> partitionIdSnapshot =
                incrementalSnapshotMap.computeIfAbsent(
                        partitionIdState.getKey(),
                        k -> new HashMap<>());
        partitionIdSnapshot.put(id, ByteSerializer.objectToByte(
                itemSnapshotsIncremental, siddhiAppContext));
    }
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