{"action":"created","comment":{"url":"https://api.github.com/repos/datastax/spark-cassandra-connector/pulls/comments/24257685","id":24257685,"diff_hunk":"@@ -0,0 +1,125 @@\n+package com.datastax.spark.connector.rdd\n+\n+import java.net.InetAddress\n+\n+\n+import com.datastax.driver.core.{PreparedStatement, Session}\n+import org.apache.spark.{Partitioner, TaskContext, Partition}\n+import org.apache.spark.rdd.RDD\n+import org.apache.spark.SparkContext._\n+import scala.reflect.ClassTag\n+\n+import com.datastax.spark.connector.cql._\n+import com.datastax.spark.connector._\n+import com.datastax.spark.connector.writer._\n+import com.datastax.spark.connector.rdd.reader._\n+import com.datastax.spark.connector.rdd.partitioner.{EndpointPartition, ReplicaPartitioner}\n+\n+// O[ld] Is the type of the RDD we are Mapping From, N[ew] the type were are mapping too Old\n+class CassandraPartitionKeyRDD[O, N] private[connector] (prev: RDD[O],\n+                                      keyspaceName: String,\n+                                      tableName: String,\n+                                      connector: CassandraConnector,\n+                                      columns: ColumnSelector = AllColumns,\n+                                      where: CqlWhereClause = CqlWhereClause.empty,\n+                                      readConf: ReadConf = ReadConf())\n+                                      (implicit oldTag: ClassTag[O], newTag: ClassTag[N],\n+                                       @transient rwf: RowWriterFactory[O], @transient rrf: RowReaderFactory[N])\n+  extends CassandraRDD[N](prev.sparkContext, connector, keyspaceName, tableName, columns, where, readConf, prev.dependencies) {\n+\n+  //Make sure copy operations make new CPKRDDs and not CRDDs\n+  override def copy(columnNames: ColumnSelector = columnNames,\n+                   where: CqlWhereClause = where,\n+                   readConf: ReadConf = readConf, connector: CassandraConnector = connector): CassandraPartitionKeyRDD[O,N] =\n+    new CassandraPartitionKeyRDD[O,N](prev, keyspaceName, tableName, connector, columnNames, where, readConf)\n+\n+  private val converter = ReplicaMapper[O](connector, keyspaceName, tableName)\n+\n+  //We need to make sure we get selectedColumnNames before serialization so that our RowReader is\n+  //built\n+  private val singleKeyCqlQuery: (String) = {\n+    logDebug(\"Generating Single Key Query Prepared Statement String\")\n+    val columns = selectedColumnNames.map(_.cql).mkString(\", \")\n+    val partitionWhere = tableDef.partitionKey.map(_.columnName).map(name => s\"$name = :$name\")","path":"spark-cassandra-connector/src/main/scala/com/datastax/spark/connector/rdd/CassandraPartitionKeyRDD.scala","position":43,"original_position":43,"commit_id":"50f4f60b901d98aee40827a8a615844aefa65a37","original_commit_id":"50f4f60b901d98aee40827a8a615844aefa65a37","user":{"login":"jacek-lewandowski","id":6516951,"avatar_url":"https://avatars.githubusercontent.com/u/6516951?v=3","gravatar_id":"","url":"https://api.github.com/users/jacek-lewandowski","html_url":"https://github.com/jacek-lewandowski","followers_url":"https://api.github.com/users/jacek-lewandowski/followers","following_url":"https://api.github.com/users/jacek-lewandowski/following{/other_user}","gists_url":"https://api.github.com/users/jacek-lewandowski/gists{/gist_id}","starred_url":"https://api.github.com/users/jacek-lewandowski/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jacek-lewandowski/subscriptions","organizations_url":"https://api.github.com/users/jacek-lewandowski/orgs","repos_url":"https://api.github.com/users/jacek-lewandowski/repos","events_url":"https://api.github.com/users/jacek-lewandowski/events{/privacy}","received_events_url":"https://api.github.com/users/jacek-lewandowski/received_events","type":"User","site_admin":false},"body":"i wonder whether you should quote the column names here","created_at":"2015-02-06T17:48:16Z","updated_at":"2015-02-06T17:48:16Z","html_url":"https://github.com/datastax/spark-cassandra-connector/pull/527#discussion_r24257685","pull_request_url":"https://api.github.com/repos/datastax/spark-cassandra-connector/pulls/527","_links":{"self":{"href":"https://api.github.com/repos/datastax/spark-cassandra-connector/pulls/comments/24257685"},"html":{"href":"https://github.com/datastax/spark-cassandra-connector/pull/527#discussion_r24257685"},"pull_request":{"href":"https://api.github.com/repos/datastax/spark-cassandra-connector/pulls/527"}}},"pull_request":{"url":"https://api.github.com/repos/datastax/spark-cassandra-connector/pulls/527","id":28189957,"html_url":"https://github.com/datastax/spark-cassandra-connector/pull/527","diff_url":"https://github.com/datastax/spark-cassandra-connector/pull/527.diff","patch_url":"https://github.com/datastax/spark-cassandra-connector/pull/527.patch","issue_url":"https://api.github.com/repos/datastax/spark-cassandra-connector/issues/527","number":527,"state":"open","locked":false,"title":"SPARKC-25: Initial work to allow RDD's to be used as Keys for C*","user":{"login":"jacek-lewandowski","id":6516951,"avatar_url":"https://avatars.githubusercontent.com/u/6516951?v=3","gravatar_id":"","url":"https://api.github.com/users/jacek-lewandowski","html_url":"https://github.com/jacek-lewandowski","followers_url":"https://api.github.com/users/jacek-lewandowski/followers","following_url":"https://api.github.com/users/jacek-lewandowski/following{/other_user}","gists_url":"https://api.github.com/users/jacek-lewandowski/gists{/gist_id}","starred_url":"https://api.github.com/users/jacek-lewandowski/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jacek-lewandowski/subscriptions","organizations_url":"https://api.github.com/users/jacek-lewandowski/orgs","repos_url":"https://api.github.com/users/jacek-lewandowski/repos","events_url":"https://api.github.com/users/jacek-lewandowski/events{/privacy}","received_events_url":"https://api.github.com/users/jacek-lewandowski/received_events","type":"User","site_admin":false},"body":"Added function keyByReplica\r\n    For keying RDD's based on their cassandra replica placement\r\nAdded function partitionByReplica\r\n    Which keys an RDD based on replica placement then creates\r\n    new partitions based on their replicas","created_at":"2015-01-28T12:35:17Z","updated_at":"2015-02-06T17:48:16Z","closed_at":null,"merged_at":null,"merge_commit_sha":"c23b75548fbaec83927c37d2990c08bd996b5fa5","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/datastax/spark-cassandra-connector/pulls/527/commits","review_comments_url":"https://api.github.com/repos/datastax/spark-cassandra-connector/pulls/527/comments","review_comment_url":"https://api.github.com/repos/datastax/spark-cassandra-connector/pulls/comments/{number}","comments_url":"https://api.github.com/repos/datastax/spark-cassandra-connector/issues/527/comments","statuses_url":"https://api.github.com/repos/datastax/spark-cassandra-connector/statuses/50f4f60b901d98aee40827a8a615844aefa65a37","head":{"label":"datastax:SPARKC-25","ref":"SPARKC-25","sha":"50f4f60b901d98aee40827a8a615844aefa65a37","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":21280887,"name":"spark-cassandra-connector","full_name":"datastax/spark-cassandra-connector","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/spark-cassandra-connector","description":"If you write a Spark application that needs access to Cassandra, this library is for you","fork":false,"url":"https://api.github.com/repos/datastax/spark-cassandra-connector","forks_url":"https://api.github.com/repos/datastax/spark-cassandra-connector/forks","keys_url":"https://api.github.com/repos/datastax/spark-cassandra-connector/keys{/key_id}","collaborators_url":"https://api.github.com/repos/datastax/spark-cassandra-connector/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/datastax/spark-cassandra-connector/teams","hooks_url":"https://api.github.com/repos/datastax/spark-cassandra-connector/hooks","issue_events_url":"https://api.github.com/repos/datastax/spark-cassandra-connector/issues/events{/number}","events_url":"https://api.github.com/repos/datastax/spark-cassandra-connector/events","assignees_url":"https://api.github.com/repos/datastax/spark-cassandra-connector/assignees{/user}","branches_url":"https://api.github.com/repos/datastax/spark-cassandra-connector/branches{/branch}","tags_url":"https://api.github.com/repos/datastax/spark-cassandra-connector/tags","blobs_url":"https://api.github.com/repos/datastax/spark-cassandra-connector/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/datastax/spark-cassandra-connector/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/datastax/spark-cassandra-connector/git/refs{/sha}","trees_url":"https://api.github.com/repos/datastax/spark-cassandra-connector/git/trees{/sha}","statuses_url":"https://api.github.com/repos/datastax/spark-cassandra-connector/statuses/{sha}","languages_url":"https://api.github.com/repos/datastax/spark-cassandra-connector/languages","stargazers_url":"https://api.github.com/repos/datastax/spark-cassandra-connector/stargazers","contributors_url":"https://api.github.com/repos/datastax/spark-cassandra-connector/contributors","subscribers_url":"https://api.github.com/repos/datastax/spark-cassandra-connector/subscribers","subscription_url":"https://api.github.com/repos/datastax/spark-cassandra-connector/subscription","commits_url":"https://api.github.com/repos/datastax/spark-cassandra-connector/commits{/sha}","git_commits_url":"https://api.github.com/repos/datastax/spark-cassandra-connector/git/commits{/sha}","comments_url":"https://api.github.com/repos/datastax/spark-cassandra-connector/comments{/number}","issue_comment_url":"https://api.github.com/repos/datastax/spark-cassandra-connector/issues/comments/{number}","contents_url":"https://api.github.com/repos/datastax/spark-cassandra-connector/contents/{+path}","compare_url":"https://api.github.com/repos/datastax/spark-cassandra-connector/compare/{base}...{head}","merges_url":"https://api.github.com/repos/datastax/spark-cassandra-connector/merges","archive_url":"https://api.github.com/repos/datastax/spark-cassandra-connector/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/datastax/spark-cassandra-connector/downloads","issues_url":"https://api.github.com/repos/datastax/spark-cassandra-connector/issues{/number}","pulls_url":"https://api.github.com/repos/datastax/spark-cassandra-connector/pulls{/number}","milestones_url":"https://api.github.com/repos/datastax/spark-cassandra-connector/milestones{/number}","notifications_url":"https://api.github.com/repos/datastax/spark-cassandra-connector/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/datastax/spark-cassandra-connector/labels{/name}","releases_url":"https://api.github.com/repos/datastax/spark-cassandra-connector/releases{/id}","created_at":"2014-06-27T15:45:54Z","updated_at":"2015-02-06T16:26:15Z","pushed_at":"2015-02-05T19:41:40Z","git_url":"git://github.com/datastax/spark-cassandra-connector.git","ssh_url":"git@github.com:datastax/spark-cassandra-connector.git","clone_url":"https://github.com/datastax/spark-cassandra-connector.git","svn_url":"https://github.com/datastax/spark-cassandra-connector","homepage":"","size":6102,"stargazers_count":373,"watchers_count":373,"language":"Scala","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":107,"mirror_url":null,"open_issues_count":27,"forks":107,"open_issues":27,"watchers":373,"default_branch":"master"}},"base":{"label":"datastax:master","ref":"master","sha":"200ec7b4e5eee388d6cec3a69f12b6d08f527130","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":21280887,"name":"spark-cassandra-connector","full_name":"datastax/spark-cassandra-connector","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/spark-cassandra-connector","description":"If you write a Spark application that needs access to Cassandra, this library is for you","fork":false,"url":"https://api.github.com/repos/datastax/spark-cassandra-connector","forks_url":"https://api.github.com/repos/datastax/spark-cassandra-connector/forks","keys_url":"https://api.github.com/repos/datastax/spark-cassandra-connector/keys{/key_id}","collaborators_url":"https://api.github.com/repos/datastax/spark-cassandra-connector/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/datastax/spark-cassandra-connector/teams","hooks_url":"https://api.github.com/repos/datastax/spark-cassandra-connector/hooks","issue_events_url":"https://api.github.com/repos/datastax/spark-cassandra-connector/issues/events{/number}","events_url":"https://api.github.com/repos/datastax/spark-cassandra-connector/events","assignees_url":"https://api.github.com/repos/datastax/spark-cassandra-connector/assignees{/user}","branches_url":"https://api.github.com/repos/datastax/spark-cassandra-connector/branches{/branch}","tags_url":"https://api.github.com/repos/datastax/spark-cassandra-connector/tags","blobs_url":"https://api.github.com/repos/datastax/spark-cassandra-connector/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/datastax/spark-cassandra-connector/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/datastax/spark-cassandra-connector/git/refs{/sha}","trees_url":"https://api.github.com/repos/datastax/spark-cassandra-connector/git/trees{/sha}","statuses_url":"https://api.github.com/repos/datastax/spark-cassandra-connector/statuses/{sha}","languages_url":"https://api.github.com/repos/datastax/spark-cassandra-connector/languages","stargazers_url":"https://api.github.com/repos/datastax/spark-cassandra-connector/stargazers","contributors_url":"https://api.github.com/repos/datastax/spark-cassandra-connector/contributors","subscribers_url":"https://api.github.com/repos/datastax/spark-cassandra-connector/subscribers","subscription_url":"https://api.github.com/repos/datastax/spark-cassandra-connector/subscription","commits_url":"https://api.github.com/repos/datastax/spark-cassandra-connector/commits{/sha}","git_commits_url":"https://api.github.com/repos/datastax/spark-cassandra-connector/git/commits{/sha}","comments_url":"https://api.github.com/repos/datastax/spark-cassandra-connector/comments{/number}","issue_comment_url":"https://api.github.com/repos/datastax/spark-cassandra-connector/issues/comments/{number}","contents_url":"https://api.github.com/repos/datastax/spark-cassandra-connector/contents/{+path}","compare_url":"https://api.github.com/repos/datastax/spark-cassandra-connector/compare/{base}...{head}","merges_url":"https://api.github.com/repos/datastax/spark-cassandra-connector/merges","archive_url":"https://api.github.com/repos/datastax/spark-cassandra-connector/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/datastax/spark-cassandra-connector/downloads","issues_url":"https://api.github.com/repos/datastax/spark-cassandra-connector/issues{/number}","pulls_url":"https://api.github.com/repos/datastax/spark-cassandra-connector/pulls{/number}","milestones_url":"https://api.github.com/repos/datastax/spark-cassandra-connector/milestones{/number}","notifications_url":"https://api.github.com/repos/datastax/spark-cassandra-connector/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/datastax/spark-cassandra-connector/labels{/name}","releases_url":"https://api.github.com/repos/datastax/spark-cassandra-connector/releases{/id}","created_at":"2014-06-27T15:45:54Z","updated_at":"2015-02-06T16:26:15Z","pushed_at":"2015-02-05T19:41:40Z","git_url":"git://github.com/datastax/spark-cassandra-connector.git","ssh_url":"git@github.com:datastax/spark-cassandra-connector.git","clone_url":"https://github.com/datastax/spark-cassandra-connector.git","svn_url":"https://github.com/datastax/spark-cassandra-connector","homepage":"","size":6102,"stargazers_count":373,"watchers_count":373,"language":"Scala","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":107,"mirror_url":null,"open_issues_count":27,"forks":107,"open_issues":27,"watchers":373,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/datastax/spark-cassandra-connector/pulls/527"},"html":{"href":"https://github.com/datastax/spark-cassandra-connector/pull/527"},"issue":{"href":"https://api.github.com/repos/datastax/spark-cassandra-connector/issues/527"},"comments":{"href":"https://api.github.com/repos/datastax/spark-cassandra-connector/issues/527/comments"},"review_comments":{"href":"https://api.github.com/repos/datastax/spark-cassandra-connector/pulls/527/comments"},"review_comment":{"href":"https://api.github.com/repos/datastax/spark-cassandra-connector/pulls/comments/{number}"},"commits":{"href":"https://api.github.com/repos/datastax/spark-cassandra-connector/pulls/527/commits"},"statuses":{"href":"https://api.github.com/repos/datastax/spark-cassandra-connector/statuses/50f4f60b901d98aee40827a8a615844aefa65a37"}}}}