Skip to content

Commit

Permalink
Re-order the private constructor so that its signature looks differen…
Browse files Browse the repository at this point in the history
…t erased than the old constructor. Add the old constructor as an overloaded constructor so that we can keep our binary compatibility to a minimum

We now are just missing copy constructors:

[error]  * synthetic method copy$default$6()scala.Option in class com.twitter.algebird.QTree does not have a correspondent in new version
[error]    filter with: ProblemFilters.exclude[MissingMethodProblem]("com.twitter.algebird.QTree.copy$default$6")
[error]  * synthetic method com$twitter$algebird$QTree$$findRankUpperBound(Long)scala.Option in class com.twitter.algebird.QTree does not have a correspondent in new version
[error]    filter with: ProblemFilters.exclude[MissingMethodProblem]("com.twitter.algebird.QTree.com$twitter$algebird$QTree$$findRankUpperBound")
[error]  * synthetic method copy$default$2()Int in class com.twitter.algebird.QTree does not have a correspondent in new version
[error]    filter with: ProblemFilters.exclude[MissingMethodProblem]("com.twitter.algebird.QTree.copy$default$2")
[error]  * synthetic method copy$default$5()scala.Option in class com.twitter.algebird.QTree does not have a correspondent in new version
[error]    filter with: ProblemFilters.exclude[MissingMethodProblem]("com.twitter.algebird.QTree.copy$default$5")
[error]  * synthetic method com$twitter$algebird$QTree$$findRankLowerBound(Long)scala.Option in class com.twitter.algebird.QTree does not have a correspondent in new version
[error]    filter with: ProblemFilters.exclude[MissingMethodProblem]("com.twitter.algebird.QTree.com$twitter$algebird$QTree$$findRankLowerBound")
[error]  * method copy(Long,Int,Long,java.lang.Object,scala.Option,scala.Option)com.twitter.algebird.QTree in class com.twitter.algebird.QTree does not have a correspondent in new version
[error]    filter with: ProblemFilters.exclude[MissingMethodProblem]("com.twitter.algebird.QTree.copy")
[error]  * synthetic method copy$default$1()Long in class com.twitter.algebird.QTree does not have a correspondent in new version
[error]    filter with: ProblemFilters.exclude[MissingMethodProblem]("com.twitter.algebird.QTree.copy$default$1")
[error]  * synthetic method copy$default$4()java.lang.Object in class com.twitter.algebird.QTree does not have a correspondent in new version
[error]    filter with: ProblemFilters.exclude[MissingMethodProblem]("com.twitter.algebird.QTree.copy$default$4")
[error]  * synthetic method copy$default$3()Long in class com.twitter.algebird.QTree does not have a correspondent in new version
[error]    filter with: ProblemFilters.exclude[MissingMethodProblem]("com.twitter.algebird.QTree.copy$default$3")
java.lang.RuntimeException: algebird-core: Binary compatibility check failed!

Do we mind that?
  • Loading branch information
ianoc committed Jul 31, 2015
1 parent e8f869b commit 74c1ebb
Showing 1 changed file with 15 additions and 12 deletions.
27 changes: 15 additions & 12 deletions algebird-core/src/main/scala/com/twitter/algebird/QTree.scala
Original file line number Diff line number Diff line change
Expand Up @@ -46,21 +46,21 @@ object QTree {
val offset = math.floor(kv._1 / math.pow(2.0, level)).toLong
require(offset >= 0, "QTree can not accept negative values")

new QTree(offset,
new QTree(kv._2,
offset,
level,
1,
kv._2,
null,
null)
}

def apply[A](kv: (Long, A)): QTree[A] = {
require(kv._1 >= 0, "QTree can not accept negative values")

new QTree(kv._1,
new QTree(kv._2,
kv._1,
0,
1,
kv._2,
null,
null)
}
Expand All @@ -73,7 +73,7 @@ object QTree {
upperChild: Option[QTree[A]]): QTree[A] = {
require(offset >= 0, "QTree can not accept negative values")

new QTree(offset, level, count, sum, lowerChild.orNull, upperChild.orNull)
new QTree(sum, offset, level, count, lowerChild.orNull, upperChild.orNull)
}

/**
Expand Down Expand Up @@ -113,9 +113,9 @@ object QTree {
assert(right.lowerBound == left.lowerBound, "lowerBound " + right.lowerBound + " != " + left.lowerBound)
assert(right.level == left.level, "level " + right.level + " != " + left.level)

new QTree[A](left.offset,
new QTree[A](monoid.plus(left.sum, right.sum),
left.offset,
left.level, left.count + right.count,
monoid.plus(left.sum, right.sum),
mergeOptions(left.lowerChildNullable, right.lowerChildNullable),
mergeOptions(left.upperChildNullable, right.upperChildNullable))
}
Expand Down Expand Up @@ -157,13 +157,13 @@ class QTreeSemigroup[A](k: Int)(implicit val underlyingMonoid: Monoid[A]) extend
}

class QTree[@specialized(Int, Long, Float, Double) A] private[algebird] (
_sum: A, //the sum at just this node (*not* including its children)
_offset: Long, //the range this tree covers is offset*(2^level) ... (offset+1)*(2^level)
_level: Int,
_count: Long, //the total count for this node and all of its children
_sum: A, //the sum at just this node (*not* including its children)
_lowerChildNullable: QTree[A],
_upperChildNullable: QTree[A])
extends scala.Product6[Long, Int, Long, A, Option[QTree[A]], Option[QTree[A]]] with java.io.Serializable {
extends scala.Product6[Long, Int, Long, A, Option[QTree[A]], Option[QTree[A]]] with Serializable {
import QTree._

val range: Double =
Expand All @@ -178,6 +178,9 @@ class QTree[@specialized(Int, Long, Float, Double) A] private[algebird] (
def lowerChild: Option[QTree[A]] = Option(_lowerChildNullable)
def upperChild: Option[QTree[A]] = Option(_upperChildNullable)

def this(offset: Long, level: Int, count: Long, sum: A, lowerChild: Option[QTree[A]], upperChild: Option[QTree[A]]) =
this(sum, offset, level, count, lowerChild.orNull, upperChild.orNull)

// Helpers to access the nullable ones from inside the QTree work
@inline private[algebird] def lowerChildNullable: QTree[A] = _lowerChildNullable
@inline private[algebird] def upperChildNullable: QTree[A] = _upperChildNullable
Expand Down Expand Up @@ -218,7 +221,7 @@ class QTree[@specialized(Int, Long, Float, Double) A] private[algebird] (
val r = if (offset % 2 == 0) null else this

val parent =
new QTree[A](nextOffset, nextLevel, _count, monoid.zero, l, r)
new QTree[A](monoid.zero, nextOffset, nextLevel, _count, l, r)

parent.extendToLevel(n)
}
Expand Down Expand Up @@ -367,7 +370,7 @@ class QTree[@specialized(Int, Long, Float, Double) A] private[algebird] (
// If we don't prune we MUST return this
private def pruneChildren(minCount: Long)(implicit m: Monoid[A]): QTree[A] =
if (_count < minCount) {
new QTree[A](_offset, _level, _count, totalSum, null, null)
new QTree[A](totalSum, _offset, _level, _count, null, null)
} else {
val newLower = pruneChild(minCount, lowerChildNullable)
val lowerNotPruned = newLower eq lowerChildNullable
Expand All @@ -376,7 +379,7 @@ class QTree[@specialized(Int, Long, Float, Double) A] private[algebird] (
if (lowerNotPruned && upperNotPruned)
this
else
new QTree[A](_offset, _level, _count, _sum, newLower, newUpper)
new QTree[A](_sum, _offset, _level, _count, newLower, newUpper)
}

// If we don't prune we MUST return child
Expand Down

0 comments on commit 74c1ebb

Please sign in to comment.