private KeyRange<ByteBuffer> buildKeyRange(final UID mapDefinitionUid,
                                               final long key,
                                               final ByteBuffer startKeyBuf) {
        // We want to scan backwards over all keys with the passed mapDefinitionUid,
        // starting with a range from == key. E.g. with the following data (ignoring mapDefUid)
        // in DB order.

        // 100-200
        // 200-300
        // 300-400
        // 400-500

        // key  | DB keys returned
        // -----|-----------------
        // 50   | [no rows]
        // 150  | 100-200
        // 300  | 300-400, 200-300, 100-200
        // 1000 | 400-500, 300-400, 200-300, 100-200

        // Set the 'to' bit of the start key to Long.MAX_VALUE to ensure we get all possible values
        // with that 'from' part.
        final Range<Long> startRange = new Range<>(key, Long.MAX_VALUE);
        final RangeStoreKey startRangeStoreKey = new RangeStoreKey(mapDefinitionUid, startRange);
        keySerde.serialize(startKeyBuf, startRangeStoreKey);

        LOGGER.trace(() -> "Using startRangeStoreKey [" + startRangeStoreKey + "]");
        // we want to scan backward from (and including, if found) our start key
        return KeyRange.atLeastBackward(startKeyBuf);
    }
Apply the passes entryConsumer for each entry found matching the supplied UID
stroom-pipeline/src/main/java/stroom/pipeline/refdata/store/offheapstore/databases/RangeStoreDb.java