Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Is map type unordered? #30

Closed
kaey opened this issue Aug 30, 2019 · 2 comments
Closed

Is map type unordered? #30

kaey opened this issue Aug 30, 2019 · 2 comments

Comments

@kaey
Copy link

kaey commented Aug 30, 2019

Spec suggests encoding json as an example and json is unordered, however it doesn't explicitly states this.

Ordered hash maps would complicate implementation for some languages, like go(map) or python(dict).

@dumblob
Copy link

dumblob commented Aug 30, 2019

Just a nit pick:

Ordered hash maps would complicate implementation for some languages, like go(map) or python(dict).

Python 3 dict is ordered. For Go (as well as any other at least a bit widespread language) there is always an ordered map module - see e.g. https://github.com/iancoleman/orderedmap .

@AngusP
Copy link
Contributor

AngusP commented Nov 21, 2019

Maps represent a sequence of field-value items, basically what we could call a dictionary data structure, or in other terms, an hash.

The theoretical datastructure 'hash' and 'dictionary' are unordered - of course some implementations do have orderings fall-out as a side-effect (insert order, usually).

I think there should be no guarantee of order made by RESP3, as this would require Redis or any other implementer of RESP3 to always return the same ordering for a map and make implementing a client tricky in a language where the 'logical' native map type to return is not ordered (for example, Go maps, Python 2 dicts) - you would either depend on a non-standard library that provides an ordered map, or ditch the ordering and return your native unordered type.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants