{"action":"created","comment":{"url":"https://api.github.com/repos/neo4j/neo4j/pulls/comments/63851020","id":63851020,"diff_hunk":"@@ -0,0 +1,77 @@\n+/*\n+ * Copyright (c) 2002-2016 \"Neo Technology,\"\n+ * Network Engine for Objects in Lund AB [http://neotechnology.com]\n+ *\n+ * This file is part of Neo4j.\n+ *\n+ * Neo4j 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 GNU General Public License\n+ * along with this program.  If not, see <http://www.gnu.org/licenses/>.\n+ */\n+package org.neo4j.io.pagecache.impl;\n+\n+import java.io.IOException;\n+import java.nio.ByteBuffer;\n+import java.nio.channels.ClosedChannelException;\n+import java.nio.channels.WritableByteChannel;\n+\n+import org.neo4j.io.pagecache.PageCursor;\n+import org.neo4j.io.pagecache.PagedFile;\n+\n+public class PagedWritableByteChannel implements WritableByteChannel\n+{\n+    private final PageCursor cursor;\n+    private boolean open = true;\n+    private int bytesLeftInCurrentPage;\n+\n+    public PagedWritableByteChannel( PagedFile pagedFile ) throws IOException\n+    {\n+        cursor = pagedFile.io( 0, PagedFile.PF_SHARED_WRITE_LOCK );\n+    }\n+\n+    @Override\n+    public int write( ByteBuffer src ) throws IOException\n+    {\n+        if ( !open )\n+        {\n+            throw new ClosedChannelException();\n+        }\n+        if ( bytesLeftInCurrentPage == 0 )\n+        {\n+            if ( !cursor.next() )\n+            {\n+                throw new IOException( \"Could not advance write cursor\" );\n+            }\n+            bytesLeftInCurrentPage = cursor.getCurrentPageSize();\n+        }\n+        int remaining = Math.min( src.remaining(), bytesLeftInCurrentPage );\n+        for ( int i = 0; i < remaining; i++ )","path":"community/io/src/main/java/org/neo4j/io/pagecache/impl/PagedWritableByteChannel.java","position":57,"original_position":57,"commit_id":"13a2faecfe8f00d181013bbaa4a86270298e9520","original_commit_id":"13a2faecfe8f00d181013bbaa4a86270298e9520","user":{"login":"chrisvest","id":7993,"avatar_url":"https://avatars.githubusercontent.com/u/7993?v=3","gravatar_id":"","url":"https://api.github.com/users/chrisvest","html_url":"https://github.com/chrisvest","followers_url":"https://api.github.com/users/chrisvest/followers","following_url":"https://api.github.com/users/chrisvest/following{/other_user}","gists_url":"https://api.github.com/users/chrisvest/gists{/gist_id}","starred_url":"https://api.github.com/users/chrisvest/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/chrisvest/subscriptions","organizations_url":"https://api.github.com/users/chrisvest/orgs","repos_url":"https://api.github.com/users/chrisvest/repos","events_url":"https://api.github.com/users/chrisvest/events{/privacy}","received_events_url":"https://api.github.com/users/chrisvest/received_events","type":"User","site_admin":false},"body":"Maybe. Write locks are never invalidated, though.","created_at":"2016-05-19T09:54:20Z","updated_at":"2016-05-19T09:54:20Z","html_url":"https://github.com/neo4j/neo4j/pull/7132#discussion_r63851020","pull_request_url":"https://api.github.com/repos/neo4j/neo4j/pulls/7132","_links":{"self":{"href":"https://api.github.com/repos/neo4j/neo4j/pulls/comments/63851020"},"html":{"href":"https://github.com/neo4j/neo4j/pull/7132#discussion_r63851020"},"pull_request":{"href":"https://api.github.com/repos/neo4j/neo4j/pulls/7132"}}},"pull_request":{"url":"https://api.github.com/repos/neo4j/neo4j/pulls/7132","id":70189911,"html_url":"https://github.com/neo4j/neo4j/pull/7132","diff_url":"https://github.com/neo4j/neo4j/pull/7132.diff","patch_url":"https://github.com/neo4j/neo4j/pull/7132.patch","issue_url":"https://api.github.com/repos/neo4j/neo4j/issues/7132","number":7132,"state":"open","locked":false,"title":"ByteChannel views for PagedFile","user":{"login":"chrisvest","id":7993,"avatar_url":"https://avatars.githubusercontent.com/u/7993?v=3","gravatar_id":"","url":"https://api.github.com/users/chrisvest","html_url":"https://github.com/chrisvest","followers_url":"https://api.github.com/users/chrisvest/followers","following_url":"https://api.github.com/users/chrisvest/following{/other_user}","gists_url":"https://api.github.com/users/chrisvest/gists{/gist_id}","starred_url":"https://api.github.com/users/chrisvest/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/chrisvest/subscriptions","organizations_url":"https://api.github.com/users/chrisvest/orgs","repos_url":"https://api.github.com/users/chrisvest/repos","events_url":"https://api.github.com/users/chrisvest/events{/privacy}","received_events_url":"https://api.github.com/users/chrisvest/received_events","type":"User","site_admin":false},"body":"This is a step towards making store-copying, for backup and HA, do reads and writes through the page cache. We need this to make those things work with proprietary IO integrations.","created_at":"2016-05-16T12:32:01Z","updated_at":"2016-05-19T09:54:20Z","closed_at":null,"merged_at":null,"merge_commit_sha":"ed22a496d44f02b1a4e0b8d923c9e0b6667cc081","assignee":{"login":"MishaDemianenko","id":12656787,"avatar_url":"https://avatars.githubusercontent.com/u/12656787?v=3","gravatar_id":"","url":"https://api.github.com/users/MishaDemianenko","html_url":"https://github.com/MishaDemianenko","followers_url":"https://api.github.com/users/MishaDemianenko/followers","following_url":"https://api.github.com/users/MishaDemianenko/following{/other_user}","gists_url":"https://api.github.com/users/MishaDemianenko/gists{/gist_id}","starred_url":"https://api.github.com/users/MishaDemianenko/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/MishaDemianenko/subscriptions","organizations_url":"https://api.github.com/users/MishaDemianenko/orgs","repos_url":"https://api.github.com/users/MishaDemianenko/repos","events_url":"https://api.github.com/users/MishaDemianenko/events{/privacy}","received_events_url":"https://api.github.com/users/MishaDemianenko/received_events","type":"User","site_admin":false},"milestone":null,"commits_url":"https://api.github.com/repos/neo4j/neo4j/pulls/7132/commits","review_comments_url":"https://api.github.com/repos/neo4j/neo4j/pulls/7132/comments","review_comment_url":"https://api.github.com/repos/neo4j/neo4j/pulls/comments{/number}","comments_url":"https://api.github.com/repos/neo4j/neo4j/issues/7132/comments","statuses_url":"https://api.github.com/repos/neo4j/neo4j/statuses/13a2faecfe8f00d181013bbaa4a86270298e9520","head":{"label":"chrisvest:3.0-pagedfile-as-channel","ref":"3.0-pagedfile-as-channel","sha":"13a2faecfe8f00d181013bbaa4a86270298e9520","user":{"login":"chrisvest","id":7993,"avatar_url":"https://avatars.githubusercontent.com/u/7993?v=3","gravatar_id":"","url":"https://api.github.com/users/chrisvest","html_url":"https://github.com/chrisvest","followers_url":"https://api.github.com/users/chrisvest/followers","following_url":"https://api.github.com/users/chrisvest/following{/other_user}","gists_url":"https://api.github.com/users/chrisvest/gists{/gist_id}","starred_url":"https://api.github.com/users/chrisvest/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/chrisvest/subscriptions","organizations_url":"https://api.github.com/users/chrisvest/orgs","repos_url":"https://api.github.com/users/chrisvest/repos","events_url":"https://api.github.com/users/chrisvest/events{/privacy}","received_events_url":"https://api.github.com/users/chrisvest/received_events","type":"User","site_admin":false},"repo":{"id":12541371,"name":"neo4j","full_name":"chrisvest/neo4j","owner":{"login":"chrisvest","id":7993,"avatar_url":"https://avatars.githubusercontent.com/u/7993?v=3","gravatar_id":"","url":"https://api.github.com/users/chrisvest","html_url":"https://github.com/chrisvest","followers_url":"https://api.github.com/users/chrisvest/followers","following_url":"https://api.github.com/users/chrisvest/following{/other_user}","gists_url":"https://api.github.com/users/chrisvest/gists{/gist_id}","starred_url":"https://api.github.com/users/chrisvest/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/chrisvest/subscriptions","organizations_url":"https://api.github.com/users/chrisvest/orgs","repos_url":"https://api.github.com/users/chrisvest/repos","events_url":"https://api.github.com/users/chrisvest/events{/privacy}","received_events_url":"https://api.github.com/users/chrisvest/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/chrisvest/neo4j","description":"The World's Leading Graph Database","fork":true,"url":"https://api.github.com/repos/chrisvest/neo4j","forks_url":"https://api.github.com/repos/chrisvest/neo4j/forks","keys_url":"https://api.github.com/repos/chrisvest/neo4j/keys{/key_id}","collaborators_url":"https://api.github.com/repos/chrisvest/neo4j/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/chrisvest/neo4j/teams","hooks_url":"https://api.github.com/repos/chrisvest/neo4j/hooks","issue_events_url":"https://api.github.com/repos/chrisvest/neo4j/issues/events{/number}","events_url":"https://api.github.com/repos/chrisvest/neo4j/events","assignees_url":"https://api.github.com/repos/chrisvest/neo4j/assignees{/user}","branches_url":"https://api.github.com/repos/chrisvest/neo4j/branches{/branch}","tags_url":"https://api.github.com/repos/chrisvest/neo4j/tags","blobs_url":"https://api.github.com/repos/chrisvest/neo4j/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/chrisvest/neo4j/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/chrisvest/neo4j/git/refs{/sha}","trees_url":"https://api.github.com/repos/chrisvest/neo4j/git/trees{/sha}","statuses_url":"https://api.github.com/repos/chrisvest/neo4j/statuses/{sha}","languages_url":"https://api.github.com/repos/chrisvest/neo4j/languages","stargazers_url":"https://api.github.com/repos/chrisvest/neo4j/stargazers","contributors_url":"https://api.github.com/repos/chrisvest/neo4j/contributors","subscribers_url":"https://api.github.com/repos/chrisvest/neo4j/subscribers","subscription_url":"https://api.github.com/repos/chrisvest/neo4j/subscription","commits_url":"https://api.github.com/repos/chrisvest/neo4j/commits{/sha}","git_commits_url":"https://api.github.com/repos/chrisvest/neo4j/git/commits{/sha}","comments_url":"https://api.github.com/repos/chrisvest/neo4j/comments{/number}","issue_comment_url":"https://api.github.com/repos/chrisvest/neo4j/issues/comments{/number}","contents_url":"https://api.github.com/repos/chrisvest/neo4j/contents/{+path}","compare_url":"https://api.github.com/repos/chrisvest/neo4j/compare/{base}...{head}","merges_url":"https://api.github.com/repos/chrisvest/neo4j/merges","archive_url":"https://api.github.com/repos/chrisvest/neo4j/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/chrisvest/neo4j/downloads","issues_url":"https://api.github.com/repos/chrisvest/neo4j/issues{/number}","pulls_url":"https://api.github.com/repos/chrisvest/neo4j/pulls{/number}","milestones_url":"https://api.github.com/repos/chrisvest/neo4j/milestones{/number}","notifications_url":"https://api.github.com/repos/chrisvest/neo4j/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/chrisvest/neo4j/labels{/name}","releases_url":"https://api.github.com/repos/chrisvest/neo4j/releases{/id}","deployments_url":"https://api.github.com/repos/chrisvest/neo4j/deployments","created_at":"2013-09-02T14:05:14Z","updated_at":"2015-03-27T13:31:38Z","pushed_at":"2016-05-19T08:28:07Z","git_url":"git://github.com/chrisvest/neo4j.git","ssh_url":"git@github.com:chrisvest/neo4j.git","clone_url":"https://github.com/chrisvest/neo4j.git","svn_url":"https://github.com/chrisvest/neo4j","homepage":"http://neo4j.org","size":291334,"stargazers_count":0,"watchers_count":0,"language":"Java","has_issues":false,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":0,"forks":0,"open_issues":0,"watchers":0,"default_branch":"master"}},"base":{"label":"neo4j:3.0","ref":"3.0","sha":"f5c2dcd970a7b9768637b59ff68971c584e5615c","user":{"login":"neo4j","id":201120,"avatar_url":"https://avatars.githubusercontent.com/u/201120?v=3","gravatar_id":"","url":"https://api.github.com/users/neo4j","html_url":"https://github.com/neo4j","followers_url":"https://api.github.com/users/neo4j/followers","following_url":"https://api.github.com/users/neo4j/following{/other_user}","gists_url":"https://api.github.com/users/neo4j/gists{/gist_id}","starred_url":"https://api.github.com/users/neo4j/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/neo4j/subscriptions","organizations_url":"https://api.github.com/users/neo4j/orgs","repos_url":"https://api.github.com/users/neo4j/repos","events_url":"https://api.github.com/users/neo4j/events{/privacy}","received_events_url":"https://api.github.com/users/neo4j/received_events","type":"Organization","site_admin":false},"repo":{"id":6650539,"name":"neo4j","full_name":"neo4j/neo4j","owner":{"login":"neo4j","id":201120,"avatar_url":"https://avatars.githubusercontent.com/u/201120?v=3","gravatar_id":"","url":"https://api.github.com/users/neo4j","html_url":"https://github.com/neo4j","followers_url":"https://api.github.com/users/neo4j/followers","following_url":"https://api.github.com/users/neo4j/following{/other_user}","gists_url":"https://api.github.com/users/neo4j/gists{/gist_id}","starred_url":"https://api.github.com/users/neo4j/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/neo4j/subscriptions","organizations_url":"https://api.github.com/users/neo4j/orgs","repos_url":"https://api.github.com/users/neo4j/repos","events_url":"https://api.github.com/users/neo4j/events{/privacy}","received_events_url":"https://api.github.com/users/neo4j/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/neo4j/neo4j","description":"Graphs for Everyone","fork":false,"url":"https://api.github.com/repos/neo4j/neo4j","forks_url":"https://api.github.com/repos/neo4j/neo4j/forks","keys_url":"https://api.github.com/repos/neo4j/neo4j/keys{/key_id}","collaborators_url":"https://api.github.com/repos/neo4j/neo4j/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/neo4j/neo4j/teams","hooks_url":"https://api.github.com/repos/neo4j/neo4j/hooks","issue_events_url":"https://api.github.com/repos/neo4j/neo4j/issues/events{/number}","events_url":"https://api.github.com/repos/neo4j/neo4j/events","assignees_url":"https://api.github.com/repos/neo4j/neo4j/assignees{/user}","branches_url":"https://api.github.com/repos/neo4j/neo4j/branches{/branch}","tags_url":"https://api.github.com/repos/neo4j/neo4j/tags","blobs_url":"https://api.github.com/repos/neo4j/neo4j/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/neo4j/neo4j/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/neo4j/neo4j/git/refs{/sha}","trees_url":"https://api.github.com/repos/neo4j/neo4j/git/trees{/sha}","statuses_url":"https://api.github.com/repos/neo4j/neo4j/statuses/{sha}","languages_url":"https://api.github.com/repos/neo4j/neo4j/languages","stargazers_url":"https://api.github.com/repos/neo4j/neo4j/stargazers","contributors_url":"https://api.github.com/repos/neo4j/neo4j/contributors","subscribers_url":"https://api.github.com/repos/neo4j/neo4j/subscribers","subscription_url":"https://api.github.com/repos/neo4j/neo4j/subscription","commits_url":"https://api.github.com/repos/neo4j/neo4j/commits{/sha}","git_commits_url":"https://api.github.com/repos/neo4j/neo4j/git/commits{/sha}","comments_url":"https://api.github.com/repos/neo4j/neo4j/comments{/number}","issue_comment_url":"https://api.github.com/repos/neo4j/neo4j/issues/comments{/number}","contents_url":"https://api.github.com/repos/neo4j/neo4j/contents/{+path}","compare_url":"https://api.github.com/repos/neo4j/neo4j/compare/{base}...{head}","merges_url":"https://api.github.com/repos/neo4j/neo4j/merges","archive_url":"https://api.github.com/repos/neo4j/neo4j/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/neo4j/neo4j/downloads","issues_url":"https://api.github.com/repos/neo4j/neo4j/issues{/number}","pulls_url":"https://api.github.com/repos/neo4j/neo4j/pulls{/number}","milestones_url":"https://api.github.com/repos/neo4j/neo4j/milestones{/number}","notifications_url":"https://api.github.com/repos/neo4j/neo4j/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/neo4j/neo4j/labels{/name}","releases_url":"https://api.github.com/repos/neo4j/neo4j/releases{/id}","deployments_url":"https://api.github.com/repos/neo4j/neo4j/deployments","created_at":"2012-11-12T08:46:15Z","updated_at":"2016-05-19T08:42:04Z","pushed_at":"2016-05-19T09:54:20Z","git_url":"git://github.com/neo4j/neo4j.git","ssh_url":"git@github.com:neo4j/neo4j.git","clone_url":"https://github.com/neo4j/neo4j.git","svn_url":"https://github.com/neo4j/neo4j","homepage":"http://neo4j.com","size":362626,"stargazers_count":2617,"watchers_count":2617,"language":"Java","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":914,"mirror_url":null,"open_issues_count":359,"forks":914,"open_issues":359,"watchers":2617,"default_branch":"3.1"}},"_links":{"self":{"href":"https://api.github.com/repos/neo4j/neo4j/pulls/7132"},"html":{"href":"https://github.com/neo4j/neo4j/pull/7132"},"issue":{"href":"https://api.github.com/repos/neo4j/neo4j/issues/7132"},"comments":{"href":"https://api.github.com/repos/neo4j/neo4j/issues/7132/comments"},"review_comments":{"href":"https://api.github.com/repos/neo4j/neo4j/pulls/7132/comments"},"review_comment":{"href":"https://api.github.com/repos/neo4j/neo4j/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/neo4j/neo4j/pulls/7132/commits"},"statuses":{"href":"https://api.github.com/repos/neo4j/neo4j/statuses/13a2faecfe8f00d181013bbaa4a86270298e9520"}}}}