Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

restore legacy ReduceOperations.approxUniques; rename bijection-aware…

… method to approximateUniqueCount
  • Loading branch information...
commit a2cac768e632edf088e9db6b32b6ac11bb25f687 1 parent a8bb6ea
@asiegel34 authored
Showing with 10 additions and 1 deletion.
  1. +10 −1 src/main/scala/com/twitter/scalding/ReduceOperations.scala
View
11 src/main/scala/com/twitter/scalding/ReduceOperations.scala
@@ -94,7 +94,7 @@ trait ReduceOperations[+Self <: ReduceOperations[Self]] extends java.io.Serializ
* 0.25% error ~ 256kB
* }}}
*/
- def approxUniques[T <% Array[Byte]](f : (Fields, Fields), errPercent : Double = 1.0) = {
+ def approximateUniqueCount[T <% Array[Byte]](f : (Fields, Fields), errPercent : Double = 1.0) = {
hyperLogLogMap[T,Double](f, errPercent) { _.estimatedSize }
}
@@ -102,6 +102,15 @@ trait ReduceOperations[+Self <: ReduceOperations[Self]] extends java.io.Serializ
hyperLogLogMap[T,HLL](f, errPercent) { hll => hll }
}
+ @deprecated("use of approximateUniqueCount is preferred.", "0.8.3")
+ def approxUniques(f : (Fields, Fields), errPercent : Double = 1.0) = {
+ // Legacy (pre-bijection) approximate unique count that uses in.toString.getBytes to
+ // obtain a long hash code. We specify the kludgy CTuple => Array[Byte] bijection
+ // explicitly.
+ hyperLogLogMap[CTuple,Double](f, errPercent) { _.estimatedSize }
+ { (in : CTuple) => in.toString.getBytes("UTF-8") }
+ }
+
private[this] def hyperLogLogMap[T <% Array[Byte],U](f : (Fields, Fields), errPercent : Double = 1.0)(fn : HLL => U) = {
//bits = log(m) == 2 *log(104/errPercent) = 2log(104) - 2*log(errPercent)
def log2(x : Double) = scala.math.log(x)/scala.math.log(2.0)
Please sign in to comment.
Something went wrong with that request. Please try again.