From d5124d91afe8e4a275d7de90187ce8967505d53a Mon Sep 17 00:00:00 2001 From: Sam Ritchie Date: Thu, 12 Sep 2013 13:57:40 -0700 Subject: [PATCH 1/2] saving. --- project/Build.scala | 2 +- .../summingbird/scalding/ScaldingStore.scala | 20 ++++++++++++++----- 2 files changed, 16 insertions(+), 6 deletions(-) diff --git a/project/Build.scala b/project/Build.scala index cab13096e..47283257f 100644 --- a/project/Build.scala +++ b/project/Build.scala @@ -185,8 +185,8 @@ object SummingbirdBuild extends Build { "com.backtype" % "dfs-datastores" % dfsDatastoresVersion, "com.backtype" % "dfs-datastores-cascading" % dfsDatastoresVersion, "com.twitter" %% "algebird-core" % algebirdVersion, - "com.twitter" %% "algebird-bijection" % algebirdVersion, withCross("com.twitter" %% "bijection-json" % bijectionVersion), + withCross("com.twitter" %% "bijection-algebird" % bijectionVersion), withCross("com.twitter" %% "chill" % chillVersion), "com.twitter" %% "scalding-core" % scaldingVersion, withCross("com.twitter" %% "scalding-commons" % "0.2.0") diff --git a/summingbird-scalding/src/main/scala/com/twitter/summingbird/scalding/ScaldingStore.scala b/summingbird-scalding/src/main/scala/com/twitter/summingbird/scalding/ScaldingStore.scala index 59a612b14..2fef0c338 100644 --- a/summingbird-scalding/src/main/scala/com/twitter/summingbird/scalding/ScaldingStore.scala +++ b/summingbird-scalding/src/main/scala/com/twitter/summingbird/scalding/ScaldingStore.scala @@ -16,7 +16,8 @@ package com.twitter.summingbird.scalding -import com.twitter.algebird.bijection.BijectedSemigroup +import com.twitter.bijection.ImplicitBijection +import com.twitter.bijection.algebird.BijectedSemigroup import com.twitter.algebird.{Monoid, Semigroup} import com.twitter.algebird.{ Universe, Empty, Interval, Intersection, InclusiveLower, ExclusiveUpper, InclusiveUpper } import com.twitter.algebird.monad.{StateWithError, Reader} @@ -132,13 +133,22 @@ trait BatchedScaldingStore[K, V] extends ScaldingStore[K, V] { self => * BijectedSemigroup[U, V], Returns the backing Bijection[U, V] * and Semigroup[U]; else None. */ - def unpackBijectedSemigroup[U]: Option[(Bijection[V, U], Semigroup[U])] = + def unpackBijectedSemigroup[U]: Option[(Bijection[V, U], Semigroup[U])] = { sg match { - case innerSg: BijectedSemigroup[U, V] => Some( - innerSg.bijection -> innerSg.sg - ) + case innerSg: BijectedSemigroup[_, _] => + def getField[F: ClassManifest](fieldName: String): F = { + val f = classOf[BijectedSemigroup[_, _]].getDeclaredField(fieldName) + f.setAccessible(true) + implicitly[ClassManifest[F]] + .erasure.asInstanceOf[Class[F]].cast(f.get(innerSg)) + } + Some(( + getField[ImplicitBijection[U, V]]("bij").bijection.inverse, + getField[Semigroup[U]]("sg") + )) case _ => None } + } def redFn[T: Semigroup] : (((Long, T), (Long, T)) => (Long, T)) = { (left, right) => From 11f6cc07453ebd1c06df11b340047f4762a4f625 Mon Sep 17 00:00:00 2001 From: Sam Ritchie Date: Thu, 12 Sep 2013 13:58:44 -0700 Subject: [PATCH 2/2] remove redundant braces --- .../scala/com/twitter/summingbird/scalding/ScaldingStore.scala | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/summingbird-scalding/src/main/scala/com/twitter/summingbird/scalding/ScaldingStore.scala b/summingbird-scalding/src/main/scala/com/twitter/summingbird/scalding/ScaldingStore.scala index 2fef0c338..b2f42d305 100644 --- a/summingbird-scalding/src/main/scala/com/twitter/summingbird/scalding/ScaldingStore.scala +++ b/summingbird-scalding/src/main/scala/com/twitter/summingbird/scalding/ScaldingStore.scala @@ -133,7 +133,7 @@ trait BatchedScaldingStore[K, V] extends ScaldingStore[K, V] { self => * BijectedSemigroup[U, V], Returns the backing Bijection[U, V] * and Semigroup[U]; else None. */ - def unpackBijectedSemigroup[U]: Option[(Bijection[V, U], Semigroup[U])] = { + def unpackBijectedSemigroup[U]: Option[(Bijection[V, U], Semigroup[U])] = sg match { case innerSg: BijectedSemigroup[_, _] => def getField[F: ClassManifest](fieldName: String): F = { @@ -148,7 +148,6 @@ trait BatchedScaldingStore[K, V] extends ScaldingStore[K, V] { self => )) case _ => None } - } def redFn[T: Semigroup] : (((Long, T), (Long, T)) => (Long, T)) = { (left, right) =>