Object/Class

com.twitter.algebird

QTree

Related Docs: class QTree | package algebird

Permalink

object QTree extends Serializable

A QTree provides an approximate Map[Double,A:Monoid] suitable for range queries, quantile queries, and combinations of these (for example, if you use a numeric A, you can derive the inter-quartile mean).

It is loosely related to the Q-Digest data structure from http://www.cs.virginia.edu/~son/cs851/papers/ucsb.sensys04.pdf, but using an immutable tree structure, and carrying a generalized sum (of type A) at each node instead of just a count.

The basic idea is to keep a binary tree, where the root represents the entire range of the input keys, and each child node represents either the lower or upper half of its parent's range. Ranges are constrained to be dyadic intervals (https://en.wikipedia.org/wiki/Interval_(mathematics)#Dyadic_intervals) for ease of merging.

To keep the size bounded, the total count carried by any sub-tree must be at least 1/(2^k) of the total count at the root. Any sub-trees that do not meet this criteria have their children pruned and become leaves. (It's important that they not be pruned away entirely, but that we keep a fringe of low-count leaves that can gain weight over time and ultimately split again when warranted).

Quantile and range queries both give hard upper and lower bounds; the true result will be somewhere in the range given.

Keys must be >= 0.

Source
QTree.scala
Linear Supertypes
Serializable, Serializable, AnyRef, Any
Ordering
  1. Alphabetic
  2. By Inheritance
Inherited
  1. QTree
  2. Serializable
  3. Serializable
  4. AnyRef
  5. Any
  1. Hide All
  2. Show All
Visibility
  1. Public
  2. All

Value Members

  1. final def !=(arg0: Any): Boolean

    Permalink
    Definition Classes
    AnyRef → Any
  2. final def ##(): Int

    Permalink
    Definition Classes
    AnyRef → Any
  3. final def ==(arg0: Any): Boolean

    Permalink
    Definition Classes
    AnyRef → Any
  4. val DefaultLevel: Int

    Permalink
  5. def apply(k: Double): QTree[Double]

    Permalink

    uses 1/65636 as the bin size, if you want to control that see other apply or value methods.

    uses 1/65636 as the bin size, if you want to control that see other apply or value methods.

    This is useful if you want to query the mean inside a range later. If you truly just care about the counts/histogram, see the value method.

  6. def apply(k: Long): QTree[Long]

    Permalink

    The common case of wanting an offset and sum for the same value This is useful if you want to query the mean inside a range later.

    The common case of wanting an offset and sum for the same value This is useful if you want to query the mean inside a range later. If you truly just care about the counts/histogram, see the value method.

  7. def apply[A](offset: Long, level: Int, count: Long, sum: A, lowerChild: Option[QTree[A]], upperChild: Option[QTree[A]]): QTree[A]

    Permalink
  8. def apply[A](kv: (Long, A)): QTree[A]

    Permalink
  9. def apply[A](kv: (Double, A), level: Int = DefaultLevel): QTree[A]

    Permalink

    level gives a bin size of 2^level. By default the bin size is 1/65536 (level = -16)

  10. final def asInstanceOf[T0]: T0

    Permalink
    Definition Classes
    Any
  11. def clone(): AnyRef

    Permalink
    Attributes
    protected[java.lang]
    Definition Classes
    AnyRef
    Annotations
    @throws( ... )
  12. final def eq(arg0: AnyRef): Boolean

    Permalink
    Definition Classes
    AnyRef
  13. def equals(arg0: Any): Boolean

    Permalink
    Definition Classes
    AnyRef → Any
  14. def finalize(): Unit

    Permalink
    Attributes
    protected[java.lang]
    Definition Classes
    AnyRef
    Annotations
    @throws( classOf[java.lang.Throwable] )
  15. final def getClass(): Class[_]

    Permalink
    Definition Classes
    AnyRef → Any
  16. def hashCode(): Int

    Permalink
    Definition Classes
    AnyRef → Any
  17. final def isInstanceOf[T0]: Boolean

    Permalink
    Definition Classes
    Any
  18. final def ne(arg0: AnyRef): Boolean

    Permalink
    Definition Classes
    AnyRef
  19. final def notify(): Unit

    Permalink
    Definition Classes
    AnyRef
  20. final def notifyAll(): Unit

    Permalink
    Definition Classes
    AnyRef
  21. final def synchronized[T0](arg0: ⇒ T0): T0

    Permalink
    Definition Classes
    AnyRef
  22. def toString(): String

    Permalink
    Definition Classes
    AnyRef → Any
  23. def unapply[A](qtree: QTree[A]): Option[(Long, Int, Long, A, Option[QTree[A]], Option[QTree[A]])]

    Permalink

    End user consumable unapply for QTree

  24. def value(v: Double, level: Int = DefaultLevel): QTree[Unit]

    Permalink

    If you are sure you only care about the approximate histogram features of QTree, you can save some space by using QTree[Unit] level gives a bin size of 2^level. By default this is 1/65536 (level = -16)

  25. def value(v: Long): QTree[Unit]

    Permalink

    If you are sure you only care about the approximate histogram features of QTree, you can save some space by using QTree[Unit]

  26. final def wait(): Unit

    Permalink
    Definition Classes
    AnyRef
    Annotations
    @throws( ... )
  27. final def wait(arg0: Long, arg1: Int): Unit

    Permalink
    Definition Classes
    AnyRef
    Annotations
    @throws( ... )
  28. final def wait(arg0: Long): Unit

    Permalink
    Definition Classes
    AnyRef
    Annotations
    @throws( ... )

Inherited from Serializable

Inherited from Serializable

Inherited from AnyRef

Inherited from Any

Ungrouped