private LmdbEnv buildStagingEnv(final LmdbEnvFactory lmdbEnvFactory,
                                    final RefStreamDefinition refStreamDefinition) {
        final Path stagingEnvBaseDir = getStagingLmdbEnvBaseDir();

        // Dir needs to be unique to avoid any clashes. Add in the datetime, stream, part to help
        // with any debugging of lingering files.
        final String subDirName = DATE_FORMATTER.format(Instant.now())
                + FILE_NAME_DELIMTER + refStreamDefinition.getStreamId()
                + FILE_NAME_DELIMTER + refStreamDefinition.getPartNumber()
                + FILE_NAME_DELIMTER + UUID.randomUUID();
        final Path subDirPath = stagingEnvBaseDir.resolve(subDirName);

        LOGGER.info("Creating temporary reference data staging LMDB environment in {}", subDirPath);
        try {
            // This will ensure the dir exists
            return lmdbEnvFactory.builder(referenceDataStagingLmdbConfigProvider.get())
                    .withMaxDbCount(2)
                    .withSubDirectory(subDirName)
                    .addEnvFlag(EnvFlags.MDB_NOTLS)
                    .build();
        } catch (Exception e) {
            throw new RuntimeException(LogUtil.message("Error building staging LMDB in {}: {}",
                    subDirPath, e.getMessage()), e);
        }
    }
Create a {@link OffHeapStagingStore} for use by one thread to load a reference stream into.
@param refStreamDefinition The {@link RefStreamDefinition} of the stream being loaded.
@param mapDefinitionUIDStore The mapDefinitionUIDStore for the destination.
stroom-pipeline/src/main/java/stroom/pipeline/refdata/store/offheapstore/OffHeapStagingStoreFactory.java