{"action":"created","comment":{"url":"https://api.github.com/repos/angles-n-daemons/popsql/pulls/comments/233688724","pull_request_review_id":175161999,"id":233688724,"node_id":"MDI0OlB1bGxSZXF1ZXN0UmV2aWV3Q29tbWVudDIzMzY4ODcyNA==","diff_hunk":"@@ -0,0 +1,71 @@\n+package pager\n+\n+import \"fmt\"\n+\n+const (\n+\tRESERVED_HEADER_PAGE_COUNT = 1\n+)\n+\n+type file interface {\n+\tRead(int, int) ([]byte, error)\n+\tWrite(int, []byte) error\n+}\n+\n+/*\n+\tPager manages the database pages for access by the BTree\n+Properties\n+\t - pageSize:      the number of bytes in each data page\n+\t - fs:            file system operator used for reading and writing to the db\n+\t - freelistIndex: the page number where the freelist starts\n+\n+\t The database has the following pages:\n+\n+\t Header:     Metadata about the database\n+\t TablePages: Data pages for the database\n+\t Freelist:   Unused pages to be allocated\n+*/\n+type Pager struct {\n+\tpageSize      int\n+\tfs            file\n+\tfreelistIndex int\n+}\n+\n+/*\n+\tGet retrieves the data page at offset i after the header\n+*/\n+func (p *Pager) Get(i int) ([]byte, error) {\n+\tif i < 0 || i >= p.freelistIndex {\n+\t\treturn nil, fmt.Errorf(\n+\t\t\t\"cannot read page %d, index must be between 0 and %d\",\n+\t\t\ti,\n+\t\t\tp.freelistIndex,\n+\t\t)\n+\t}\n+\n+\toffset := (i * p.pageSize) + (RESERVED_HEADER_PAGE_COUNT * p.pageSize)\n+\treturn p.fs.Read(offset, p.pageSize)\n+}\n+\n+/*\n+\tSet puts a data page at offset i with the bytes in content\n+*/\n+func (p *Pager) Set(i int, content []byte) error {","path":"internal/backend/pager/pager.go","position":52,"original_position":52,"commit_id":"d03331d935fbcd914fa1bef4188a05403fdb6fe4","original_commit_id":"d03331d935fbcd914fa1bef4188a05403fdb6fe4","user":{"login":"caiyo","id":1775255,"node_id":"MDQ6VXNlcjE3NzUyNTU=","avatar_url":"https://avatars1.githubusercontent.com/u/1775255?v=4","gravatar_id":"","url":"https://api.github.com/users/caiyo","html_url":"https://github.com/caiyo","followers_url":"https://api.github.com/users/caiyo/followers","following_url":"https://api.github.com/users/caiyo/following{/other_user}","gists_url":"https://api.github.com/users/caiyo/gists{/gist_id}","starred_url":"https://api.github.com/users/caiyo/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/caiyo/subscriptions","organizations_url":"https://api.github.com/users/caiyo/orgs","repos_url":"https://api.github.com/users/caiyo/repos","events_url":"https://api.github.com/users/caiyo/events{/privacy}","received_events_url":"https://api.github.com/users/caiyo/received_events","type":"User","site_admin":false},"body":"Also is there ever going to be a need to know where you wrote the content to? would it make sense to return the offset or something here?","created_at":"2018-11-15T01:54:42Z","updated_at":"2018-11-15T01:54:42Z","html_url":"https://github.com/angles-n-daemons/popsql/pull/6#discussion_r233688724","pull_request_url":"https://api.github.com/repos/angles-n-daemons/popsql/pulls/6","author_association":"NONE","_links":{"self":{"href":"https://api.github.com/repos/angles-n-daemons/popsql/pulls/comments/233688724"},"html":{"href":"https://github.com/angles-n-daemons/popsql/pull/6#discussion_r233688724"},"pull_request":{"href":"https://api.github.com/repos/angles-n-daemons/popsql/pulls/6"}},"in_reply_to_id":233688071},"pull_request":{"url":"https://api.github.com/repos/angles-n-daemons/popsql/pulls/6","id":230491617,"node_id":"MDExOlB1bGxSZXF1ZXN0MjMwNDkxNjE3","html_url":"https://github.com/angles-n-daemons/popsql/pull/6","diff_url":"https://github.com/angles-n-daemons/popsql/pull/6.diff","patch_url":"https://github.com/angles-n-daemons/popsql/pull/6.patch","issue_url":"https://api.github.com/repos/angles-n-daemons/popsql/issues/6","number":6,"state":"open","locked":false,"title":"Add initial pager implementation","user":{"login":"angles-n-daemons","id":7353765,"node_id":"MDQ6VXNlcjczNTM3NjU=","avatar_url":"https://avatars0.githubusercontent.com/u/7353765?v=4","gravatar_id":"","url":"https://api.github.com/users/angles-n-daemons","html_url":"https://github.com/angles-n-daemons","followers_url":"https://api.github.com/users/angles-n-daemons/followers","following_url":"https://api.github.com/users/angles-n-daemons/following{/other_user}","gists_url":"https://api.github.com/users/angles-n-daemons/gists{/gist_id}","starred_url":"https://api.github.com/users/angles-n-daemons/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/angles-n-daemons/subscriptions","organizations_url":"https://api.github.com/users/angles-n-daemons/orgs","repos_url":"https://api.github.com/users/angles-n-daemons/repos","events_url":"https://api.github.com/users/angles-n-daemons/events{/privacy}","received_events_url":"https://api.github.com/users/angles-n-daemons/received_events","type":"User","site_admin":false},"body":"The *Pager* is the interface through which the B-Tree will fetch and write data pages from the database file.\r\n\r\nThe following properties exist on the *Pager*:\r\n - *pageSize*: the block size that the OS uses to interface with files on disk\r\n - *fs*: a file interface which can be mock, Unix, or Windows implementation\r\n - *freelistIndex*: the page offset of the first free page in the database\r\n\r\n_Rules_:\r\n * The first page of the database is ALWAYS a header page for metadata information.\r\n * The following pages for now will be allocated pages by the B-Tree.\r\n * After the allocated B-Tree pages will be the freelist until the end of the database file.\r\n\r\nWork to be addressed:\r\n - [ ] Allow for resizing the database file when the freelist is exhausted.\r\n - [ ] Allow for writing to pages on the freelist.\r\n - [ ] Allow for reading/writing the header page.\r\n - [ ] Add lock pages and journals for ACID compliance.\r\n\r\nDocumentation on the data format on the file system can be found here:\r\nhttps://www.sqlite.org/fileformat2.html\r\nRefer to section 1.2 to learn more about the database pages.","created_at":"2018-11-13T14:19:19Z","updated_at":"2018-11-15T01:54:42Z","closed_at":null,"merged_at":null,"merge_commit_sha":"07b04f072132e9c49ce403ec56f9b7a982952ab2","assignee":null,"assignees":[],"requested_reviewers":[],"requested_teams":[],"labels":[],"milestone":null,"commits_url":"https://api.github.com/repos/angles-n-daemons/popsql/pulls/6/commits","review_comments_url":"https://api.github.com/repos/angles-n-daemons/popsql/pulls/6/comments","review_comment_url":"https://api.github.com/repos/angles-n-daemons/popsql/pulls/comments{/number}","comments_url":"https://api.github.com/repos/angles-n-daemons/popsql/issues/6/comments","statuses_url":"https://api.github.com/repos/angles-n-daemons/popsql/statuses/d03331d935fbcd914fa1bef4188a05403fdb6fe4","head":{"label":"angles-n-daemons:bd/pager-init","ref":"bd/pager-init","sha":"d03331d935fbcd914fa1bef4188a05403fdb6fe4","user":{"login":"angles-n-daemons","id":7353765,"node_id":"MDQ6VXNlcjczNTM3NjU=","avatar_url":"https://avatars0.githubusercontent.com/u/7353765?v=4","gravatar_id":"","url":"https://api.github.com/users/angles-n-daemons","html_url":"https://github.com/angles-n-daemons","followers_url":"https://api.github.com/users/angles-n-daemons/followers","following_url":"https://api.github.com/users/angles-n-daemons/following{/other_user}","gists_url":"https://api.github.com/users/angles-n-daemons/gists{/gist_id}","starred_url":"https://api.github.com/users/angles-n-daemons/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/angles-n-daemons/subscriptions","organizations_url":"https://api.github.com/users/angles-n-daemons/orgs","repos_url":"https://api.github.com/users/angles-n-daemons/repos","events_url":"https://api.github.com/users/angles-n-daemons/events{/privacy}","received_events_url":"https://api.github.com/users/angles-n-daemons/received_events","type":"User","site_admin":false},"repo":{"id":151879567,"node_id":"MDEwOlJlcG9zaXRvcnkxNTE4Nzk1Njc=","name":"popsql","full_name":"angles-n-daemons/popsql","private":false,"owner":{"login":"angles-n-daemons","id":7353765,"node_id":"MDQ6VXNlcjczNTM3NjU=","avatar_url":"https://avatars0.githubusercontent.com/u/7353765?v=4","gravatar_id":"","url":"https://api.github.com/users/angles-n-daemons","html_url":"https://github.com/angles-n-daemons","followers_url":"https://api.github.com/users/angles-n-daemons/followers","following_url":"https://api.github.com/users/angles-n-daemons/following{/other_user}","gists_url":"https://api.github.com/users/angles-n-daemons/gists{/gist_id}","starred_url":"https://api.github.com/users/angles-n-daemons/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/angles-n-daemons/subscriptions","organizations_url":"https://api.github.com/users/angles-n-daemons/orgs","repos_url":"https://api.github.com/users/angles-n-daemons/repos","events_url":"https://api.github.com/users/angles-n-daemons/events{/privacy}","received_events_url":"https://api.github.com/users/angles-n-daemons/received_events","type":"User","site_admin":false},"html_url":"https://github.com/angles-n-daemons/popsql","description":"golang port of sqlite","fork":false,"url":"https://api.github.com/repos/angles-n-daemons/popsql","forks_url":"https://api.github.com/repos/angles-n-daemons/popsql/forks","keys_url":"https://api.github.com/repos/angles-n-daemons/popsql/keys{/key_id}","collaborators_url":"https://api.github.com/repos/angles-n-daemons/popsql/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/angles-n-daemons/popsql/teams","hooks_url":"https://api.github.com/repos/angles-n-daemons/popsql/hooks","issue_events_url":"https://api.github.com/repos/angles-n-daemons/popsql/issues/events{/number}","events_url":"https://api.github.com/repos/angles-n-daemons/popsql/events","assignees_url":"https://api.github.com/repos/angles-n-daemons/popsql/assignees{/user}","branches_url":"https://api.github.com/repos/angles-n-daemons/popsql/branches{/branch}","tags_url":"https://api.github.com/repos/angles-n-daemons/popsql/tags","blobs_url":"https://api.github.com/repos/angles-n-daemons/popsql/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/angles-n-daemons/popsql/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/angles-n-daemons/popsql/git/refs{/sha}","trees_url":"https://api.github.com/repos/angles-n-daemons/popsql/git/trees{/sha}","statuses_url":"https://api.github.com/repos/angles-n-daemons/popsql/statuses/{sha}","languages_url":"https://api.github.com/repos/angles-n-daemons/popsql/languages","stargazers_url":"https://api.github.com/repos/angles-n-daemons/popsql/stargazers","contributors_url":"https://api.github.com/repos/angles-n-daemons/popsql/contributors","subscribers_url":"https://api.github.com/repos/angles-n-daemons/popsql/subscribers","subscription_url":"https://api.github.com/repos/angles-n-daemons/popsql/subscription","commits_url":"https://api.github.com/repos/angles-n-daemons/popsql/commits{/sha}","git_commits_url":"https://api.github.com/repos/angles-n-daemons/popsql/git/commits{/sha}","comments_url":"https://api.github.com/repos/angles-n-daemons/popsql/comments{/number}","issue_comment_url":"https://api.github.com/repos/angles-n-daemons/popsql/issues/comments{/number}","contents_url":"https://api.github.com/repos/angles-n-daemons/popsql/contents/{+path}","compare_url":"https://api.github.com/repos/angles-n-daemons/popsql/compare/{base}...{head}","merges_url":"https://api.github.com/repos/angles-n-daemons/popsql/merges","archive_url":"https://api.github.com/repos/angles-n-daemons/popsql/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/angles-n-daemons/popsql/downloads","issues_url":"https://api.github.com/repos/angles-n-daemons/popsql/issues{/number}","pulls_url":"https://api.github.com/repos/angles-n-daemons/popsql/pulls{/number}","milestones_url":"https://api.github.com/repos/angles-n-daemons/popsql/milestones{/number}","notifications_url":"https://api.github.com/repos/angles-n-daemons/popsql/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/angles-n-daemons/popsql/labels{/name}","releases_url":"https://api.github.com/repos/angles-n-daemons/popsql/releases{/id}","deployments_url":"https://api.github.com/repos/angles-n-daemons/popsql/deployments","created_at":"2018-10-06T20:36:31Z","updated_at":"2018-11-13T13:14:53Z","pushed_at":"2018-11-13T14:19:20Z","git_url":"git://github.com/angles-n-daemons/popsql.git","ssh_url":"git@github.com:angles-n-daemons/popsql.git","clone_url":"https://github.com/angles-n-daemons/popsql.git","svn_url":"https://github.com/angles-n-daemons/popsql","homepage":null,"size":15,"stargazers_count":1,"watchers_count":1,"language":"Go","has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"archived":false,"open_issues_count":1,"license":{"key":"mit","name":"MIT License","spdx_id":"MIT","url":"https://api.github.com/licenses/mit","node_id":"MDc6TGljZW5zZTEz"},"forks":0,"open_issues":1,"watchers":1,"default_branch":"master"}},"base":{"label":"angles-n-daemons:master","ref":"master","sha":"03c80787292bf16dc5f48c492003692227a0c1d0","user":{"login":"angles-n-daemons","id":7353765,"node_id":"MDQ6VXNlcjczNTM3NjU=","avatar_url":"https://avatars0.githubusercontent.com/u/7353765?v=4","gravatar_id":"","url":"https://api.github.com/users/angles-n-daemons","html_url":"https://github.com/angles-n-daemons","followers_url":"https://api.github.com/users/angles-n-daemons/followers","following_url":"https://api.github.com/users/angles-n-daemons/following{/other_user}","gists_url":"https://api.github.com/users/angles-n-daemons/gists{/gist_id}","starred_url":"https://api.github.com/users/angles-n-daemons/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/angles-n-daemons/subscriptions","organizations_url":"https://api.github.com/users/angles-n-daemons/orgs","repos_url":"https://api.github.com/users/angles-n-daemons/repos","events_url":"https://api.github.com/users/angles-n-daemons/events{/privacy}","received_events_url":"https://api.github.com/users/angles-n-daemons/received_events","type":"User","site_admin":false},"repo":{"id":151879567,"node_id":"MDEwOlJlcG9zaXRvcnkxNTE4Nzk1Njc=","name":"popsql","full_name":"angles-n-daemons/popsql","private":false,"owner":{"login":"angles-n-daemons","id":7353765,"node_id":"MDQ6VXNlcjczNTM3NjU=","avatar_url":"https://avatars0.githubusercontent.com/u/7353765?v=4","gravatar_id":"","url":"https://api.github.com/users/angles-n-daemons","html_url":"https://github.com/angles-n-daemons","followers_url":"https://api.github.com/users/angles-n-daemons/followers","following_url":"https://api.github.com/users/angles-n-daemons/following{/other_user}","gists_url":"https://api.github.com/users/angles-n-daemons/gists{/gist_id}","starred_url":"https://api.github.com/users/angles-n-daemons/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/angles-n-daemons/subscriptions","organizations_url":"https://api.github.com/users/angles-n-daemons/orgs","repos_url":"https://api.github.com/users/angles-n-daemons/repos","events_url":"https://api.github.com/users/angles-n-daemons/events{/privacy}","received_events_url":"https://api.github.com/users/angles-n-daemons/received_events","type":"User","site_admin":false},"html_url":"https://github.com/angles-n-daemons/popsql","description":"golang port of sqlite","fork":false,"url":"https://api.github.com/repos/angles-n-daemons/popsql","forks_url":"https://api.github.com/repos/angles-n-daemons/popsql/forks","keys_url":"https://api.github.com/repos/angles-n-daemons/popsql/keys{/key_id}","collaborators_url":"https://api.github.com/repos/angles-n-daemons/popsql/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/angles-n-daemons/popsql/teams","hooks_url":"https://api.github.com/repos/angles-n-daemons/popsql/hooks","issue_events_url":"https://api.github.com/repos/angles-n-daemons/popsql/issues/events{/number}","events_url":"https://api.github.com/repos/angles-n-daemons/popsql/events","assignees_url":"https://api.github.com/repos/angles-n-daemons/popsql/assignees{/user}","branches_url":"https://api.github.com/repos/angles-n-daemons/popsql/branches{/branch}","tags_url":"https://api.github.com/repos/angles-n-daemons/popsql/tags","blobs_url":"https://api.github.com/repos/angles-n-daemons/popsql/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/angles-n-daemons/popsql/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/angles-n-daemons/popsql/git/refs{/sha}","trees_url":"https://api.github.com/repos/angles-n-daemons/popsql/git/trees{/sha}","statuses_url":"https://api.github.com/repos/angles-n-daemons/popsql/statuses/{sha}","languages_url":"https://api.github.com/repos/angles-n-daemons/popsql/languages","stargazers_url":"https://api.github.com/repos/angles-n-daemons/popsql/stargazers","contributors_url":"https://api.github.com/repos/angles-n-daemons/popsql/contributors","subscribers_url":"https://api.github.com/repos/angles-n-daemons/popsql/subscribers","subscription_url":"https://api.github.com/repos/angles-n-daemons/popsql/subscription","commits_url":"https://api.github.com/repos/angles-n-daemons/popsql/commits{/sha}","git_commits_url":"https://api.github.com/repos/angles-n-daemons/popsql/git/commits{/sha}","comments_url":"https://api.github.com/repos/angles-n-daemons/popsql/comments{/number}","issue_comment_url":"https://api.github.com/repos/angles-n-daemons/popsql/issues/comments{/number}","contents_url":"https://api.github.com/repos/angles-n-daemons/popsql/contents/{+path}","compare_url":"https://api.github.com/repos/angles-n-daemons/popsql/compare/{base}...{head}","merges_url":"https://api.github.com/repos/angles-n-daemons/popsql/merges","archive_url":"https://api.github.com/repos/angles-n-daemons/popsql/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/angles-n-daemons/popsql/downloads","issues_url":"https://api.github.com/repos/angles-n-daemons/popsql/issues{/number}","pulls_url":"https://api.github.com/repos/angles-n-daemons/popsql/pulls{/number}","milestones_url":"https://api.github.com/repos/angles-n-daemons/popsql/milestones{/number}","notifications_url":"https://api.github.com/repos/angles-n-daemons/popsql/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/angles-n-daemons/popsql/labels{/name}","releases_url":"https://api.github.com/repos/angles-n-daemons/popsql/releases{/id}","deployments_url":"https://api.github.com/repos/angles-n-daemons/popsql/deployments","created_at":"2018-10-06T20:36:31Z","updated_at":"2018-11-13T13:14:53Z","pushed_at":"2018-11-13T14:19:20Z","git_url":"git://github.com/angles-n-daemons/popsql.git","ssh_url":"git@github.com:angles-n-daemons/popsql.git","clone_url":"https://github.com/angles-n-daemons/popsql.git","svn_url":"https://github.com/angles-n-daemons/popsql","homepage":null,"size":15,"stargazers_count":1,"watchers_count":1,"language":"Go","has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"archived":false,"open_issues_count":1,"license":{"key":"mit","name":"MIT License","spdx_id":"MIT","url":"https://api.github.com/licenses/mit","node_id":"MDc6TGljZW5zZTEz"},"forks":0,"open_issues":1,"watchers":1,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/angles-n-daemons/popsql/pulls/6"},"html":{"href":"https://github.com/angles-n-daemons/popsql/pull/6"},"issue":{"href":"https://api.github.com/repos/angles-n-daemons/popsql/issues/6"},"comments":{"href":"https://api.github.com/repos/angles-n-daemons/popsql/issues/6/comments"},"review_comments":{"href":"https://api.github.com/repos/angles-n-daemons/popsql/pulls/6/comments"},"review_comment":{"href":"https://api.github.com/repos/angles-n-daemons/popsql/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/angles-n-daemons/popsql/pulls/6/commits"},"statuses":{"href":"https://api.github.com/repos/angles-n-daemons/popsql/statuses/d03331d935fbcd914fa1bef4188a05403fdb6fe4"}},"author_association":"OWNER"}}
{"actor":{"display_login":"caiyo"}}