public <T> T streamEntries(final Txn<ByteBuffer> txn,
                               final KeyRange<K> keyRange,
                               final Function<Stream<Entry<K, V>>, T> streamFunction) {

        try (final PooledByteBuffer startKeyPooledBuffer = getPooledKeyBuffer();
                final PooledByteBuffer stopKeyPooledBuffer = getPooledKeyBuffer()) {

            final KeyRange<ByteBuffer> serialisedKeyRange = serialiseKeyRange(startKeyPooledBuffer,
                    stopKeyPooledBuffer,
                    keyRange);

            return streamEntriesAsBytes(txn, serialisedKeyRange, entryStream -> {
                final Stream<Entry<K, V>> deSerialisedStream = entryStream.map(keyVal -> {
                    K key = deserializeKey(keyVal.key());
                    V value = deserializeValue(keyVal.val());
                    return Map.entry(key, value);
                });

                return streamFunction.apply(deSerialisedStream);
            });
        }
    }
Stream all entries found in keyRange in the order they are found in the DB.

@param streamFunction A function to map a {@link Stream} to a return value T
@return The result of the stream mapping function.
stroom-lmdb/src/main/java/stroom/lmdb/AbstractLmdbDb.java