UID getOrCreateUid(final Txn<ByteBuffer> writeTxn,
                       final MapDefinition mapDefinition,
                       final PooledByteBuffer uidPooledBuffer) {
        Preconditions.checkArgument(!writeTxn.isReadOnly(), "Must be a write transaction");

        try (final PooledByteBuffer mapDefinitionPooledBuffer = mapUidForwardDb.getPooledKeyBuffer()) {

            final ByteBuffer mapDefinitionBuffer = mapDefinitionPooledBuffer.getByteBuffer();

            mapUidForwardDb.serializeKey(mapDefinitionBuffer, mapDefinition);

            // if we already have a UID for this mapDefinition return it
            // if not, create the pair of entries and return the created UID
            return mapUidForwardDb.getAsBytes(writeTxn, mapDefinitionBuffer)
                    .map(uidBuffer -> {
                        LOGGER.trace(() ->
                                LogUtil.message("Found existing UID {}", ByteBufferUtils.byteBufferInfo(uidBuffer)));
                        return mapUidForwardDb.deserializeValue(uidBuffer);
                    })
                    .orElseGet(() ->
                            createForwardReversePair(writeTxn, mapDefinitionBuffer, uidPooledBuffer));
        }
    }
Returns the UID corresponding to the passed mapDefinition if it exists in the two mapping DBs. If it doesn't
exist, a forward and reverse mapping will be created and the new UID returned. The returned UID wraps a
direct allocation {@link ByteBuffer} owned by LMDB so it may ONLY be used whilst still inside the passed
{@link Txn}.
stroom-pipeline/src/main/java/stroom/pipeline/refdata/store/offheapstore/MapDefinitionUIDStore.java