### Initialize and use Sketch Map Source: https://twitter.github.io/algebird/datatypes/approx/countminsketch.html This example demonstrates setting up Sketch Map parameters, creating a monoid, populating it with data, and querying frequencies. ```scala val DELTA = 1E-8 // DELTA: Double = 1.0E-8 val EPS = 0.001 // EPS: Double = 0.001 val SEED = 1 // SEED: Int = 1 val HEAVY_HITTERS_COUNT = 10 // HEAVY_HITTERS_COUNT: Int = 10 implicit def string2Bytes(i : String) = i.toCharArray.map(_.toByte) // string2Bytes: (i: String)Array[Byte] val PARAMS = SketchMapParams[String](SEED, EPS, DELTA, HEAVY_HITTERS_COUNT) // PARAMS: com.twitter.algebird.SketchMapParams[String] = SketchMapParams(1,2719,19,10) val MONOID = SketchMap.monoid[String, Long](PARAMS) // MONOID: com.twitter.algebird.SketchMapMonoid[String,Long] = com.twitter.algebird.SketchMapMonoid@61ec1133 val data = List( ("1", 1L), ("3", 2L), ("4", 1L), ("5", 1L) ) // data: List[(String, Long)] = List((1,1), (3,2), (4,1), (5,1)) val sm = MONOID.create(data) // sm: com.twitter.algebird.SketchMap[String,Long] = // SketchMap(Row: 19, Cols: 2719. Dense elements: // List((282,1), (763,2), (2172,1), (2523,1)) // List((112,1), (364,2), (923,1), (2433,1)) // List((1615,1), (1652,1), (1794,2), (2357,1)) // List((497,2), (1687,1), (2288,1), (2395,1)) // List((1115,2), (1252,1), (1441,1), (1798,1)) // List((309,1), (556,2), (944,1), (2580,1)) // List((474,1), (570,2), (1073,1), (2271,1)) // List((194,1), (1101,2), (1420,1), (2296,1)) // List((505,1), (1943,1), (1949,1), (2047,2)) // List((1062,1), (1646,1), (1840,1), (2139,2)) // List((549,1), (820,1), (1468,1), (1547,2)) // List((837,2), (1064,1), (1941,1), (2305,1)) // List((338,1), (482,1), (1331,2), (2285,1)) // List((158,1), (1010,2), (1244,1), (1725,1)) // List((90,1), (606,1), (1464,1), (1474,2)) // List((143,1), (768,1), (935,2), (1340,1)) // List(... sm.totalValue // res4: Long = 5 MONOID.frequency(sm, "1") // res5: Long = 1 MONOID.frequency(sm, "2") // res6: Long = 0 MONOID.frequency(sm, "3") // res7: Long = 2 ``` -------------------------------- ### Create QTree[String] input values Source: https://twitter.github.io/algebird/datatypes/approx/q_tree.html Example input values used to construct a QTree[String], where String acts as a Monoid under concatenation. ```text - 0.1, "he" - 0.2, "ll" - 0.21, "o" - 0.26, "wo" - 0.3, "r" - 0.4, "l" - 0.49, "d" ``` -------------------------------- ### def apply[X, A, B, C, D, E, F, G, H, I, J, K, L, M, N, O, P, Q, R, S, T, U, V](applyX: (A, B, C, D, E, F, G, H, I, J, K, L, M, N, O, P, Q, R, S, T, U, V) => X, unapplyX: (X) => Option[(A, B, C, D, E, F, G, H, I, J, K, L, M, N, O, P, Q, R, S, T, U, V)])(implicit aring: Ring[A], bring: Ring[B], cring: Ring[C], dring: Ring[D], ering: Ring[E], fring: Ring[F], gring: Ring[G], hring: Ring[H], iring: Ring[I], jring: Ring[J], kring: Ring[K], lring: Ring[L], mring: Ring[M], nring: Ring[N], oring: Ring[O], pring: Ring[P], qring: Ring[Q], rring: Ring[R], sring: Ring[S], tring: Ring[T], uring: Ring[U], vring: Ring[V]): Ring[X] Source: https://twitter.github.io/algebird/api/com/twitter/algebird/Ring%24.html Creates a Ring instance for a product type X with 22 components, using the provided apply and unapply functions and implicit Ring instances for each component type. ```APIDOC ## def apply[X, A, B, C, D, E, F, G, H, I, J, K, L, M, N, O, P, Q, R, S, T, U, V](applyX: (A, B, C, D, E, F, G, H, I, J, K, L, M, N, O, P, Q, R, S, T, U, V) => X, unapplyX: (X) => Option[(A, B, C, D, E, F, G, H, I, J, K, L, M, N, O, P, Q, R, S, T, U, V)])(implicit aring: Ring[A], bring: Ring[B], cring: Ring[C], dring: Ring[D], ering: Ring[E], fring: Ring[F], gring: Ring[G], hring: Ring[H], iring: Ring[I], jring: Ring[J], kring: Ring[K], lring: Ring[L], mring: Ring[M], nring: Ring[N], oring: Ring[O], pring: Ring[P], qring: Ring[Q], rring: Ring[R], sring: Ring[S], tring: Ring[T], uring: Ring[U], vring: Ring[V]): Ring[X] ### Description Creates a Ring instance for a product type X with 22 components, using the provided apply and unapply functions and implicit Ring instances for each component type. ### Parameters - applyX: (A, B, C, D, E, F, G, H, I, J, K, L, M, N, O, P, Q, R, S, T, U, V) => X - Required - Function to construct X from its components. - unapplyX: (X) => Option[(A, B, C, D, E, F, G, H, I, J, K, L, M, N, O, P, Q, R, S, T, U, V)] - Required - Function to deconstruct X into its components. - aring: Ring[A] - implicit - Ring instance for type A. - bring: Ring[B] - implicit - Ring instance for type B. - cring: Ring[C] - implicit - Ring instance for type C. - dring: Ring[D] - implicit - Ring instance for type D. - ering: Ring[E] - implicit - Ring instance for type E. - fring: Ring[F] - implicit - Ring instance for type F. - gring: Ring[G] - implicit - Ring instance for type G. - hring: Ring[H] - implicit - Ring instance for type H. - iring: Ring[I] - implicit - Ring instance for type I. - jring: Ring[J] - implicit - Ring instance for type J. - kring: Ring[K] - implicit - Ring instance for type K. - lring: Ring[L] - implicit - Ring instance for type L. - mring: Ring[M] - implicit - Ring instance for type M. - nring: Ring[N] - implicit - Ring instance for type N. - oring: Ring[O] - implicit - Ring instance for type O. - pring: Ring[P] - implicit - Ring instance for type P. - qring: Ring[Q] - implicit - Ring instance for type Q. - rring: Ring[R] - implicit - Ring instance for type R. - sring: Ring[S] - implicit - Ring instance for type S. - tring: Ring[T] - implicit - Ring instance for type T. - uring: Ring[U] - implicit - Ring instance for type U. - vring: Ring[V] - implicit - Ring instance for type V. ### Returns Ring[X] - A Ring instance for the product type X. ``` -------------------------------- ### val get: T Source: https://twitter.github.io/algebird/api/com/twitter/algebird/First.html The `get` value holds the wrapped instance of type `T`. ```APIDOC ## val get: T ### Description Wrapped instance of `T`. ``` -------------------------------- ### def apply[X, A, B, C, D, E, F, G, H, I, J, K, L, M, N, O, P, Q, R, S, T, U](applyX: (A, B, C, D, E, F, G, H, I, J, K, L, M, N, O, P, Q, R, S, T, U) => X, unapplyX: (X) => Option[(A, B, C, D, E, F, G, H, I, J, K, L, M, N, O, P, Q, R, S, T, U)])(implicit aring: Ring[A], bring: Ring[B], cring: Ring[C], dring: Ring[D], ering: Ring[E], fring: Ring[F], gring: Ring[G], hring: Ring[H], iring: Ring[I], jring: Ring[J], kring: Ring[K], lring: Ring[L], mring: Ring[M], nring: Ring[N], oring: Ring[O], pring: Ring[P], qring: Ring[Q], rring: Ring[R], sring: Ring[S], tring: Ring[T], uring: Ring[U]): Ring[X] Source: https://twitter.github.io/algebird/api/com/twitter/algebird/Ring%24.html Creates a Ring instance for a product type X with 21 components, using the provided apply and unapply functions and implicit Ring instances for each component type. ```APIDOC ## def apply[X, A, B, C, D, E, F, G, H, I, J, K, L, M, N, O, P, Q, R, S, T, U](applyX: (A, B, C, D, E, F, G, H, I, J, K, L, M, N, O, P, Q, R, S, T, U) => X, unapplyX: (X) => Option[(A, B, C, D, E, F, G, H, I, J, K, L, M, N, O, P, Q, R, S, T, U)])(implicit aring: Ring[A], bring: Ring[B], cring: Ring[C], dring: Ring[D], ering: Ring[E], fring: Ring[F], gring: Ring[G], hring: Ring[H], iring: Ring[I], jring: Ring[J], kring: Ring[K], lring: Ring[L], mring: Ring[M], nring: Ring[N], oring: Ring[O], pring: Ring[P], qring: Ring[Q], rring: Ring[R], sring: Ring[S], tring: Ring[T], uring: Ring[U]): Ring[X] ### Description Creates a Ring instance for a product type X with 21 components, using the provided apply and unapply functions and implicit Ring instances for each component type. ### Parameters - applyX: (A, B, C, D, E, F, G, H, I, J, K, L, M, N, O, P, Q, R, S, T, U) => X - Required - Function to construct X from its components. - unapplyX: (X) => Option[(A, B, C, D, E, F, G, H, I, J, K, L, M, N, O, P, Q, R, S, T, U)] - Required - Function to deconstruct X into its components. - aring: Ring[A] - implicit - Ring instance for type A. - bring: Ring[B] - implicit - Ring instance for type B. - cring: Ring[C] - implicit - Ring instance for type C. - dring: Ring[D] - implicit - Ring instance for type D. - ering: Ring[E] - implicit - Ring instance for type E. - fring: Ring[F] - implicit - Ring instance for type F. - gring: Ring[G] - implicit - Ring instance for type G. - hring: Ring[H] - implicit - Ring instance for type H. - iring: Ring[I] - implicit - Ring instance for type I. - jring: Ring[J] - implicit - Ring instance for type J. - kring: Ring[K] - implicit - Ring instance for type K. - lring: Ring[L] - implicit - Ring instance for type L. - mring: Ring[M] - implicit - Ring instance for type M. - nring: Ring[N] - implicit - Ring instance for type N. - oring: Ring[O] - implicit - Ring instance for type O. - pring: Ring[P] - implicit - Ring instance for type P. - qring: Ring[Q] - implicit - Ring instance for type Q. - rring: Ring[R] - implicit - Ring instance for type R. - sring: Ring[S] - implicit - Ring instance for type S. - tring: Ring[T] - implicit - Ring instance for type T. - uring: Ring[U] - implicit - Ring instance for type U. ### Returns Ring[X] - A Ring instance for the product type X. ``` -------------------------------- ### Jekyll installation commands Source: https://twitter.github.io/algebird/contributing.html Commands to install Jekyll locally depending on the package manager. ```bash yum install jekyll apt-get install jekyll gem install jekyll ``` -------------------------------- ### RightFolded2 input list example Source: https://twitter.github.io/algebird/datatypes/right_folded.html An example list of values of type In or Out used by the RightFolded2 monoid. ```text I I I O I O O I O I O ``` -------------------------------- ### create(example: Array[Byte], timestamp: Long): HLLSeries Source: https://twitter.github.io/algebird/api/com/twitter/algebird/HyperLogLogSeriesMonoid.html Creates an HLLSeries from a byte array example and a timestamp. ```APIDOC ## create(example: Array[Byte], timestamp: Long): HLLSeries ### Description Creates an HLLSeries from a byte array example and a timestamp. ### Method `def create(example: Array[Byte], timestamp: Long): HLLSeries` ### Parameters - **example** (Array[Byte]) - Required - The byte array to be added to the series. - **timestamp** (Long) - Required - The timestamp associated with the example. ### Returns - **HLLSeries** - The created HLLSeries. ``` -------------------------------- ### def apply[X, A, B, C, D, E, F, G, H, I, J, K, L, M, N, O, P, Q, R, S](applyX: (A, B, C, D, E, F, G, H, I, J, K, L, M, N, O, P, Q, R, S) => X, unapplyX: (X) => Option[(A, B, C, D, E, F, G, H, I, J, K, L, M, N, O, P, Q, R, S)])(implicit aring: Ring[A], bring: Ring[B], cring: Ring[C], dring: Ring[D], ering: Ring[E], fring: Ring[F], gring: Ring[G], hring: Ring[H], iring: Ring[I], jring: Ring[J], kring: Ring[K], lring: Ring[L], mring: Ring[M], nring: Ring[N], oring: Ring[O], pring: Ring[P], qring: Ring[Q], rring: Ring[R], sring: Ring[S]): Ring[X] Source: https://twitter.github.io/algebird/api/com/twitter/algebird/Ring%24.html Creates a Ring instance for a product type X with 19 components, using the provided apply and unapply functions and implicit Ring instances for each component type. ```APIDOC ## def apply[X, A, B, C, D, E, F, G, H, I, J, K, L, M, N, O, P, Q, R, S](applyX: (A, B, C, D, E, F, G, H, I, J, K, L, M, N, O, P, Q, R, S) => X, unapplyX: (X) => Option[(A, B, C, D, E, F, G, H, I, J, K, L, M, N, O, P, Q, R, S)])(implicit aring: Ring[A], bring: Ring[B], cring: Ring[C], dring: Ring[D], ering: Ring[E], fring: Ring[F], gring: Ring[G], hring: Ring[H], iring: Ring[I], jring: Ring[J], kring: Ring[K], lring: Ring[L], mring: Ring[M], nring: Ring[N], oring: Ring[O], pring: Ring[P], qring: Ring[Q], rring: Ring[R], sring: Ring[S]): Ring[X] ### Description Creates a Ring instance for a product type X with 19 components, using the provided apply and unapply functions and implicit Ring instances for each component type. ### Parameters - applyX: (A, B, C, D, E, F, G, H, I, J, K, L, M, N, O, P, Q, R, S) => X - Required - Function to construct X from its components. - unapplyX: (X) => Option[(A, B, C, D, E, F, G, H, I, J, K, L, M, N, O, P, Q, R, S)] - Required - Function to deconstruct X into its components. - aring: Ring[A] - implicit - Ring instance for type A. - bring: Ring[B] - implicit - Ring instance for type B. - cring: Ring[C] - implicit - Ring instance for type C. - dring: Ring[D] - implicit - Ring instance for type D. - ering: Ring[E] - implicit - Ring instance for type E. - fring: Ring[F] - implicit - Ring instance for type F. - gring: Ring[G] - implicit - Ring instance for type G. - hring: Ring[H] - implicit - Ring instance for type H. - iring: Ring[I] - implicit - Ring instance for type I. - jring: Ring[J] - implicit - Ring instance for type J. - kring: Ring[K] - implicit - Ring instance for type K. - lring: Ring[L] - implicit - Ring instance for type L. - mring: Ring[M] - implicit - Ring instance for type M. - nring: Ring[N] - implicit - Ring instance for type N. - oring: Ring[O] - implicit - Ring instance for type O. - pring: Ring[P] - implicit - Ring instance for type P. - qring: Ring[Q] - implicit - Ring instance for type Q. - rring: Ring[R] - implicit - Ring instance for type R. - sring: Ring[S] - implicit - Ring instance for type S. ### Returns Ring[X] - A Ring instance for the product type X. ``` -------------------------------- ### def apply[X, A, B, C, D, E, F, G, H, I, J, K, L, M, N, O, P, Q, R, S, T](applyX: (A, B, C, D, E, F, G, H, I, J, K, L, M, N, O, P, Q, R, S, T) => X, unapplyX: (X) => Option[(A, B, C, D, E, F, G, H, I, J, K, L, M, N, O, P, Q, R, S, T)])(implicit aring: Ring[A], bring: Ring[B], cring: Ring[C], dring: Ring[D], ering: Ring[E], fring: Ring[F], gring: Ring[G], hring: Ring[H], iring: Ring[I], jring: Ring[J], kring: Ring[K], lring: Ring[L], mring: Ring[M], nring: Ring[N], oring: Ring[O], pring: Ring[P], qring: Ring[Q], rring: Ring[R], sring: Ring[S], tring: Ring[T]): Ring[X] Source: https://twitter.github.io/algebird/api/com/twitter/algebird/Ring%24.html Creates a Ring instance for a product type X with 20 components, using the provided apply and unapply functions and implicit Ring instances for each component type. ```APIDOC ## def apply[X, A, B, C, D, E, F, G, H, I, J, K, L, M, N, O, P, Q, R, S, T](applyX: (A, B, C, D, E, F, G, H, I, J, K, L, M, N, O, P, Q, R, S, T) => X, unapplyX: (X) => Option[(A, B, C, D, E, F, G, H, I, J, K, L, M, N, O, P, Q, R, S, T)])(implicit aring: Ring[A], bring: Ring[B], cring: Ring[C], dring: Ring[D], ering: Ring[E], fring: Ring[F], gring: Ring[G], hring: Ring[H], iring: Ring[I], jring: Ring[J], kring: Ring[K], lring: Ring[L], mring: Ring[M], nring: Ring[N], oring: Ring[O], pring: Ring[P], qring: Ring[Q], rring: Ring[R], sring: Ring[S], tring: Ring[T]): Ring[X] ### Description Creates a Ring instance for a product type X with 20 components, using the provided apply and unapply functions and implicit Ring instances for each component type. ### Parameters - applyX: (A, B, C, D, E, F, G, H, I, J, K, L, M, N, O, P, Q, R, S, T) => X - Required - Function to construct X from its components. - unapplyX: (X) => Option[(A, B, C, D, E, F, G, H, I, J, K, L, M, N, O, P, Q, R, S, T)] - Required - Function to deconstruct X into its components. - aring: Ring[A] - implicit - Ring instance for type A. - bring: Ring[B] - implicit - Ring instance for type B. - cring: Ring[C] - implicit - Ring instance for type C. - dring: Ring[D] - implicit - Ring instance for type D. - ering: Ring[E] - implicit - Ring instance for type E. - fring: Ring[F] - implicit - Ring instance for type F. - gring: Ring[G] - implicit - Ring instance for type G. - hring: Ring[H] - implicit - Ring instance for type H. - iring: Ring[I] - implicit - Ring instance for type I. - jring: Ring[J] - implicit - Ring instance for type J. - kring: Ring[K] - implicit - Ring instance for type K. - lring: Ring[L] - implicit - Ring instance for type L. - mring: Ring[M] - implicit - Ring instance for type M. - nring: Ring[N] - implicit - Ring instance for type N. - oring: Ring[O] - implicit - Ring instance for type O. - pring: Ring[P] - implicit - Ring instance for type P. - qring: Ring[Q] - implicit - Ring instance for type Q. - rring: Ring[R] - implicit - Ring instance for type R. - sring: Ring[S] - implicit - Ring instance for type S. - tring: Ring[T] - implicit - Ring instance for type T. ### Returns Ring[X] - A Ring instance for the product type X. ``` -------------------------------- ### case class Identity[T](get: T) Source: https://twitter.github.io/algebird/api/com/twitter/algebird/Identity.html Creates an Identity instance wrapping a value of type T. The constructor takes a single parameter 'get' of type T. ```APIDOC ## case class Identity[T](get: T) ### Description Creates an Identity instance that wraps a value of type T. ### Constructor `new Identity(get: T)` ### Parameters - **get** (T) - Required - The value to wrap. ### Accessor - **val get: T** - Returns the wrapped value. ``` -------------------------------- ### uniqueCount[T]: MonoidAggregator[T, Set[T], Int] Source: https://twitter.github.io/algebird/api/com/twitter/algebird/Aggregator%24.html This builds an in-memory Set, and then finally gets the size of that set. This may not be scalable if the Uniques are very large. You might check the approximateUniqueCount or HyperLogLog Aggregator to get an approximate version of this that is scalable. ```APIDOC ## uniqueCount[T]: MonoidAggregator[T, Set[T], Int] ### Description This builds an in-memory Set, and then finally gets the size of that set. This may not be scalable if the Uniques are very large. You might check the approximateUniqueCount or HyperLogLog Aggregator to get an approximate version of this that is scalable. ### Method Function ### Signature ```scala def uniqueCount[T]: MonoidAggregator[T, Set[T], Int] ``` ### Return Value MonoidAggregator[T, Set[T], Int] - An aggregator that counts the number of unique items. ``` -------------------------------- ### apply[X, A, B, C, D, E, F, G, H, I, J, K, L, M, N](applyX: (A, B, C, D, E, F, G, H, I, J, K, L, M, N) => X, unapplyX: (X) => Option[(A, B, C, D, E, F, G, H, I, J, K, L, M, N)])(implicit aring: Ring[A], bring: Ring[B], cring: Ring[C], dring: Ring[D], ering: Ring[E], fring: Ring[F], gring: Ring[G], hring: Ring[H], iring: Ring[I], jring: Ring[J], kring: Ring[K], lring: Ring[L], mring: Ring[M], nring: Ring[N]): Ring[X] Source: https://twitter.github.io/algebird/api/com/twitter/algebird/ProductRings.html Creates a Ring for a product type X with fourteen components, using the provided apply and unapply functions and implicit Rings for each component. ```APIDOC ## apply[X, A, B, C, D, E, F, G, H, I, J, K, L, M, N](applyX: (A, B, C, D, E, F, G, H, I, J, K, L, M, N) => X, unapplyX: (X) => Option[(A, B, C, D, E, F, G, H, I, J, K, L, M, N)])(implicit aring: Ring[A], bring: Ring[B], cring: Ring[C], dring: Ring[D], ering: Ring[E], fring: Ring[F], gring: Ring[G], hring: Ring[H], iring: Ring[I], jring: Ring[J], kring: Ring[K], lring: Ring[L], mring: Ring[M], nring: Ring[N]): Ring[X] ### Description Creates a Ring for a product type X with fourteen components, using the provided apply and unapply functions and implicit Rings for each component. ### Method apply ### Parameters - **applyX** ((A, B, C, D, E, F, G, H, I, J, K, L, M, N) => X) - Required - Function to construct X from its components. - **unapplyX** ((X) => Option[(A, B, C, D, E, F, G, H, I, J, K, L, M, N)]) - Required - Function to decompose X into its components. - **aring** (Ring[A]) - Required (implicit) - Ring instance for type A. - **bring** (Ring[B]) - Required (implicit) - Ring instance for type B. - **cring** (Ring[C]) - Required (implicit) - Ring instance for type C. - **dring** (Ring[D]) - Required (implicit) - Ring instance for type D. - **ering** (Ring[E]) - Required (implicit) - Ring instance for type E. - **fring** (Ring[F]) - Required (implicit) - Ring instance for type F. - **gring** (Ring[G]) - Required (implicit) - Ring instance for type G. - **hring** (Ring[H]) - Required (implicit) - Ring instance for type H. - **iring** (Ring[I]) - Required (implicit) - Ring instance for type I. - **jring** (Ring[J]) - Required (implicit) - Ring instance for type J. - **kring** (Ring[K]) - Required (implicit) - Ring instance for type K. - **lring** (Ring[L]) - Required (implicit) - Ring instance for type L. - **mring** (Ring[M]) - Required (implicit) - Ring instance for type M. - **nring** (Ring[N]) - Required (implicit) - Ring instance for type N. ### Returns - **Ring[X]** - A Ring instance for the product type X. ``` -------------------------------- ### Create and use a CMS instance Source: https://twitter.github.io/algebird/api/com/twitter/algebird/CMS.html Demonstrates how to create a CMS monoid for Long elements, instantiate a CMS, and estimate the frequency of an element. ```scala // Creates a monoid for a CMS that can count `Long` elements. val cmsMonoid: CMSMonoid[Long] = { val eps = 0.001 val delta = 1E-10 val seed = 1 CMS.monoid[Long](eps, delta, seed) } // Creates a CMS instance that has counted the element `1L`. val cms: CMS[Long] = cmsMonoid.create(1L) // Estimates the frequency of `1L` val estimate: Approximate[Long] = cms.frequency(1L) ``` -------------------------------- ### Canonical.fromLong example Source: https://twitter.github.io/algebird/api/com/twitter/algebird/ExpHist%24%24Canonical%24.html Example output of Canonical.fromLong(15, 2) showing the vector of coefficients in the l-canonical representation. The result Vector(3, 2, 2) corresponds to 15 = (3 * 2^0) + (2 * 2^1) + (2 * 2^2). ```scala scala> Canonical.fromLong(15, 2) res0: Vector[Int] = Vector(3, 2, 2) ``` -------------------------------- ### def apply[X, A, B, C, D, E, F, G, H, I, J, K, L, M, N, O, P, Q, R](applyX: (A, B, C, D, E, F, G, H, I, J, K, L, M, N, O, P, Q, R) => X, unapplyX: (X) => Option[(A, B, C, D, E, F, G, H, I, J, K, L, M, N, O, P, Q, R)])(implicit aring: Ring[A], bring: Ring[B], cring: Ring[C], dring: Ring[D], ering: Ring[E], fring: Ring[F], gring: Ring[G], hring: Ring[H], iring: Ring[I], jring: Ring[J], kring: Ring[K], lring: Ring[L], mring: Ring[M], nring: Ring[N], oring: Ring[O], pring: Ring[P], qring: Ring[Q], rring: Ring[R]): Ring[X] Source: https://twitter.github.io/algebird/api/com/twitter/algebird/Ring%24.html Creates a Ring instance for a product type X with 18 components, using the provided apply and unapply functions and implicit Ring instances for each component type. ```APIDOC ## def apply[X, A, B, C, D, E, F, G, H, I, J, K, L, M, N, O, P, Q, R](applyX: (A, B, C, D, E, F, G, H, I, J, K, L, M, N, O, P, Q, R) => X, unapplyX: (X) => Option[(A, B, C, D, E, F, G, H, I, J, K, L, M, N, O, P, Q, R)])(implicit aring: Ring[A], bring: Ring[B], cring: Ring[C], dring: Ring[D], ering: Ring[E], fring: Ring[F], gring: Ring[G], hring: Ring[H], iring: Ring[I], jring: Ring[J], kring: Ring[K], lring: Ring[L], mring: Ring[M], nring: Ring[N], oring: Ring[O], pring: Ring[P], qring: Ring[Q], rring: Ring[R]): Ring[X] ### Description Creates a Ring instance for a product type X with 18 components, using the provided apply and unapply functions and implicit Ring instances for each component type. ### Parameters - applyX: (A, B, C, D, E, F, G, H, I, J, K, L, M, N, O, P, Q, R) => X - Required - Function to construct X from its components. - unapplyX: (X) => Option[(A, B, C, D, E, F, G, H, I, J, K, L, M, N, O, P, Q, R)] - Required - Function to deconstruct X into its components. - aring: Ring[A] - implicit - Ring instance for type A. - bring: Ring[B] - implicit - Ring instance for type B. - cring: Ring[C] - implicit - Ring instance for type C. - dring: Ring[D] - implicit - Ring instance for type D. - ering: Ring[E] - implicit - Ring instance for type E. - fring: Ring[F] - implicit - Ring instance for type F. - gring: Ring[G] - implicit - Ring instance for type G. - hring: Ring[H] - implicit - Ring instance for type H. - iring: Ring[I] - implicit - Ring instance for type I. - jring: Ring[J] - implicit - Ring instance for type J. - kring: Ring[K] - implicit - Ring instance for type K. - lring: Ring[L] - implicit - Ring instance for type L. - mring: Ring[M] - implicit - Ring instance for type M. - nring: Ring[N] - implicit - Ring instance for type N. - oring: Ring[O] - implicit - Ring instance for type O. - pring: Ring[P] - implicit - Ring instance for type P. - qring: Ring[Q] - implicit - Ring instance for type Q. - rring: Ring[R] - implicit - Ring instance for type R. ### Returns Ring[X] - A Ring instance for the product type X. ``` -------------------------------- ### contramap usage example for CMSHasherByteArray Source: https://twitter.github.io/algebird/api/com/twitter/algebird/CMSHasher%24%24CMSHasherByteArray%24.html Shows how to create a CMSHasher for an unsupported type (Double) by using contramap on CMSHasherArrayByte. The example defines a function f that converts a Double to an Array[Byte] and then creates an implicit CMSHasher[Double]. ```scala def f(d: Double): Array[Byte] = { val l: Long = java.lang.Double.doubleToLongBits(d) java.nio.ByteBuffer.allocate(8).putLong(l).array() } implicit val cmsHasherDouble: CMSHasher[Double] = CMSHasherArrayByte.contramap((d: Double) => f(d)) ``` -------------------------------- ### get Source: https://twitter.github.io/algebird/api/com/twitter/algebird/monad/Trampoline.html Triggers the computation which is run exactly once. ```APIDOC ## get ### Description Triggers the computation which is run exactly once. ### Method `def get: A` ### Parameters None ### Returns - **A** - The result of the computation. ``` -------------------------------- ### apply[X, A, B, C, D, E, F, G, H, I, J, K, L, M](applyX: (A, B, C, D, E, F, G, H, I, J, K, L, M) => X, unapplyX: (X) => Option[(A, B, C, D, E, F, G, H, I, J, K, L, M)])(implicit aring: Ring[A], bring: Ring[B], cring: Ring[C], dring: Ring[D], ering: Ring[E], fring: Ring[F], gring: Ring[G], hring: Ring[H], iring: Ring[I], jring: Ring[J], kring: Ring[K], lring: Ring[L], mring: Ring[M]): Ring[X] Source: https://twitter.github.io/algebird/api/com/twitter/algebird/ProductRings.html Creates a Ring for a product type X with thirteen components, using the provided apply and unapply functions and implicit Rings for each component. ```APIDOC ## apply[X, A, B, C, D, E, F, G, H, I, J, K, L, M](applyX: (A, B, C, D, E, F, G, H, I, J, K, L, M) => X, unapplyX: (X) => Option[(A, B, C, D, E, F, G, H, I, J, K, L, M)])(implicit aring: Ring[A], bring: Ring[B], cring: Ring[C], dring: Ring[D], ering: Ring[E], fring: Ring[F], gring: Ring[G], hring: Ring[H], iring: Ring[I], jring: Ring[J], kring: Ring[K], lring: Ring[L], mring: Ring[M]): Ring[X] ### Description Creates a Ring for a product type X with thirteen components, using the provided apply and unapply functions and implicit Rings for each component. ### Method apply ### Parameters - **applyX** ((A, B, C, D, E, F, G, H, I, J, K, L, M) => X) - Required - Function to construct X from its components. - **unapplyX** ((X) => Option[(A, B, C, D, E, F, G, H, I, J, K, L, M)]) - Required - Function to decompose X into its components. - **aring** (Ring[A]) - Required (implicit) - Ring instance for type A. - **bring** (Ring[B]) - Required (implicit) - Ring instance for type B. - **cring** (Ring[C]) - Required (implicit) - Ring instance for type C. - **dring** (Ring[D]) - Required (implicit) - Ring instance for type D. - **ering** (Ring[E]) - Required (implicit) - Ring instance for type E. - **fring** (Ring[F]) - Required (implicit) - Ring instance for type F. - **gring** (Ring[G]) - Required (implicit) - Ring instance for type G. - **hring** (Ring[H]) - Required (implicit) - Ring instance for type H. - **iring** (Ring[I]) - Required (implicit) - Ring instance for type I. - **jring** (Ring[J]) - Required (implicit) - Ring instance for type J. - **kring** (Ring[K]) - Required (implicit) - Ring instance for type K. - **lring** (Ring[L]) - Required (implicit) - Ring instance for type L. - **mring** (Ring[M]) - Required (implicit) - Ring instance for type M. ### Returns - **Ring[X]** - A Ring instance for the product type X. ``` -------------------------------- ### val get: A Source: https://twitter.github.io/algebird/api/com/twitter/algebird/ResetValue.html Returns the wrapped value of type A. ```APIDOC ## val get: A ### Description Returns the wrapped value of type A. ### Method `get` ### Returns - **A** - The wrapped value. ``` -------------------------------- ### new Product5Ring(apply: (A, B, C, D, E) => X, unapply: (X) => Option[(A, B, C, D, E)])(implicit aring: Ring[A], bring: Ring[B], cring: Ring[C], dring: Ring[D], ering: Ring[E]) Source: https://twitter.github.io/algebird/api/com/twitter/algebird/Product5Ring.html Constructs a Product5Ring instance by providing apply and unapply functions along with implicit Ring instances for each component type. ```APIDOC ## Constructor: new Product5Ring(apply: (A, B, C, D, E) => X, unapply: (X) => Option[(A, B, C, D, E)])(implicit aring: Ring[A], bring: Ring[B], cring: Ring[C], dring: Ring[D], ering: Ring[E]) ### Description Creates a new Product5Ring instance that combines five rings into a product ring. ### Parameters - **apply** ((A, B, C, D, E) => X) - Required - Function to construct X from five components. - **unapply** ((X) => Option[(A, B, C, D, E)]) - Required - Function to extract the five components from X. - **aring** (Ring[A]) - Required (implicit) - Ring instance for type A. - **bring** (Ring[B]) - Required (implicit) - Ring instance for type B. - **cring** (Ring[C]) - Required (implicit) - Ring instance for type C. - **dring** (Ring[D]) - Required (implicit) - Ring instance for type D. - **ering** (Ring[E]) - Required (implicit) - Ring instance for type E. ```