private LmdbEnv createEnvironment(final LmdbEnvFactory lmdbEnvFactory,
                                      final ReferenceDataLmdbConfig lmdbConfig,
                                      final String subDirName) {

        // By default LMDB opens with readonly mmaps so you cannot mutate the bytebuffers inside a txn.
        // Instead you need to create a new bytebuffer for the value and put that. If you want faster writes
        // then you can use EnvFlags.MDB_WRITEMAP in the open() call to allow mutation inside a txn but that
        // comes with greater risk of corruption.

        // NOTE on setMapSize() from LMDB author found on https://groups.google.com/forum/#!topic/caffe-users/0RKsTTYRGpQ
        // On Windows the OS sets the filesize equal to the mapsize. (MacOS requires that too, and allocates
        // all of the physical space up front, it doesn't support sparse files.) The mapsize should not be
        // hardcoded into software, it needs to be reconfigurable. On Windows and MacOS you really shouldn't
        // set it larger than the amount of free space on the filesystem.

        final SimpleEnvBuilder builder = lmdbEnvFactory.builder(lmdbConfig)
                .withMaxDbCount(7)
                .addEnvFlag(EnvFlags.MDB_NOTLS);

        if (subDirName != null) {
            builder.withSubDirectory(subDirName);
        }

        final String name = Objects.requireNonNullElse(subDirName, LEGACY_STORE_NAME);
        final LmdbEnv env = builder
                .withSubDirectory(subDirName)
                .withName(name)
                .build();

        LOGGER.debug(() -> LogUtil.message("Created Ref Data LMDB Env: {}, localDir: {}, existing databases: [{}]",
                name, env.getLocalDir().toAbsolutePath(), String.join(",", env.getDbiNames())));
        return env;
    }
For use in testing at SMALL scale. Dumps the content of each DB to the logger.
stroom-pipeline/src/main/java/stroom/pipeline/refdata/store/offheapstore/RefDataLmdbEnv.java