{"action":"created","comment":{"url":"https://api.github.com/repos/twitter/storehaus/pulls/comments/46881593","id":46881593,"diff_hunk":"@@ -0,0 +1,294 @@\n+/*\n+ * Copyright 2014 Twitter, Inc.\n+ *\n+ * Licensed under the Apache License, Version 2.0 (the \"License\"); you may\n+ * not use this file except in compliance with the License. You may obtain\n+ * a copy of the License at\n+ *\n+ *     http://www.apache.org/licenses/LICENSE-2.0\n+ *\n+ * Unless required by applicable law or agreed to in writing, software\n+ * distributed under the License is distributed on an \"AS IS\" BASIS,\n+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n+ * See the License for the specific language governing permissions and\n+ * limitations under the License.\n+ */\n+package com.twitter.storehaus.cassandra.cql\n+\n+import com.twitter.util.{Duration, Future, FuturePool, Return, Time, Throw}\n+import com.twitter.concurrent.Spool\n+import com.datastax.driver.core.{BatchStatement, ConsistencyLevel, ResultSet, Row, Statement}\n+import com.datastax.driver.core.policies.{LoadBalancingPolicy, Policies, ReconnectionPolicy, RetryPolicy, RoundRobinPolicy, TokenAwarePolicy}\n+import com.datastax.driver.core.querybuilder.{BuiltStatement, Clause, QueryBuilder, Update, Select}\n+import com.twitter.storehaus.{IterableStore, QueryableStore, ReadableStore, Store}\n+import com.websudos.phantom.CassandraPrimitive\n+import java.util.concurrent.{Executors, TimeUnit}\n+import scala.annotation.tailrec\n+import scala.collection.JavaConversions._\n+import scala.collection.mutable.ArrayBuffer\n+import scala.language.implicitConversions\n+import shapeless._\n+import HList._\n+import ops.hlist.Mapper\n+import ops.hlist.Mapped\n+import poly._\n+import Nat._\n+import UnaryTCConstraint._\n+import org.slf4j.LoggerFactory\n+\n+object AbstractCQLCassandraCompositeStore {\n+  \n+  /**\n+   * used for mapping the keys in the HLists to Strings\n+   */\n+  object keyStringMapping extends (CassandraPrimitive ~>> String) {\n+    override def apply[T](c: CassandraPrimitive[T]) = c.cassandraType\n+  }\n+  \n+  /**\n+   * used to map over an example key to implicit serializers\n+   */\n+  object cassandraSerializerCreation extends Poly1 {\n+    implicit def default[T : CassandraPrimitive] = at[T](_ => implicitly[CassandraPrimitive[T]])\n+  }\n+\n+  /**\n+   * creates an HList of serializers (CasasandraPrimitives) given an example \n+   * key HList and pulls serializers out of implicit scope.\n+   */\n+  def getSerializerHListByExample[KL <: HList, SL <: HList](keys: KL)(implicit mapper: Mapper.Aux[cassandraSerializerCreation.type, KL, SL]) : SL = {\n+    keys.map(cassandraSerializerCreation)\n+  } \n+\n+  /**\n+   * helper trait for declaring the HList recursive function \n+   * to append keys on an ArrayBuffer in a type safe way\n+   */\n+  trait Append2Composite[R <: ArrayBuffer[Clause], K <: HList, Q <: HList] {\n+    def apply(r: R, k: K, s: List[String], ser: Q): Unit\n+  }\n+\n+  /**\n+   * helper implicits for the recursion itself\n+   */\n+  object Append2Composite {\n+    implicit def hnilAppend2Composite[R <: ArrayBuffer[Clause]] = new Append2Composite[R, HNil, HNil] {\n+      override def apply(r: R, k: HNil, s: List[String], ser: HNil): Unit = {}\n+    }\n+    implicit def hlistAppend2Composite[R <: ArrayBuffer[Clause], M, K <: HList, P, Q <: HList](\n+      implicit a2c: Append2Composite[R, K, Q]) = new Append2Composite[R, M :: K, P :: Q] {\n+    \toverride def apply(r: R, k: M :: K, s: List[String], ser: P :: Q): Unit = {\n+   \t      r.add(QueryBuilder.eq(s\"\"\"\\\"${s.head}\\\"\"\"\", ser.head.asInstanceOf[CassandraPrimitive[Any]].toCType(k.head)))\n+    \t  a2c(r, k.tail, s.tail, ser.tail) \n+    \t}\n+      }\n+  }\n+\n+  /**\n+   * recursive function callee implicit\n+   */\n+  implicit def append2Composite[R <: ArrayBuffer[Clause], K <: HList, S <: List[String], Q <: HList](r: R)(k: K, s: List[String], ser: Q)\n+  \t(implicit a2c: Append2Composite[R, K, Q]) = a2c(r, k, s, ser) \n+    \n+  /**\n+   * helper trait for declaring the HList recursive function \n+   * to create a key from a row\n+   * K is the type of HList to return the key, S are the serializers\n+   */\n+  trait Row2Result[K <: HList, S <: HList] {","path":"storehaus-cassandra/src/main/scala/com/twitter/storehaus/cassandra/cql/AbstractCQLCassandraCompositeStore.scala","position":98,"original_position":98,"commit_id":"3b9975c68b8e7168cc025eea235b76184253acad","original_commit_id":"3b9975c68b8e7168cc025eea235b76184253acad","user":{"login":"travisbrown","id":316049,"avatar_url":"https://avatars.githubusercontent.com/u/316049?v=3","gravatar_id":"","url":"https://api.github.com/users/travisbrown","html_url":"https://github.com/travisbrown","followers_url":"https://api.github.com/users/travisbrown/followers","following_url":"https://api.github.com/users/travisbrown/following{/other_user}","gists_url":"https://api.github.com/users/travisbrown/gists{/gist_id}","starred_url":"https://api.github.com/users/travisbrown/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/travisbrown/subscriptions","organizations_url":"https://api.github.com/users/travisbrown/orgs","repos_url":"https://api.github.com/users/travisbrown/repos","events_url":"https://api.github.com/users/travisbrown/events{/privacy}","received_events_url":"https://api.github.com/users/travisbrown/received_events","type":"User","site_admin":false},"body":"Sorry, I was using `DepFn1` as shorthand for the approach of making the uniquely-determined type parameter a type member. If the `apply` on `DepFn1` doesn't have the right signature, it'd make sense just to change this to `RowResult[K <: HList] { type Out <: HList ...`.","created_at":"2015-12-07T21:39:37Z","updated_at":"2015-12-07T21:39:37Z","html_url":"https://github.com/twitter/storehaus/pull/282#discussion_r46881593","pull_request_url":"https://api.github.com/repos/twitter/storehaus/pulls/282","_links":{"self":{"href":"https://api.github.com/repos/twitter/storehaus/pulls/comments/46881593"},"html":{"href":"https://github.com/twitter/storehaus/pull/282#discussion_r46881593"},"pull_request":{"href":"https://api.github.com/repos/twitter/storehaus/pulls/282"}}},"pull_request":{"url":"https://api.github.com/repos/twitter/storehaus/pulls/282","id":44330209,"html_url":"https://github.com/twitter/storehaus/pull/282","diff_url":"https://github.com/twitter/storehaus/pull/282.diff","patch_url":"https://github.com/twitter/storehaus/pull/282.patch","issue_url":"https://api.github.com/repos/twitter/storehaus/issues/282","number":282,"state":"open","locked":false,"title":"Feature/storehaus cassandra only","user":{"login":"Rechzen","id":13225891,"avatar_url":"https://avatars.githubusercontent.com/u/13225891?v=3","gravatar_id":"","url":"https://api.github.com/users/Rechzen","html_url":"https://github.com/Rechzen","followers_url":"https://api.github.com/users/Rechzen/followers","following_url":"https://api.github.com/users/Rechzen/following{/other_user}","gists_url":"https://api.github.com/users/Rechzen/gists{/gist_id}","starred_url":"https://api.github.com/users/Rechzen/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Rechzen/subscriptions","organizations_url":"https://api.github.com/users/Rechzen/orgs","repos_url":"https://api.github.com/users/Rechzen/repos","events_url":"https://api.github.com/users/Rechzen/events{/privacy}","received_events_url":"https://api.github.com/users/Rechzen/received_events","type":"User","site_admin":false},"body":"As discussed in #211 ","created_at":"2015-09-07T08:18:30Z","updated_at":"2015-12-07T21:39:37Z","closed_at":null,"merged_at":null,"merge_commit_sha":"e9158b902945a913e550c6ae0d239c2c759f4eb2","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/twitter/storehaus/pulls/282/commits","review_comments_url":"https://api.github.com/repos/twitter/storehaus/pulls/282/comments","review_comment_url":"https://api.github.com/repos/twitter/storehaus/pulls/comments{/number}","comments_url":"https://api.github.com/repos/twitter/storehaus/issues/282/comments","statuses_url":"https://api.github.com/repos/twitter/storehaus/statuses/3b9975c68b8e7168cc025eea235b76184253acad","head":{"label":"AndreasPetter:feature/storehaus-cassandra-only","ref":"feature/storehaus-cassandra-only","sha":"3b9975c68b8e7168cc025eea235b76184253acad","user":{"login":"AndreasPetter","id":6032072,"avatar_url":"https://avatars.githubusercontent.com/u/6032072?v=3","gravatar_id":"","url":"https://api.github.com/users/AndreasPetter","html_url":"https://github.com/AndreasPetter","followers_url":"https://api.github.com/users/AndreasPetter/followers","following_url":"https://api.github.com/users/AndreasPetter/following{/other_user}","gists_url":"https://api.github.com/users/AndreasPetter/gists{/gist_id}","starred_url":"https://api.github.com/users/AndreasPetter/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/AndreasPetter/subscriptions","organizations_url":"https://api.github.com/users/AndreasPetter/orgs","repos_url":"https://api.github.com/users/AndreasPetter/repos","events_url":"https://api.github.com/users/AndreasPetter/events{/privacy}","received_events_url":"https://api.github.com/users/AndreasPetter/received_events","type":"User","site_admin":false},"repo":{"id":16484791,"name":"storehaus","full_name":"AndreasPetter/storehaus","owner":{"login":"AndreasPetter","id":6032072,"avatar_url":"https://avatars.githubusercontent.com/u/6032072?v=3","gravatar_id":"","url":"https://api.github.com/users/AndreasPetter","html_url":"https://github.com/AndreasPetter","followers_url":"https://api.github.com/users/AndreasPetter/followers","following_url":"https://api.github.com/users/AndreasPetter/following{/other_user}","gists_url":"https://api.github.com/users/AndreasPetter/gists{/gist_id}","starred_url":"https://api.github.com/users/AndreasPetter/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/AndreasPetter/subscriptions","organizations_url":"https://api.github.com/users/AndreasPetter/orgs","repos_url":"https://api.github.com/users/AndreasPetter/repos","events_url":"https://api.github.com/users/AndreasPetter/events{/privacy}","received_events_url":"https://api.github.com/users/AndreasPetter/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/AndreasPetter/storehaus","description":"Storehaus is a library that makes it easy to work with asynchronous key value stores","fork":true,"url":"https://api.github.com/repos/AndreasPetter/storehaus","forks_url":"https://api.github.com/repos/AndreasPetter/storehaus/forks","keys_url":"https://api.github.com/repos/AndreasPetter/storehaus/keys{/key_id}","collaborators_url":"https://api.github.com/repos/AndreasPetter/storehaus/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/AndreasPetter/storehaus/teams","hooks_url":"https://api.github.com/repos/AndreasPetter/storehaus/hooks","issue_events_url":"https://api.github.com/repos/AndreasPetter/storehaus/issues/events{/number}","events_url":"https://api.github.com/repos/AndreasPetter/storehaus/events","assignees_url":"https://api.github.com/repos/AndreasPetter/storehaus/assignees{/user}","branches_url":"https://api.github.com/repos/AndreasPetter/storehaus/branches{/branch}","tags_url":"https://api.github.com/repos/AndreasPetter/storehaus/tags","blobs_url":"https://api.github.com/repos/AndreasPetter/storehaus/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/AndreasPetter/storehaus/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/AndreasPetter/storehaus/git/refs{/sha}","trees_url":"https://api.github.com/repos/AndreasPetter/storehaus/git/trees{/sha}","statuses_url":"https://api.github.com/repos/AndreasPetter/storehaus/statuses/{sha}","languages_url":"https://api.github.com/repos/AndreasPetter/storehaus/languages","stargazers_url":"https://api.github.com/repos/AndreasPetter/storehaus/stargazers","contributors_url":"https://api.github.com/repos/AndreasPetter/storehaus/contributors","subscribers_url":"https://api.github.com/repos/AndreasPetter/storehaus/subscribers","subscription_url":"https://api.github.com/repos/AndreasPetter/storehaus/subscription","commits_url":"https://api.github.com/repos/AndreasPetter/storehaus/commits{/sha}","git_commits_url":"https://api.github.com/repos/AndreasPetter/storehaus/git/commits{/sha}","comments_url":"https://api.github.com/repos/AndreasPetter/storehaus/comments{/number}","issue_comment_url":"https://api.github.com/repos/AndreasPetter/storehaus/issues/comments{/number}","contents_url":"https://api.github.com/repos/AndreasPetter/storehaus/contents/{+path}","compare_url":"https://api.github.com/repos/AndreasPetter/storehaus/compare/{base}...{head}","merges_url":"https://api.github.com/repos/AndreasPetter/storehaus/merges","archive_url":"https://api.github.com/repos/AndreasPetter/storehaus/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/AndreasPetter/storehaus/downloads","issues_url":"https://api.github.com/repos/AndreasPetter/storehaus/issues{/number}","pulls_url":"https://api.github.com/repos/AndreasPetter/storehaus/pulls{/number}","milestones_url":"https://api.github.com/repos/AndreasPetter/storehaus/milestones{/number}","notifications_url":"https://api.github.com/repos/AndreasPetter/storehaus/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/AndreasPetter/storehaus/labels{/name}","releases_url":"https://api.github.com/repos/AndreasPetter/storehaus/releases{/id}","created_at":"2014-02-03T16:20:59Z","updated_at":"2015-05-04T14:38:15Z","pushed_at":"2015-09-07T19:23:17Z","git_url":"git://github.com/AndreasPetter/storehaus.git","ssh_url":"git@github.com:AndreasPetter/storehaus.git","clone_url":"https://github.com/AndreasPetter/storehaus.git","svn_url":"https://github.com/AndreasPetter/storehaus","homepage":"","size":2841,"stargazers_count":1,"watchers_count":1,"language":"Scala","has_issues":false,"has_downloads":true,"has_wiki":true,"has_pages":true,"forks_count":1,"mirror_url":null,"open_issues_count":0,"forks":1,"open_issues":0,"watchers":1,"default_branch":"feature/storehaus-cacading"}},"base":{"label":"twitter:develop","ref":"develop","sha":"03b627e14d4064dd8079e52c526eafcee9cdcf7f","user":{"login":"twitter","id":50278,"avatar_url":"https://avatars.githubusercontent.com/u/50278?v=3","gravatar_id":"","url":"https://api.github.com/users/twitter","html_url":"https://github.com/twitter","followers_url":"https://api.github.com/users/twitter/followers","following_url":"https://api.github.com/users/twitter/following{/other_user}","gists_url":"https://api.github.com/users/twitter/gists{/gist_id}","starred_url":"https://api.github.com/users/twitter/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/twitter/subscriptions","organizations_url":"https://api.github.com/users/twitter/orgs","repos_url":"https://api.github.com/users/twitter/repos","events_url":"https://api.github.com/users/twitter/events{/privacy}","received_events_url":"https://api.github.com/users/twitter/received_events","type":"Organization","site_admin":false},"repo":{"id":7762878,"name":"storehaus","full_name":"twitter/storehaus","owner":{"login":"twitter","id":50278,"avatar_url":"https://avatars.githubusercontent.com/u/50278?v=3","gravatar_id":"","url":"https://api.github.com/users/twitter","html_url":"https://github.com/twitter","followers_url":"https://api.github.com/users/twitter/followers","following_url":"https://api.github.com/users/twitter/following{/other_user}","gists_url":"https://api.github.com/users/twitter/gists{/gist_id}","starred_url":"https://api.github.com/users/twitter/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/twitter/subscriptions","organizations_url":"https://api.github.com/users/twitter/orgs","repos_url":"https://api.github.com/users/twitter/repos","events_url":"https://api.github.com/users/twitter/events{/privacy}","received_events_url":"https://api.github.com/users/twitter/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/twitter/storehaus","description":"Storehaus is a library that makes it easy to work with asynchronous key value stores","fork":false,"url":"https://api.github.com/repos/twitter/storehaus","forks_url":"https://api.github.com/repos/twitter/storehaus/forks","keys_url":"https://api.github.com/repos/twitter/storehaus/keys{/key_id}","collaborators_url":"https://api.github.com/repos/twitter/storehaus/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/twitter/storehaus/teams","hooks_url":"https://api.github.com/repos/twitter/storehaus/hooks","issue_events_url":"https://api.github.com/repos/twitter/storehaus/issues/events{/number}","events_url":"https://api.github.com/repos/twitter/storehaus/events","assignees_url":"https://api.github.com/repos/twitter/storehaus/assignees{/user}","branches_url":"https://api.github.com/repos/twitter/storehaus/branches{/branch}","tags_url":"https://api.github.com/repos/twitter/storehaus/tags","blobs_url":"https://api.github.com/repos/twitter/storehaus/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/twitter/storehaus/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/twitter/storehaus/git/refs{/sha}","trees_url":"https://api.github.com/repos/twitter/storehaus/git/trees{/sha}","statuses_url":"https://api.github.com/repos/twitter/storehaus/statuses/{sha}","languages_url":"https://api.github.com/repos/twitter/storehaus/languages","stargazers_url":"https://api.github.com/repos/twitter/storehaus/stargazers","contributors_url":"https://api.github.com/repos/twitter/storehaus/contributors","subscribers_url":"https://api.github.com/repos/twitter/storehaus/subscribers","subscription_url":"https://api.github.com/repos/twitter/storehaus/subscription","commits_url":"https://api.github.com/repos/twitter/storehaus/commits{/sha}","git_commits_url":"https://api.github.com/repos/twitter/storehaus/git/commits{/sha}","comments_url":"https://api.github.com/repos/twitter/storehaus/comments{/number}","issue_comment_url":"https://api.github.com/repos/twitter/storehaus/issues/comments{/number}","contents_url":"https://api.github.com/repos/twitter/storehaus/contents/{+path}","compare_url":"https://api.github.com/repos/twitter/storehaus/compare/{base}...{head}","merges_url":"https://api.github.com/repos/twitter/storehaus/merges","archive_url":"https://api.github.com/repos/twitter/storehaus/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/twitter/storehaus/downloads","issues_url":"https://api.github.com/repos/twitter/storehaus/issues{/number}","pulls_url":"https://api.github.com/repos/twitter/storehaus/pulls{/number}","milestones_url":"https://api.github.com/repos/twitter/storehaus/milestones{/number}","notifications_url":"https://api.github.com/repos/twitter/storehaus/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/twitter/storehaus/labels{/name}","releases_url":"https://api.github.com/repos/twitter/storehaus/releases{/id}","created_at":"2013-01-22T22:34:05Z","updated_at":"2015-12-07T09:28:30Z","pushed_at":"2015-10-20T17:27:51Z","git_url":"git://github.com/twitter/storehaus.git","ssh_url":"git@github.com:twitter/storehaus.git","clone_url":"https://github.com/twitter/storehaus.git","svn_url":"https://github.com/twitter/storehaus","homepage":"","size":4434,"stargazers_count":339,"watchers_count":339,"language":"Scala","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":true,"forks_count":52,"mirror_url":null,"open_issues_count":72,"forks":52,"open_issues":72,"watchers":339,"default_branch":"develop"}},"_links":{"self":{"href":"https://api.github.com/repos/twitter/storehaus/pulls/282"},"html":{"href":"https://github.com/twitter/storehaus/pull/282"},"issue":{"href":"https://api.github.com/repos/twitter/storehaus/issues/282"},"comments":{"href":"https://api.github.com/repos/twitter/storehaus/issues/282/comments"},"review_comments":{"href":"https://api.github.com/repos/twitter/storehaus/pulls/282/comments"},"review_comment":{"href":"https://api.github.com/repos/twitter/storehaus/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/twitter/storehaus/pulls/282/commits"},"statuses":{"href":"https://api.github.com/repos/twitter/storehaus/statuses/3b9975c68b8e7168cc025eea235b76184253acad"}}}}