These are a collection of CRDTs as described by the following paper:
http://hal.archives-ouvertes.fr/docs/00/55/55/88/PDF/techreport.pdf
| from guard import Guard | |
| import webob | |
| from webob import Request | |
| import webob.exc | |
| def method(*method_list): | |
| def inner(request, *args, **kwargs): | |
| return request.method in method_list |
| from collections import Mapping | |
| def force_str(str_or_unicode): | |
| if type(str_or_unicode) is unicode: | |
| return str_or_unicode.encode("utf-8") | |
| else: | |
| return str_or_unicode | |
| class RiakMapping(Mapping): |
| from webob.dec import wsgify | |
| from webob import Response | |
| import roaf | |
| from roaf.micro import App, Data | |
| from roaf.data.dictcollection import DictCollection | |
| from roaf.resources.collections import CollectionResource | |
| from roaf.middleware.default import DefaultMiddleware | |
| from roaf.serializers import jsoncodec as json | |
| from formencode import Schema, validators | |
| from pyquery import PyQuery |
| def chunk(l, size): | |
| chunk_l = [] | |
| for x in l: | |
| if len(chunk_l) == size: | |
| yield chunk_l | |
| chunk_l = [x] | |
| else: | |
| chunk_l.append(x) | |
| for x in chunk(range(10), 2): |
These are a collection of CRDTs as described by the following paper:
http://hal.archives-ouvertes.fr/docs/00/55/55/88/PDF/techreport.pdf
| (env)Erics-MacBook-Pro:crdt eric$ python /tmp/millionkeys.py | |
| Add: | |
| 0.573606014252 | |
| Serialize: | |
| 0.552729129791 | |
| Sort, Slice: | |
| 0.511281967163 | |
| Deserialize: | |
| 0.156991004944 |
| def ichunk(s, size): | |
| return (s[i: i+size] for i in xrange(0, len(s), size)) | |
| def ichain(iterable): | |
| """Better than itertools.chain because it does not use *args""" | |
| for inner in iterable: | |
| for item in inner: | |
| yield item |
| (->> collection | |
| (map expr) | |
| sort | |
| flatten | |
| unique) |
| (def collection [1 2 [3 4] [4 5] 6 7 [7 8]]) | |
| (println | |
| (->> collection | |
| flatten | |
| (map #(* % 2)) ; this could use the #(* % 2) lambda shorthand | |
| distinct | |
| sort)) | |
| ; => (2 4 6 8 10 12 14 16) |
| *.class | |
| *.jar | |
| countby |