{"action":"created","comment":{"url":"https://api.github.com/repos/lasp-lang/types/pulls/comments/72766886","id":72766886,"diff_hunk":"@@ -0,0 +1,291 @@\n+%%\n+%% Copyright (c) 2015-2016 Christopher Meiklejohn.  All Rights Reserved.\n+%% Copyright (c) 2007-2012 Basho Technologies, Inc.  All Rights Reserved.\n+%%\n+%% This file is provided to you under the Apache License,\n+%% Version 2.0 (the \"License\"); you may not use this file\n+%% except in compliance with the License.  You may obtain\n+%% a copy of the License at\n+%%\n+%%   http://www.apache.org/licenses/LICENSE-2.0\n+%%\n+%% Unless required by applicable law or agreed to in writing,\n+%% software distributed under the License is distributed on an\n+%% \"AS IS\" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY\n+%% KIND, either express or implied.  See the License for the\n+%% specific language governing permissions and limitations\n+%% under the License.\n+%%\n+%% -------------------------------------------------------------------\n+\n+%% @doc Pure No Compaction CRDT: pure op-based implementation\n+%% of mutate and query without POLog compaction.\n+%%\n+\n+-module(pure_no_compaction).\n+-author(\"Georges Younes <georges.r.younes@gmail.com>\").\n+\n+\n+-ifdef(TEST).\n+-include_lib(\"eunit/include/eunit.hrl\").\n+-endif.\n+\n+-export([mutate/3, query/1]).\n+\n+-type pure_op() :: term().\n+\n+%% @doc Update with no polog compaction.\n+-spec mutate(pure_op(), pure_type:id(), pure_type:crdt()) ->\n+    {ok, pure_type:crdt()}.\n+mutate(Op, VV, {Type, {POLog, Crystal}}) ->\n+    {ok, {Type, {orddict:store(VV, Op, POLog), Crystal}}}.\n+\n+%% @doc Specific query for no polog compaction pure data types.\n+-spec query(pure_type:crdt()) -> term().\n+query({pure_gcounter, {POLog0, _Crystal}}) ->\n+    orddict:fold(\n+        fun(_Key, Value, Acc) ->\n+            case Value of\n+                increment ->\n+                    Acc + 1;\n+                {increment, Val} ->\n+                    Acc + Val\n+            end\n+        end,\n+        0,\n+        POLog0\n+    );\n+query({pure_pncounter, {POLog0, _Crystal}}) ->\n+    orddict:fold(\n+        fun(_Key, Value, Acc) ->\n+            case Value of\n+                increment ->\n+                    Acc + 1;\n+                {increment, Val} ->\n+                    Acc + Val;\n+                decrement ->\n+                    Acc - 1;\n+                {decrement, Val} ->\n+                    Acc - Val\n+            end\n+        end,\n+        0,\n+        POLog0\n+    );\n+query({pure_gset, {POLog0, _Crystal}}) ->\n+    sets:from_list(orddict:fold(\n+        fun(_Key, {add, El}, Acc) ->\n+                ordsets:add_element(El, Acc)\n+        end,\n+        ordsets:new(),\n+        POLog0\n+    ));\n+query({pure_twopset, {POLog0, _Crystal}}) ->\n+    {Add, Rmv} = orddict:fold(\n+        fun(_Key, {Op, El}, {Acc1, Acc2}) ->\n+            case Op of\n+                add ->\n+                    {ordsets:add_element(El, Acc1), Acc2};\n+                rmv ->\n+                    {Acc1, ordsets:add_element(El, Acc2)}\n+            end\n+        end,\n+        {ordsets:new(), ordsets:new()},\n+        POLog0\n+    ),\n+    sets:from_list(ordsets:subtract(Add, Rmv));\n+query({pure_aworset, {POLog0, _Crystal}}) ->\n+    POLog1 = orddict:fold(\n+        fun(Key0, {Op0, El0}, Acc0) ->\n+            case orddict:fold(\n+                fun(Key1, {Op1, El1}, Acc1) ->\n+                    case El0 =:= El1 andalso Op0 =:= add andalso Op1 =:= rmv of\n+                        true ->\n+                            Acc1 andalso not pure_trcb:happened_before(Key0, Key1);\n+                        false ->\n+                            Acc1\n+                    end\n+                end,\n+                true,\n+                POLog0\n+            ) of\n+                true ->\n+                    orddict:store(Key0, {Op0, El0}, Acc0);\n+                false ->\n+                    Acc0\n+            end\n+        end,\n+        orddict:new(),\n+        POLog0\n+    ),\n+    sets:from_list([El || {_Key, {Op, El}} <- orddict:to_list(POLog1), Op =:= add]);","path":"src/pure_no_compaction.erl","position":121,"original_position":121,"commit_id":"147c2f50088542ca1a9049415f317fc6f4febf90","original_commit_id":"147c2f50088542ca1a9049415f317fc6f4febf90","user":{"login":"CBaquero","id":1908492,"avatar_url":"https://avatars.githubusercontent.com/u/1908492?v=3","gravatar_id":"","url":"https://api.github.com/users/CBaquero","html_url":"https://github.com/CBaquero","followers_url":"https://api.github.com/users/CBaquero/followers","following_url":"https://api.github.com/users/CBaquero/following{/other_user}","gists_url":"https://api.github.com/users/CBaquero/gists{/gist_id}","starred_url":"https://api.github.com/users/CBaquero/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/CBaquero/subscriptions","organizations_url":"https://api.github.com/users/CBaquero/orgs","repos_url":"https://api.github.com/users/CBaquero/repos","events_url":"https://api.github.com/users/CBaquero/events{/privacy}","received_events_url":"https://api.github.com/users/CBaquero/received_events","type":"User","site_admin":false},"body":"Ok, the query semantics look now much more clear from the code.","created_at":"2016-07-29T09:40:50Z","updated_at":"2016-07-29T09:40:50Z","html_url":"https://github.com/lasp-lang/types/pull/53#discussion_r72766886","pull_request_url":"https://api.github.com/repos/lasp-lang/types/pulls/53","_links":{"self":{"href":"https://api.github.com/repos/lasp-lang/types/pulls/comments/72766886"},"html":{"href":"https://github.com/lasp-lang/types/pull/53#discussion_r72766886"},"pull_request":{"href":"https://api.github.com/repos/lasp-lang/types/pulls/53"}}},"pull_request":{"url":"https://api.github.com/repos/lasp-lang/types/pulls/53","id":78198374,"html_url":"https://github.com/lasp-lang/types/pull/53","diff_url":"https://github.com/lasp-lang/types/pull/53.diff","patch_url":"https://github.com/lasp-lang/types/pull/53.patch","issue_url":"https://api.github.com/repos/lasp-lang/types/issues/53","number":53,"state":"open","locked":false,"title":"implement all queries for Pure with no compaction + tests","user":{"login":"gyounes","id":12084070,"avatar_url":"https://avatars.githubusercontent.com/u/12084070?v=3","gravatar_id":"","url":"https://api.github.com/users/gyounes","html_url":"https://github.com/gyounes","followers_url":"https://api.github.com/users/gyounes/followers","following_url":"https://api.github.com/users/gyounes/following{/other_user}","gists_url":"https://api.github.com/users/gyounes/gists{/gist_id}","starred_url":"https://api.github.com/users/gyounes/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/gyounes/subscriptions","organizations_url":"https://api.github.com/users/gyounes/orgs","repos_url":"https://api.github.com/users/gyounes/repos","events_url":"https://api.github.com/users/gyounes/events{/privacy}","received_events_url":"https://api.github.com/users/gyounes/received_events","type":"User","site_admin":false},"body":"","created_at":"2016-07-20T18:45:17Z","updated_at":"2016-07-29T09:40:50Z","closed_at":null,"merged_at":null,"merge_commit_sha":"4f4af27e92dcefd0b4bfb8099e1a6d2736b69e09","assignee":{"login":"cmeiklejohn","id":44939,"avatar_url":"https://avatars.githubusercontent.com/u/44939?v=3","gravatar_id":"","url":"https://api.github.com/users/cmeiklejohn","html_url":"https://github.com/cmeiklejohn","followers_url":"https://api.github.com/users/cmeiklejohn/followers","following_url":"https://api.github.com/users/cmeiklejohn/following{/other_user}","gists_url":"https://api.github.com/users/cmeiklejohn/gists{/gist_id}","starred_url":"https://api.github.com/users/cmeiklejohn/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/cmeiklejohn/subscriptions","organizations_url":"https://api.github.com/users/cmeiklejohn/orgs","repos_url":"https://api.github.com/users/cmeiklejohn/repos","events_url":"https://api.github.com/users/cmeiklejohn/events{/privacy}","received_events_url":"https://api.github.com/users/cmeiklejohn/received_events","type":"User","site_admin":false},"assignees":[{"login":"cmeiklejohn","id":44939,"avatar_url":"https://avatars.githubusercontent.com/u/44939?v=3","gravatar_id":"","url":"https://api.github.com/users/cmeiklejohn","html_url":"https://github.com/cmeiklejohn","followers_url":"https://api.github.com/users/cmeiklejohn/followers","following_url":"https://api.github.com/users/cmeiklejohn/following{/other_user}","gists_url":"https://api.github.com/users/cmeiklejohn/gists{/gist_id}","starred_url":"https://api.github.com/users/cmeiklejohn/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/cmeiklejohn/subscriptions","organizations_url":"https://api.github.com/users/cmeiklejohn/orgs","repos_url":"https://api.github.com/users/cmeiklejohn/repos","events_url":"https://api.github.com/users/cmeiklejohn/events{/privacy}","received_events_url":"https://api.github.com/users/cmeiklejohn/received_events","type":"User","site_admin":false}],"milestone":null,"commits_url":"https://api.github.com/repos/lasp-lang/types/pulls/53/commits","review_comments_url":"https://api.github.com/repos/lasp-lang/types/pulls/53/comments","review_comment_url":"https://api.github.com/repos/lasp-lang/types/pulls/comments{/number}","comments_url":"https://api.github.com/repos/lasp-lang/types/issues/53/comments","statuses_url":"https://api.github.com/repos/lasp-lang/types/statuses/147c2f50088542ca1a9049415f317fc6f4febf90","head":{"label":"lasp-lang:no_compaction","ref":"no_compaction","sha":"147c2f50088542ca1a9049415f317fc6f4febf90","user":{"login":"lasp-lang","id":12764735,"avatar_url":"https://avatars.githubusercontent.com/u/12764735?v=3","gravatar_id":"","url":"https://api.github.com/users/lasp-lang","html_url":"https://github.com/lasp-lang","followers_url":"https://api.github.com/users/lasp-lang/followers","following_url":"https://api.github.com/users/lasp-lang/following{/other_user}","gists_url":"https://api.github.com/users/lasp-lang/gists{/gist_id}","starred_url":"https://api.github.com/users/lasp-lang/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/lasp-lang/subscriptions","organizations_url":"https://api.github.com/users/lasp-lang/orgs","repos_url":"https://api.github.com/users/lasp-lang/repos","events_url":"https://api.github.com/users/lasp-lang/events{/privacy}","received_events_url":"https://api.github.com/users/lasp-lang/received_events","type":"Organization","site_admin":false},"repo":{"id":58376282,"name":"types","full_name":"lasp-lang/types","owner":{"login":"lasp-lang","id":12764735,"avatar_url":"https://avatars.githubusercontent.com/u/12764735?v=3","gravatar_id":"","url":"https://api.github.com/users/lasp-lang","html_url":"https://github.com/lasp-lang","followers_url":"https://api.github.com/users/lasp-lang/followers","following_url":"https://api.github.com/users/lasp-lang/following{/other_user}","gists_url":"https://api.github.com/users/lasp-lang/gists{/gist_id}","starred_url":"https://api.github.com/users/lasp-lang/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/lasp-lang/subscriptions","organizations_url":"https://api.github.com/users/lasp-lang/orgs","repos_url":"https://api.github.com/users/lasp-lang/repos","events_url":"https://api.github.com/users/lasp-lang/events{/privacy}","received_events_url":"https://api.github.com/users/lasp-lang/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/lasp-lang/types","description":"Prototype implementation of Conflict-free Replicated Data Types (CRDTs) in Erlang.","fork":false,"url":"https://api.github.com/repos/lasp-lang/types","forks_url":"https://api.github.com/repos/lasp-lang/types/forks","keys_url":"https://api.github.com/repos/lasp-lang/types/keys{/key_id}","collaborators_url":"https://api.github.com/repos/lasp-lang/types/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/lasp-lang/types/teams","hooks_url":"https://api.github.com/repos/lasp-lang/types/hooks","issue_events_url":"https://api.github.com/repos/lasp-lang/types/issues/events{/number}","events_url":"https://api.github.com/repos/lasp-lang/types/events","assignees_url":"https://api.github.com/repos/lasp-lang/types/assignees{/user}","branches_url":"https://api.github.com/repos/lasp-lang/types/branches{/branch}","tags_url":"https://api.github.com/repos/lasp-lang/types/tags","blobs_url":"https://api.github.com/repos/lasp-lang/types/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/lasp-lang/types/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/lasp-lang/types/git/refs{/sha}","trees_url":"https://api.github.com/repos/lasp-lang/types/git/trees{/sha}","statuses_url":"https://api.github.com/repos/lasp-lang/types/statuses/{sha}","languages_url":"https://api.github.com/repos/lasp-lang/types/languages","stargazers_url":"https://api.github.com/repos/lasp-lang/types/stargazers","contributors_url":"https://api.github.com/repos/lasp-lang/types/contributors","subscribers_url":"https://api.github.com/repos/lasp-lang/types/subscribers","subscription_url":"https://api.github.com/repos/lasp-lang/types/subscription","commits_url":"https://api.github.com/repos/lasp-lang/types/commits{/sha}","git_commits_url":"https://api.github.com/repos/lasp-lang/types/git/commits{/sha}","comments_url":"https://api.github.com/repos/lasp-lang/types/comments{/number}","issue_comment_url":"https://api.github.com/repos/lasp-lang/types/issues/comments{/number}","contents_url":"https://api.github.com/repos/lasp-lang/types/contents/{+path}","compare_url":"https://api.github.com/repos/lasp-lang/types/compare/{base}...{head}","merges_url":"https://api.github.com/repos/lasp-lang/types/merges","archive_url":"https://api.github.com/repos/lasp-lang/types/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/lasp-lang/types/downloads","issues_url":"https://api.github.com/repos/lasp-lang/types/issues{/number}","pulls_url":"https://api.github.com/repos/lasp-lang/types/pulls{/number}","milestones_url":"https://api.github.com/repos/lasp-lang/types/milestones{/number}","notifications_url":"https://api.github.com/repos/lasp-lang/types/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/lasp-lang/types/labels{/name}","releases_url":"https://api.github.com/repos/lasp-lang/types/releases{/id}","deployments_url":"https://api.github.com/repos/lasp-lang/types/deployments","created_at":"2016-05-09T12:52:35Z","updated_at":"2016-07-24T14:41:51Z","pushed_at":"2016-07-28T18:23:10Z","git_url":"git://github.com/lasp-lang/types.git","ssh_url":"git@github.com:lasp-lang/types.git","clone_url":"https://github.com/lasp-lang/types.git","svn_url":"https://github.com/lasp-lang/types","homepage":"https://lasp-lang.org","size":1255,"stargazers_count":11,"watchers_count":11,"language":"Erlang","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":2,"mirror_url":null,"open_issues_count":1,"forks":2,"open_issues":1,"watchers":11,"default_branch":"master"}},"base":{"label":"lasp-lang:master","ref":"master","sha":"663577b1aa9d4adc919c0866e8b2cb70f3e5e491","user":{"login":"lasp-lang","id":12764735,"avatar_url":"https://avatars.githubusercontent.com/u/12764735?v=3","gravatar_id":"","url":"https://api.github.com/users/lasp-lang","html_url":"https://github.com/lasp-lang","followers_url":"https://api.github.com/users/lasp-lang/followers","following_url":"https://api.github.com/users/lasp-lang/following{/other_user}","gists_url":"https://api.github.com/users/lasp-lang/gists{/gist_id}","starred_url":"https://api.github.com/users/lasp-lang/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/lasp-lang/subscriptions","organizations_url":"https://api.github.com/users/lasp-lang/orgs","repos_url":"https://api.github.com/users/lasp-lang/repos","events_url":"https://api.github.com/users/lasp-lang/events{/privacy}","received_events_url":"https://api.github.com/users/lasp-lang/received_events","type":"Organization","site_admin":false},"repo":{"id":58376282,"name":"types","full_name":"lasp-lang/types","owner":{"login":"lasp-lang","id":12764735,"avatar_url":"https://avatars.githubusercontent.com/u/12764735?v=3","gravatar_id":"","url":"https://api.github.com/users/lasp-lang","html_url":"https://github.com/lasp-lang","followers_url":"https://api.github.com/users/lasp-lang/followers","following_url":"https://api.github.com/users/lasp-lang/following{/other_user}","gists_url":"https://api.github.com/users/lasp-lang/gists{/gist_id}","starred_url":"https://api.github.com/users/lasp-lang/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/lasp-lang/subscriptions","organizations_url":"https://api.github.com/users/lasp-lang/orgs","repos_url":"https://api.github.com/users/lasp-lang/repos","events_url":"https://api.github.com/users/lasp-lang/events{/privacy}","received_events_url":"https://api.github.com/users/lasp-lang/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/lasp-lang/types","description":"Prototype implementation of Conflict-free Replicated Data Types (CRDTs) in Erlang.","fork":false,"url":"https://api.github.com/repos/lasp-lang/types","forks_url":"https://api.github.com/repos/lasp-lang/types/forks","keys_url":"https://api.github.com/repos/lasp-lang/types/keys{/key_id}","collaborators_url":"https://api.github.com/repos/lasp-lang/types/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/lasp-lang/types/teams","hooks_url":"https://api.github.com/repos/lasp-lang/types/hooks","issue_events_url":"https://api.github.com/repos/lasp-lang/types/issues/events{/number}","events_url":"https://api.github.com/repos/lasp-lang/types/events","assignees_url":"https://api.github.com/repos/lasp-lang/types/assignees{/user}","branches_url":"https://api.github.com/repos/lasp-lang/types/branches{/branch}","tags_url":"https://api.github.com/repos/lasp-lang/types/tags","blobs_url":"https://api.github.com/repos/lasp-lang/types/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/lasp-lang/types/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/lasp-lang/types/git/refs{/sha}","trees_url":"https://api.github.com/repos/lasp-lang/types/git/trees{/sha}","statuses_url":"https://api.github.com/repos/lasp-lang/types/statuses/{sha}","languages_url":"https://api.github.com/repos/lasp-lang/types/languages","stargazers_url":"https://api.github.com/repos/lasp-lang/types/stargazers","contributors_url":"https://api.github.com/repos/lasp-lang/types/contributors","subscribers_url":"https://api.github.com/repos/lasp-lang/types/subscribers","subscription_url":"https://api.github.com/repos/lasp-lang/types/subscription","commits_url":"https://api.github.com/repos/lasp-lang/types/commits{/sha}","git_commits_url":"https://api.github.com/repos/lasp-lang/types/git/commits{/sha}","comments_url":"https://api.github.com/repos/lasp-lang/types/comments{/number}","issue_comment_url":"https://api.github.com/repos/lasp-lang/types/issues/comments{/number}","contents_url":"https://api.github.com/repos/lasp-lang/types/contents/{+path}","compare_url":"https://api.github.com/repos/lasp-lang/types/compare/{base}...{head}","merges_url":"https://api.github.com/repos/lasp-lang/types/merges","archive_url":"https://api.github.com/repos/lasp-lang/types/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/lasp-lang/types/downloads","issues_url":"https://api.github.com/repos/lasp-lang/types/issues{/number}","pulls_url":"https://api.github.com/repos/lasp-lang/types/pulls{/number}","milestones_url":"https://api.github.com/repos/lasp-lang/types/milestones{/number}","notifications_url":"https://api.github.com/repos/lasp-lang/types/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/lasp-lang/types/labels{/name}","releases_url":"https://api.github.com/repos/lasp-lang/types/releases{/id}","deployments_url":"https://api.github.com/repos/lasp-lang/types/deployments","created_at":"2016-05-09T12:52:35Z","updated_at":"2016-07-24T14:41:51Z","pushed_at":"2016-07-28T18:23:10Z","git_url":"git://github.com/lasp-lang/types.git","ssh_url":"git@github.com:lasp-lang/types.git","clone_url":"https://github.com/lasp-lang/types.git","svn_url":"https://github.com/lasp-lang/types","homepage":"https://lasp-lang.org","size":1255,"stargazers_count":11,"watchers_count":11,"language":"Erlang","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":2,"mirror_url":null,"open_issues_count":1,"forks":2,"open_issues":1,"watchers":11,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/lasp-lang/types/pulls/53"},"html":{"href":"https://github.com/lasp-lang/types/pull/53"},"issue":{"href":"https://api.github.com/repos/lasp-lang/types/issues/53"},"comments":{"href":"https://api.github.com/repos/lasp-lang/types/issues/53/comments"},"review_comments":{"href":"https://api.github.com/repos/lasp-lang/types/pulls/53/comments"},"review_comment":{"href":"https://api.github.com/repos/lasp-lang/types/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/lasp-lang/types/pulls/53/commits"},"statuses":{"href":"https://api.github.com/repos/lasp-lang/types/statuses/147c2f50088542ca1a9049415f317fc6f4febf90"}}}}
{"actor":{"display_login":"CBaquero"}}