{"action":"created","comment":{"url":"https://api.github.com/repos/wikimedia/restbase-mod-table-cassandra/pulls/comments/28474199","id":28474199,"diff_hunk":"@@ -0,0 +1,57 @@\n+\"use strict\";\n+\n+var dbu = require('./dbutils');\n+var P = require('bluebird');\n+\n+/**\n+ * Applies a revision retention policy to a sequence of rows.\n+ *\n+ * @param {object} db; instance of DB\n+ * @param {object} request; request to use as baseline\n+ * @param {object} schema; the table schema\n+ */\n+function RevisionPolicyManager(db, request, schema) {\n+    this.db = db;\n+    this.request = request;\n+    this.schema = schema;\n+    this.policy = schema.revisionRetentionPolicy;\n+    this.noop = this.policy.type === 'all' ? true : false;\n+    this.count = 0;\n+}\n+\n+/**\n+ * Process one row in the sequence.\n+ *\n+ * @param {object} row; a row object.\n+ * @return a promise that resolves when the corresponding update is complete.\n+ */\n+RevisionPolicyManager.prototype.handleRow = function(row) {\n+    var self = this;\n+\n+    if (self.noop) {\n+        return P.resolve();\n+    }\n+\n+    if (self.count < self.policy.count) {\n+        self.count++;\n+        return P.resolve();\n+    }\n+\n+    var request = self.request.extend({ ttl: self.policy.grace_ttl });\n+    Object.keys(request.query.attributes).forEach(function(key) {\n+        request.query.attributes[key] = row[key];\n+    });\n+    request.query.timestamp = null;\n+\n+    var query = dbu.buildPutQuery(request);","path":"lib/revisionPolicy.js","position":46,"original_position":46,"commit_id":"0a55e1b73356f00fed0cff2a71559325fe87a059","original_commit_id":"0a55e1b73356f00fed0cff2a71559325fe87a059","user":{"login":"gwicke","id":1225898,"avatar_url":"https://avatars.githubusercontent.com/u/1225898?v=3","gravatar_id":"","url":"https://api.github.com/users/gwicke","html_url":"https://github.com/gwicke","followers_url":"https://api.github.com/users/gwicke/followers","following_url":"https://api.github.com/users/gwicke/following{/other_user}","gists_url":"https://api.github.com/users/gwicke/gists{/gist_id}","starred_url":"https://api.github.com/users/gwicke/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/gwicke/subscriptions","organizations_url":"https://api.github.com/users/gwicke/orgs","repos_url":"https://api.github.com/users/gwicke/repos","events_url":"https://api.github.com/users/gwicke/events{/privacy}","received_events_url":"https://api.github.com/users/gwicke/received_events","type":"User","site_admin":false},"body":"This overwrites the index keys, but not necessarily all the columns. Will that still remove the entire row once the TTL elapses?","created_at":"2015-04-15T23:49:47Z","updated_at":"2015-04-15T23:49:47Z","html_url":"https://github.com/wikimedia/restbase-mod-table-cassandra/pull/92#discussion_r28474199","pull_request_url":"https://api.github.com/repos/wikimedia/restbase-mod-table-cassandra/pulls/92","_links":{"self":{"href":"https://api.github.com/repos/wikimedia/restbase-mod-table-cassandra/pulls/comments/28474199"},"html":{"href":"https://github.com/wikimedia/restbase-mod-table-cassandra/pull/92#discussion_r28474199"},"pull_request":{"href":"https://api.github.com/repos/wikimedia/restbase-mod-table-cassandra/pulls/92"}}},"pull_request":{"url":"https://api.github.com/repos/wikimedia/restbase-mod-table-cassandra/pulls/92","id":33368769,"html_url":"https://github.com/wikimedia/restbase-mod-table-cassandra/pull/92","diff_url":"https://github.com/wikimedia/restbase-mod-table-cassandra/pull/92.diff","patch_url":"https://github.com/wikimedia/restbase-mod-table-cassandra/pull/92.patch","issue_url":"https://api.github.com/repos/wikimedia/restbase-mod-table-cassandra/issues/92","number":92,"state":"open","locked":false,"title":"implement revision retention policy","user":{"login":"eevans","id":64348,"avatar_url":"https://avatars.githubusercontent.com/u/64348?v=3","gravatar_id":"","url":"https://api.github.com/users/eevans","html_url":"https://github.com/eevans","followers_url":"https://api.github.com/users/eevans/followers","following_url":"https://api.github.com/users/eevans/following{/other_user}","gists_url":"https://api.github.com/users/eevans/gists{/gist_id}","starred_url":"https://api.github.com/users/eevans/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/eevans/subscriptions","organizations_url":"https://api.github.com/users/eevans/orgs","repos_url":"https://api.github.com/users/eevans/repos","events_url":"https://api.github.com/users/eevans/events{/privacy}","received_events_url":"https://api.github.com/users/eevans/received_events","type":"User","site_admin":false},"body":"This branch:\r\n\r\n * implements a test case for a policy of `latest`\r\n * adds support for CQL generation of `USING TTL` queries\r\n * adds an async-safe utility method for performing arbitrarily large Cassandra queries, and paging through the results\r\n * adds `RevisionPolicyManager` (currently supports policy types of `all`, and `latest`), and wires it into a refactored `DB#_rebuildIndexes` (renamed `DB#_backgroundUpdates`).\r\n\r\nSee: https://phabricator.wikimedia.org/T94524","created_at":"2015-04-15T15:51:14Z","updated_at":"2015-04-15T23:49:47Z","closed_at":null,"merged_at":null,"merge_commit_sha":"f269aafe1b0990962fd1a4c233123cf6e9a928c0","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/wikimedia/restbase-mod-table-cassandra/pulls/92/commits","review_comments_url":"https://api.github.com/repos/wikimedia/restbase-mod-table-cassandra/pulls/92/comments","review_comment_url":"https://api.github.com/repos/wikimedia/restbase-mod-table-cassandra/pulls/comments{/number}","comments_url":"https://api.github.com/repos/wikimedia/restbase-mod-table-cassandra/issues/92/comments","statuses_url":"https://api.github.com/repos/wikimedia/restbase-mod-table-cassandra/statuses/0a55e1b73356f00fed0cff2a71559325fe87a059","head":{"label":"eevans:T94524","ref":"T94524","sha":"0a55e1b73356f00fed0cff2a71559325fe87a059","user":{"login":"eevans","id":64348,"avatar_url":"https://avatars.githubusercontent.com/u/64348?v=3","gravatar_id":"","url":"https://api.github.com/users/eevans","html_url":"https://github.com/eevans","followers_url":"https://api.github.com/users/eevans/followers","following_url":"https://api.github.com/users/eevans/following{/other_user}","gists_url":"https://api.github.com/users/eevans/gists{/gist_id}","starred_url":"https://api.github.com/users/eevans/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/eevans/subscriptions","organizations_url":"https://api.github.com/users/eevans/orgs","repos_url":"https://api.github.com/users/eevans/repos","events_url":"https://api.github.com/users/eevans/events{/privacy}","received_events_url":"https://api.github.com/users/eevans/received_events","type":"User","site_admin":false},"repo":{"id":31746867,"name":"restbase-mod-table-cassandra","full_name":"eevans/restbase-mod-table-cassandra","owner":{"login":"eevans","id":64348,"avatar_url":"https://avatars.githubusercontent.com/u/64348?v=3","gravatar_id":"","url":"https://api.github.com/users/eevans","html_url":"https://github.com/eevans","followers_url":"https://api.github.com/users/eevans/followers","following_url":"https://api.github.com/users/eevans/following{/other_user}","gists_url":"https://api.github.com/users/eevans/gists{/gist_id}","starred_url":"https://api.github.com/users/eevans/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/eevans/subscriptions","organizations_url":"https://api.github.com/users/eevans/orgs","repos_url":"https://api.github.com/users/eevans/repos","events_url":"https://api.github.com/users/eevans/events{/privacy}","received_events_url":"https://api.github.com/users/eevans/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/eevans/restbase-mod-table-cassandra","description":"Cassandra table storage backend for RESTBase","fork":true,"url":"https://api.github.com/repos/eevans/restbase-mod-table-cassandra","forks_url":"https://api.github.com/repos/eevans/restbase-mod-table-cassandra/forks","keys_url":"https://api.github.com/repos/eevans/restbase-mod-table-cassandra/keys{/key_id}","collaborators_url":"https://api.github.com/repos/eevans/restbase-mod-table-cassandra/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/eevans/restbase-mod-table-cassandra/teams","hooks_url":"https://api.github.com/repos/eevans/restbase-mod-table-cassandra/hooks","issue_events_url":"https://api.github.com/repos/eevans/restbase-mod-table-cassandra/issues/events{/number}","events_url":"https://api.github.com/repos/eevans/restbase-mod-table-cassandra/events","assignees_url":"https://api.github.com/repos/eevans/restbase-mod-table-cassandra/assignees{/user}","branches_url":"https://api.github.com/repos/eevans/restbase-mod-table-cassandra/branches{/branch}","tags_url":"https://api.github.com/repos/eevans/restbase-mod-table-cassandra/tags","blobs_url":"https://api.github.com/repos/eevans/restbase-mod-table-cassandra/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/eevans/restbase-mod-table-cassandra/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/eevans/restbase-mod-table-cassandra/git/refs{/sha}","trees_url":"https://api.github.com/repos/eevans/restbase-mod-table-cassandra/git/trees{/sha}","statuses_url":"https://api.github.com/repos/eevans/restbase-mod-table-cassandra/statuses/{sha}","languages_url":"https://api.github.com/repos/eevans/restbase-mod-table-cassandra/languages","stargazers_url":"https://api.github.com/repos/eevans/restbase-mod-table-cassandra/stargazers","contributors_url":"https://api.github.com/repos/eevans/restbase-mod-table-cassandra/contributors","subscribers_url":"https://api.github.com/repos/eevans/restbase-mod-table-cassandra/subscribers","subscription_url":"https://api.github.com/repos/eevans/restbase-mod-table-cassandra/subscription","commits_url":"https://api.github.com/repos/eevans/restbase-mod-table-cassandra/commits{/sha}","git_commits_url":"https://api.github.com/repos/eevans/restbase-mod-table-cassandra/git/commits{/sha}","comments_url":"https://api.github.com/repos/eevans/restbase-mod-table-cassandra/comments{/number}","issue_comment_url":"https://api.github.com/repos/eevans/restbase-mod-table-cassandra/issues/comments{/number}","contents_url":"https://api.github.com/repos/eevans/restbase-mod-table-cassandra/contents/{+path}","compare_url":"https://api.github.com/repos/eevans/restbase-mod-table-cassandra/compare/{base}...{head}","merges_url":"https://api.github.com/repos/eevans/restbase-mod-table-cassandra/merges","archive_url":"https://api.github.com/repos/eevans/restbase-mod-table-cassandra/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/eevans/restbase-mod-table-cassandra/downloads","issues_url":"https://api.github.com/repos/eevans/restbase-mod-table-cassandra/issues{/number}","pulls_url":"https://api.github.com/repos/eevans/restbase-mod-table-cassandra/pulls{/number}","milestones_url":"https://api.github.com/repos/eevans/restbase-mod-table-cassandra/milestones{/number}","notifications_url":"https://api.github.com/repos/eevans/restbase-mod-table-cassandra/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/eevans/restbase-mod-table-cassandra/labels{/name}","releases_url":"https://api.github.com/repos/eevans/restbase-mod-table-cassandra/releases{/id}","created_at":"2015-03-06T01:44:58Z","updated_at":"2015-03-06T01:44:58Z","pushed_at":"2015-04-15T15:41:39Z","git_url":"git://github.com/eevans/restbase-mod-table-cassandra.git","ssh_url":"git@github.com:eevans/restbase-mod-table-cassandra.git","clone_url":"https://github.com/eevans/restbase-mod-table-cassandra.git","svn_url":"https://github.com/eevans/restbase-mod-table-cassandra","homepage":"","size":574,"stargazers_count":0,"watchers_count":0,"language":"JavaScript","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":"wikimedia:master","ref":"master","sha":"e841e2a43c3ca12df74ac45d56b684e87b6fdc98","user":{"login":"wikimedia","id":56668,"avatar_url":"https://avatars.githubusercontent.com/u/56668?v=3","gravatar_id":"","url":"https://api.github.com/users/wikimedia","html_url":"https://github.com/wikimedia","followers_url":"https://api.github.com/users/wikimedia/followers","following_url":"https://api.github.com/users/wikimedia/following{/other_user}","gists_url":"https://api.github.com/users/wikimedia/gists{/gist_id}","starred_url":"https://api.github.com/users/wikimedia/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/wikimedia/subscriptions","organizations_url":"https://api.github.com/users/wikimedia/orgs","repos_url":"https://api.github.com/users/wikimedia/repos","events_url":"https://api.github.com/users/wikimedia/events{/privacy}","received_events_url":"https://api.github.com/users/wikimedia/received_events","type":"Organization","site_admin":false},"repo":{"id":13256940,"name":"restbase-mod-table-cassandra","full_name":"wikimedia/restbase-mod-table-cassandra","owner":{"login":"wikimedia","id":56668,"avatar_url":"https://avatars.githubusercontent.com/u/56668?v=3","gravatar_id":"","url":"https://api.github.com/users/wikimedia","html_url":"https://github.com/wikimedia","followers_url":"https://api.github.com/users/wikimedia/followers","following_url":"https://api.github.com/users/wikimedia/following{/other_user}","gists_url":"https://api.github.com/users/wikimedia/gists{/gist_id}","starred_url":"https://api.github.com/users/wikimedia/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/wikimedia/subscriptions","organizations_url":"https://api.github.com/users/wikimedia/orgs","repos_url":"https://api.github.com/users/wikimedia/repos","events_url":"https://api.github.com/users/wikimedia/events{/privacy}","received_events_url":"https://api.github.com/users/wikimedia/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/wikimedia/restbase-mod-table-cassandra","description":"Cassandra table storage backend for RESTBase","fork":false,"url":"https://api.github.com/repos/wikimedia/restbase-mod-table-cassandra","forks_url":"https://api.github.com/repos/wikimedia/restbase-mod-table-cassandra/forks","keys_url":"https://api.github.com/repos/wikimedia/restbase-mod-table-cassandra/keys{/key_id}","collaborators_url":"https://api.github.com/repos/wikimedia/restbase-mod-table-cassandra/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/wikimedia/restbase-mod-table-cassandra/teams","hooks_url":"https://api.github.com/repos/wikimedia/restbase-mod-table-cassandra/hooks","issue_events_url":"https://api.github.com/repos/wikimedia/restbase-mod-table-cassandra/issues/events{/number}","events_url":"https://api.github.com/repos/wikimedia/restbase-mod-table-cassandra/events","assignees_url":"https://api.github.com/repos/wikimedia/restbase-mod-table-cassandra/assignees{/user}","branches_url":"https://api.github.com/repos/wikimedia/restbase-mod-table-cassandra/branches{/branch}","tags_url":"https://api.github.com/repos/wikimedia/restbase-mod-table-cassandra/tags","blobs_url":"https://api.github.com/repos/wikimedia/restbase-mod-table-cassandra/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/wikimedia/restbase-mod-table-cassandra/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/wikimedia/restbase-mod-table-cassandra/git/refs{/sha}","trees_url":"https://api.github.com/repos/wikimedia/restbase-mod-table-cassandra/git/trees{/sha}","statuses_url":"https://api.github.com/repos/wikimedia/restbase-mod-table-cassandra/statuses/{sha}","languages_url":"https://api.github.com/repos/wikimedia/restbase-mod-table-cassandra/languages","stargazers_url":"https://api.github.com/repos/wikimedia/restbase-mod-table-cassandra/stargazers","contributors_url":"https://api.github.com/repos/wikimedia/restbase-mod-table-cassandra/contributors","subscribers_url":"https://api.github.com/repos/wikimedia/restbase-mod-table-cassandra/subscribers","subscription_url":"https://api.github.com/repos/wikimedia/restbase-mod-table-cassandra/subscription","commits_url":"https://api.github.com/repos/wikimedia/restbase-mod-table-cassandra/commits{/sha}","git_commits_url":"https://api.github.com/repos/wikimedia/restbase-mod-table-cassandra/git/commits{/sha}","comments_url":"https://api.github.com/repos/wikimedia/restbase-mod-table-cassandra/comments{/number}","issue_comment_url":"https://api.github.com/repos/wikimedia/restbase-mod-table-cassandra/issues/comments{/number}","contents_url":"https://api.github.com/repos/wikimedia/restbase-mod-table-cassandra/contents/{+path}","compare_url":"https://api.github.com/repos/wikimedia/restbase-mod-table-cassandra/compare/{base}...{head}","merges_url":"https://api.github.com/repos/wikimedia/restbase-mod-table-cassandra/merges","archive_url":"https://api.github.com/repos/wikimedia/restbase-mod-table-cassandra/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/wikimedia/restbase-mod-table-cassandra/downloads","issues_url":"https://api.github.com/repos/wikimedia/restbase-mod-table-cassandra/issues{/number}","pulls_url":"https://api.github.com/repos/wikimedia/restbase-mod-table-cassandra/pulls{/number}","milestones_url":"https://api.github.com/repos/wikimedia/restbase-mod-table-cassandra/milestones{/number}","notifications_url":"https://api.github.com/repos/wikimedia/restbase-mod-table-cassandra/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/wikimedia/restbase-mod-table-cassandra/labels{/name}","releases_url":"https://api.github.com/repos/wikimedia/restbase-mod-table-cassandra/releases{/id}","created_at":"2013-10-01T22:03:02Z","updated_at":"2015-04-01T17:40:09Z","pushed_at":"2015-04-15T15:51:15Z","git_url":"git://github.com/wikimedia/restbase-mod-table-cassandra.git","ssh_url":"git@github.com:wikimedia/restbase-mod-table-cassandra.git","clone_url":"https://github.com/wikimedia/restbase-mod-table-cassandra.git","svn_url":"https://github.com/wikimedia/restbase-mod-table-cassandra","homepage":"","size":2327,"stargazers_count":10,"watchers_count":10,"language":"JavaScript","has_issues":false,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":7,"mirror_url":null,"open_issues_count":3,"forks":7,"open_issues":3,"watchers":10,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/wikimedia/restbase-mod-table-cassandra/pulls/92"},"html":{"href":"https://github.com/wikimedia/restbase-mod-table-cassandra/pull/92"},"issue":{"href":"https://api.github.com/repos/wikimedia/restbase-mod-table-cassandra/issues/92"},"comments":{"href":"https://api.github.com/repos/wikimedia/restbase-mod-table-cassandra/issues/92/comments"},"review_comments":{"href":"https://api.github.com/repos/wikimedia/restbase-mod-table-cassandra/pulls/92/comments"},"review_comment":{"href":"https://api.github.com/repos/wikimedia/restbase-mod-table-cassandra/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/wikimedia/restbase-mod-table-cassandra/pulls/92/commits"},"statuses":{"href":"https://api.github.com/repos/wikimedia/restbase-mod-table-cassandra/statuses/0a55e1b73356f00fed0cff2a71559325fe87a059"}}}}