{"action":"created","comment":{"url":"https://api.github.com/repos/datastax/java-driver/pulls/comments/28607589","id":28607589,"diff_hunk":"@@ -326,4 +326,49 @@ public Statement setPagingState(PagingState pagingState) {\n     ByteBuffer getPagingState() {\n         return pagingState;\n     }\n+\n+    /**\n+     * Sets whether this statement is idempotent.\n+     * <p>\n+     * See {@link #isIdempotent()} for more explanations about this property.\n+     *\n+     * @param idempotent the new value.\n+     * @return this {@code Statement} object.\n+     */\n+    public Statement setIdempotent(boolean idempotent) {\n+        this.idempotent = idempotent;\n+        return this;\n+    }\n+\n+    /**\n+     * Whether this statement is idempotent, i.e. whether it can be applied multiple times\n+     * without changing the result beyond the initial application.\n+     * <p>\n+     * Idempotency plays a role in {@link com.datastax.driver.core.policies.SpeculativeExecutionPolicy speculative executions}.\n+     * If a statement is <em>not idempotent</em>, the driver will not schedule speculative\n+     * executions for it.\n+     * <p>\n+     * Note that this method can return {@code null}, in which case the driver will default to\n+     * {@link QueryOptions#getDefaultIdempotency()}.\n+     * <p>\n+     * By default, this method returns {@code null} for all statements, except for\n+     * {@link BuiltStatement}s, where the value will be inferred from the query: if it updates\n+     * counters or prepends/appends to a list, the result will be {@code false}, otherwise it\n+     * will be {@code true}. In all cases, calling {@link #setIdempotent(boolean)} forces a\n+     * value that overrides every other mechanism.\n+     *\n+     * @return whether this statement is idempotent, or {@code null} to use\n+     * {@link QueryOptions#getDefaultIdempotency()}.\n+     */\n+    public Boolean isIdempotent() {","path":"driver-core/src/main/java/com/datastax/driver/core/Statement.java","position":58,"original_position":58,"commit_id":"5c420a6cce407eeb0f1773d91ffdfa7b33dd6796","original_commit_id":"14d382680df1655d5da115b3d9461aeb54cdc5d7","user":{"login":"adutra","id":463876,"avatar_url":"https://avatars.githubusercontent.com/u/463876?v=3","gravatar_id":"","url":"https://api.github.com/users/adutra","html_url":"https://github.com/adutra","followers_url":"https://api.github.com/users/adutra/followers","following_url":"https://api.github.com/users/adutra/following{/other_user}","gists_url":"https://api.github.com/users/adutra/gists{/gist_id}","starred_url":"https://api.github.com/users/adutra/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/adutra/subscriptions","organizations_url":"https://api.github.com/users/adutra/orgs","repos_url":"https://api.github.com/users/adutra/repos","events_url":"https://api.github.com/users/adutra/events{/privacy}","received_events_url":"https://api.github.com/users/adutra/received_events","type":"User","site_admin":false},"body":"I'm slightly disturbed here by the asymmetric getter/setter pair. If idempotency is a property of statements, a statement is either idempotent or non-idempotent, so null values sound strange and conceptually would mean \"I don't know if I'm idempotent\" or \"I may be idempotent\". \r\nI understand that this comes from the need to introduce a \"default\" idempotency cluster-wide. \r\nBut in this case the message we are sending here to the receiver slid from the initial intent: \"Are you idempotent?\" to: \"Do you allow speculative execution?\" - in which case it would be fine to return null (meaning \"I don't know if I can be executed speculatively, ask the cluster\").\r\nI would suggest to make the API clearer:\r\n* Renaming the property to `speculativeExecutionPermission` or stg in the style\r\n* Instead of Boolean, use an enum like `SpeculativeExecutionPermission { DEFAULT, ALLOW, DENY }`","created_at":"2015-04-17T16:12:29Z","updated_at":"2015-04-17T16:12:29Z","html_url":"https://github.com/datastax/java-driver/pull/310#discussion_r28607589","pull_request_url":"https://api.github.com/repos/datastax/java-driver/pulls/310","_links":{"self":{"href":"https://api.github.com/repos/datastax/java-driver/pulls/comments/28607589"},"html":{"href":"https://github.com/datastax/java-driver/pull/310#discussion_r28607589"},"pull_request":{"href":"https://api.github.com/repos/datastax/java-driver/pulls/310"}}},"pull_request":{"url":"https://api.github.com/repos/datastax/java-driver/pulls/310","id":32207052,"html_url":"https://github.com/datastax/java-driver/pull/310","diff_url":"https://github.com/datastax/java-driver/pull/310.diff","patch_url":"https://github.com/datastax/java-driver/pull/310.patch","issue_url":"https://api.github.com/repos/datastax/java-driver/issues/310","number":310,"state":"open","locked":false,"title":"Speculative query execution (JAVA-561)","user":{"login":"olim7t","id":259423,"avatar_url":"https://avatars.githubusercontent.com/u/259423?v=3","gravatar_id":"","url":"https://api.github.com/users/olim7t","html_url":"https://github.com/olim7t","followers_url":"https://api.github.com/users/olim7t/followers","following_url":"https://api.github.com/users/olim7t/following{/other_user}","gists_url":"https://api.github.com/users/olim7t/gists{/gist_id}","starred_url":"https://api.github.com/users/olim7t/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/olim7t/subscriptions","organizations_url":"https://api.github.com/users/olim7t/orgs","repos_url":"https://api.github.com/users/olim7t/repos","events_url":"https://api.github.com/users/olim7t/events{/privacy}","received_events_url":"https://api.github.com/users/olim7t/received_events","type":"User","site_admin":false},"body":"Preemptively query the next host when the current one takes too long to respond. Introduces a new `SpeculativeExecutionPolicy` (I deliberately avoided the word \"retry\" which was already used in driver jargon).\r\n\r\nMost of the `RequestHandler` logic was extracted in a `SpeculativeExecution` inner class. A RequestHandler starts multiple SpeculativeExecutions which compete for the same query plan. This allows:\r\n* coherent integration with the retry logic: each SpeculativeExecution can still retry, as defined by the `RetryPolicy`.\r\n* few changes to existing synchronization code. Each SpeculativeExecution manages its own requests with the existing `QueryState` mechanism, and the RequestHandler coordinates all SpeculativeExecutions.","created_at":"2015-03-30T08:40:09Z","updated_at":"2015-04-17T16:12:29Z","closed_at":null,"merged_at":null,"merge_commit_sha":"976168c58657ebf6b671571c6c43143adc412d4c","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/datastax/java-driver/pulls/310/commits","review_comments_url":"https://api.github.com/repos/datastax/java-driver/pulls/310/comments","review_comment_url":"https://api.github.com/repos/datastax/java-driver/pulls/comments{/number}","comments_url":"https://api.github.com/repos/datastax/java-driver/issues/310/comments","statuses_url":"https://api.github.com/repos/datastax/java-driver/statuses/5c420a6cce407eeb0f1773d91ffdfa7b33dd6796","head":{"label":"datastax:java561","ref":"java561","sha":"5c420a6cce407eeb0f1773d91ffdfa7b33dd6796","user":{"login":"datastax","id":573369,"avatar_url":"https://avatars.githubusercontent.com/u/573369?v=3","gravatar_id":"","url":"https://api.github.com/users/datastax","html_url":"https://github.com/datastax","followers_url":"https://api.github.com/users/datastax/followers","following_url":"https://api.github.com/users/datastax/following{/other_user}","gists_url":"https://api.github.com/users/datastax/gists{/gist_id}","starred_url":"https://api.github.com/users/datastax/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/datastax/subscriptions","organizations_url":"https://api.github.com/users/datastax/orgs","repos_url":"https://api.github.com/users/datastax/repos","events_url":"https://api.github.com/users/datastax/events{/privacy}","received_events_url":"https://api.github.com/users/datastax/received_events","type":"Organization","site_admin":false},"repo":{"id":6765281,"name":"java-driver","full_name":"datastax/java-driver","owner":{"login":"datastax","id":573369,"avatar_url":"https://avatars.githubusercontent.com/u/573369?v=3","gravatar_id":"","url":"https://api.github.com/users/datastax","html_url":"https://github.com/datastax","followers_url":"https://api.github.com/users/datastax/followers","following_url":"https://api.github.com/users/datastax/following{/other_user}","gists_url":"https://api.github.com/users/datastax/gists{/gist_id}","starred_url":"https://api.github.com/users/datastax/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/datastax/subscriptions","organizations_url":"https://api.github.com/users/datastax/orgs","repos_url":"https://api.github.com/users/datastax/repos","events_url":"https://api.github.com/users/datastax/events{/privacy}","received_events_url":"https://api.github.com/users/datastax/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/datastax/java-driver","description":"DataStax Java Driver for Apache Cassandra","fork":false,"url":"https://api.github.com/repos/datastax/java-driver","forks_url":"https://api.github.com/repos/datastax/java-driver/forks","keys_url":"https://api.github.com/repos/datastax/java-driver/keys{/key_id}","collaborators_url":"https://api.github.com/repos/datastax/java-driver/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/datastax/java-driver/teams","hooks_url":"https://api.github.com/repos/datastax/java-driver/hooks","issue_events_url":"https://api.github.com/repos/datastax/java-driver/issues/events{/number}","events_url":"https://api.github.com/repos/datastax/java-driver/events","assignees_url":"https://api.github.com/repos/datastax/java-driver/assignees{/user}","branches_url":"https://api.github.com/repos/datastax/java-driver/branches{/branch}","tags_url":"https://api.github.com/repos/datastax/java-driver/tags","blobs_url":"https://api.github.com/repos/datastax/java-driver/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/datastax/java-driver/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/datastax/java-driver/git/refs{/sha}","trees_url":"https://api.github.com/repos/datastax/java-driver/git/trees{/sha}","statuses_url":"https://api.github.com/repos/datastax/java-driver/statuses/{sha}","languages_url":"https://api.github.com/repos/datastax/java-driver/languages","stargazers_url":"https://api.github.com/repos/datastax/java-driver/stargazers","contributors_url":"https://api.github.com/repos/datastax/java-driver/contributors","subscribers_url":"https://api.github.com/repos/datastax/java-driver/subscribers","subscription_url":"https://api.github.com/repos/datastax/java-driver/subscription","commits_url":"https://api.github.com/repos/datastax/java-driver/commits{/sha}","git_commits_url":"https://api.github.com/repos/datastax/java-driver/git/commits{/sha}","comments_url":"https://api.github.com/repos/datastax/java-driver/comments{/number}","issue_comment_url":"https://api.github.com/repos/datastax/java-driver/issues/comments{/number}","contents_url":"https://api.github.com/repos/datastax/java-driver/contents/{+path}","compare_url":"https://api.github.com/repos/datastax/java-driver/compare/{base}...{head}","merges_url":"https://api.github.com/repos/datastax/java-driver/merges","archive_url":"https://api.github.com/repos/datastax/java-driver/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/datastax/java-driver/downloads","issues_url":"https://api.github.com/repos/datastax/java-driver/issues{/number}","pulls_url":"https://api.github.com/repos/datastax/java-driver/pulls{/number}","milestones_url":"https://api.github.com/repos/datastax/java-driver/milestones{/number}","notifications_url":"https://api.github.com/repos/datastax/java-driver/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/datastax/java-driver/labels{/name}","releases_url":"https://api.github.com/repos/datastax/java-driver/releases{/id}","created_at":"2012-11-19T18:44:41Z","updated_at":"2015-04-17T09:03:14Z","pushed_at":"2015-04-17T16:05:18Z","git_url":"git://github.com/datastax/java-driver.git","ssh_url":"git@github.com:datastax/java-driver.git","clone_url":"https://github.com/datastax/java-driver.git","svn_url":"https://github.com/datastax/java-driver","homepage":null,"size":19259,"stargazers_count":442,"watchers_count":442,"language":"Java","has_issues":false,"has_downloads":true,"has_wiki":true,"has_pages":true,"forks_count":292,"mirror_url":null,"open_issues_count":31,"forks":292,"open_issues":31,"watchers":442,"default_branch":"2.1"}},"base":{"label":"datastax:2.0","ref":"2.0","sha":"0715c61e9fc78c59661d944152098c368f8f7d7a","user":{"login":"datastax","id":573369,"avatar_url":"https://avatars.githubusercontent.com/u/573369?v=3","gravatar_id":"","url":"https://api.github.com/users/datastax","html_url":"https://github.com/datastax","followers_url":"https://api.github.com/users/datastax/followers","following_url":"https://api.github.com/users/datastax/following{/other_user}","gists_url":"https://api.github.com/users/datastax/gists{/gist_id}","starred_url":"https://api.github.com/users/datastax/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/datastax/subscriptions","organizations_url":"https://api.github.com/users/datastax/orgs","repos_url":"https://api.github.com/users/datastax/repos","events_url":"https://api.github.com/users/datastax/events{/privacy}","received_events_url":"https://api.github.com/users/datastax/received_events","type":"Organization","site_admin":false},"repo":{"id":6765281,"name":"java-driver","full_name":"datastax/java-driver","owner":{"login":"datastax","id":573369,"avatar_url":"https://avatars.githubusercontent.com/u/573369?v=3","gravatar_id":"","url":"https://api.github.com/users/datastax","html_url":"https://github.com/datastax","followers_url":"https://api.github.com/users/datastax/followers","following_url":"https://api.github.com/users/datastax/following{/other_user}","gists_url":"https://api.github.com/users/datastax/gists{/gist_id}","starred_url":"https://api.github.com/users/datastax/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/datastax/subscriptions","organizations_url":"https://api.github.com/users/datastax/orgs","repos_url":"https://api.github.com/users/datastax/repos","events_url":"https://api.github.com/users/datastax/events{/privacy}","received_events_url":"https://api.github.com/users/datastax/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/datastax/java-driver","description":"DataStax Java Driver for Apache Cassandra","fork":false,"url":"https://api.github.com/repos/datastax/java-driver","forks_url":"https://api.github.com/repos/datastax/java-driver/forks","keys_url":"https://api.github.com/repos/datastax/java-driver/keys{/key_id}","collaborators_url":"https://api.github.com/repos/datastax/java-driver/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/datastax/java-driver/teams","hooks_url":"https://api.github.com/repos/datastax/java-driver/hooks","issue_events_url":"https://api.github.com/repos/datastax/java-driver/issues/events{/number}","events_url":"https://api.github.com/repos/datastax/java-driver/events","assignees_url":"https://api.github.com/repos/datastax/java-driver/assignees{/user}","branches_url":"https://api.github.com/repos/datastax/java-driver/branches{/branch}","tags_url":"https://api.github.com/repos/datastax/java-driver/tags","blobs_url":"https://api.github.com/repos/datastax/java-driver/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/datastax/java-driver/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/datastax/java-driver/git/refs{/sha}","trees_url":"https://api.github.com/repos/datastax/java-driver/git/trees{/sha}","statuses_url":"https://api.github.com/repos/datastax/java-driver/statuses/{sha}","languages_url":"https://api.github.com/repos/datastax/java-driver/languages","stargazers_url":"https://api.github.com/repos/datastax/java-driver/stargazers","contributors_url":"https://api.github.com/repos/datastax/java-driver/contributors","subscribers_url":"https://api.github.com/repos/datastax/java-driver/subscribers","subscription_url":"https://api.github.com/repos/datastax/java-driver/subscription","commits_url":"https://api.github.com/repos/datastax/java-driver/commits{/sha}","git_commits_url":"https://api.github.com/repos/datastax/java-driver/git/commits{/sha}","comments_url":"https://api.github.com/repos/datastax/java-driver/comments{/number}","issue_comment_url":"https://api.github.com/repos/datastax/java-driver/issues/comments{/number}","contents_url":"https://api.github.com/repos/datastax/java-driver/contents/{+path}","compare_url":"https://api.github.com/repos/datastax/java-driver/compare/{base}...{head}","merges_url":"https://api.github.com/repos/datastax/java-driver/merges","archive_url":"https://api.github.com/repos/datastax/java-driver/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/datastax/java-driver/downloads","issues_url":"https://api.github.com/repos/datastax/java-driver/issues{/number}","pulls_url":"https://api.github.com/repos/datastax/java-driver/pulls{/number}","milestones_url":"https://api.github.com/repos/datastax/java-driver/milestones{/number}","notifications_url":"https://api.github.com/repos/datastax/java-driver/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/datastax/java-driver/labels{/name}","releases_url":"https://api.github.com/repos/datastax/java-driver/releases{/id}","created_at":"2012-11-19T18:44:41Z","updated_at":"2015-04-17T09:03:14Z","pushed_at":"2015-04-17T16:05:18Z","git_url":"git://github.com/datastax/java-driver.git","ssh_url":"git@github.com:datastax/java-driver.git","clone_url":"https://github.com/datastax/java-driver.git","svn_url":"https://github.com/datastax/java-driver","homepage":null,"size":19259,"stargazers_count":442,"watchers_count":442,"language":"Java","has_issues":false,"has_downloads":true,"has_wiki":true,"has_pages":true,"forks_count":292,"mirror_url":null,"open_issues_count":31,"forks":292,"open_issues":31,"watchers":442,"default_branch":"2.1"}},"_links":{"self":{"href":"https://api.github.com/repos/datastax/java-driver/pulls/310"},"html":{"href":"https://github.com/datastax/java-driver/pull/310"},"issue":{"href":"https://api.github.com/repos/datastax/java-driver/issues/310"},"comments":{"href":"https://api.github.com/repos/datastax/java-driver/issues/310/comments"},"review_comments":{"href":"https://api.github.com/repos/datastax/java-driver/pulls/310/comments"},"review_comment":{"href":"https://api.github.com/repos/datastax/java-driver/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/datastax/java-driver/pulls/310/commits"},"statuses":{"href":"https://api.github.com/repos/datastax/java-driver/statuses/5c420a6cce407eeb0f1773d91ffdfa7b33dd6796"}}}}