@Override
    public EffectiveMetaSet getEffectiveStreams(final EffectiveMetaDataCriteria effectiveMetaDataCriteria) {

        LOGGER.debug("getEffectiveStreams({})", effectiveMetaDataCriteria);

        Objects.requireNonNull(effectiveMetaDataCriteria);
        final Period period = Objects.requireNonNull(effectiveMetaDataCriteria.getEffectivePeriod());
        // Inclusive
        final long fromMs = Objects.requireNonNull(period.getFromMs());
        // Exclusive
        final long toMs = Objects.requireNonNull(period.getToMs());
        final String feedName = effectiveMetaDataCriteria.getFeed();
        final String typeName = effectiveMetaDataCriteria.getType();

        // Debatable whether we should throw an exception if the feed/type don't exist
        final Optional<Integer> optFeedId = feedDao.get(feedName);
        if (optFeedId.isEmpty()) {
            LOGGER.debug("Feed {} not found in the {} table.",
                    feedName, META_FEED.NAME);
            return EffectiveMetaSet.empty();
        }
        final int feedId = optFeedId.get();

        final Optional<Integer> optTypeId = metaTypeDao.get(typeName);
        if (optTypeId.isEmpty()) {
            LOGGER.warn("Meta Type {} not found in the database", typeName);
            return EffectiveMetaSet.empty();
        }
        final int typeId = optTypeId.get();

        final Builder metaSetBuilder = EffectiveMetaSet.builder(feedName, typeName);

        JooqUtil.context(metaDbConnProvider,
                context -> {
                    // Try to get a single stream that is just before our range.  This is so that we always
                    // have a stream (unless there are no streams at all) that was effective at the start
                    // of our range.
                    final var selectUpToRange = createBaseEffectiveStreamsQuery(
                            context, feedId, typeId)
                            .and(meta.EFFECTIVE_TIME.lessOrEqual(fromMs))
                            .orderBy(meta.EFFECTIVE_TIME.desc())
                            .limit(1);

                    // Get the streams in our range
                    final var selectInRange = createBaseEffectiveStreamsQuery(
                            context, feedId, typeId)
                            .and(meta.EFFECTIVE_TIME.greaterThan(fromMs))
                            .and(meta.EFFECTIVE_TIME.lessThan(toMs));

                    // We want to include dups so that we can log and remove them later
                    final var select = selectUpToRange.unionAll(selectInRange);

                    LOGGER.debug("select:\n{}", select);

                    select.fetch()
                            .forEach(rec ->
                                    metaSetBuilder.add(
                                            rec.get(meta.ID),
                                            rec.get(meta.EFFECTIVE_TIME)));
                });

        final EffectiveMetaSet streamsInOrBelowRange = metaSetBuilder.build();

        LOGGER.debug(() -> LogUtil.message("returning {} effective streams for feedId: {}, typeId: {}, criteria: {}",
                streamsInOrBelowRange.size(),
                streamsInOrBelowRange.getFeedName(),
                streamsInOrBelowRange.getTypeName(),
                effectiveMetaDataCriteria));

        return streamsInOrBelowRange;
    }
@return True if any term in any rule expression uses at least one of {@code fields}.
stroom-meta/stroom-meta-impl-db/src/main/java/stroom/meta/impl/db/MetaDaoImpl.java