{"action":"created","comment":{"url":"https://api.github.com/repos/VoltDB/voltdb/pulls/comments/73583120","id":73583120,"diff_hunk":"@@ -73,6 +75,141 @@ public synchronized void discard() {\n         }\n     }\n \n+    /**\n+     * Used to read entries from the PBD. Multiple readers may be active at the same time,\n+     * but only one read or write may happen concurrently.\n+     */\n+    private class ReadCursor implements BinaryDequeReader {\n+        private final String m_cursorId;\n+        private long m_segmentId;\n+        private int m_numObjects;\n+        private boolean m_closed;\n+\n+        public ReadCursor(String cursorId) throws IOException {\n+            m_cursorId = cursorId;\n+            m_segmentId = m_segments.firstKey();\n+            m_numObjects = countNumObjects();\n+        }\n+\n+        private int countNumObjects() throws IOException {\n+            int numObjects = 0;\n+            for (PBDSegment segment : m_segments.values()) {\n+                numObjects += segment.getNumEntries();\n+            }\n+\n+            return numObjects;\n+        }\n+\n+        public void close() {\n+            m_closed = true;\n+        }\n+\n+        @Override\n+        public BBContainer poll(OutputContainerFactory ocf) throws IOException {\n+            synchronized (PersistentBinaryDeque.this) {\n+                if (m_closed) {\n+                    throw new IOException(\"Reader \" + m_cursorId + \" has been closed\");\n+                }\n+                assertions();\n+\n+                BBContainer retcont = null;\n+                PBDSegment segment = null;\n+\n+                // It is possible that the last segment got removed\n+                long firstSegmentId = peekFirstSegment().segmentId();\n+                while (m_segmentId < firstSegmentId) m_segmentId++;\n+\n+                long currSegmentId = m_segmentId;\n+                while (m_segments.containsKey(currSegmentId)) {\n+                    PBDSegment s = m_segments.get(currSegmentId);\n+                    if (!s.isOpenForReading(m_cursorId)) {\n+                        s.openForRead(m_cursorId);\n+                    }\n+\n+                    if (s.hasMoreEntries(m_cursorId)) {\n+                        segment = s;\n+                        retcont = segment.poll(m_cursorId, ocf);\n+                        m_segmentId = currSegmentId;\n+                        break;\n+                    }\n+                    currSegmentId++;\n+                }\n+\n+                if (retcont == null) {\n+                    return null;\n+                }\n+\n+                decrementNumObjects();\n+                assertions();\n+                assert (retcont.b() != null);\n+                return wrapRetCont(segment, retcont);\n+            }\n+        }\n+\n+        private void decrementNumObjects() {\n+            m_numObjects--;\n+            assert(m_numObjects >= 0);\n+        }\n+\n+        @Override\n+        public int getNumObjects() throws IOException {\n+            if (m_closed) {\n+                throw new IOException(\"Reader \" + m_cursorId + \" has been closed\");\n+            }\n+            return m_numObjects;\n+        }\n+\n+        /*\n+         * Don't use size in bytes to determine empty, could potentially\n+         * diverge from object count on crash or power failure\n+         * although incredibly unlikely\n+         */\n+        @Override\n+        public long sizeInBytes() throws IOException {\n+            synchronized(PersistentBinaryDeque.this) {\n+                if (m_closed) {\n+                    throw new IOException(\"Reader \" + m_cursorId + \" has been closed\");\n+                }\n+                assertions();\n+                long size = 0;\n+                for (PBDSegment segment : m_segments.values()) {","path":"src/frontend/org/voltdb/utils/PersistentBinaryDeque.java","position":118,"original_position":118,"commit_id":"b227c71d4469552be0c1c2774af8babd46827905","original_commit_id":"b227c71d4469552be0c1c2774af8babd46827905","user":{"login":"manjujames","id":12613581,"avatar_url":"https://avatars.githubusercontent.com/u/12613581?v=3","gravatar_id":"","url":"https://api.github.com/users/manjujames","html_url":"https://github.com/manjujames","followers_url":"https://api.github.com/users/manjujames/followers","following_url":"https://api.github.com/users/manjujames/following{/other_user}","gists_url":"https://api.github.com/users/manjujames/gists{/gist_id}","starred_url":"https://api.github.com/users/manjujames/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/manjujames/subscriptions","organizations_url":"https://api.github.com/users/manjujames/orgs","repos_url":"https://api.github.com/users/manjujames/repos","events_url":"https://api.github.com/users/manjujames/events{/privacy}","received_events_url":"https://api.github.com/users/manjujames/received_events","type":"User","site_admin":false},"body":"I changed this method to use segment.size() for segments that this cursor hasn't started reading (no openForRead) and just uncompressedBytesToRead for segment that is currently being read.","created_at":"2016-08-04T19:02:09Z","updated_at":"2016-08-04T19:02:09Z","html_url":"https://github.com/VoltDB/voltdb/pull/3774#discussion_r73583120","pull_request_url":"https://api.github.com/repos/VoltDB/voltdb/pulls/3774","_links":{"self":{"href":"https://api.github.com/repos/VoltDB/voltdb/pulls/comments/73583120"},"html":{"href":"https://github.com/VoltDB/voltdb/pull/3774#discussion_r73583120"},"pull_request":{"href":"https://api.github.com/repos/VoltDB/voltdb/pulls/3774"}}},"pull_request":{"url":"https://api.github.com/repos/VoltDB/voltdb/pulls/3774","id":78386080,"html_url":"https://github.com/VoltDB/voltdb/pull/3774","diff_url":"https://github.com/VoltDB/voltdb/pull/3774.diff","patch_url":"https://github.com/VoltDB/voltdb/pull/3774.patch","issue_url":"https://api.github.com/repos/VoltDB/voltdb/issues/3774","number":3774,"state":"open","locked":false,"title":"Eng 10622","user":{"login":"manjujames","id":12613581,"avatar_url":"https://avatars.githubusercontent.com/u/12613581?v=3","gravatar_id":"","url":"https://api.github.com/users/manjujames","html_url":"https://github.com/manjujames","followers_url":"https://api.github.com/users/manjujames/followers","following_url":"https://api.github.com/users/manjujames/following{/other_user}","gists_url":"https://api.github.com/users/manjujames/gists{/gist_id}","starred_url":"https://api.github.com/users/manjujames/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/manjujames/subscriptions","organizations_url":"https://api.github.com/users/manjujames/orgs","repos_url":"https://api.github.com/users/manjujames/repos","events_url":"https://api.github.com/users/manjujames/events{/privacy}","received_events_url":"https://api.github.com/users/manjujames/received_events","type":"User","site_admin":false},"body":"PersistentBinaryDeque changes to support multiple readers.\r\nI still need to figure out what to do with cursors when we close PBD. May be this can be done with the next ticket where we make changes to InvocationBufferQueue.","created_at":"2016-07-21T20:57:02Z","updated_at":"2016-08-04T19:02:09Z","closed_at":null,"merged_at":null,"merge_commit_sha":"f0787918e67f8acb717583f51ee34da945a47efd","assignee":null,"assignees":[],"milestone":null,"commits_url":"https://api.github.com/repos/VoltDB/voltdb/pulls/3774/commits","review_comments_url":"https://api.github.com/repos/VoltDB/voltdb/pulls/3774/comments","review_comment_url":"https://api.github.com/repos/VoltDB/voltdb/pulls/comments{/number}","comments_url":"https://api.github.com/repos/VoltDB/voltdb/issues/3774/comments","statuses_url":"https://api.github.com/repos/VoltDB/voltdb/statuses/b227c71d4469552be0c1c2774af8babd46827905","head":{"label":"VoltDB:ENG-10622","ref":"ENG-10622","sha":"b227c71d4469552be0c1c2774af8babd46827905","user":{"login":"VoltDB","id":703910,"avatar_url":"https://avatars.githubusercontent.com/u/703910?v=3","gravatar_id":"","url":"https://api.github.com/users/VoltDB","html_url":"https://github.com/VoltDB","followers_url":"https://api.github.com/users/VoltDB/followers","following_url":"https://api.github.com/users/VoltDB/following{/other_user}","gists_url":"https://api.github.com/users/VoltDB/gists{/gist_id}","starred_url":"https://api.github.com/users/VoltDB/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/VoltDB/subscriptions","organizations_url":"https://api.github.com/users/VoltDB/orgs","repos_url":"https://api.github.com/users/VoltDB/repos","events_url":"https://api.github.com/users/VoltDB/events{/privacy}","received_events_url":"https://api.github.com/users/VoltDB/received_events","type":"Organization","site_admin":false},"repo":{"id":2445970,"name":"voltdb","full_name":"VoltDB/voltdb","owner":{"login":"VoltDB","id":703910,"avatar_url":"https://avatars.githubusercontent.com/u/703910?v=3","gravatar_id":"","url":"https://api.github.com/users/VoltDB","html_url":"https://github.com/VoltDB","followers_url":"https://api.github.com/users/VoltDB/followers","following_url":"https://api.github.com/users/VoltDB/following{/other_user}","gists_url":"https://api.github.com/users/VoltDB/gists{/gist_id}","starred_url":"https://api.github.com/users/VoltDB/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/VoltDB/subscriptions","organizations_url":"https://api.github.com/users/VoltDB/orgs","repos_url":"https://api.github.com/users/VoltDB/repos","events_url":"https://api.github.com/users/VoltDB/events{/privacy}","received_events_url":"https://api.github.com/users/VoltDB/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/VoltDB/voltdb","description":"VoltDB","fork":false,"url":"https://api.github.com/repos/VoltDB/voltdb","forks_url":"https://api.github.com/repos/VoltDB/voltdb/forks","keys_url":"https://api.github.com/repos/VoltDB/voltdb/keys{/key_id}","collaborators_url":"https://api.github.com/repos/VoltDB/voltdb/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/VoltDB/voltdb/teams","hooks_url":"https://api.github.com/repos/VoltDB/voltdb/hooks","issue_events_url":"https://api.github.com/repos/VoltDB/voltdb/issues/events{/number}","events_url":"https://api.github.com/repos/VoltDB/voltdb/events","assignees_url":"https://api.github.com/repos/VoltDB/voltdb/assignees{/user}","branches_url":"https://api.github.com/repos/VoltDB/voltdb/branches{/branch}","tags_url":"https://api.github.com/repos/VoltDB/voltdb/tags","blobs_url":"https://api.github.com/repos/VoltDB/voltdb/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/VoltDB/voltdb/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/VoltDB/voltdb/git/refs{/sha}","trees_url":"https://api.github.com/repos/VoltDB/voltdb/git/trees{/sha}","statuses_url":"https://api.github.com/repos/VoltDB/voltdb/statuses/{sha}","languages_url":"https://api.github.com/repos/VoltDB/voltdb/languages","stargazers_url":"https://api.github.com/repos/VoltDB/voltdb/stargazers","contributors_url":"https://api.github.com/repos/VoltDB/voltdb/contributors","subscribers_url":"https://api.github.com/repos/VoltDB/voltdb/subscribers","subscription_url":"https://api.github.com/repos/VoltDB/voltdb/subscription","commits_url":"https://api.github.com/repos/VoltDB/voltdb/commits{/sha}","git_commits_url":"https://api.github.com/repos/VoltDB/voltdb/git/commits{/sha}","comments_url":"https://api.github.com/repos/VoltDB/voltdb/comments{/number}","issue_comment_url":"https://api.github.com/repos/VoltDB/voltdb/issues/comments{/number}","contents_url":"https://api.github.com/repos/VoltDB/voltdb/contents/{+path}","compare_url":"https://api.github.com/repos/VoltDB/voltdb/compare/{base}...{head}","merges_url":"https://api.github.com/repos/VoltDB/voltdb/merges","archive_url":"https://api.github.com/repos/VoltDB/voltdb/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/VoltDB/voltdb/downloads","issues_url":"https://api.github.com/repos/VoltDB/voltdb/issues{/number}","pulls_url":"https://api.github.com/repos/VoltDB/voltdb/pulls{/number}","milestones_url":"https://api.github.com/repos/VoltDB/voltdb/milestones{/number}","notifications_url":"https://api.github.com/repos/VoltDB/voltdb/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/VoltDB/voltdb/labels{/name}","releases_url":"https://api.github.com/repos/VoltDB/voltdb/releases{/id}","deployments_url":"https://api.github.com/repos/VoltDB/voltdb/deployments","created_at":"2011-09-23T18:46:12Z","updated_at":"2016-08-03T08:54:43Z","pushed_at":"2016-08-04T18:59:36Z","git_url":"git://github.com/VoltDB/voltdb.git","ssh_url":"git@github.com:VoltDB/voltdb.git","clone_url":"https://github.com/VoltDB/voltdb.git","svn_url":"https://github.com/VoltDB/voltdb","homepage":"http://community.voltdb.com/","size":614488,"stargazers_count":826,"watchers_count":826,"language":"Java","has_issues":false,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":252,"mirror_url":null,"open_issues_count":38,"forks":252,"open_issues":38,"watchers":826,"default_branch":"master"}},"base":{"label":"VoltDB:master","ref":"master","sha":"a2f4518dbcc53339f4e20c64eed50e9d8dde3f7b","user":{"login":"VoltDB","id":703910,"avatar_url":"https://avatars.githubusercontent.com/u/703910?v=3","gravatar_id":"","url":"https://api.github.com/users/VoltDB","html_url":"https://github.com/VoltDB","followers_url":"https://api.github.com/users/VoltDB/followers","following_url":"https://api.github.com/users/VoltDB/following{/other_user}","gists_url":"https://api.github.com/users/VoltDB/gists{/gist_id}","starred_url":"https://api.github.com/users/VoltDB/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/VoltDB/subscriptions","organizations_url":"https://api.github.com/users/VoltDB/orgs","repos_url":"https://api.github.com/users/VoltDB/repos","events_url":"https://api.github.com/users/VoltDB/events{/privacy}","received_events_url":"https://api.github.com/users/VoltDB/received_events","type":"Organization","site_admin":false},"repo":{"id":2445970,"name":"voltdb","full_name":"VoltDB/voltdb","owner":{"login":"VoltDB","id":703910,"avatar_url":"https://avatars.githubusercontent.com/u/703910?v=3","gravatar_id":"","url":"https://api.github.com/users/VoltDB","html_url":"https://github.com/VoltDB","followers_url":"https://api.github.com/users/VoltDB/followers","following_url":"https://api.github.com/users/VoltDB/following{/other_user}","gists_url":"https://api.github.com/users/VoltDB/gists{/gist_id}","starred_url":"https://api.github.com/users/VoltDB/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/VoltDB/subscriptions","organizations_url":"https://api.github.com/users/VoltDB/orgs","repos_url":"https://api.github.com/users/VoltDB/repos","events_url":"https://api.github.com/users/VoltDB/events{/privacy}","received_events_url":"https://api.github.com/users/VoltDB/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/VoltDB/voltdb","description":"VoltDB","fork":false,"url":"https://api.github.com/repos/VoltDB/voltdb","forks_url":"https://api.github.com/repos/VoltDB/voltdb/forks","keys_url":"https://api.github.com/repos/VoltDB/voltdb/keys{/key_id}","collaborators_url":"https://api.github.com/repos/VoltDB/voltdb/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/VoltDB/voltdb/teams","hooks_url":"https://api.github.com/repos/VoltDB/voltdb/hooks","issue_events_url":"https://api.github.com/repos/VoltDB/voltdb/issues/events{/number}","events_url":"https://api.github.com/repos/VoltDB/voltdb/events","assignees_url":"https://api.github.com/repos/VoltDB/voltdb/assignees{/user}","branches_url":"https://api.github.com/repos/VoltDB/voltdb/branches{/branch}","tags_url":"https://api.github.com/repos/VoltDB/voltdb/tags","blobs_url":"https://api.github.com/repos/VoltDB/voltdb/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/VoltDB/voltdb/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/VoltDB/voltdb/git/refs{/sha}","trees_url":"https://api.github.com/repos/VoltDB/voltdb/git/trees{/sha}","statuses_url":"https://api.github.com/repos/VoltDB/voltdb/statuses/{sha}","languages_url":"https://api.github.com/repos/VoltDB/voltdb/languages","stargazers_url":"https://api.github.com/repos/VoltDB/voltdb/stargazers","contributors_url":"https://api.github.com/repos/VoltDB/voltdb/contributors","subscribers_url":"https://api.github.com/repos/VoltDB/voltdb/subscribers","subscription_url":"https://api.github.com/repos/VoltDB/voltdb/subscription","commits_url":"https://api.github.com/repos/VoltDB/voltdb/commits{/sha}","git_commits_url":"https://api.github.com/repos/VoltDB/voltdb/git/commits{/sha}","comments_url":"https://api.github.com/repos/VoltDB/voltdb/comments{/number}","issue_comment_url":"https://api.github.com/repos/VoltDB/voltdb/issues/comments{/number}","contents_url":"https://api.github.com/repos/VoltDB/voltdb/contents/{+path}","compare_url":"https://api.github.com/repos/VoltDB/voltdb/compare/{base}...{head}","merges_url":"https://api.github.com/repos/VoltDB/voltdb/merges","archive_url":"https://api.github.com/repos/VoltDB/voltdb/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/VoltDB/voltdb/downloads","issues_url":"https://api.github.com/repos/VoltDB/voltdb/issues{/number}","pulls_url":"https://api.github.com/repos/VoltDB/voltdb/pulls{/number}","milestones_url":"https://api.github.com/repos/VoltDB/voltdb/milestones{/number}","notifications_url":"https://api.github.com/repos/VoltDB/voltdb/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/VoltDB/voltdb/labels{/name}","releases_url":"https://api.github.com/repos/VoltDB/voltdb/releases{/id}","deployments_url":"https://api.github.com/repos/VoltDB/voltdb/deployments","created_at":"2011-09-23T18:46:12Z","updated_at":"2016-08-03T08:54:43Z","pushed_at":"2016-08-04T18:59:36Z","git_url":"git://github.com/VoltDB/voltdb.git","ssh_url":"git@github.com:VoltDB/voltdb.git","clone_url":"https://github.com/VoltDB/voltdb.git","svn_url":"https://github.com/VoltDB/voltdb","homepage":"http://community.voltdb.com/","size":614488,"stargazers_count":826,"watchers_count":826,"language":"Java","has_issues":false,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":252,"mirror_url":null,"open_issues_count":38,"forks":252,"open_issues":38,"watchers":826,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/VoltDB/voltdb/pulls/3774"},"html":{"href":"https://github.com/VoltDB/voltdb/pull/3774"},"issue":{"href":"https://api.github.com/repos/VoltDB/voltdb/issues/3774"},"comments":{"href":"https://api.github.com/repos/VoltDB/voltdb/issues/3774/comments"},"review_comments":{"href":"https://api.github.com/repos/VoltDB/voltdb/pulls/3774/comments"},"review_comment":{"href":"https://api.github.com/repos/VoltDB/voltdb/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/VoltDB/voltdb/pulls/3774/commits"},"statuses":{"href":"https://api.github.com/repos/VoltDB/voltdb/statuses/b227c71d4469552be0c1c2774af8babd46827905"}}}}
{"actor":{"display_login":"manjujames"}}