private RefStreamDefinition getValueFromNestedContextStream(final PipelineReference pipelineReference,
                                                                final String mapName,
                                                                final String keyName,
                                                                final ReferenceDataResult result) {

        LOGGER.trace(() -> LogUtil.message(
                "getNestedStreamEventList called, pipe: {}, feed: {}, streamType: {}, map: {}, key: {}",
                pipelineReference.getName(),
                pipelineReference.getFeed().getName(),
                pipelineReference.getStreamType(),
                mapName,
                keyName));

        // Get nested stream part.
        final long partIndex = metaHolder.getPartIndex();

        LOGGER.trace(() -> LogUtil.message("StreamId: {}, parentStreamId: {}",
                metaHolder.getMeta().getId(),
                metaHolder.getMeta().getParentMetaId()));

        // the parent stream appears to be null at this point so just use the stream id
        final RefStreamDefinition refStreamDefinition = new RefStreamDefinition(
                pipelineReference.getPipeline(),
                getPipelineVersion(pipelineReference),
                metaHolder.getMeta().getId(),
                partIndex);

        // This is a context stream so the context stream is the effective stream
        result.addEffectiveStream(pipelineReference, refStreamDefinition);

        // Establish if we have the data for the context stream in the store
        // Context data is only relevant to the event stream it is associated with so is therefore
        // transient and is stored on heap rather than in LMDB.
        final RefDataStore onHeapRefDataStore = refDataStoreHolder.getOnHeapRefDataStore();

        final Optional<ProcessingState> optLoadState = onHeapRefDataStore.getLoadState(refStreamDefinition);
        LOGGER.trace("optLoadState: {}", optLoadState);
        final boolean isRefLoadRequired = optLoadState
                .filter(loadState ->
                        loadState.equals(ProcessingState.COMPLETE))
                .isEmpty();
        LOGGER.trace("optLoadState: {}, isRefLoadRequired: {}", optLoadState, isRefLoadRequired);

        if (optLoadState.isPresent() && optLoadState.get().equals(ProcessingState.FAILED)) {
            throw new RuntimeException(LogUtil.message(
                    "Reference stream {} has been loaded previously but failed, unable to lookup key {} in map {}",
                    refStreamDefinition.getStreamId(), keyName, mapName));

        } else {
            MapAvailability mapAvailability = refDataStoreHolder.getMapAvailabilityInStream(
                    pipelineReference, refStreamDefinition, mapName);
            logMapAvailability(pipelineReference, mapName, result, refStreamDefinition, mapAvailability);

            if (mapAvailability.isLookupRequired()) {
                if (isRefLoadRequired) {
                    // data is not in the store so load it
                    final InputStreamProvider provider = metaHolder.getInputStreamProvider();
                    // There may not be a provider for this stream type if we do not
                    // have any context data stream.
                    if (provider != null) {
                        final SizeAwareInputStream inputStream = provider.get(pipelineReference.getStreamType());
                        loadContextData(
                                metaHolder.getMeta(),
                                inputStream,
                                pipelineReference.getPipeline(),
                                refStreamDefinition,
                                onHeapRefDataStore);

                    }
                } else {
                    LOGGER.trace("Data already loaded for {}", refStreamDefinition);
                }

                // Now the data is known to be loaded, record the maps available in the stream
                // for subsequent lookups
                refDataStoreHolder.addKnownMapNames(
                        onHeapRefDataStore,
                        refStreamDefinition);

                if (MapAvailability.UNKNOWN.equals(mapAvailability)) {
                    // Re-check the availability now we have the facts
                    mapAvailability = refDataStoreHolder.getMapAvailabilityInStream(
                            pipelineReference, refStreamDefinition, mapName);
                    logMapAvailability(pipelineReference, mapName, result, refStreamDefinition, mapAvailability);
                }

                // Now we have established the available maps in the stream check again whether we need to
                // lookup or not
                if (mapAvailability.isLookupRequired()) {
                    // Add a proxy to the lookup value now we know it is loaded
                    setValueProxyOnResult(
                            onHeapRefDataStore,
                            mapName,
                            keyName,
                            result,
                            refStreamDefinition);
                }
            }
        }

        return refStreamDefinition;
    }
Get an event list from a stream that is a nested child of the current
stream context and is therefore not effective time sensitive.
i.e. a context stream attached to this stream and contains data applicable
to this stream only.
stroom-pipeline/src/main/java/stroom/pipeline/refdata/ReferenceData.java