@Override
  public KeyValueSnapshot<byte[], byte[]> snapshot(byte[] from, byte[] to) {
    // TODO: Bug: SAMZA-2564: does not satisfy immutability constraint, since entrySet is backed by the underlying map.
    // snapshot the underlying map
    Set<Map.Entry<byte[], byte[]>> entries = this.underlying.subMap(from, to).entrySet();
    return new KeyValueSnapshot<byte[], byte[]>() {
      @Override
      public KeyValueIterator<byte[], byte[]> iterator() {
        return new InMemoryIterator(entries.iterator(), metrics);
      }

      @Override
      public void close() {
      }
    };
  }
@param metrics A metrics instance to publish key-value store related statistics
samza-kv-inmemory/src/main/java/org/apache/samza/storage/kv/inmemory/InMemoryKeyValueStore.java