private void migrateRefStreamDef(final RefStreamDefinition refStreamDefinition,
                                     final OffHeapRefDataLoader destStoreLoader) {
        LOGGER.debug("Migrating entries for refStreamDefinition: {}", refStreamDefinition);
        try {
            // We are pulling data from an existing store, so duplicates have already been
            // dealt with
            destStoreLoader.initialise(false, LoaderMode.MIGRATE);
            final int maxCommits = referenceDataConfig.getMaxPutsBeforeCommit();

            try (final PooledByteBuffer uidPooledByteBuffer = mapDefinitionUIDStore.getUidPooledByteBuffer();
                    final BatchingWriteTxn destBatchingWriteTxn = destinationStore.getLmdbEnvironment()
                            .openBatchingWriteTxn(maxCommits)) {

                final ByteBuffer uidByteBuffer = uidPooledByteBuffer.getByteBuffer();

                // Read txn on source store
                sourceStore.getLmdbEnvironment().doWithReadTxn(sourceReadTxn -> {
                    final List<MapDefinition> mapDefinitions = mapDefinitionUIDStore.getMapDefinitions(sourceReadTxn,
                            refStreamDefinition);

                    // Init the state for task info logging
                    migrationState = new MigrationState(mapDefinitions.size());

                    mapDefinitions.forEach(mapDefinition -> {
                        final UID mapUid = mapDefinitionUIDStore.getUid(sourceReadTxn, mapDefinition, uidByteBuffer)
                                .orElseThrow(() ->
                                        new RuntimeException("No UID for mapDefinition " + mapDefinition));

                        // As far as possible do the migration without any serialisation
                        migrateKeyValueEntries(
                                destStoreLoader,
                                destBatchingWriteTxn,
                                sourceReadTxn,
                                mapDefinition,
                                mapUid);

                        migrateRangeValueEntries(
                                destStoreLoader,
                                destBatchingWriteTxn,
                                sourceReadTxn,
                                mapDefinition,
                                mapUid);

                        migrationState.mapsMigrated.incrementAndGet();
                    });
                });
                destBatchingWriteTxn.commit();
            }

            destStoreLoader.completeProcessing(ProcessingState.COMPLETE);
        } catch (Exception e) {
            destStoreLoader.completeProcessing(ProcessingState.FAILED);
            throw new RuntimeException(e);
        }

    }
Migrate the data for refStreamId into destinationStore
stroom-pipeline/src/main/java/stroom/pipeline/refdata/store/offheapstore/StoreMigrator.java