# Implementing VersionStamps in bindings

**URL:** <https://forums.foundationdb.org/t/implementing-versionstamps-in-bindings/250>\
**Category:** FoundationDB Core\
**Created:** [April 24, 2018, 7:05pm UTC](https://forums.foundationdb.org/t/implementing-versionstamps-in-bindings/250 "2018-04-24T19:05:11Z")\
**Posts on this page:** 5\
**Page:** 2

<div class="post-metadata">

**Author:** ![KrzysFR](https://sea1.discourse-cdn.com/foundationdb/user_avatar/forums.foundationdb.org/krzysfr/32/43_2.png) [@KrzysFR](https://forums.foundationdb.org/u/KrzysFR)\
**Post date:** [May 9, 2018, 5:17pm UTC](https://forums.foundationdb.org/t/implementing-versionstamps-in-bindings/250/21 "2018-05-09T17:17:40Z")

</div>

Well I’m glad to have chosen a different way, because my tuple encoder is now extracted from the FDB binding and used elsewhere (where it does not know what an API version is).

I’ve chosen to instead use a random byte token that is searched by `SetVersionStampedKey(...)` to get the offfset, so I can trivially fix this by checking the API version there 🙂

So to be exact, depending on the API Version:

- API \< 400:
  - Both not supported (=\> FAIL).

- API \< 520:
  - `SET_VERSIONSTAMPED_KEY` must add a two byte offset
  - `SET_VERSIONSTAMPED_VALUE` does not have any offset at all (first 10 bytes overwritten)

- API \>= 520:
  - `SET_VERSIONSTAMPED_KEY` must add a four byte offset
  - `SET_VERSIONSTAMPED_VALUE` must add a four byte offset as well

---

<div class="post-metadata">

**Author:** ![alloc](https://sea1.discourse-cdn.com/foundationdb/user_avatar/forums.foundationdb.org/alloc/32/9_2.png) [@alloc](https://forums.foundationdb.org/u/alloc)\
**Post date:** [May 9, 2018, 5:23pm UTC](https://forums.foundationdb.org/t/implementing-versionstamps-in-bindings/250/22 "2018-05-09T17:23:42Z")

</div>

I think the contract is actually “API Version \< 520” and “API Version \>= 520”, but yeah, that’s otherwise correct.

---

<div class="post-metadata">

**Author:** ![KrzysFR](https://sea1.discourse-cdn.com/foundationdb/user_avatar/forums.foundationdb.org/krzysfr/32/43_2.png) [@KrzysFR](https://forums.foundationdb.org/u/KrzysFR)\
**Post date:** [May 9, 2018, 5:57pm UTC](https://forums.foundationdb.org/t/implementing-versionstamps-in-bindings/250/23 "2018-05-09T17:57:59Z")

</div>

_I have updated my comment above with the API version._

---

<div class="post-metadata">

**Author:** ![KrzysFR](https://sea1.discourse-cdn.com/foundationdb/user_avatar/forums.foundationdb.org/krzysfr/32/43_2.png) [@KrzysFR](https://forums.foundationdb.org/u/KrzysFR)\
**Post date:** [May 9, 2018, 6:10pm UTC](https://forums.foundationdb.org/t/implementing-versionstamps-in-bindings/250/24 "2018-05-09T18:10:26Z")

</div>

@alloc I forgot to test for the minimum supported API version for VersionStamps.

The [release notes](https://github.com/apple/foundationdb/blob/master/documentation/sphinx/source/old-release-notes/release-notes-400.rst) says that they appeared in version 4.0.1. Does this correspond to API version **400** or **401**?

---

<div class="post-metadata">

**Author:** ![alloc](https://sea1.discourse-cdn.com/foundationdb/user_avatar/forums.foundationdb.org/alloc/32/9_2.png) [@alloc](https://forums.foundationdb.org/u/alloc)\
**Post date:** [May 9, 2018, 6:14pm UTC](https://forums.foundationdb.org/t/implementing-versionstamps-in-bindings/250/25 "2018-05-09T18:14:10Z")

</div>

I think that’s a bug in our documentation. I think we _actually_ introduced in 4.0.0, not 4.0.1 (despite the release notes). I believe it’s API version 400 either way.

[Previous page](https://forums.foundationdb.org/t/implementing-versionstamps-in-bindings/250.md?page=1)
