public ByteBuffer getNextUid(final Txn<ByteBuffer> txn,
                                 final PooledByteBuffer newUidPooledBuffer) {
        final ByteBuffer nextUidBuffer = newUidPooledBuffer.getByteBuffer();
        // scan backwards over all entries to find the first (i.e. highest) key
        try (CursorIterable<ByteBuffer> cursorIterable = getLmdbDbi().iterate(txn, KeyRange.allBackward())) {
            final Iterator<KeyVal<ByteBuffer>> iterator = cursorIterable.iterator();
            if (iterator.hasNext()) {
                final CursorIterable.KeyVal<ByteBuffer> highestKeyVal = iterator.next();

                final ByteBuffer highestUidBuffer = highestKeyVal.key();

                LAMBDA_LOGGER.trace(() ->
                        LogUtil.message("highestKey: {}", ByteBufferUtils.byteBufferInfo(highestUidBuffer)));

                // DB has a UID in it so create a new one that is one higher
                // in the pooled buffer
                // Need to use the key buffer before the txn uses a cursor elsewhere so
                // we write into our own buffer.
                UID.wrap(highestUidBuffer)
                        .writeNextUid(nextUidBuffer);
            } else {
                // Empty DB so create the lowest UID into the pooled buffer
                UID.writeMinimumValue(nextUidBuffer);
            }
        }
        // Not owned by LMDB
        return nextUidBuffer;
    }
@return A bytebuffer of the next UID, NOT owned by LMDB
stroom-pipeline/src/main/java/stroom/pipeline/refdata/store/offheapstore/databases/MapUidReverseDb.java