{"action":"created","comment":{"url":"https://api.github.com/repos/coala/cEPs/pulls/comments/189471067","pull_request_review_id":121654943,"id":189471067,"diff_hunk":"@@ -0,0 +1,189 @@\n+# Optimize caching for the NextGen-Core\n+\n+| Metadata |                                           |\n+| -------- | ----------------------------------------- |\n+| cEP      | 26                                        |\n+| Version  | 1.0                                       |\n+| Title    | Optimize caching for the NextGen-Core     |\n+| Authors  | Palash Nigam <mailto:npalash25@gmail.com> |\n+| Status   | Implementation Due                        |\n+| Type     | Feature                                   |\n+\n+## Abstract\n+\n+This document describes how a caching mechanism (an enhanced version of the one\n+being used by the old core) will be implemented and integrated with the\n+NextGen-Core as a part of this\n+[GSoC project](https://summerofcode.withgoogle.com/projects/#6434190552203264).\n+\n+## Introduction\n+\n+Since the NextGen-Core aims to provide faster speed and better performance for\n+coala-runs on large codebases it needs caching to achieve this kind of\n+performance.\n+\n+Structure wise the NextGen cache is a dictionary with bear types and cache\n+tables as key-value pairs. The cache tables themselves are\n+dictionary-like-objects that map the `persistent_hash`s of the task objects to\n+the bear results. This current mechanism will be further enhanced by adding\n+features like `FileFactory` class to load files, `Directory` class to interface\n+with the directories, ignoring unmodified directories during successive runs and\n+adding cache control flags for better usability and providing the user various\n+options to perform caching according to a project's needs.\n+\n+## Implementation\n+\n+The implementation will be divided into four parts\n+\n+- Prototype for `FileFactory` class implementation.\n+- Prototype for `Directory` class implementation.\n+- Ignore directories functionality.\n+- Cache control flags.\n+\n+### Prototype of FileFactory class implementation\n+\n+This class will follow the Factory design pattern and will act as a proxy to\n+dealing with files. This class will have various methods to provide the file\n+contents in different forms like string, binary format, etc. With the help of\n+this class that we can replace the actual file contents in our file-dict with\n+these objects which will itself be a performance improvement.\n+\n+The following is the prototype for `FileFactory` class.\n+\n+```python\n+import linecache\n+import os\n+\n+from coalib.core.PersistentHash import persistent_hash\n+\n+\n+class FileFactory:\n+    def __init__(self, filename, parent):\n+        self.filename = filename\n+        self.parent = os.path.abspath(os.path.join(self.filename, os.pardir))\n+\n+    @classmethod\n+    def open(cls, filename, newline=None):\n+        return cls(filename, newline=newline)\n+\n+    def file_as_bytes(self):\n+        with open(self.filename, 'rb') as fp:\n+            return fp.read()\n+\n+    def file_as_string(self):\n+        return self.file_as_bytes().decode()\n+\n+    def file_as_list(self):\n+        self.lines = linecache.getlines(self.filename)\n+        self.linecount = len(self.lines)\n+\n+    def get_line(self, line):\n+        return linecache.getline(self.filename, line)\n+\n+    @property\n+    def timestamp(self):\n+        # get the last modified timestamp of the file\n+        return os.path.gettime(self.filename)\n+\n+    def hash(self):\n+        # hash the absolute file path to get a unique hash\n+        return persistent_hash(self.filename)\n+```\n+\n+### Prototype of Directory class implementation\n+\n+The objects of this class will also reside in the file-set (formerly known as\n+the file-dict) The objects of this class can also be used by `DirectoryBears` as\n+discussed on this thread [#4999](https://github.com/coala/coala/issues/4999) by\n+performing a simple type check on the entries in the dict, whether the objects","path":"cEP-0026.md","position":98,"original_position":98,"commit_id":"a9afa85ae0e1081747b7c53aecc3aef893a5cfe7","original_commit_id":"a9afa85ae0e1081747b7c53aecc3aef893a5cfe7","user":{"login":"Makman2","id":6023916,"avatar_url":"https://avatars3.githubusercontent.com/u/6023916?v=4","gravatar_id":"","url":"https://api.github.com/users/Makman2","html_url":"https://github.com/Makman2","followers_url":"https://api.github.com/users/Makman2/followers","following_url":"https://api.github.com/users/Makman2/following{/other_user}","gists_url":"https://api.github.com/users/Makman2/gists{/gist_id}","starred_url":"https://api.github.com/users/Makman2/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Makman2/subscriptions","organizations_url":"https://api.github.com/users/Makman2/orgs","repos_url":"https://api.github.com/users/Makman2/repos","events_url":"https://api.github.com/users/Makman2/events{/privacy}","received_events_url":"https://api.github.com/users/Makman2/received_events","type":"User","site_admin":false},"body":"dict --> file-set :)","created_at":"2018-05-20T21:26:38Z","updated_at":"2018-05-20T21:40:39Z","html_url":"https://github.com/coala/cEPs/pull/146#discussion_r189471067","pull_request_url":"https://api.github.com/repos/coala/cEPs/pulls/146","author_association":"MEMBER","_links":{"self":{"href":"https://api.github.com/repos/coala/cEPs/pulls/comments/189471067"},"html":{"href":"https://github.com/coala/cEPs/pull/146#discussion_r189471067"},"pull_request":{"href":"https://api.github.com/repos/coala/cEPs/pulls/146"}}},"pull_request":{"url":"https://api.github.com/repos/coala/cEPs/pulls/146","id":187383295,"html_url":"https://github.com/coala/cEPs/pull/146","diff_url":"https://github.com/coala/cEPs/pull/146.diff","patch_url":"https://github.com/coala/cEPs/pull/146.patch","issue_url":"https://api.github.com/repos/coala/cEPs/issues/146","number":146,"state":"open","locked":false,"title":"cEP-0026.md: Adds optimize caching cEP","user":{"login":"palash25","id":21367710,"avatar_url":"https://avatars0.githubusercontent.com/u/21367710?v=4","gravatar_id":"","url":"https://api.github.com/users/palash25","html_url":"https://github.com/palash25","followers_url":"https://api.github.com/users/palash25/followers","following_url":"https://api.github.com/users/palash25/following{/other_user}","gists_url":"https://api.github.com/users/palash25/gists{/gist_id}","starred_url":"https://api.github.com/users/palash25/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/palash25/subscriptions","organizations_url":"https://api.github.com/users/palash25/orgs","repos_url":"https://api.github.com/users/palash25/repos","events_url":"https://api.github.com/users/palash25/events{/privacy}","received_events_url":"https://api.github.com/users/palash25/received_events","type":"User","site_admin":false},"body":"","created_at":"2018-05-11T07:04:34Z","updated_at":"2018-05-20T21:40:40Z","closed_at":null,"merged_at":null,"merge_commit_sha":"8b4863b7b3d2319ac3012b30e624ad225e438fbf","assignee":null,"assignees":[],"requested_reviewers":[{"login":"fneu","id":7591685,"avatar_url":"https://avatars2.githubusercontent.com/u/7591685?v=4","gravatar_id":"","url":"https://api.github.com/users/fneu","html_url":"https://github.com/fneu","followers_url":"https://api.github.com/users/fneu/followers","following_url":"https://api.github.com/users/fneu/following{/other_user}","gists_url":"https://api.github.com/users/fneu/gists{/gist_id}","starred_url":"https://api.github.com/users/fneu/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/fneu/subscriptions","organizations_url":"https://api.github.com/users/fneu/orgs","repos_url":"https://api.github.com/users/fneu/repos","events_url":"https://api.github.com/users/fneu/events{/privacy}","received_events_url":"https://api.github.com/users/fneu/received_events","type":"User","site_admin":false},{"login":"ksdme","id":12156014,"avatar_url":"https://avatars1.githubusercontent.com/u/12156014?v=4","gravatar_id":"","url":"https://api.github.com/users/ksdme","html_url":"https://github.com/ksdme","followers_url":"https://api.github.com/users/ksdme/followers","following_url":"https://api.github.com/users/ksdme/following{/other_user}","gists_url":"https://api.github.com/users/ksdme/gists{/gist_id}","starred_url":"https://api.github.com/users/ksdme/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ksdme/subscriptions","organizations_url":"https://api.github.com/users/ksdme/orgs","repos_url":"https://api.github.com/users/ksdme/repos","events_url":"https://api.github.com/users/ksdme/events{/privacy}","received_events_url":"https://api.github.com/users/ksdme/received_events","type":"User","site_admin":false}],"requested_teams":[],"labels":[{"id":391778081,"url":"https://api.github.com/repos/coala/cEPs/labels/process/pending%20review","name":"process/pending review","color":"c2e0c6","default":false},{"id":421901408,"url":"https://api.github.com/repos/coala/cEPs/labels/size/S","name":"size/S","color":"ededed","default":false}],"milestone":null,"commits_url":"https://api.github.com/repos/coala/cEPs/pulls/146/commits","review_comments_url":"https://api.github.com/repos/coala/cEPs/pulls/146/comments","review_comment_url":"https://api.github.com/repos/coala/cEPs/pulls/comments{/number}","comments_url":"https://api.github.com/repos/coala/cEPs/issues/146/comments","statuses_url":"https://api.github.com/repos/coala/cEPs/statuses/a9afa85ae0e1081747b7c53aecc3aef893a5cfe7","head":{"label":"palash25:caching-cep","ref":"caching-cep","sha":"a9afa85ae0e1081747b7c53aecc3aef893a5cfe7","user":{"login":"palash25","id":21367710,"avatar_url":"https://avatars0.githubusercontent.com/u/21367710?v=4","gravatar_id":"","url":"https://api.github.com/users/palash25","html_url":"https://github.com/palash25","followers_url":"https://api.github.com/users/palash25/followers","following_url":"https://api.github.com/users/palash25/following{/other_user}","gists_url":"https://api.github.com/users/palash25/gists{/gist_id}","starred_url":"https://api.github.com/users/palash25/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/palash25/subscriptions","organizations_url":"https://api.github.com/users/palash25/orgs","repos_url":"https://api.github.com/users/palash25/repos","events_url":"https://api.github.com/users/palash25/events{/privacy}","received_events_url":"https://api.github.com/users/palash25/received_events","type":"User","site_admin":false},"repo":{"id":133002360,"name":"cEPs","full_name":"palash25/cEPs","owner":{"login":"palash25","id":21367710,"avatar_url":"https://avatars0.githubusercontent.com/u/21367710?v=4","gravatar_id":"","url":"https://api.github.com/users/palash25","html_url":"https://github.com/palash25","followers_url":"https://api.github.com/users/palash25/followers","following_url":"https://api.github.com/users/palash25/following{/other_user}","gists_url":"https://api.github.com/users/palash25/gists{/gist_id}","starred_url":"https://api.github.com/users/palash25/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/palash25/subscriptions","organizations_url":"https://api.github.com/users/palash25/orgs","repos_url":"https://api.github.com/users/palash25/repos","events_url":"https://api.github.com/users/palash25/events{/privacy}","received_events_url":"https://api.github.com/users/palash25/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/palash25/cEPs","description":"coala Enhancement Proposals","fork":true,"url":"https://api.github.com/repos/palash25/cEPs","forks_url":"https://api.github.com/repos/palash25/cEPs/forks","keys_url":"https://api.github.com/repos/palash25/cEPs/keys{/key_id}","collaborators_url":"https://api.github.com/repos/palash25/cEPs/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/palash25/cEPs/teams","hooks_url":"https://api.github.com/repos/palash25/cEPs/hooks","issue_events_url":"https://api.github.com/repos/palash25/cEPs/issues/events{/number}","events_url":"https://api.github.com/repos/palash25/cEPs/events","assignees_url":"https://api.github.com/repos/palash25/cEPs/assignees{/user}","branches_url":"https://api.github.com/repos/palash25/cEPs/branches{/branch}","tags_url":"https://api.github.com/repos/palash25/cEPs/tags","blobs_url":"https://api.github.com/repos/palash25/cEPs/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/palash25/cEPs/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/palash25/cEPs/git/refs{/sha}","trees_url":"https://api.github.com/repos/palash25/cEPs/git/trees{/sha}","statuses_url":"https://api.github.com/repos/palash25/cEPs/statuses/{sha}","languages_url":"https://api.github.com/repos/palash25/cEPs/languages","stargazers_url":"https://api.github.com/repos/palash25/cEPs/stargazers","contributors_url":"https://api.github.com/repos/palash25/cEPs/contributors","subscribers_url":"https://api.github.com/repos/palash25/cEPs/subscribers","subscription_url":"https://api.github.com/repos/palash25/cEPs/subscription","commits_url":"https://api.github.com/repos/palash25/cEPs/commits{/sha}","git_commits_url":"https://api.github.com/repos/palash25/cEPs/git/commits{/sha}","comments_url":"https://api.github.com/repos/palash25/cEPs/comments{/number}","issue_comment_url":"https://api.github.com/repos/palash25/cEPs/issues/comments{/number}","contents_url":"https://api.github.com/repos/palash25/cEPs/contents/{+path}","compare_url":"https://api.github.com/repos/palash25/cEPs/compare/{base}...{head}","merges_url":"https://api.github.com/repos/palash25/cEPs/merges","archive_url":"https://api.github.com/repos/palash25/cEPs/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/palash25/cEPs/downloads","issues_url":"https://api.github.com/repos/palash25/cEPs/issues{/number}","pulls_url":"https://api.github.com/repos/palash25/cEPs/pulls{/number}","milestones_url":"https://api.github.com/repos/palash25/cEPs/milestones{/number}","notifications_url":"https://api.github.com/repos/palash25/cEPs/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/palash25/cEPs/labels{/name}","releases_url":"https://api.github.com/repos/palash25/cEPs/releases{/id}","deployments_url":"https://api.github.com/repos/palash25/cEPs/deployments","created_at":"2018-05-11T07:03:05Z","updated_at":"2018-05-11T07:03:07Z","pushed_at":"2018-05-20T17:25:13Z","git_url":"git://github.com/palash25/cEPs.git","ssh_url":"git@github.com:palash25/cEPs.git","clone_url":"https://github.com/palash25/cEPs.git","svn_url":"https://github.com/palash25/cEPs","homepage":null,"size":107,"stargazers_count":0,"watchers_count":0,"language":null,"has_issues":false,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"archived":false,"open_issues_count":0,"license":{"key":"mit","name":"MIT License","spdx_id":"MIT","url":"https://api.github.com/licenses/mit"},"forks":0,"open_issues":0,"watchers":0,"default_branch":"master"}},"base":{"label":"coala:master","ref":"master","sha":"95bc075d25b5603b3a0d5c2ab291c73f0e858897","user":{"login":"coala","id":10620750,"avatar_url":"https://avatars3.githubusercontent.com/u/10620750?v=4","gravatar_id":"","url":"https://api.github.com/users/coala","html_url":"https://github.com/coala","followers_url":"https://api.github.com/users/coala/followers","following_url":"https://api.github.com/users/coala/following{/other_user}","gists_url":"https://api.github.com/users/coala/gists{/gist_id}","starred_url":"https://api.github.com/users/coala/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/coala/subscriptions","organizations_url":"https://api.github.com/users/coala/orgs","repos_url":"https://api.github.com/users/coala/repos","events_url":"https://api.github.com/users/coala/events{/privacy}","received_events_url":"https://api.github.com/users/coala/received_events","type":"Organization","site_admin":false},"repo":{"id":60130869,"name":"cEPs","full_name":"coala/cEPs","owner":{"login":"coala","id":10620750,"avatar_url":"https://avatars3.githubusercontent.com/u/10620750?v=4","gravatar_id":"","url":"https://api.github.com/users/coala","html_url":"https://github.com/coala","followers_url":"https://api.github.com/users/coala/followers","following_url":"https://api.github.com/users/coala/following{/other_user}","gists_url":"https://api.github.com/users/coala/gists{/gist_id}","starred_url":"https://api.github.com/users/coala/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/coala/subscriptions","organizations_url":"https://api.github.com/users/coala/orgs","repos_url":"https://api.github.com/users/coala/repos","events_url":"https://api.github.com/users/coala/events{/privacy}","received_events_url":"https://api.github.com/users/coala/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/coala/cEPs","description":"coala Enhancement Proposals","fork":false,"url":"https://api.github.com/repos/coala/cEPs","forks_url":"https://api.github.com/repos/coala/cEPs/forks","keys_url":"https://api.github.com/repos/coala/cEPs/keys{/key_id}","collaborators_url":"https://api.github.com/repos/coala/cEPs/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/coala/cEPs/teams","hooks_url":"https://api.github.com/repos/coala/cEPs/hooks","issue_events_url":"https://api.github.com/repos/coala/cEPs/issues/events{/number}","events_url":"https://api.github.com/repos/coala/cEPs/events","assignees_url":"https://api.github.com/repos/coala/cEPs/assignees{/user}","branches_url":"https://api.github.com/repos/coala/cEPs/branches{/branch}","tags_url":"https://api.github.com/repos/coala/cEPs/tags","blobs_url":"https://api.github.com/repos/coala/cEPs/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/coala/cEPs/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/coala/cEPs/git/refs{/sha}","trees_url":"https://api.github.com/repos/coala/cEPs/git/trees{/sha}","statuses_url":"https://api.github.com/repos/coala/cEPs/statuses/{sha}","languages_url":"https://api.github.com/repos/coala/cEPs/languages","stargazers_url":"https://api.github.com/repos/coala/cEPs/stargazers","contributors_url":"https://api.github.com/repos/coala/cEPs/contributors","subscribers_url":"https://api.github.com/repos/coala/cEPs/subscribers","subscription_url":"https://api.github.com/repos/coala/cEPs/subscription","commits_url":"https://api.github.com/repos/coala/cEPs/commits{/sha}","git_commits_url":"https://api.github.com/repos/coala/cEPs/git/commits{/sha}","comments_url":"https://api.github.com/repos/coala/cEPs/comments{/number}","issue_comment_url":"https://api.github.com/repos/coala/cEPs/issues/comments{/number}","contents_url":"https://api.github.com/repos/coala/cEPs/contents/{+path}","compare_url":"https://api.github.com/repos/coala/cEPs/compare/{base}...{head}","merges_url":"https://api.github.com/repos/coala/cEPs/merges","archive_url":"https://api.github.com/repos/coala/cEPs/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/coala/cEPs/downloads","issues_url":"https://api.github.com/repos/coala/cEPs/issues{/number}","pulls_url":"https://api.github.com/repos/coala/cEPs/pulls{/number}","milestones_url":"https://api.github.com/repos/coala/cEPs/milestones{/number}","notifications_url":"https://api.github.com/repos/coala/cEPs/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/coala/cEPs/labels{/name}","releases_url":"https://api.github.com/repos/coala/cEPs/releases{/id}","deployments_url":"https://api.github.com/repos/coala/cEPs/deployments","created_at":"2016-05-31T23:37:51Z","updated_at":"2018-05-20T11:51:40Z","pushed_at":"2018-05-20T21:15:14Z","git_url":"git://github.com/coala/cEPs.git","ssh_url":"git@github.com:coala/cEPs.git","clone_url":"https://github.com/coala/cEPs.git","svn_url":"https://github.com/coala/cEPs","homepage":null,"size":103,"stargazers_count":20,"watchers_count":20,"language":null,"has_issues":true,"has_projects":false,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":45,"mirror_url":null,"archived":false,"open_issues_count":52,"license":{"key":"mit","name":"MIT License","spdx_id":"MIT","url":"https://api.github.com/licenses/mit"},"forks":45,"open_issues":52,"watchers":20,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/coala/cEPs/pulls/146"},"html":{"href":"https://github.com/coala/cEPs/pull/146"},"issue":{"href":"https://api.github.com/repos/coala/cEPs/issues/146"},"comments":{"href":"https://api.github.com/repos/coala/cEPs/issues/146/comments"},"review_comments":{"href":"https://api.github.com/repos/coala/cEPs/pulls/146/comments"},"review_comment":{"href":"https://api.github.com/repos/coala/cEPs/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/coala/cEPs/pulls/146/commits"},"statuses":{"href":"https://api.github.com/repos/coala/cEPs/statuses/a9afa85ae0e1081747b7c53aecc3aef893a5cfe7"}},"author_association":"MEMBER"}}
{"actor":{"display_login":"Makman2"}}