{"action":"created","comment":{"url":"https://api.github.com/repos/fediq/mipt-java-2016/pulls/comments/89875204","pull_request_review_id":10405128,"id":89875204,"diff_hunk":"@@ -0,0 +1,191 @@\n+package ru.mipt.java2016.homework.g597.spirin.task3;\n+\n+import com.google.common.cache.CacheBuilder;\n+import com.google.common.cache.CacheLoader;\n+import com.google.common.cache.LoadingCache;\n+import ru.mipt.java2016.homework.base.task2.KeyValueStorage;\n+\n+import java.io.File;\n+import java.io.FileNotFoundException;\n+import java.io.IOException;\n+import java.io.RandomAccessFile;\n+import java.nio.file.Files;\n+import java.nio.file.Paths;\n+import java.util.HashMap;\n+import java.util.Iterator;\n+import java.util.Map;\n+import java.util.concurrent.ExecutionException;\n+import java.util.concurrent.locks.ReadWriteLock;\n+import java.util.concurrent.locks.ReentrantReadWriteLock;\n+\n+/**\n+ * Created by whoami on 11/21/16.\n+ */\n+public class HighPerformanceKeyValueStorage<K, V> implements KeyValueStorage<K, V>, AutoCloseable {\n+\n+    private final SerializationStrategy<K> keySerializer;\n+    private final SerializationStrategy<V> valueSerializer;\n+\n+    private final RandomAccessFile offsetStorage;\n+    private final RandomAccessFile dataStorage;\n+\n+    private Map<K, Long> offsets;\n+\n+    private ReadWriteLock lock;\n+    private boolean isOpen;\n+\n+    private LoadingCache<K, V> cache;\n+\n+    /**\n+     *  Suppose that name is a template for name of file storage\n+     */\n+    HighPerformanceKeyValueStorage(String path, String name,\n+                                   SerializationStrategy<K> keySerializer,\n+                                   SerializationStrategy<V> valueSerializer) throws IOException {\n+\n+        handleFileExistence(path);\n+\n+        this.keySerializer = keySerializer;\n+        this.valueSerializer = valueSerializer;\n+\n+        offsetStorage = new RandomAccessFile(path + File.separator + name + \".offset\", \"rw\");\n+        dataStorage = new RandomAccessFile(path + File.separator + name + \".data\", \"rw\");\n+\n+        offsetStorage.getChannel().lock();\n+\n+        offsets = new HashMap<>();\n+        cache = CacheBuilder.newBuilder().maximumSize(100).build(new CacheLoader<K, V>() {","path":"homework-g597-spirin/src/main/java/ru/mipt/java2016/homework/g597/spirin/task3/HighPerformanceKeyValueStorage.java","position":null,"original_position":57,"commit_id":"9945a325834decdb83551f28b096efcb7be63d4c","original_commit_id":"8dc4a5a464f2db00a13132505f815e4e5691a220","user":{"login":"ignorer","id":4057463,"avatar_url":"https://avatars.githubusercontent.com/u/4057463?v=3","gravatar_id":"","url":"https://api.github.com/users/ignorer","html_url":"https://github.com/ignorer","followers_url":"https://api.github.com/users/ignorer/followers","following_url":"https://api.github.com/users/ignorer/following{/other_user}","gists_url":"https://api.github.com/users/ignorer/gists{/gist_id}","starred_url":"https://api.github.com/users/ignorer/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ignorer/subscriptions","organizations_url":"https://api.github.com/users/ignorer/orgs","repos_url":"https://api.github.com/users/ignorer/repos","events_url":"https://api.github.com/users/ignorer/events{/privacy}","received_events_url":"https://api.github.com/users/ignorer/received_events","type":"User","site_admin":false},"body":"А, всё, перечитал, понял, как это работает.","created_at":"2016-11-28T20:18:38Z","updated_at":"2016-11-28T20:18:39Z","html_url":"https://github.com/fediq/mipt-java-2016/pull/286#discussion_r89875204","pull_request_url":"https://api.github.com/repos/fediq/mipt-java-2016/pulls/286","_links":{"self":{"href":"https://api.github.com/repos/fediq/mipt-java-2016/pulls/comments/89875204"},"html":{"href":"https://github.com/fediq/mipt-java-2016/pull/286#discussion_r89875204"},"pull_request":{"href":"https://api.github.com/repos/fediq/mipt-java-2016/pulls/286"}}},"pull_request":{"url":"https://api.github.com/repos/fediq/mipt-java-2016/pulls/286","id":94740767,"html_url":"https://github.com/fediq/mipt-java-2016/pull/286","diff_url":"https://github.com/fediq/mipt-java-2016/pull/286.diff","patch_url":"https://github.com/fediq/mipt-java-2016/pull/286.patch","issue_url":"https://api.github.com/repos/fediq/mipt-java-2016/issues/286","number":286,"state":"open","locked":false,"title":"Spirin [group 597]","user":{"login":"mountain-viewer","id":17014724,"avatar_url":"https://avatars.githubusercontent.com/u/17014724?v=3","gravatar_id":"","url":"https://api.github.com/users/mountain-viewer","html_url":"https://github.com/mountain-viewer","followers_url":"https://api.github.com/users/mountain-viewer/followers","following_url":"https://api.github.com/users/mountain-viewer/following{/other_user}","gists_url":"https://api.github.com/users/mountain-viewer/gists{/gist_id}","starred_url":"https://api.github.com/users/mountain-viewer/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mountain-viewer/subscriptions","organizations_url":"https://api.github.com/users/mountain-viewer/orgs","repos_url":"https://api.github.com/users/mountain-viewer/repos","events_url":"https://api.github.com/users/mountain-viewer/events{/privacy}","received_events_url":"https://api.github.com/users/mountain-viewer/received_events","type":"User","site_admin":false},"body":"","created_at":"2016-11-22T03:12:25Z","updated_at":"2016-11-28T20:18:39Z","closed_at":null,"merged_at":null,"merge_commit_sha":"3e2efa6836cd4e3837e72b26e8cda4aea8eb55e7","assignee":{"login":"ignorer","id":4057463,"avatar_url":"https://avatars.githubusercontent.com/u/4057463?v=3","gravatar_id":"","url":"https://api.github.com/users/ignorer","html_url":"https://github.com/ignorer","followers_url":"https://api.github.com/users/ignorer/followers","following_url":"https://api.github.com/users/ignorer/following{/other_user}","gists_url":"https://api.github.com/users/ignorer/gists{/gist_id}","starred_url":"https://api.github.com/users/ignorer/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ignorer/subscriptions","organizations_url":"https://api.github.com/users/ignorer/orgs","repos_url":"https://api.github.com/users/ignorer/repos","events_url":"https://api.github.com/users/ignorer/events{/privacy}","received_events_url":"https://api.github.com/users/ignorer/received_events","type":"User","site_admin":false},"assignees":[{"login":"ignorer","id":4057463,"avatar_url":"https://avatars.githubusercontent.com/u/4057463?v=3","gravatar_id":"","url":"https://api.github.com/users/ignorer","html_url":"https://github.com/ignorer","followers_url":"https://api.github.com/users/ignorer/followers","following_url":"https://api.github.com/users/ignorer/following{/other_user}","gists_url":"https://api.github.com/users/ignorer/gists{/gist_id}","starred_url":"https://api.github.com/users/ignorer/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ignorer/subscriptions","organizations_url":"https://api.github.com/users/ignorer/orgs","repos_url":"https://api.github.com/users/ignorer/repos","events_url":"https://api.github.com/users/ignorer/events{/privacy}","received_events_url":"https://api.github.com/users/ignorer/received_events","type":"User","site_admin":false}],"milestone":null,"commits_url":"https://api.github.com/repos/fediq/mipt-java-2016/pulls/286/commits","review_comments_url":"https://api.github.com/repos/fediq/mipt-java-2016/pulls/286/comments","review_comment_url":"https://api.github.com/repos/fediq/mipt-java-2016/pulls/comments{/number}","comments_url":"https://api.github.com/repos/fediq/mipt-java-2016/issues/286/comments","statuses_url":"https://api.github.com/repos/fediq/mipt-java-2016/statuses/9945a325834decdb83551f28b096efcb7be63d4c","head":{"label":"mountain-viewer:master","ref":"master","sha":"9945a325834decdb83551f28b096efcb7be63d4c","user":{"login":"mountain-viewer","id":17014724,"avatar_url":"https://avatars.githubusercontent.com/u/17014724?v=3","gravatar_id":"","url":"https://api.github.com/users/mountain-viewer","html_url":"https://github.com/mountain-viewer","followers_url":"https://api.github.com/users/mountain-viewer/followers","following_url":"https://api.github.com/users/mountain-viewer/following{/other_user}","gists_url":"https://api.github.com/users/mountain-viewer/gists{/gist_id}","starred_url":"https://api.github.com/users/mountain-viewer/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mountain-viewer/subscriptions","organizations_url":"https://api.github.com/users/mountain-viewer/orgs","repos_url":"https://api.github.com/users/mountain-viewer/repos","events_url":"https://api.github.com/users/mountain-viewer/events{/privacy}","received_events_url":"https://api.github.com/users/mountain-viewer/received_events","type":"User","site_admin":false},"repo":{"id":70844061,"name":"mipt-java-2016","full_name":"mountain-viewer/mipt-java-2016","owner":{"login":"mountain-viewer","id":17014724,"avatar_url":"https://avatars.githubusercontent.com/u/17014724?v=3","gravatar_id":"","url":"https://api.github.com/users/mountain-viewer","html_url":"https://github.com/mountain-viewer","followers_url":"https://api.github.com/users/mountain-viewer/followers","following_url":"https://api.github.com/users/mountain-viewer/following{/other_user}","gists_url":"https://api.github.com/users/mountain-viewer/gists{/gist_id}","starred_url":"https://api.github.com/users/mountain-viewer/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mountain-viewer/subscriptions","organizations_url":"https://api.github.com/users/mountain-viewer/orgs","repos_url":"https://api.github.com/users/mountain-viewer/repos","events_url":"https://api.github.com/users/mountain-viewer/events{/privacy}","received_events_url":"https://api.github.com/users/mountain-viewer/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/mountain-viewer/mipt-java-2016","description":"Практическая часть курса \"Программирование на Java\", 2016 год","fork":true,"url":"https://api.github.com/repos/mountain-viewer/mipt-java-2016","forks_url":"https://api.github.com/repos/mountain-viewer/mipt-java-2016/forks","keys_url":"https://api.github.com/repos/mountain-viewer/mipt-java-2016/keys{/key_id}","collaborators_url":"https://api.github.com/repos/mountain-viewer/mipt-java-2016/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/mountain-viewer/mipt-java-2016/teams","hooks_url":"https://api.github.com/repos/mountain-viewer/mipt-java-2016/hooks","issue_events_url":"https://api.github.com/repos/mountain-viewer/mipt-java-2016/issues/events{/number}","events_url":"https://api.github.com/repos/mountain-viewer/mipt-java-2016/events","assignees_url":"https://api.github.com/repos/mountain-viewer/mipt-java-2016/assignees{/user}","branches_url":"https://api.github.com/repos/mountain-viewer/mipt-java-2016/branches{/branch}","tags_url":"https://api.github.com/repos/mountain-viewer/mipt-java-2016/tags","blobs_url":"https://api.github.com/repos/mountain-viewer/mipt-java-2016/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/mountain-viewer/mipt-java-2016/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/mountain-viewer/mipt-java-2016/git/refs{/sha}","trees_url":"https://api.github.com/repos/mountain-viewer/mipt-java-2016/git/trees{/sha}","statuses_url":"https://api.github.com/repos/mountain-viewer/mipt-java-2016/statuses/{sha}","languages_url":"https://api.github.com/repos/mountain-viewer/mipt-java-2016/languages","stargazers_url":"https://api.github.com/repos/mountain-viewer/mipt-java-2016/stargazers","contributors_url":"https://api.github.com/repos/mountain-viewer/mipt-java-2016/contributors","subscribers_url":"https://api.github.com/repos/mountain-viewer/mipt-java-2016/subscribers","subscription_url":"https://api.github.com/repos/mountain-viewer/mipt-java-2016/subscription","commits_url":"https://api.github.com/repos/mountain-viewer/mipt-java-2016/commits{/sha}","git_commits_url":"https://api.github.com/repos/mountain-viewer/mipt-java-2016/git/commits{/sha}","comments_url":"https://api.github.com/repos/mountain-viewer/mipt-java-2016/comments{/number}","issue_comment_url":"https://api.github.com/repos/mountain-viewer/mipt-java-2016/issues/comments{/number}","contents_url":"https://api.github.com/repos/mountain-viewer/mipt-java-2016/contents/{+path}","compare_url":"https://api.github.com/repos/mountain-viewer/mipt-java-2016/compare/{base}...{head}","merges_url":"https://api.github.com/repos/mountain-viewer/mipt-java-2016/merges","archive_url":"https://api.github.com/repos/mountain-viewer/mipt-java-2016/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/mountain-viewer/mipt-java-2016/downloads","issues_url":"https://api.github.com/repos/mountain-viewer/mipt-java-2016/issues{/number}","pulls_url":"https://api.github.com/repos/mountain-viewer/mipt-java-2016/pulls{/number}","milestones_url":"https://api.github.com/repos/mountain-viewer/mipt-java-2016/milestones{/number}","notifications_url":"https://api.github.com/repos/mountain-viewer/mipt-java-2016/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/mountain-viewer/mipt-java-2016/labels{/name}","releases_url":"https://api.github.com/repos/mountain-viewer/mipt-java-2016/releases{/id}","deployments_url":"https://api.github.com/repos/mountain-viewer/mipt-java-2016/deployments","created_at":"2016-10-13T20:10:43Z","updated_at":"2016-10-31T06:06:26Z","pushed_at":"2016-11-28T19:17:50Z","git_url":"git://github.com/mountain-viewer/mipt-java-2016.git","ssh_url":"git@github.com:mountain-viewer/mipt-java-2016.git","clone_url":"https://github.com/mountain-viewer/mipt-java-2016.git","svn_url":"https://github.com/mountain-viewer/mipt-java-2016","homepage":null,"size":1786,"stargazers_count":1,"watchers_count":1,"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":1,"default_branch":"master"}},"base":{"label":"fediq:master","ref":"master","sha":"1993779c39fba1d9912f5d46fae70c6520d735cf","user":{"login":"fediq","id":1057798,"avatar_url":"https://avatars.githubusercontent.com/u/1057798?v=3","gravatar_id":"","url":"https://api.github.com/users/fediq","html_url":"https://github.com/fediq","followers_url":"https://api.github.com/users/fediq/followers","following_url":"https://api.github.com/users/fediq/following{/other_user}","gists_url":"https://api.github.com/users/fediq/gists{/gist_id}","starred_url":"https://api.github.com/users/fediq/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/fediq/subscriptions","organizations_url":"https://api.github.com/users/fediq/orgs","repos_url":"https://api.github.com/users/fediq/repos","events_url":"https://api.github.com/users/fediq/events{/privacy}","received_events_url":"https://api.github.com/users/fediq/received_events","type":"User","site_admin":false},"repo":{"id":69496783,"name":"mipt-java-2016","full_name":"fediq/mipt-java-2016","owner":{"login":"fediq","id":1057798,"avatar_url":"https://avatars.githubusercontent.com/u/1057798?v=3","gravatar_id":"","url":"https://api.github.com/users/fediq","html_url":"https://github.com/fediq","followers_url":"https://api.github.com/users/fediq/followers","following_url":"https://api.github.com/users/fediq/following{/other_user}","gists_url":"https://api.github.com/users/fediq/gists{/gist_id}","starred_url":"https://api.github.com/users/fediq/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/fediq/subscriptions","organizations_url":"https://api.github.com/users/fediq/orgs","repos_url":"https://api.github.com/users/fediq/repos","events_url":"https://api.github.com/users/fediq/events{/privacy}","received_events_url":"https://api.github.com/users/fediq/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/fediq/mipt-java-2016","description":"Практическая часть курса \"Программирование на Java\", 2016 год","fork":false,"url":"https://api.github.com/repos/fediq/mipt-java-2016","forks_url":"https://api.github.com/repos/fediq/mipt-java-2016/forks","keys_url":"https://api.github.com/repos/fediq/mipt-java-2016/keys{/key_id}","collaborators_url":"https://api.github.com/repos/fediq/mipt-java-2016/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/fediq/mipt-java-2016/teams","hooks_url":"https://api.github.com/repos/fediq/mipt-java-2016/hooks","issue_events_url":"https://api.github.com/repos/fediq/mipt-java-2016/issues/events{/number}","events_url":"https://api.github.com/repos/fediq/mipt-java-2016/events","assignees_url":"https://api.github.com/repos/fediq/mipt-java-2016/assignees{/user}","branches_url":"https://api.github.com/repos/fediq/mipt-java-2016/branches{/branch}","tags_url":"https://api.github.com/repos/fediq/mipt-java-2016/tags","blobs_url":"https://api.github.com/repos/fediq/mipt-java-2016/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/fediq/mipt-java-2016/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/fediq/mipt-java-2016/git/refs{/sha}","trees_url":"https://api.github.com/repos/fediq/mipt-java-2016/git/trees{/sha}","statuses_url":"https://api.github.com/repos/fediq/mipt-java-2016/statuses/{sha}","languages_url":"https://api.github.com/repos/fediq/mipt-java-2016/languages","stargazers_url":"https://api.github.com/repos/fediq/mipt-java-2016/stargazers","contributors_url":"https://api.github.com/repos/fediq/mipt-java-2016/contributors","subscribers_url":"https://api.github.com/repos/fediq/mipt-java-2016/subscribers","subscription_url":"https://api.github.com/repos/fediq/mipt-java-2016/subscription","commits_url":"https://api.github.com/repos/fediq/mipt-java-2016/commits{/sha}","git_commits_url":"https://api.github.com/repos/fediq/mipt-java-2016/git/commits{/sha}","comments_url":"https://api.github.com/repos/fediq/mipt-java-2016/comments{/number}","issue_comment_url":"https://api.github.com/repos/fediq/mipt-java-2016/issues/comments{/number}","contents_url":"https://api.github.com/repos/fediq/mipt-java-2016/contents/{+path}","compare_url":"https://api.github.com/repos/fediq/mipt-java-2016/compare/{base}...{head}","merges_url":"https://api.github.com/repos/fediq/mipt-java-2016/merges","archive_url":"https://api.github.com/repos/fediq/mipt-java-2016/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/fediq/mipt-java-2016/downloads","issues_url":"https://api.github.com/repos/fediq/mipt-java-2016/issues{/number}","pulls_url":"https://api.github.com/repos/fediq/mipt-java-2016/pulls{/number}","milestones_url":"https://api.github.com/repos/fediq/mipt-java-2016/milestones{/number}","notifications_url":"https://api.github.com/repos/fediq/mipt-java-2016/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/fediq/mipt-java-2016/labels{/name}","releases_url":"https://api.github.com/repos/fediq/mipt-java-2016/releases{/id}","deployments_url":"https://api.github.com/repos/fediq/mipt-java-2016/deployments","created_at":"2016-09-28T19:29:28Z","updated_at":"2016-11-28T12:49:12Z","pushed_at":"2016-11-28T20:09:53Z","git_url":"git://github.com/fediq/mipt-java-2016.git","ssh_url":"git@github.com:fediq/mipt-java-2016.git","clone_url":"https://github.com/fediq/mipt-java-2016.git","svn_url":"https://github.com/fediq/mipt-java-2016","homepage":null,"size":4398,"stargazers_count":14,"watchers_count":14,"language":"Java","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":88,"mirror_url":null,"open_issues_count":67,"forks":88,"open_issues":67,"watchers":14,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/fediq/mipt-java-2016/pulls/286"},"html":{"href":"https://github.com/fediq/mipt-java-2016/pull/286"},"issue":{"href":"https://api.github.com/repos/fediq/mipt-java-2016/issues/286"},"comments":{"href":"https://api.github.com/repos/fediq/mipt-java-2016/issues/286/comments"},"review_comments":{"href":"https://api.github.com/repos/fediq/mipt-java-2016/pulls/286/comments"},"review_comment":{"href":"https://api.github.com/repos/fediq/mipt-java-2016/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/fediq/mipt-java-2016/pulls/286/commits"},"statuses":{"href":"https://api.github.com/repos/fediq/mipt-java-2016/statuses/9945a325834decdb83551f28b096efcb7be63d4c"}}}}
{"actor":{"display_login":"ignorer"}}