{"action":"created","comment":{"url":"https://api.github.com/repos/mldbai/mldb/pulls/comments/69005238","id":69005238,"diff_hunk":"@@ -0,0 +1,166 @@\n+// This file is part of MLDB. Copyright 2015 Datacratic. All rights reserved.\n+\n+/** dist_table_procedure.h                                         -*- C++ -*-\n+    Simon Lemieux, June 2015\n+    Copyright (c) 2015 Datacratic Inc.  All rights reserved.\n+\n+    distTable procedure\n+\n+    Note that this was mainly copied from stats_table_procedure.h in a hurry.\n+    This will probably be revisited.\n+*/\n+\n+#pragma once\n+\n+#include \"types/value_description.h\"\n+#include \"server/plugin_resource.h\"\n+#include \"server/mldb_server.h\"\n+#include \"mldb/core/procedure.h\"\n+#include \"mldb/core/function.h\"\n+#include \"sql/sql_expression.h\"\n+#include \"mldb/jml/db/persistent_fwd.h\"\n+#include \"mldb/types/optional.h\"\n+#include \"mldb/types/string.h\"\n+\n+namespace Datacratic {\n+namespace MLDB {\n+\n+\n+/*****************************************************************************/\n+/* DIST TABLE                                                               */\n+/*****************************************************************************/\n+\n+struct DistTable {\n+\n+    DistTable(const ColumnName & colName=ColumnName(\"ND\"),\n+            const std::vector<Utf8String> & outcome_names = {})\n+        : colName(colName), outcome_names(outcome_names)\n+    {\n+    }\n+\n+    DistTable(const std::string & filename);\n+\n+    // Add the value of an outcome in our aggregations, for a given feature\n+    void increment(const Utf8String & featureValue, uint outcome,\n+                   double targetValue);\n+\n+    // returns the stats (count, avg, std, min, max) for a given featureValue\n+    // and outcome\n+    std::tuple<uint64_t, double, double, double, double> getStats(\n+        const Utf8String & featureValue, int outcome) const;\n+\n+    void save(const std::string & filename) const;\n+    void serialize(ML::DB::Store_Writer & store) const;\n+    void reconstitute(ML::DB::Store_Reader & store);\n+\n+    ColumnName colName;\n+\n+    std::vector<Utf8String> outcome_names;\n+\n+    uint64_t getNbOutcomes() const { return outcome_names.size(); }\n+\n+    // key: name of one of the values for our column\n+    // value: aggregation for each outcome. The map allows for NULL in one \n+    // outcome while NOT NULL in another\n+    std::unordered_map<Utf8String,","path":"plugins/dist_table_procedure.h","position":65,"original_position":65,"commit_id":"f82f39a2ba4a027e098856d97cc46f3037eb99fa","original_commit_id":"f82f39a2ba4a027e098856d97cc46f3037eb99fa","user":{"login":"mailletf","id":569421,"avatar_url":"https://avatars.githubusercontent.com/u/569421?v=3","gravatar_id":"","url":"https://api.github.com/users/mailletf","html_url":"https://github.com/mailletf","followers_url":"https://api.github.com/users/mailletf/followers","following_url":"https://api.github.com/users/mailletf/following{/other_user}","gists_url":"https://api.github.com/users/mailletf/gists{/gist_id}","starred_url":"https://api.github.com/users/mailletf/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mailletf/subscriptions","organizations_url":"https://api.github.com/users/mailletf/orgs","repos_url":"https://api.github.com/users/mailletf/repos","events_url":"https://api.github.com/users/mailletf/events{/privacy}","received_events_url":"https://api.github.com/users/mailletf/received_events","type":"User","site_admin":false},"body":"ces map la auraient du être fait en une seule map. genre une map qui contient une struct avec toutes tes stats. présenement pour aller voir toutes tes stats, tu dois faire 6 * 2 lookups dans des map. de l'autre manière tu en fais seulement 2 à faire et tu es rendu à ta struct qui te donne un accès à tes stats (avg, vars, M2s, etc) directement","created_at":"2016-06-29T18:48:14Z","updated_at":"2016-06-29T18:48:14Z","html_url":"https://github.com/mldbai/mldb/pull/471#discussion_r69005238","pull_request_url":"https://api.github.com/repos/mldbai/mldb/pulls/471","_links":{"self":{"href":"https://api.github.com/repos/mldbai/mldb/pulls/comments/69005238"},"html":{"href":"https://github.com/mldbai/mldb/pull/471#discussion_r69005238"},"pull_request":{"href":"https://api.github.com/repos/mldbai/mldb/pulls/471"}}},"pull_request":{"url":"https://api.github.com/repos/mldbai/mldb/pulls/471","id":75691534,"html_url":"https://github.com/mldbai/mldb/pull/471","diff_url":"https://github.com/mldbai/mldb/pull/471.diff","patch_url":"https://github.com/mldbai/mldb/pull/471.patch","issue_url":"https://api.github.com/repos/mldbai/mldb/issues/471","number":471,"state":"open","locked":false,"title":"Mldb 1750 dist tables","user":{"login":"simlmx","id":1105380,"avatar_url":"https://avatars.githubusercontent.com/u/1105380?v=3","gravatar_id":"","url":"https://api.github.com/users/simlmx","html_url":"https://github.com/simlmx","followers_url":"https://api.github.com/users/simlmx/followers","following_url":"https://api.github.com/users/simlmx/following{/other_user}","gists_url":"https://api.github.com/users/simlmx/gists{/gist_id}","starred_url":"https://api.github.com/users/simlmx/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/simlmx/subscriptions","organizations_url":"https://api.github.com/users/simlmx/orgs","repos_url":"https://api.github.com/users/simlmx/repos","events_url":"https://api.github.com/users/simlmx/events{/privacy}","received_events_url":"https://api.github.com/users/simlmx/received_events","type":"User","site_admin":false},"body":"First version of distribution tables, the numeric-value version of the stats tables.","created_at":"2016-06-29T17:48:30Z","updated_at":"2016-06-29T18:48:14Z","closed_at":null,"merged_at":null,"merge_commit_sha":"57dfe3e0c392b570814bd1f75975eae3e3580a3b","assignee":null,"assignees":[],"milestone":null,"commits_url":"https://api.github.com/repos/mldbai/mldb/pulls/471/commits","review_comments_url":"https://api.github.com/repos/mldbai/mldb/pulls/471/comments","review_comment_url":"https://api.github.com/repos/mldbai/mldb/pulls/comments{/number}","comments_url":"https://api.github.com/repos/mldbai/mldb/issues/471/comments","statuses_url":"https://api.github.com/repos/mldbai/mldb/statuses/f82f39a2ba4a027e098856d97cc46f3037eb99fa","head":{"label":"mldbai:MLDB-1750-dist-tables","ref":"MLDB-1750-dist-tables","sha":"f82f39a2ba4a027e098856d97cc46f3037eb99fa","user":{"login":"mldbai","id":11510172,"avatar_url":"https://avatars.githubusercontent.com/u/11510172?v=3","gravatar_id":"","url":"https://api.github.com/users/mldbai","html_url":"https://github.com/mldbai","followers_url":"https://api.github.com/users/mldbai/followers","following_url":"https://api.github.com/users/mldbai/following{/other_user}","gists_url":"https://api.github.com/users/mldbai/gists{/gist_id}","starred_url":"https://api.github.com/users/mldbai/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mldbai/subscriptions","organizations_url":"https://api.github.com/users/mldbai/orgs","repos_url":"https://api.github.com/users/mldbai/repos","events_url":"https://api.github.com/users/mldbai/events{/privacy}","received_events_url":"https://api.github.com/users/mldbai/received_events","type":"Organization","site_admin":false},"repo":{"id":47634692,"name":"mldb","full_name":"mldbai/mldb","owner":{"login":"mldbai","id":11510172,"avatar_url":"https://avatars.githubusercontent.com/u/11510172?v=3","gravatar_id":"","url":"https://api.github.com/users/mldbai","html_url":"https://github.com/mldbai","followers_url":"https://api.github.com/users/mldbai/followers","following_url":"https://api.github.com/users/mldbai/following{/other_user}","gists_url":"https://api.github.com/users/mldbai/gists{/gist_id}","starred_url":"https://api.github.com/users/mldbai/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mldbai/subscriptions","organizations_url":"https://api.github.com/users/mldbai/orgs","repos_url":"https://api.github.com/users/mldbai/repos","events_url":"https://api.github.com/users/mldbai/events{/privacy}","received_events_url":"https://api.github.com/users/mldbai/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/mldbai/mldb","description":"MLDB is the Machine Learning Database","fork":false,"url":"https://api.github.com/repos/mldbai/mldb","forks_url":"https://api.github.com/repos/mldbai/mldb/forks","keys_url":"https://api.github.com/repos/mldbai/mldb/keys{/key_id}","collaborators_url":"https://api.github.com/repos/mldbai/mldb/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/mldbai/mldb/teams","hooks_url":"https://api.github.com/repos/mldbai/mldb/hooks","issue_events_url":"https://api.github.com/repos/mldbai/mldb/issues/events{/number}","events_url":"https://api.github.com/repos/mldbai/mldb/events","assignees_url":"https://api.github.com/repos/mldbai/mldb/assignees{/user}","branches_url":"https://api.github.com/repos/mldbai/mldb/branches{/branch}","tags_url":"https://api.github.com/repos/mldbai/mldb/tags","blobs_url":"https://api.github.com/repos/mldbai/mldb/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/mldbai/mldb/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/mldbai/mldb/git/refs{/sha}","trees_url":"https://api.github.com/repos/mldbai/mldb/git/trees{/sha}","statuses_url":"https://api.github.com/repos/mldbai/mldb/statuses/{sha}","languages_url":"https://api.github.com/repos/mldbai/mldb/languages","stargazers_url":"https://api.github.com/repos/mldbai/mldb/stargazers","contributors_url":"https://api.github.com/repos/mldbai/mldb/contributors","subscribers_url":"https://api.github.com/repos/mldbai/mldb/subscribers","subscription_url":"https://api.github.com/repos/mldbai/mldb/subscription","commits_url":"https://api.github.com/repos/mldbai/mldb/commits{/sha}","git_commits_url":"https://api.github.com/repos/mldbai/mldb/git/commits{/sha}","comments_url":"https://api.github.com/repos/mldbai/mldb/comments{/number}","issue_comment_url":"https://api.github.com/repos/mldbai/mldb/issues/comments{/number}","contents_url":"https://api.github.com/repos/mldbai/mldb/contents/{+path}","compare_url":"https://api.github.com/repos/mldbai/mldb/compare/{base}...{head}","merges_url":"https://api.github.com/repos/mldbai/mldb/merges","archive_url":"https://api.github.com/repos/mldbai/mldb/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/mldbai/mldb/downloads","issues_url":"https://api.github.com/repos/mldbai/mldb/issues{/number}","pulls_url":"https://api.github.com/repos/mldbai/mldb/pulls{/number}","milestones_url":"https://api.github.com/repos/mldbai/mldb/milestones{/number}","notifications_url":"https://api.github.com/repos/mldbai/mldb/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/mldbai/mldb/labels{/name}","releases_url":"https://api.github.com/repos/mldbai/mldb/releases{/id}","deployments_url":"https://api.github.com/repos/mldbai/mldb/deployments","created_at":"2015-12-08T16:34:16Z","updated_at":"2016-06-29T16:49:23Z","pushed_at":"2016-06-29T18:43:05Z","git_url":"git://github.com/mldbai/mldb.git","ssh_url":"git@github.com:mldbai/mldb.git","clone_url":"https://github.com/mldbai/mldb.git","svn_url":"https://github.com/mldbai/mldb","homepage":"http://mldb.ai","size":22251,"stargazers_count":170,"watchers_count":170,"language":"C++","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":11,"mirror_url":null,"open_issues_count":7,"forks":11,"open_issues":7,"watchers":170,"default_branch":"master"}},"base":{"label":"mldbai:master","ref":"master","sha":"9c4ff90f87fa0c4ba5f005853d0daf060a579579","user":{"login":"mldbai","id":11510172,"avatar_url":"https://avatars.githubusercontent.com/u/11510172?v=3","gravatar_id":"","url":"https://api.github.com/users/mldbai","html_url":"https://github.com/mldbai","followers_url":"https://api.github.com/users/mldbai/followers","following_url":"https://api.github.com/users/mldbai/following{/other_user}","gists_url":"https://api.github.com/users/mldbai/gists{/gist_id}","starred_url":"https://api.github.com/users/mldbai/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mldbai/subscriptions","organizations_url":"https://api.github.com/users/mldbai/orgs","repos_url":"https://api.github.com/users/mldbai/repos","events_url":"https://api.github.com/users/mldbai/events{/privacy}","received_events_url":"https://api.github.com/users/mldbai/received_events","type":"Organization","site_admin":false},"repo":{"id":47634692,"name":"mldb","full_name":"mldbai/mldb","owner":{"login":"mldbai","id":11510172,"avatar_url":"https://avatars.githubusercontent.com/u/11510172?v=3","gravatar_id":"","url":"https://api.github.com/users/mldbai","html_url":"https://github.com/mldbai","followers_url":"https://api.github.com/users/mldbai/followers","following_url":"https://api.github.com/users/mldbai/following{/other_user}","gists_url":"https://api.github.com/users/mldbai/gists{/gist_id}","starred_url":"https://api.github.com/users/mldbai/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mldbai/subscriptions","organizations_url":"https://api.github.com/users/mldbai/orgs","repos_url":"https://api.github.com/users/mldbai/repos","events_url":"https://api.github.com/users/mldbai/events{/privacy}","received_events_url":"https://api.github.com/users/mldbai/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/mldbai/mldb","description":"MLDB is the Machine Learning Database","fork":false,"url":"https://api.github.com/repos/mldbai/mldb","forks_url":"https://api.github.com/repos/mldbai/mldb/forks","keys_url":"https://api.github.com/repos/mldbai/mldb/keys{/key_id}","collaborators_url":"https://api.github.com/repos/mldbai/mldb/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/mldbai/mldb/teams","hooks_url":"https://api.github.com/repos/mldbai/mldb/hooks","issue_events_url":"https://api.github.com/repos/mldbai/mldb/issues/events{/number}","events_url":"https://api.github.com/repos/mldbai/mldb/events","assignees_url":"https://api.github.com/repos/mldbai/mldb/assignees{/user}","branches_url":"https://api.github.com/repos/mldbai/mldb/branches{/branch}","tags_url":"https://api.github.com/repos/mldbai/mldb/tags","blobs_url":"https://api.github.com/repos/mldbai/mldb/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/mldbai/mldb/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/mldbai/mldb/git/refs{/sha}","trees_url":"https://api.github.com/repos/mldbai/mldb/git/trees{/sha}","statuses_url":"https://api.github.com/repos/mldbai/mldb/statuses/{sha}","languages_url":"https://api.github.com/repos/mldbai/mldb/languages","stargazers_url":"https://api.github.com/repos/mldbai/mldb/stargazers","contributors_url":"https://api.github.com/repos/mldbai/mldb/contributors","subscribers_url":"https://api.github.com/repos/mldbai/mldb/subscribers","subscription_url":"https://api.github.com/repos/mldbai/mldb/subscription","commits_url":"https://api.github.com/repos/mldbai/mldb/commits{/sha}","git_commits_url":"https://api.github.com/repos/mldbai/mldb/git/commits{/sha}","comments_url":"https://api.github.com/repos/mldbai/mldb/comments{/number}","issue_comment_url":"https://api.github.com/repos/mldbai/mldb/issues/comments{/number}","contents_url":"https://api.github.com/repos/mldbai/mldb/contents/{+path}","compare_url":"https://api.github.com/repos/mldbai/mldb/compare/{base}...{head}","merges_url":"https://api.github.com/repos/mldbai/mldb/merges","archive_url":"https://api.github.com/repos/mldbai/mldb/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/mldbai/mldb/downloads","issues_url":"https://api.github.com/repos/mldbai/mldb/issues{/number}","pulls_url":"https://api.github.com/repos/mldbai/mldb/pulls{/number}","milestones_url":"https://api.github.com/repos/mldbai/mldb/milestones{/number}","notifications_url":"https://api.github.com/repos/mldbai/mldb/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/mldbai/mldb/labels{/name}","releases_url":"https://api.github.com/repos/mldbai/mldb/releases{/id}","deployments_url":"https://api.github.com/repos/mldbai/mldb/deployments","created_at":"2015-12-08T16:34:16Z","updated_at":"2016-06-29T16:49:23Z","pushed_at":"2016-06-29T18:43:05Z","git_url":"git://github.com/mldbai/mldb.git","ssh_url":"git@github.com:mldbai/mldb.git","clone_url":"https://github.com/mldbai/mldb.git","svn_url":"https://github.com/mldbai/mldb","homepage":"http://mldb.ai","size":22251,"stargazers_count":170,"watchers_count":170,"language":"C++","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":11,"mirror_url":null,"open_issues_count":7,"forks":11,"open_issues":7,"watchers":170,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/mldbai/mldb/pulls/471"},"html":{"href":"https://github.com/mldbai/mldb/pull/471"},"issue":{"href":"https://api.github.com/repos/mldbai/mldb/issues/471"},"comments":{"href":"https://api.github.com/repos/mldbai/mldb/issues/471/comments"},"review_comments":{"href":"https://api.github.com/repos/mldbai/mldb/pulls/471/comments"},"review_comment":{"href":"https://api.github.com/repos/mldbai/mldb/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/mldbai/mldb/pulls/471/commits"},"statuses":{"href":"https://api.github.com/repos/mldbai/mldb/statuses/f82f39a2ba4a027e098856d97cc46f3037eb99fa"}}}}
{"actor":{"display_login":"mailletf"}}