# FoundationDB as backend for JanusGraph - Iterate through all vertices

**URL:** <https://forums.foundationdb.org/t/foundationdb-as-backend-for-janusgraph-iterate-through-all-vertices/2280>\
**Category:** Using Layers\
**Created:** [August 6, 2020, 6:41pm UTC](https://forums.foundationdb.org/t/foundationdb-as-backend-for-janusgraph-iterate-through-all-vertices/2280 "2020-08-06T18:41:32Z")\
**Posts on this page:** 1\
**Showing post:** 3

<div class="post-metadata">

**Author:** ![SarthakGhosh16](https://avatars.discourse-cdn.com/v4/letter/s/ba9def/32.png) [@SarthakGhosh16](https://forums.foundationdb.org/u/SarthakGhosh16)\
**Post date:** [August 9, 2020, 9:04pm UTC](https://forums.foundationdb.org/t/foundationdb-as-backend-for-janusgraph-iterate-through-all-vertices/2280/3 "2020-08-09T21:04:08Z")

</div>

Gaurav,  
Thanks for the link. I tried few things which were mentioned there.

The idea is,

1. I get the startKey, endKey and limit from `query.limit()` - then get `Iterable<KeyValue> Range`
2. Start consuming keyValues
3. Hit error → create new txn → get nextKey from where the error occured → go to Step 1.
4. When consumed all, then `break`

2 questions here:

1. Is this idea okay?
2. If yes, what would be the break condition here? How do I get that

> [@Large Range Scans - avoid 5s limit](https://forums.foundationdb.org/t/large-range-scans-avoid-5s-limit/292/10):
>
> Here is the almost complete code snippet that I currently use for this purpose. It should be straight forward to extend/update it: // input byte[] start, byte[] end, boolean reverse final AtomicReference\<byte[]\> seen = new AtomicReference\<\>(null); fdb.readAsync(tx -\> { // DO: Set timeout, num retries on the transaction object (tx) byte[] en = end; byte[] st = start; if (reverse) { en = seen.get() != null ? seen.get() : end; } else { // Note: nextKey is merg…

Thanks!!

---

_[View the full topic](https://forums.foundationdb.org/t/foundationdb-as-backend-for-janusgraph-iterate-through-all-vertices/2280)._
