Skip to content

Commit

Permalink
Merge branch 'hotfix/0.1.11' into develop
Browse files Browse the repository at this point in the history
Conflicts:
	version.sbt
  • Loading branch information
johnynek committed Mar 12, 2013
2 parents 971ee75 + 6d82ed8 commit 7e8adcd
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 5 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ For example, average, moving average, max/min, set
analytics.

## Maven
Current version is `0.1.10`. groupid=`"com.twitter"` artifact=`"algebird-core_2.9.2"`.
Current version is `0.1.11`. groupid=`"com.twitter"` artifact=`"algebird-core_2.9.2"`.

## Questions
> Why not use spire?
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -377,6 +377,7 @@ case class CMSHash(a : Int, b : Int, width : Int) extends Function1[Long, Int] {
/**
* The 2-dimensional table of counters used in the Count-Min sketch.
* Each row corresponds to a particular hash function.
* TODO: implement a dense matrix type, and use it here
*/
case class CMSCountsTable(counts : Vector[Vector[Long]]) {
assert(depth > 0, "Table must have at least 1 row.")
Expand Down Expand Up @@ -409,10 +410,14 @@ case class CMSCountsTable(counts : Vector[Vector[Long]]) {
*/
def ++(other : CMSCountsTable) : CMSCountsTable = {
assert((depth, width) == (other.depth, other.width), "Tables must have the same dimensions.")

(0 to (depth - 1)).zip(0 to (width - 1)).foldLeft(this) {
case (table, pos) => table + (pos, other.getCount(pos))
val iil = Monoid.plus[IndexedSeq[IndexedSeq[Long]]](counts, other.counts)
def toVector[V](is: IndexedSeq[V]): Vector[V] = {
is match {
case v: Vector[V] => v
case _ => Vector(is: _*)
}
}
CMSCountsTable(toVector(iil.map { toVector(_) }))
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,13 @@ class CountMinSketchTest extends Specification {
cms.frequency(0).estimate must be_==(0)
cms.frequency(1).estimate must be_==(1)
cms.frequency(2).estimate must be_==(2)

val three = CMS_MONOID.create(Seq(1L, 1L, 1L))
three.frequency(1L).estimate must be_==(3)
val four = CMS_MONOID.create(Seq(1L, 1L, 1L, 1L))
four.frequency(1L).estimate must be_==(4)
val cms2 = CMS_MONOID.plus(four, three)
cms2.frequency(1L).estimate must be_==(7)
}

"estimate inner products" in {
Expand Down
2 changes: 1 addition & 1 deletion version.sbt
Original file line number Diff line number Diff line change
@@ -1 +1 @@
version in ThisBuild := "0.1.10-SNAPSHOT"
version in ThisBuild := "0.1.12-SNAPSHOT"

0 comments on commit 7e8adcd

Please sign in to comment.