atomic operations

110 views
Skip to first unread message

Casey Bodley

unread,
Aug 10, 2012, 11:06:04 AM8/10/12
to hyperdex...@googlegroups.com
I was looking at atomic_add() with the following use case in mind: generating unique, auto-incrementing keys.

space autoincrement
dimensions key (int64), next_value (int64)
key key auto 1 3

results = hyperclient.atomic_add('autoincrement', 0, {'next_value': 1})
unique_key = results['next_value']

However, none of the atomic functions appear to return the resulting values. This really seems to limit their usefulness, if you can't also retrieve the result atomically. Would this be a reasonable feature request?

Emin Gün Sirer

unread,
Aug 10, 2012, 6:43:04 PM8/10/12
to hyperdex...@googlegroups.com
Absolutely! This is on our short-term todo list.
> --
>
>

Robert Escriva

unread,
Aug 24, 2012, 5:21:52 PM8/24/12
to hyperdex...@googlegroups.com
To follow up, I've created a public issue[1] on GitHub.

-Robert

1. https://github.com/rescrv/HyperDex/issues/72
> --
>
>

Holger Winkelmann

unread,
Jan 21, 2015, 7:32:45 AM1/21/15
to hyperdex...@googlegroups.com
HI,

We are just evaluation hyperdex, there was the expectation for this behavior for atomic operations. Do you have some news here?

BTW: I have asked the same question in the github issue.

Robert Escriva

unread,
Jan 22, 2015, 12:35:46 PM1/22/15
to hyperdex...@googlegroups.com
Hi Holger,

We chatted on IRC, but I'm following up here with the same discussion
for the wider audience on the mailing list.

You can get much the same behavior as an atomic_add that returns the
value as a pair of get/cond_put operations. Imagine that we had a space
like this:

space kv key k attribute int count

we could do an atomic increment from Python like this:

>>> c = hyperdex.client.Client('localhost', 1982)
>>> v = c.get('kv', 'some key')
>>> c.cond_put('kv', 'some key', {'v': v['count']}, {'v': v['count'] + 1})
True
>>> old_value = v['count']
>>> new_value = v['count'] + 1

Best,
Robert
> --
> You received this message because you are subscribed to the Google Groups
> "hyperdex-discuss" group.
> To unsubscribe from this group and stop receiving emails from it, send an email
> to hyperdex-discu...@googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.

Reply all
Reply to author
Forward
0 new messages