private long countChildren(final Key parentKey,
                                   final int depth) {
            // If we don't have any children at the requested depth then return 0.
            final LmdbDataStore dataStore = readContext.dataStore;
            if (dataStore.compiledSorters.size() <= depth) {
                return 0;
            }

            final AtomicLong atomicLong = new AtomicLong();
            dataStore.lmdbRowKeyFactory.createChildKeyRange(parentKey, keyRange ->
                    atomicLong.set(readContext.readResult(keyRange, iterator -> {
                        long count = 0;
                        while (iterator.hasNext()
                               && !Thread.currentThread().isInterrupted()) {
                            iterator.next();
                            // FIXME : NOTE THIS COUNT IS NOT FILTERED BY THE MAPPER.
                            count++;
                        }
                        return count;
                    })));
            return atomicLong.get();
        }
Write data from the data store to an output removing them from the datastore as we go as they will be transferred
to another store.

@param output The output to write to.
stroom-query/stroom-query-common/src/main/java/stroom/query/common/v2/LmdbDataStore.java