{"action":"created","comment":{"url":"https://api.github.com/repos/lsst/qserv/pulls/comments/50759760","id":50759760,"diff_hunk":"@@ -0,0 +1,139 @@\n+// -*- LSST-C++ -*-\n+/*\n+ * LSST Data Management System\n+ * Copyright 2016 LSST Corporation.\n+ *\n+ * This product includes software developed by the\n+ * LSST Project (http://www.lsst.org/).\n+ *\n+ * This program is free software: you can redistribute it and/or modify\n+ * it under the terms of the GNU General Public License as published by\n+ * the Free Software Foundation, either version 3 of the License, or\n+ * (at your option) any later version.\n+ *\n+ * This program is distributed in the hope that it will be useful,\n+ * but WITHOUT ANY WARRANTY; without even the implied warranty of\n+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\n+ * GNU General Public License for more details.\n+ *\n+ * You should have received a copy of the LSST License Statement and\n+ * the GNU General Public License along with this program.  If not,\n+ * see <http://www.lsstcorp.org/LegalNotices/>.\n+ */\n+\n+// Class header\n+#include \"memman/MemFileSet.h\"\n+\n+// System Headers\n+#include <errno.h>\n+\n+// Qserv Headers\n+#include \"memman/MemFile.h\"\n+#include \"memman/Memory.h\"\n+\n+namespace lsst {\n+namespace qserv {\n+namespace memman {\n+\n+/******************************************************************************/\n+/*                            D e s t r u c t o r                             */\n+/******************************************************************************/\n+  \n+MemFileSet::~MemFileSet() {\n+\n+    // Unreference every fle in our file set. This action will also cause\n+    // memory to be unlocked if no one else is using the file then the file\n+    // object will be deleted as well.\n+    //\n+    for (auto mfP : _lockFiles) {mfP->release();}\n+    for (auto mfP : _flexFiles) {mfP->release();}\n+}\n+\n+/******************************************************************************/\n+/*                                   a d d                                    */\n+/******************************************************************************/\n+\n+int MemFileSet::add(std::string const& tabname, int chunk,\n+                    bool iFile, bool mustLK) {\n+\n+    std::string fPath(_memory.filePath(tabname, chunk, iFile));\n+\n+    // Obtain a memory file object for this table and chunk\n+    //\n+    MemFile::MFResult mfResult = MemFile::obtain(fPath, _memory, !mustLK);\n+    if (mfResult.mfP == 0) return mfResult.retc;\n+\n+    // Add to the appropriate file set\n+    //\n+    if (mustLK) {\n+        _lockFiles.push_back(mfResult.mfP);\n+    } else {\n+        _flexFiles.push_back(mfResult.mfP);\n+    }\n+    _numFiles++;\n+    return 0;\n+}\n+  \n+/******************************************************************************/\n+/*                               l o c k A l l                                */\n+/******************************************************************************/\n+\n+int MemFileSet::lockAll() {\n+\n+    MemFile::MLResult mlResult;\n+    uint64_t bytesLocked, bytesMax, freeBytes;\n+\n+    // Calculate the number of bytes available at this point. Note that we force\n+    // freeBytes to be atleast 1 to make memlock check before it tries locking\n+    // the file to avoid a useless memory map operation if it can't be locked.\n+    // By the time we get here someone else may have already locked the file.\n+    //\n+    bytesMax    = _memory.bytesMax();\n+    bytesLocked = _memory.bytesLocked();\n+    if (bytesMax <= bytesLocked) freeBytes = 1;","path":"core/modules/memman/MemFileSet.cc","position":93,"original_position":93,"commit_id":"b9ab256d8594bffc7d819856b7b9e78a7935d66e","original_commit_id":"b9ab256d8594bffc7d819856b7b9e78a7935d66e","user":{"login":"fritzm","id":1530638,"avatar_url":"https://avatars.githubusercontent.com/u/1530638?v=3","gravatar_id":"","url":"https://api.github.com/users/fritzm","html_url":"https://github.com/fritzm","followers_url":"https://api.github.com/users/fritzm/followers","following_url":"https://api.github.com/users/fritzm/following{/other_user}","gists_url":"https://api.github.com/users/fritzm/gists{/gist_id}","starred_url":"https://api.github.com/users/fritzm/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/fritzm/subscriptions","organizations_url":"https://api.github.com/users/fritzm/orgs","repos_url":"https://api.github.com/users/fritzm/repos","events_url":"https://api.github.com/users/fritzm/events{/privacy}","received_events_url":"https://api.github.com/users/fritzm/received_events","type":"User","site_admin":false},"body":"hmm, you use fully line broken if/else above (line 68) but non-broken if/else here and below in the same file?  pick consistent style throughout file?","created_at":"2016-01-25T21:35:04Z","updated_at":"2016-01-25T21:35:04Z","html_url":"https://github.com/lsst/qserv/pull/178#discussion_r50759760","pull_request_url":"https://api.github.com/repos/lsst/qserv/pulls/178","_links":{"self":{"href":"https://api.github.com/repos/lsst/qserv/pulls/comments/50759760"},"html":{"href":"https://github.com/lsst/qserv/pull/178#discussion_r50759760"},"pull_request":{"href":"https://api.github.com/repos/lsst/qserv/pulls/178"}}},"pull_request":{"url":"https://api.github.com/repos/lsst/qserv/pulls/178","id":55656559,"html_url":"https://github.com/lsst/qserv/pull/178","diff_url":"https://github.com/lsst/qserv/pull/178.diff","patch_url":"https://github.com/lsst/qserv/pull/178.patch","issue_url":"https://api.github.com/repos/lsst/qserv/issues/178","number":178,"state":"open","locked":false,"title":"Ticket/dm 4677","user":{"login":"jgates108","id":6558057,"avatar_url":"https://avatars.githubusercontent.com/u/6558057?v=3","gravatar_id":"","url":"https://api.github.com/users/jgates108","html_url":"https://github.com/jgates108","followers_url":"https://api.github.com/users/jgates108/followers","following_url":"https://api.github.com/users/jgates108/following{/other_user}","gists_url":"https://api.github.com/users/jgates108/gists{/gist_id}","starred_url":"https://api.github.com/users/jgates108/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jgates108/subscriptions","organizations_url":"https://api.github.com/users/jgates108/orgs","repos_url":"https://api.github.com/users/jgates108/repos","events_url":"https://api.github.com/users/jgates108/events{/privacy}","received_events_url":"https://api.github.com/users/jgates108/received_events","type":"User","site_admin":false},"body":"","created_at":"2016-01-11T18:06:28Z","updated_at":"2016-01-25T21:35:04Z","closed_at":null,"merged_at":null,"merge_commit_sha":"4ec6ef9543294b495ee9b59416c2a2baa730e702","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/lsst/qserv/pulls/178/commits","review_comments_url":"https://api.github.com/repos/lsst/qserv/pulls/178/comments","review_comment_url":"https://api.github.com/repos/lsst/qserv/pulls/comments{/number}","comments_url":"https://api.github.com/repos/lsst/qserv/issues/178/comments","statuses_url":"https://api.github.com/repos/lsst/qserv/statuses/b9ab256d8594bffc7d819856b7b9e78a7935d66e","head":{"label":"lsst:ticket/DM-4677","ref":"ticket/DM-4677","sha":"b9ab256d8594bffc7d819856b7b9e78a7935d66e","user":{"login":"lsst","id":1134504,"avatar_url":"https://avatars.githubusercontent.com/u/1134504?v=3","gravatar_id":"","url":"https://api.github.com/users/lsst","html_url":"https://github.com/lsst","followers_url":"https://api.github.com/users/lsst/followers","following_url":"https://api.github.com/users/lsst/following{/other_user}","gists_url":"https://api.github.com/users/lsst/gists{/gist_id}","starred_url":"https://api.github.com/users/lsst/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/lsst/subscriptions","organizations_url":"https://api.github.com/users/lsst/orgs","repos_url":"https://api.github.com/users/lsst/repos","events_url":"https://api.github.com/users/lsst/events{/privacy}","received_events_url":"https://api.github.com/users/lsst/received_events","type":"Organization","site_admin":false},"repo":{"id":23013460,"name":"qserv","full_name":"lsst/qserv","owner":{"login":"lsst","id":1134504,"avatar_url":"https://avatars.githubusercontent.com/u/1134504?v=3","gravatar_id":"","url":"https://api.github.com/users/lsst","html_url":"https://github.com/lsst","followers_url":"https://api.github.com/users/lsst/followers","following_url":"https://api.github.com/users/lsst/following{/other_user}","gists_url":"https://api.github.com/users/lsst/gists{/gist_id}","starred_url":"https://api.github.com/users/lsst/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/lsst/subscriptions","organizations_url":"https://api.github.com/users/lsst/orgs","repos_url":"https://api.github.com/users/lsst/repos","events_url":"https://api.github.com/users/lsst/events{/privacy}","received_events_url":"https://api.github.com/users/lsst/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/lsst/qserv","description":"LSST Query Services","fork":false,"url":"https://api.github.com/repos/lsst/qserv","forks_url":"https://api.github.com/repos/lsst/qserv/forks","keys_url":"https://api.github.com/repos/lsst/qserv/keys{/key_id}","collaborators_url":"https://api.github.com/repos/lsst/qserv/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/lsst/qserv/teams","hooks_url":"https://api.github.com/repos/lsst/qserv/hooks","issue_events_url":"https://api.github.com/repos/lsst/qserv/issues/events{/number}","events_url":"https://api.github.com/repos/lsst/qserv/events","assignees_url":"https://api.github.com/repos/lsst/qserv/assignees{/user}","branches_url":"https://api.github.com/repos/lsst/qserv/branches{/branch}","tags_url":"https://api.github.com/repos/lsst/qserv/tags","blobs_url":"https://api.github.com/repos/lsst/qserv/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/lsst/qserv/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/lsst/qserv/git/refs{/sha}","trees_url":"https://api.github.com/repos/lsst/qserv/git/trees{/sha}","statuses_url":"https://api.github.com/repos/lsst/qserv/statuses/{sha}","languages_url":"https://api.github.com/repos/lsst/qserv/languages","stargazers_url":"https://api.github.com/repos/lsst/qserv/stargazers","contributors_url":"https://api.github.com/repos/lsst/qserv/contributors","subscribers_url":"https://api.github.com/repos/lsst/qserv/subscribers","subscription_url":"https://api.github.com/repos/lsst/qserv/subscription","commits_url":"https://api.github.com/repos/lsst/qserv/commits{/sha}","git_commits_url":"https://api.github.com/repos/lsst/qserv/git/commits{/sha}","comments_url":"https://api.github.com/repos/lsst/qserv/comments{/number}","issue_comment_url":"https://api.github.com/repos/lsst/qserv/issues/comments{/number}","contents_url":"https://api.github.com/repos/lsst/qserv/contents/{+path}","compare_url":"https://api.github.com/repos/lsst/qserv/compare/{base}...{head}","merges_url":"https://api.github.com/repos/lsst/qserv/merges","archive_url":"https://api.github.com/repos/lsst/qserv/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/lsst/qserv/downloads","issues_url":"https://api.github.com/repos/lsst/qserv/issues{/number}","pulls_url":"https://api.github.com/repos/lsst/qserv/pulls{/number}","milestones_url":"https://api.github.com/repos/lsst/qserv/milestones{/number}","notifications_url":"https://api.github.com/repos/lsst/qserv/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/lsst/qserv/labels{/name}","releases_url":"https://api.github.com/repos/lsst/qserv/releases{/id}","deployments_url":"https://api.github.com/repos/lsst/qserv/deployments","created_at":"2014-08-16T07:50:36Z","updated_at":"2016-01-11T23:05:52Z","pushed_at":"2016-01-25T19:12:21Z","git_url":"git://github.com/lsst/qserv.git","ssh_url":"git@github.com:lsst/qserv.git","clone_url":"https://github.com/lsst/qserv.git","svn_url":"https://github.com/lsst/qserv","homepage":"http://dm.lsst.org/","size":14687,"stargazers_count":5,"watchers_count":5,"language":"C++","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":6,"mirror_url":null,"open_issues_count":9,"forks":6,"open_issues":9,"watchers":5,"default_branch":"master"}},"base":{"label":"lsst:master","ref":"master","sha":"d6be3aad7136649e9c27dd693c0089acbcdcfcae","user":{"login":"lsst","id":1134504,"avatar_url":"https://avatars.githubusercontent.com/u/1134504?v=3","gravatar_id":"","url":"https://api.github.com/users/lsst","html_url":"https://github.com/lsst","followers_url":"https://api.github.com/users/lsst/followers","following_url":"https://api.github.com/users/lsst/following{/other_user}","gists_url":"https://api.github.com/users/lsst/gists{/gist_id}","starred_url":"https://api.github.com/users/lsst/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/lsst/subscriptions","organizations_url":"https://api.github.com/users/lsst/orgs","repos_url":"https://api.github.com/users/lsst/repos","events_url":"https://api.github.com/users/lsst/events{/privacy}","received_events_url":"https://api.github.com/users/lsst/received_events","type":"Organization","site_admin":false},"repo":{"id":23013460,"name":"qserv","full_name":"lsst/qserv","owner":{"login":"lsst","id":1134504,"avatar_url":"https://avatars.githubusercontent.com/u/1134504?v=3","gravatar_id":"","url":"https://api.github.com/users/lsst","html_url":"https://github.com/lsst","followers_url":"https://api.github.com/users/lsst/followers","following_url":"https://api.github.com/users/lsst/following{/other_user}","gists_url":"https://api.github.com/users/lsst/gists{/gist_id}","starred_url":"https://api.github.com/users/lsst/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/lsst/subscriptions","organizations_url":"https://api.github.com/users/lsst/orgs","repos_url":"https://api.github.com/users/lsst/repos","events_url":"https://api.github.com/users/lsst/events{/privacy}","received_events_url":"https://api.github.com/users/lsst/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/lsst/qserv","description":"LSST Query Services","fork":false,"url":"https://api.github.com/repos/lsst/qserv","forks_url":"https://api.github.com/repos/lsst/qserv/forks","keys_url":"https://api.github.com/repos/lsst/qserv/keys{/key_id}","collaborators_url":"https://api.github.com/repos/lsst/qserv/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/lsst/qserv/teams","hooks_url":"https://api.github.com/repos/lsst/qserv/hooks","issue_events_url":"https://api.github.com/repos/lsst/qserv/issues/events{/number}","events_url":"https://api.github.com/repos/lsst/qserv/events","assignees_url":"https://api.github.com/repos/lsst/qserv/assignees{/user}","branches_url":"https://api.github.com/repos/lsst/qserv/branches{/branch}","tags_url":"https://api.github.com/repos/lsst/qserv/tags","blobs_url":"https://api.github.com/repos/lsst/qserv/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/lsst/qserv/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/lsst/qserv/git/refs{/sha}","trees_url":"https://api.github.com/repos/lsst/qserv/git/trees{/sha}","statuses_url":"https://api.github.com/repos/lsst/qserv/statuses/{sha}","languages_url":"https://api.github.com/repos/lsst/qserv/languages","stargazers_url":"https://api.github.com/repos/lsst/qserv/stargazers","contributors_url":"https://api.github.com/repos/lsst/qserv/contributors","subscribers_url":"https://api.github.com/repos/lsst/qserv/subscribers","subscription_url":"https://api.github.com/repos/lsst/qserv/subscription","commits_url":"https://api.github.com/repos/lsst/qserv/commits{/sha}","git_commits_url":"https://api.github.com/repos/lsst/qserv/git/commits{/sha}","comments_url":"https://api.github.com/repos/lsst/qserv/comments{/number}","issue_comment_url":"https://api.github.com/repos/lsst/qserv/issues/comments{/number}","contents_url":"https://api.github.com/repos/lsst/qserv/contents/{+path}","compare_url":"https://api.github.com/repos/lsst/qserv/compare/{base}...{head}","merges_url":"https://api.github.com/repos/lsst/qserv/merges","archive_url":"https://api.github.com/repos/lsst/qserv/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/lsst/qserv/downloads","issues_url":"https://api.github.com/repos/lsst/qserv/issues{/number}","pulls_url":"https://api.github.com/repos/lsst/qserv/pulls{/number}","milestones_url":"https://api.github.com/repos/lsst/qserv/milestones{/number}","notifications_url":"https://api.github.com/repos/lsst/qserv/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/lsst/qserv/labels{/name}","releases_url":"https://api.github.com/repos/lsst/qserv/releases{/id}","deployments_url":"https://api.github.com/repos/lsst/qserv/deployments","created_at":"2014-08-16T07:50:36Z","updated_at":"2016-01-11T23:05:52Z","pushed_at":"2016-01-25T19:12:21Z","git_url":"git://github.com/lsst/qserv.git","ssh_url":"git@github.com:lsst/qserv.git","clone_url":"https://github.com/lsst/qserv.git","svn_url":"https://github.com/lsst/qserv","homepage":"http://dm.lsst.org/","size":14687,"stargazers_count":5,"watchers_count":5,"language":"C++","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":6,"mirror_url":null,"open_issues_count":9,"forks":6,"open_issues":9,"watchers":5,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/lsst/qserv/pulls/178"},"html":{"href":"https://github.com/lsst/qserv/pull/178"},"issue":{"href":"https://api.github.com/repos/lsst/qserv/issues/178"},"comments":{"href":"https://api.github.com/repos/lsst/qserv/issues/178/comments"},"review_comments":{"href":"https://api.github.com/repos/lsst/qserv/pulls/178/comments"},"review_comment":{"href":"https://api.github.com/repos/lsst/qserv/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/lsst/qserv/pulls/178/commits"},"statuses":{"href":"https://api.github.com/repos/lsst/qserv/statuses/b9ab256d8594bffc7d819856b7b9e78a7935d66e"}}}}