{"action":"created","comment":{"url":"https://api.github.com/repos/basho/riak_kv/pulls/comments/72275122","id":72275122,"diff_hunk":"@@ -0,0 +1,376 @@\n+%% -*- coding: utf-8 -*-\n+%% -------------------------------------------------------------------\n+%%\n+%% riak_dt_hll: Datatype to approximate/estimate number of distinct\n+%%              elements in a set. Best to read \"HyperLogLog in\n+%%              Practice: Algorithmic Engineering of a State of the\n+%%              Art Cardinality Esitmation Algorithm\" from Google, of\n+%%              which many of the libs reference.\n+%%\n+%% Copyright (c) 2016 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+-module(riak_dt_hll).\n+\n+-behaviour(riak_dt).\n+\n+-include(\"riak_kv_types.hrl\").\n+\n+-ifdef(EQC).\n+-include_lib(\"eqc/include/eqc.hrl\").\n+-export([within_error_check/3, gen_op/0, update_expected/3, eqc_state_value/1]).\n+-define(NUMTESTS, 1000).\n+-endif.\n+\n+-ifdef(TEST).\n+-include_lib(\"eunit/include/eunit.hrl\").\n+-endif.\n+\n+%% API\n+-export([new/0, value/1, value/2]).\n+-export([update/3, update/4, merge/2, equal/2]).\n+-export([to_binary/1, from_binary/1]).\n+-export([to_binary/2]).\n+-export([stats/1, stat/2]).\n+-export([parent_clock/2]).\n+-export([to_version/2]).\n+\n+%% Additional APIs for hyperloglog types\n+-export([new/1, reduce/2, precision/1, check_precision_and_reduce/2]).\n+\n+-export_type([hllset/0, card/0, precision/0]).\n+\n+-define(HYPER_DEFAULT_BACKEND, hyper_binary).\n+-define(STATS, [bytes, precision]).\n+\n+-define(DT_HLLSET_TAG, 86).\n+-define(TAG, ?DT_HLLSET_TAG).\n+-define(V1_VERS, 1).\n+\n+%% Error macros pulled from riak_dt_tags.hrl\n+-define(UNSUPPORTED_VERSION(Vers), {error, unsupported_version, Vers}).\n+-define(INVALID_BINARY, {error, invalid_binary}).\n+-define(UNSUPPORTED_VERSION, {error, unsupported_version,\n+                              Vers :: pos_integer()}).\n+-define(OPS, [add, add_all]).\n+\n+-record(hyper, {p :: precision(),\n+                registers :: {module(), registers()}}).\n+\n+-opaque hllset() :: #hyper{}.\n+\n+-type hllset_op() :: {add|add_all, term()|list(term())} |\n+                     {update, [hllset_op()]}.\n+\n+-type precision() :: hyper:precision().\n+-type registers() :: hyper:registers().\n+-type card() :: number().\n+-type actor() :: riak_dt:actor().\n+-type stat() :: bytes | precision.\n+\n+-spec new() -> hllset().\n+new() ->\n+    new(?HYPER_DEFAULT_PRECISION).\n+\n+-spec new(precision()|riak_kv_bucket:props()) -> hllset().\n+new(Precision) when is_integer(Precision), Precision > 3\n+                    andalso Precision < 17 ->\n+    hyper:new(Precision, ?HYPER_DEFAULT_BACKEND);\n+new(BProps) when is_list(BProps) ->\n+    Precision = proplists:get_value(hll_precision, BProps,\n+                                    ?HYPER_DEFAULT_PRECISION),\n+    new(Precision);\n+new(_) ->\n+    new(?HYPER_DEFAULT_PRECISION).\n+\n+-spec reduce(hllset(), precision()) -> hllset().\n+reduce(HllSet, NewPrecision) ->","path":"src/riak_dt_hll.erl","position":102,"original_position":102,"commit_id":"074a55a53429e7561db6c17c818a9bcc1d1dd4d3","original_commit_id":"074a55a53429e7561db6c17c818a9bcc1d1dd4d3","user":{"login":"zeeshanlakhani","id":202820,"avatar_url":"https://avatars.githubusercontent.com/u/202820?v=3","gravatar_id":"","url":"https://api.github.com/users/zeeshanlakhani","html_url":"https://github.com/zeeshanlakhani","followers_url":"https://api.github.com/users/zeeshanlakhani/followers","following_url":"https://api.github.com/users/zeeshanlakhani/following{/other_user}","gists_url":"https://api.github.com/users/zeeshanlakhani/gists{/gist_id}","starred_url":"https://api.github.com/users/zeeshanlakhani/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/zeeshanlakhani/subscriptions","organizations_url":"https://api.github.com/users/zeeshanlakhani/orgs","repos_url":"https://api.github.com/users/zeeshanlakhani/repos","events_url":"https://api.github.com/users/zeeshanlakhani/events{/privacy}","received_events_url":"https://api.github.com/users/zeeshanlakhani/received_events","type":"User","site_admin":false},"body":"Also, agree w/ crashing. ","created_at":"2016-07-26T15:36:45Z","updated_at":"2016-07-26T15:36:45Z","html_url":"https://github.com/basho/riak_kv/pull/1435#discussion_r72275122","pull_request_url":"https://api.github.com/repos/basho/riak_kv/pulls/1435","_links":{"self":{"href":"https://api.github.com/repos/basho/riak_kv/pulls/comments/72275122"},"html":{"href":"https://github.com/basho/riak_kv/pull/1435#discussion_r72275122"},"pull_request":{"href":"https://api.github.com/repos/basho/riak_kv/pulls/1435"}}},"pull_request":{"url":"https://api.github.com/repos/basho/riak_kv/pulls/1435","id":77026887,"html_url":"https://github.com/basho/riak_kv/pull/1435","diff_url":"https://github.com/basho/riak_kv/pull/1435.diff","patch_url":"https://github.com/basho/riak_kv/pull/1435.patch","issue_url":"https://api.github.com/repos/basho/riak_kv/issues/1435","number":1435,"state":"open","locked":false,"title":"Feature: zl hll datatypes in a set (off develop-2.2. version)","user":{"login":"zeeshanlakhani","id":202820,"avatar_url":"https://avatars.githubusercontent.com/u/202820?v=3","gravatar_id":"","url":"https://api.github.com/users/zeeshanlakhani","html_url":"https://github.com/zeeshanlakhani","followers_url":"https://api.github.com/users/zeeshanlakhani/followers","following_url":"https://api.github.com/users/zeeshanlakhani/following{/other_user}","gists_url":"https://api.github.com/users/zeeshanlakhani/gists{/gist_id}","starred_url":"https://api.github.com/users/zeeshanlakhani/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/zeeshanlakhani/subscriptions","organizations_url":"https://api.github.com/users/zeeshanlakhani/orgs","repos_url":"https://api.github.com/users/zeeshanlakhani/repos","events_url":"https://api.github.com/users/zeeshanlakhani/events{/privacy}","received_events_url":"https://api.github.com/users/zeeshanlakhani/received_events","type":"User","site_admin":false},"body":"Original: https://github.com/basho/riak_kv/pull/1380\r\n\r\n- type cleanup and new hll type(s)\r\n- riak_dt_hll.erl module -> riak_dt behavior, but fits best in riak_kv for now\r\n- necessary updates for new DT to riak_kv_crdt + riak_kv_crdt_json + riak_object (handle precision props around merge)\r\n- adds typical DT stats, but also special byte(s) stats for HLL(sets)\r\n- validation of datatype buckets around precision property and a bit of validation refactoring around dt's\r\n- able to reduce precision if within acceptable criteria\r\n\r\nStill Open Qs:\r\n- uses branch of riak_api that would eventually be a tag probably? **tagging in general really**!\r\n- make sure pipe/yokozuna doesn't break b/c HLL DT. Value should be in use for pipe... YZ use-case may only be storing field to see if it's in a certain range ^^ @JeetKunDoug and @fadushin?\r\n\r\n### Build Tips\r\n\r\n- I'm setting riak_kv to this branch in riak_ee to run this stuff... no official *ee* branch yet.\r\n- I have not created a branch for repl/repl_pb_api that uses the riak_pb *feature-zl-hll_datatypes* branch in the rebar.config for the api lib. I've just been updating it manually for now. \r\n\r\n## Related PRs and/or branches to review and/or figure out the right dependecies\r\n\r\n- [x] : riak_pb : https://github.com/basho/riak_pb/pull/183\r\n- [x] : riak_api : https://github.com/basho/riak_api/tree/feature-zl-hll_datatypes | **NOTE** now off up develop-2.2, only integral thing is riak_pb version\r\n- [x] : yokozuna : https://github.com/basho/yokozuna/pull/658\r\n- [x] : riak-erlang-client  : https://github.com/basho/riak-erlang-client/pull/268\r\n- [x] : riak-erlang-http-client : https://github.com/basho/riak-erlang-http-client/pull/56\r\n- [x] : riak-test : https://github.com/basho/riak_test/pull/1104\r\n- [x] : hyper (fork) : https://github.com/basho/hyper/pull/1 | **NOTE** need this PR reviewed/merged and we'll to tag hyper for in riak_kv's rebar.config.","created_at":"2016-07-11T21:31:22Z","updated_at":"2016-07-26T15:36:45Z","closed_at":null,"merged_at":null,"merge_commit_sha":"2acb863150c95b53721c4323b19af22e9e4f2410","assignee":null,"assignees":[],"milestone":null,"commits_url":"https://api.github.com/repos/basho/riak_kv/pulls/1435/commits","review_comments_url":"https://api.github.com/repos/basho/riak_kv/pulls/1435/comments","review_comment_url":"https://api.github.com/repos/basho/riak_kv/pulls/comments{/number}","comments_url":"https://api.github.com/repos/basho/riak_kv/issues/1435/comments","statuses_url":"https://api.github.com/repos/basho/riak_kv/statuses/074a55a53429e7561db6c17c818a9bcc1d1dd4d3","head":{"label":"basho:feature-zl-hll_datatypes","ref":"feature-zl-hll_datatypes","sha":"074a55a53429e7561db6c17c818a9bcc1d1dd4d3","user":{"login":"basho","id":176293,"avatar_url":"https://avatars.githubusercontent.com/u/176293?v=3","gravatar_id":"","url":"https://api.github.com/users/basho","html_url":"https://github.com/basho","followers_url":"https://api.github.com/users/basho/followers","following_url":"https://api.github.com/users/basho/following{/other_user}","gists_url":"https://api.github.com/users/basho/gists{/gist_id}","starred_url":"https://api.github.com/users/basho/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/basho/subscriptions","organizations_url":"https://api.github.com/users/basho/orgs","repos_url":"https://api.github.com/users/basho/repos","events_url":"https://api.github.com/users/basho/events{/privacy}","received_events_url":"https://api.github.com/users/basho/received_events","type":"Organization","site_admin":false},"repo":{"id":791522,"name":"riak_kv","full_name":"basho/riak_kv","owner":{"login":"basho","id":176293,"avatar_url":"https://avatars.githubusercontent.com/u/176293?v=3","gravatar_id":"","url":"https://api.github.com/users/basho","html_url":"https://github.com/basho","followers_url":"https://api.github.com/users/basho/followers","following_url":"https://api.github.com/users/basho/following{/other_user}","gists_url":"https://api.github.com/users/basho/gists{/gist_id}","starred_url":"https://api.github.com/users/basho/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/basho/subscriptions","organizations_url":"https://api.github.com/users/basho/orgs","repos_url":"https://api.github.com/users/basho/repos","events_url":"https://api.github.com/users/basho/events{/privacy}","received_events_url":"https://api.github.com/users/basho/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/basho/riak_kv","description":"Riak Key/Value Store","fork":false,"url":"https://api.github.com/repos/basho/riak_kv","forks_url":"https://api.github.com/repos/basho/riak_kv/forks","keys_url":"https://api.github.com/repos/basho/riak_kv/keys{/key_id}","collaborators_url":"https://api.github.com/repos/basho/riak_kv/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/basho/riak_kv/teams","hooks_url":"https://api.github.com/repos/basho/riak_kv/hooks","issue_events_url":"https://api.github.com/repos/basho/riak_kv/issues/events{/number}","events_url":"https://api.github.com/repos/basho/riak_kv/events","assignees_url":"https://api.github.com/repos/basho/riak_kv/assignees{/user}","branches_url":"https://api.github.com/repos/basho/riak_kv/branches{/branch}","tags_url":"https://api.github.com/repos/basho/riak_kv/tags","blobs_url":"https://api.github.com/repos/basho/riak_kv/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/basho/riak_kv/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/basho/riak_kv/git/refs{/sha}","trees_url":"https://api.github.com/repos/basho/riak_kv/git/trees{/sha}","statuses_url":"https://api.github.com/repos/basho/riak_kv/statuses/{sha}","languages_url":"https://api.github.com/repos/basho/riak_kv/languages","stargazers_url":"https://api.github.com/repos/basho/riak_kv/stargazers","contributors_url":"https://api.github.com/repos/basho/riak_kv/contributors","subscribers_url":"https://api.github.com/repos/basho/riak_kv/subscribers","subscription_url":"https://api.github.com/repos/basho/riak_kv/subscription","commits_url":"https://api.github.com/repos/basho/riak_kv/commits{/sha}","git_commits_url":"https://api.github.com/repos/basho/riak_kv/git/commits{/sha}","comments_url":"https://api.github.com/repos/basho/riak_kv/comments{/number}","issue_comment_url":"https://api.github.com/repos/basho/riak_kv/issues/comments{/number}","contents_url":"https://api.github.com/repos/basho/riak_kv/contents/{+path}","compare_url":"https://api.github.com/repos/basho/riak_kv/compare/{base}...{head}","merges_url":"https://api.github.com/repos/basho/riak_kv/merges","archive_url":"https://api.github.com/repos/basho/riak_kv/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/basho/riak_kv/downloads","issues_url":"https://api.github.com/repos/basho/riak_kv/issues{/number}","pulls_url":"https://api.github.com/repos/basho/riak_kv/pulls{/number}","milestones_url":"https://api.github.com/repos/basho/riak_kv/milestones{/number}","notifications_url":"https://api.github.com/repos/basho/riak_kv/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/basho/riak_kv/labels{/name}","releases_url":"https://api.github.com/repos/basho/riak_kv/releases{/id}","deployments_url":"https://api.github.com/repos/basho/riak_kv/deployments","created_at":"2010-07-22T17:27:35Z","updated_at":"2016-07-26T02:29:56Z","pushed_at":"2016-07-26T14:41:39Z","git_url":"git://github.com/basho/riak_kv.git","ssh_url":"git@github.com:basho/riak_kv.git","clone_url":"https://github.com/basho/riak_kv.git","svn_url":"https://github.com/basho/riak_kv","homepage":"","size":27360,"stargazers_count":328,"watchers_count":328,"language":"Erlang","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":134,"mirror_url":null,"open_issues_count":178,"forks":134,"open_issues":178,"watchers":328,"default_branch":"develop"}},"base":{"label":"basho:develop-2.2","ref":"develop-2.2","sha":"8fc4fa1484ad86a08266dbf703527d97f11cfe70","user":{"login":"basho","id":176293,"avatar_url":"https://avatars.githubusercontent.com/u/176293?v=3","gravatar_id":"","url":"https://api.github.com/users/basho","html_url":"https://github.com/basho","followers_url":"https://api.github.com/users/basho/followers","following_url":"https://api.github.com/users/basho/following{/other_user}","gists_url":"https://api.github.com/users/basho/gists{/gist_id}","starred_url":"https://api.github.com/users/basho/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/basho/subscriptions","organizations_url":"https://api.github.com/users/basho/orgs","repos_url":"https://api.github.com/users/basho/repos","events_url":"https://api.github.com/users/basho/events{/privacy}","received_events_url":"https://api.github.com/users/basho/received_events","type":"Organization","site_admin":false},"repo":{"id":791522,"name":"riak_kv","full_name":"basho/riak_kv","owner":{"login":"basho","id":176293,"avatar_url":"https://avatars.githubusercontent.com/u/176293?v=3","gravatar_id":"","url":"https://api.github.com/users/basho","html_url":"https://github.com/basho","followers_url":"https://api.github.com/users/basho/followers","following_url":"https://api.github.com/users/basho/following{/other_user}","gists_url":"https://api.github.com/users/basho/gists{/gist_id}","starred_url":"https://api.github.com/users/basho/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/basho/subscriptions","organizations_url":"https://api.github.com/users/basho/orgs","repos_url":"https://api.github.com/users/basho/repos","events_url":"https://api.github.com/users/basho/events{/privacy}","received_events_url":"https://api.github.com/users/basho/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/basho/riak_kv","description":"Riak Key/Value Store","fork":false,"url":"https://api.github.com/repos/basho/riak_kv","forks_url":"https://api.github.com/repos/basho/riak_kv/forks","keys_url":"https://api.github.com/repos/basho/riak_kv/keys{/key_id}","collaborators_url":"https://api.github.com/repos/basho/riak_kv/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/basho/riak_kv/teams","hooks_url":"https://api.github.com/repos/basho/riak_kv/hooks","issue_events_url":"https://api.github.com/repos/basho/riak_kv/issues/events{/number}","events_url":"https://api.github.com/repos/basho/riak_kv/events","assignees_url":"https://api.github.com/repos/basho/riak_kv/assignees{/user}","branches_url":"https://api.github.com/repos/basho/riak_kv/branches{/branch}","tags_url":"https://api.github.com/repos/basho/riak_kv/tags","blobs_url":"https://api.github.com/repos/basho/riak_kv/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/basho/riak_kv/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/basho/riak_kv/git/refs{/sha}","trees_url":"https://api.github.com/repos/basho/riak_kv/git/trees{/sha}","statuses_url":"https://api.github.com/repos/basho/riak_kv/statuses/{sha}","languages_url":"https://api.github.com/repos/basho/riak_kv/languages","stargazers_url":"https://api.github.com/repos/basho/riak_kv/stargazers","contributors_url":"https://api.github.com/repos/basho/riak_kv/contributors","subscribers_url":"https://api.github.com/repos/basho/riak_kv/subscribers","subscription_url":"https://api.github.com/repos/basho/riak_kv/subscription","commits_url":"https://api.github.com/repos/basho/riak_kv/commits{/sha}","git_commits_url":"https://api.github.com/repos/basho/riak_kv/git/commits{/sha}","comments_url":"https://api.github.com/repos/basho/riak_kv/comments{/number}","issue_comment_url":"https://api.github.com/repos/basho/riak_kv/issues/comments{/number}","contents_url":"https://api.github.com/repos/basho/riak_kv/contents/{+path}","compare_url":"https://api.github.com/repos/basho/riak_kv/compare/{base}...{head}","merges_url":"https://api.github.com/repos/basho/riak_kv/merges","archive_url":"https://api.github.com/repos/basho/riak_kv/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/basho/riak_kv/downloads","issues_url":"https://api.github.com/repos/basho/riak_kv/issues{/number}","pulls_url":"https://api.github.com/repos/basho/riak_kv/pulls{/number}","milestones_url":"https://api.github.com/repos/basho/riak_kv/milestones{/number}","notifications_url":"https://api.github.com/repos/basho/riak_kv/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/basho/riak_kv/labels{/name}","releases_url":"https://api.github.com/repos/basho/riak_kv/releases{/id}","deployments_url":"https://api.github.com/repos/basho/riak_kv/deployments","created_at":"2010-07-22T17:27:35Z","updated_at":"2016-07-26T02:29:56Z","pushed_at":"2016-07-26T14:41:39Z","git_url":"git://github.com/basho/riak_kv.git","ssh_url":"git@github.com:basho/riak_kv.git","clone_url":"https://github.com/basho/riak_kv.git","svn_url":"https://github.com/basho/riak_kv","homepage":"","size":27360,"stargazers_count":328,"watchers_count":328,"language":"Erlang","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":134,"mirror_url":null,"open_issues_count":178,"forks":134,"open_issues":178,"watchers":328,"default_branch":"develop"}},"_links":{"self":{"href":"https://api.github.com/repos/basho/riak_kv/pulls/1435"},"html":{"href":"https://github.com/basho/riak_kv/pull/1435"},"issue":{"href":"https://api.github.com/repos/basho/riak_kv/issues/1435"},"comments":{"href":"https://api.github.com/repos/basho/riak_kv/issues/1435/comments"},"review_comments":{"href":"https://api.github.com/repos/basho/riak_kv/pulls/1435/comments"},"review_comment":{"href":"https://api.github.com/repos/basho/riak_kv/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/basho/riak_kv/pulls/1435/commits"},"statuses":{"href":"https://api.github.com/repos/basho/riak_kv/statuses/074a55a53429e7561db6c17c818a9bcc1d1dd4d3"}}}}
{"actor":{"display_login":"zeeshanlakhani"}}